From 14d4b9d95c1de8e4c287a75db188ff74fba5fb9e Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Tue, 11 Oct 2022 10:30:45 +0300 Subject: [PATCH] chore: generate API reference (#2410) --- docs/api/admin-spec3.json | 1121 ++++++- docs/api/admin-spec3.yaml | 1551 ++++++--- .../JavaScript/order-edits/postundefined | 7 + .../order-edits_{id}/deleteundefined | 7 + .../JavaScript/order-edits_{id}/getundefined | 7 + .../JavaScript/order-edits_{id}/postundefined | 8 + .../order-edits_{id}_cancel/postundefined | 7 + .../deleteundefined | 7 + .../order-edits_{id}_confirm/postundefined | 7 + .../order-edits_{id}_items/postundefined | 7 + .../deleteundefined | 7 + .../postundefined | 7 + .../order-edits_{id}_request/postundefined | 7 + .../Shell/order-edits/postundefined | 3 + .../Shell/order-edits_{id}/deleteundefined | 2 + .../Shell/order-edits_{id}/getundefined | 2 + .../Shell/order-edits_{id}/postundefined | 6 + .../order-edits_{id}_cancel/postundefined | 2 + .../deleteundefined | 2 + .../order-edits_{id}_confirm/postundefined | 2 + .../order-edits_{id}_items/postundefined | 3 + .../deleteundefined | 2 + .../postundefined | 3 + .../order-edits_{id}_request/postundefined | 2 + .../admin/components/schemas/line_item.yaml | 9 + .../admin/components/schemas/order_edit.yaml | 14 +- docs/api/admin/openapi.yaml | 115 +- docs/api/admin/paths/order-edits.yaml | 40 + docs/api/admin/paths/order-edits_{id}.yaml | 140 + .../admin/paths/order-edits_{id}_cancel.yaml | 43 + .../order-edits_{id}_changes_{change_id}.yaml | 54 + .../admin/paths/order-edits_{id}_confirm.yaml | 43 + .../admin/paths/order-edits_{id}_items.yaml | 47 + .../order-edits_{id}_items_{item_id}.yaml | 108 + .../admin/paths/order-edits_{id}_request.yaml | 43 + docs/api/store-spec3.json | 302 +- docs/api/store-spec3.yaml | 2920 +++++++++-------- .../JavaScript/order-edits_{id}/getundefined | 6 + .../order-edits_{id}_complete/postundefined | 6 + .../order-edits_{id}_decline/postundefined | 6 + .../Shell/order-edits_{id}/getundefined | 1 + .../order-edits_{id}_complete/postundefined | 1 + .../order-edits_{id}_decline/postundefined | 1 + .../store/components/schemas/line_item.yaml | 9 + .../store/components/schemas/order_edit.yaml | 14 +- docs/api/store/openapi.yaml | 145 +- docs/api/store/paths/order-edits_{id}.yaml | 43 + .../paths/order-edits_{id}_complete.yaml | 39 + .../store/paths/order-edits_{id}_decline.yaml | 47 + 49 files changed, 5045 insertions(+), 1930 deletions(-) create mode 100644 docs/api/admin/code_samples/JavaScript/order-edits/postundefined create mode 100644 docs/api/admin/code_samples/JavaScript/order-edits_{id}/deleteundefined create mode 100644 docs/api/admin/code_samples/JavaScript/order-edits_{id}/getundefined create mode 100644 docs/api/admin/code_samples/JavaScript/order-edits_{id}/postundefined create mode 100644 docs/api/admin/code_samples/JavaScript/order-edits_{id}_cancel/postundefined create mode 100644 docs/api/admin/code_samples/JavaScript/order-edits_{id}_changes_{change_id}/deleteundefined create mode 100644 docs/api/admin/code_samples/JavaScript/order-edits_{id}_confirm/postundefined create mode 100644 docs/api/admin/code_samples/JavaScript/order-edits_{id}_items/postundefined create mode 100644 docs/api/admin/code_samples/JavaScript/order-edits_{id}_items_{item_id}/deleteundefined create mode 100644 docs/api/admin/code_samples/JavaScript/order-edits_{id}_items_{item_id}/postundefined create mode 100644 docs/api/admin/code_samples/JavaScript/order-edits_{id}_request/postundefined create mode 100644 docs/api/admin/code_samples/Shell/order-edits/postundefined create mode 100644 docs/api/admin/code_samples/Shell/order-edits_{id}/deleteundefined create mode 100644 docs/api/admin/code_samples/Shell/order-edits_{id}/getundefined create mode 100644 docs/api/admin/code_samples/Shell/order-edits_{id}/postundefined create mode 100644 docs/api/admin/code_samples/Shell/order-edits_{id}_cancel/postundefined create mode 100644 docs/api/admin/code_samples/Shell/order-edits_{id}_changes_{change_id}/deleteundefined create mode 100644 docs/api/admin/code_samples/Shell/order-edits_{id}_confirm/postundefined create mode 100644 docs/api/admin/code_samples/Shell/order-edits_{id}_items/postundefined create mode 100644 docs/api/admin/code_samples/Shell/order-edits_{id}_items_{item_id}/deleteundefined create mode 100644 docs/api/admin/code_samples/Shell/order-edits_{id}_items_{item_id}/postundefined create mode 100644 docs/api/admin/code_samples/Shell/order-edits_{id}_request/postundefined create mode 100644 docs/api/admin/paths/order-edits.yaml create mode 100644 docs/api/admin/paths/order-edits_{id}.yaml create mode 100644 docs/api/admin/paths/order-edits_{id}_cancel.yaml create mode 100644 docs/api/admin/paths/order-edits_{id}_changes_{change_id}.yaml create mode 100644 docs/api/admin/paths/order-edits_{id}_confirm.yaml create mode 100644 docs/api/admin/paths/order-edits_{id}_items.yaml create mode 100644 docs/api/admin/paths/order-edits_{id}_items_{item_id}.yaml create mode 100644 docs/api/admin/paths/order-edits_{id}_request.yaml create mode 100644 docs/api/store/code_samples/JavaScript/order-edits_{id}/getundefined create mode 100644 docs/api/store/code_samples/JavaScript/order-edits_{id}_complete/postundefined create mode 100644 docs/api/store/code_samples/JavaScript/order-edits_{id}_decline/postundefined create mode 100644 docs/api/store/code_samples/Shell/order-edits_{id}/getundefined create mode 100644 docs/api/store/code_samples/Shell/order-edits_{id}_complete/postundefined create mode 100644 docs/api/store/code_samples/Shell/order-edits_{id}_decline/postundefined create mode 100644 docs/api/store/paths/order-edits_{id}.yaml create mode 100644 docs/api/store/paths/order-edits_{id}_complete.yaml create mode 100644 docs/api/store/paths/order-edits_{id}_decline.yaml diff --git a/docs/api/admin-spec3.json b/docs/api/admin-spec3.json index 92a6943bac..77a021132f 100644 --- a/docs/api/admin-spec3.json +++ b/docs/api/admin-spec3.json @@ -15,6 +15,89 @@ info: + + + ## Expanding Fields + + + In many endpoints you'll find an `expand` query parameter that can be passed + to the endpoint. You can use the `expand` query parameter to unpack an + entity's relations and return them in the response. + + + For example, when you list customers you can also retrieve their groups by + passing to the `expand` query parameter the value `groups`. + + + You can expand more than one relation by separating the relations in the + `expand` query parameter with a comma. For example, to retrieve both the + orders and the groups of a customer, pass to the `expand` query parameter + the value `groups,orders`. + + + Please note that the parameters you pass to `expand` replace any relations + that are expanded by default. + + + ## Selecting Fields + + + In many endpoints you'll find a `fields` query parameter that can be passed + to the endpoint. You can use the `fields` query parameter to specify which + fields in the entity should be returned in the response. + + + You can pass more than one field by seperating the field names in the + `fields` query parameter with a comma. + + + Only the fields you pass to `field` will be retrieved and returned in the + response. Any fields that are returned by default will not be returned in + this case. This does not affect relations. + + + For example, to only select the `title` and `description` fields of a + product, pass to the `fields` query parameter the value `title,description`. + + + ## Pagination + + + ### Query Parameters + + + In listing endpoints, such as list customers or list products, you can + control the pagination using the query parameters `limit` and `offset`. + + + `limit` is used to specify the maximum number of items that can be return in + the response. `offset` is used to specify how many items to skip before + returning the resulting entities. + + + You can use the `offset` query parameter to change between pages. For + example, if the limit is 50, at page 1 the offset should be 0; at page 2 the + offset should be 50, and so on. + + + ### Response Fields + + + In listing fields, aside from the entities retrieved, there are three + pagination-related fields returned: `count`, `limit`, and `offset`. + + + Similarly to the query parameters, `limit` is the maximum number of items + that can be returned in the response, and `field` is the number of items + that were skipped before the entities in the result. + + + `count` is the total number of available items of this entity. It can be + used to determine how many pages are there. + + + For example, if the `count` is 100 and the `limit` is 50, you can divide the + `count` by the `limit` to get the number of pages: `100/50 = 2 pages`. license: name: MIT url: 'https://github.com/medusajs/medusa/blob/master/LICENSE' @@ -225,171 +308,6 @@ paths: $ref: '#/components/responses/invalid_request_error' '500': $ref: '#/components/responses/500_error' - /auth: - post: - operationId: PostAuth - summary: User Login - x-authenticated: false - description: Logs a User in and authorizes them to manage Store settings. - parameters: [] - requestBody: - content: - application/json: - schema: - type: object - required: - - email - - password - properties: - email: - type: string - description: The User's email. - password: - type: string - description: The User's password. - x-codeSamples: - - lang: JavaScript - label: JS Client - source: > - import Medusa from "@medusajs/medusa-js" - - const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: - 3 }) - - medusa.admin.auth.createSession({ - email: 'user@example.com', - password: 'supersecret' - }).then((({ user }) => { - console.log(user.id); - }); - - lang: Shell - label: cURL - source: | - curl --location --request POST 'https://medusa-url.com/admin/auth' \ - --header 'Content-Type: application/json' \ - --data-raw '{ - "email": "user@example.com", - "password": "supersecret" - }' - tags: - - Auth - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - user: - $ref: '#/components/schemas/user' - '400': - $ref: '#/components/responses/400_error' - '401': - $ref: '#/components/responses/incorrect_credentials' - '404': - $ref: '#/components/responses/not_found_error' - '409': - $ref: '#/components/responses/invalid_state_error' - '422': - $ref: '#/components/responses/invalid_request_error' - '500': - $ref: '#/components/responses/500_error' - delete: - operationId: DeleteAuth - summary: User Logout - x-authenticated: true - description: Deletes the current session for the logged in user. - x-codeSamples: - - lang: JavaScript - label: JS Client - source: > - import Medusa from "@medusajs/medusa-js" - - const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: - 3 }) - - // must be previously logged in or use api token - - medusa.admin.auth.deleteSession() - - lang: Shell - label: cURL - source: > - curl --location --request DELETE 'https://medusa-url.com/admin/auth' - \ - - --header 'Authorization: Bearer {api_token}' - security: - - api_token: [] - - cookie_auth: [] - tags: - - Auth - responses: - '200': - description: OK - '400': - $ref: '#/components/responses/400_error' - '401': - $ref: '#/components/responses/unauthorized' - '404': - $ref: '#/components/responses/not_found_error' - '409': - $ref: '#/components/responses/invalid_state_error' - '422': - $ref: '#/components/responses/invalid_request_error' - '500': - $ref: '#/components/responses/500_error' - get: - operationId: GetAuth - summary: Get Current User - x-authenticated: true - description: Gets the currently logged in User. - x-codeSamples: - - lang: JavaScript - label: JS Client - source: > - import Medusa from "@medusajs/medusa-js" - - const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: - 3 }) - - // must be previously logged in or use api token - - medusa.admin.auth.getSession() - - .then(({ user }) => { - console.log(user.id); - }); - - lang: Shell - label: cURL - source: | - curl --location --request GET 'https://medusa-url.com/admin/auth' \ - --header 'Authorization: Bearer {api_token}' - security: - - api_token: [] - - cookie_auth: [] - tags: - - Auth - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - user: - $ref: '#/components/schemas/user' - '400': - $ref: '#/components/responses/400_error' - '401': - $ref: '#/components/responses/unauthorized' - '404': - $ref: '#/components/responses/not_found_error' - '409': - $ref: '#/components/responses/invalid_state_error' - '422': - $ref: '#/components/responses/invalid_request_error' - '500': - $ref: '#/components/responses/500_error' '/batch-jobs/{id}/cancel': post: operationId: PostBatchJobsBatchJobCancel @@ -980,6 +898,171 @@ paths: $ref: '#/components/responses/invalid_request_error' '500': $ref: '#/components/responses/500_error' + /auth: + post: + operationId: PostAuth + summary: User Login + x-authenticated: false + description: Logs a User in and authorizes them to manage Store settings. + parameters: [] + requestBody: + content: + application/json: + schema: + type: object + required: + - email + - password + properties: + email: + type: string + description: The User's email. + password: + type: string + description: The User's password. + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + medusa.admin.auth.createSession({ + email: 'user@example.com', + password: 'supersecret' + }).then((({ user }) => { + console.log(user.id); + }); + - lang: Shell + label: cURL + source: | + curl --location --request POST 'https://medusa-url.com/admin/auth' \ + --header 'Content-Type: application/json' \ + --data-raw '{ + "email": "user@example.com", + "password": "supersecret" + }' + tags: + - Auth + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + user: + $ref: '#/components/schemas/user' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/incorrect_credentials' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' + delete: + operationId: DeleteAuth + summary: User Logout + x-authenticated: true + description: Deletes the current session for the logged in user. + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged in or use api token + + medusa.admin.auth.deleteSession() + - lang: Shell + label: cURL + source: > + curl --location --request DELETE 'https://medusa-url.com/admin/auth' + \ + + --header 'Authorization: Bearer {api_token}' + security: + - api_token: [] + - cookie_auth: [] + tags: + - Auth + responses: + '200': + description: OK + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' + get: + operationId: GetAuth + summary: Get Current User + x-authenticated: true + description: Gets the currently logged in User. + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged in or use api token + + medusa.admin.auth.getSession() + + .then(({ user }) => { + console.log(user.id); + }); + - lang: Shell + label: cURL + source: | + curl --location --request GET 'https://medusa-url.com/admin/auth' \ + --header 'Authorization: Bearer {api_token}' + security: + - api_token: [] + - cookie_auth: [] + tags: + - Auth + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + user: + $ref: '#/components/schemas/user' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' '/collections/{id}/products/batch': post: operationId: PostProductsToCollection @@ -6490,6 +6573,689 @@ paths: $ref: '#/components/responses/invalid_request_error' '500': $ref: '#/components/responses/500_error' + '/order-edits/{id}/items': + post: + operationId: PostOrderEditsEditLineItems + summary: Add an line item to an order (edit) + description: Create an OrderEdit LineItem. + parameters: + - in: path + name: id + required: true + description: The ID of the Order Edit. + schema: + type: string + x-authenticated: true + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged in or use api token + + medusa.admin.orderEdit.addLineItem(order_edit_id, { variant_id, + quantity }) + .then(({ order_edit }) => { + console.log(order_edit.id) + }) + - lang: Shell + label: cURL + source: > + curl --location --request POST + 'https://medusa-url.com/admin/order-edits/{id}/items' \ + + --header 'Authorization: Bearer {api_token}' + + -d '{ "variant_id": "some_variant_id", "quantity": 3 }' + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: '#/components/schemas/order_edit' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' + '/order-edits/{id}/cancel': + post: + operationId: PostOrderEditsOrderEditCancel + summary: Cancel an OrderEdit + description: Cancels an OrderEdit. + x-authenticated: true + parameters: + - in: path + name: id + required: true + description: The ID of the OrderEdit. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged in or use api token + + medusa.admin.orderEdit.cancel(orderEditId) + .then(({ order_edit }) => { + console.log(order_edit.id) + }) + - lang: Shell + label: cURL + source: > + curl --location --request POST + 'https://medusa-url.com/admin/order-edits/:id/cancel' \ + + --header 'Authorization: Bearer {api_token}' + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: '#/components/schemas/order_edit' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '500': + $ref: '#/components/responses/500_error' + '/order-edits/{id}/confirm': + post: + operationId: PostOrderEditsOrderEditConfirm + summary: Confirms an OrderEdit + description: Confirms an OrderEdit. + x-authenticated: true + parameters: + - in: path + name: id + required: true + description: The ID of the order edit. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged in or use api token + + medusa.admin.orderEdit.confirm(orderEditId) + .then(({ order_edit }) => { + console.log(order_edit.id) + }) + - lang: Shell + label: cURL + source: > + curl --location --request POST + 'https://medusa-url.com/admin/order-edits/:id/confirm' \ + + --header 'Authorization: Bearer {api_token}' + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: '#/components/schemas/order_edit' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '500': + $ref: '#/components/responses/500_error' + /order-edits: + post: + operationId: PostOrderEdits + summary: Create an OrderEdit + description: Creates an OrderEdit. + x-authenticated: true + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged in or use api token + + medusa.admin.orderEdit.create({ order_id, internal_note }) + .then(({ order_edit }) => { + console.log(order_edit.id) + }) + - lang: Shell + label: cURL + source: > + curl --location --request POST + 'https://medusa-url.com/admin/order-edits' \ + + --header 'Authorization: Bearer {api_token}' + + -d '{ "order_id": "my_order_id", "internal_note": "my_optional_note" + }' + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: '#/components/schemas/order_edit' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' + '/order-edits/{id}/items/{item_id}': + delete: + operationId: DeleteOrderEditsOrderEditLineItemsLineItem + summary: Delete line items from an order edit and create change item + description: Delete line items from an order edit and create change item + x-authenticated: true + parameters: + - in: path + name: id + required: true + description: The ID of the Order Edit to delete from. + schema: + type: string + - in: path + name: item_id + required: true + description: The ID of the order edit item to delete from order. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged in or use api token + + medusa.admin.orderEdits.removeLineItem(order_edit_id, line_item_id) + .then(({ order_edit }) => { + console.log(order_edit.id) + }) + - lang: Shell + label: cURL + source: > + curl --location --request DELETE + 'https://medusa-url.com/admin/order-edits/{id}/items/{item_id}' \ + + --header 'Authorization: Bearer {api_token}' + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: '#/components/schemas/order_edit' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' + post: + operationId: PostOrderEditsEditLineItemsLineItem + summary: Create or update the order edit change holding the line item changes + description: Create or update the order edit change holding the line item changes + x-authenticated: true + parameters: + - in: path + name: id + required: true + description: The ID of the Order Edit to update. + schema: + type: string + - in: path + name: item_id + required: true + description: The ID of the order edit item to update. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged in or use api token + + medusa.admin.orderEdits.updateLineItem(order_edit_id, line_item_id) + .then(({ order_edit }) => { + console.log(order_edit.id) + }) + - lang: Shell + label: cURL + source: > + curl --location --request POST + 'https://medusa-url.com/admin/order-edits/{id}/items/{item_id}' \ + + --header 'Authorization: Bearer {api_token}' + + -d '{ "quantity": 5 }' + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: '#/components/schemas/order_edit' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' + '/order-edits/{id}/changes/{change_id}': + delete: + operationId: DeleteOrderEditsOrderEditItemChange + summary: Delete an Order Edit Item Change + description: Deletes an Order Edit Item Change + x-authenticated: true + parameters: + - in: path + name: id + required: true + description: The ID of the Order Edit to delete. + schema: + type: string + - in: path + name: change_id + required: true + description: The ID of the Order Edit Item Change to delete. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged in or use api token + + medusa.admin.orderEdits.deleteItemChange(item_change_id, + order_edit_id) + .then(({ id, object, deleted }) => { + console.log(id) + }) + - lang: Shell + label: cURL + source: > + curl --location --request DELETE + 'https://medusa-url.com/admin/order-edits/{id}/changes/{change_id}' + \ + + --header 'Authorization: Bearer {api_token}' + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + id: + type: string + description: The ID of the deleted Order Edit Item Change. + object: + type: string + description: The type of the object that was deleted. + format: item_change + deleted: + type: boolean + description: Whether or not the Order Edit Item Change was deleted. + default: true + '400': + $ref: '#/components/responses/400_error' + '/order-edits/{id}': + delete: + operationId: DeleteOrderEditsOrderEdit + summary: Delete an Order Edit + description: Deletes an Order Edit + x-authenticated: true + parameters: + - in: path + name: id + required: true + description: The ID of the Order Edit to delete. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged in or use api token + + medusa.admin.orderEdits.delete(edit_id) + .then(({ id, object, deleted }) => { + console.log(id) + }) + - lang: Shell + label: cURL + source: > + curl --location --request DELETE + 'https://medusa-url.com/admin/order-edits/{id}' \ + + --header 'Authorization: Bearer {api_token}' + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + id: + type: string + description: The ID of the deleted Order Edit. + object: + type: string + description: The type of the object that was deleted. + format: order_edit + deleted: + type: boolean + description: Whether or not the Order Edit was deleted. + default: true + '400': + $ref: '#/components/responses/400_error' + get: + operationId: GetOrderEditsOrderEdit + summary: Retrieve an OrderEdit + description: Retrieves a OrderEdit. + x-authenticated: true + parameters: + - in: path + name: id + required: true + description: The ID of the OrderEdit. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged in or use api token + + medusa.admin.orderEdit.retrieve(orderEditId) + .then(({ order_edit }) => { + console.log(order_edit.id) + }) + - lang: Shell + label: cURL + source: > + curl --location --request GET + 'https://medusa-url.com/admin/order-edits/{id}' \ + + --header 'Authorization: Bearer {api_token}' + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: '#/components/schemas/order_edit' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' + post: + operationId: PostOrderEditsOrderEdit + summary: Updates an OrderEdit + description: Updates a OrderEdit. + x-authenticated: true + parameters: + - in: path + name: id + required: true + description: The ID of the OrderEdit. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged in or use api token + + const params = {internal_note: "internal reason XY"} + + medusa.admin.orderEdit.update(orderEditId, params) + .then(({ order_edit }) => { + console.log(order_edit.id) + }) + - lang: Shell + label: cURL + source: > + curl --location --request POST + 'https://medusa-url.com/admin/order-edits/{id}' \ + + --header 'Authorization: Bearer {api_token}' + + --header 'Content-Type: application/json' \ + + --data-raw '{ + "internal_note": "internal reason XY" + }' + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: '#/components/schemas/order_edit' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' + '/order-edits/{id}/request': + post: + operationId: PostOrderEditsOrderEditRequest + summary: Request order edit confirmation + description: Request customer confirmation of an Order Edit + x-authenticated: true + parameters: + - in: path + name: id + required: true + description: The ID of the Order Edit to request confirmation from. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged in or use api token + + medusa.admin.orderEdits.requestConfirmation(edit_id) + .then({ order_edit }) => { + console.log(order_edit.id) + }) + - lang: Shell + label: cURL + source: > + curl --location --request POST + 'https://medusa-url.com/admin/order-edits/{id}/request' \ + + --header 'Authorization: Bearer {api_token}' + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: '#/components/schemas/order_edit' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '500': + $ref: '#/components/responses/500_error' '/orders/{id}/shipping-methods': post: operationId: PostOrdersOrderShippingMethods @@ -20630,6 +21396,17 @@ components: includes_tax: description: '[EXPERIMENTAL] Indicates if the line item unit_price include tax' type: boolean + original_item_id: + description: '[EXPERIMENTAL] The id of the original line item' + type: string + order_edit_id: + description: >- + [EXPERIMENTAL] The ID of the order edit to which a cloned item + belongs + type: string + order_edit: + description: '[EXPERIMENTAL] The order edit joined' + type: object created_at: type: string description: The date with timezone at which the resource was created. @@ -21035,12 +21812,24 @@ components: type: string subtotal: type: integer - description: The subtotal for line items computed from changes. + description: The total of subtotal example: 8000 discount_total: type: integer description: The total of discount example: 800 + shipping_total: + type: integer + description: The total of the shipping amount + example: 800 + gift_card_total: + type: integer + description: The total of the gift card amount + example: 800 + gift_card_tax_total: + type: integer + description: The total of the gift card tax amount + example: 800 tax_total: type: integer description: The total of tax diff --git a/docs/api/admin-spec3.yaml b/docs/api/admin-spec3.yaml index 92a6943bac..3e381bfa63 100644 --- a/docs/api/admin-spec3.yaml +++ b/docs/api/admin-spec3.yaml @@ -15,6 +15,89 @@ info: + + + ## Expanding Fields + + + In many endpoints you'll find an `expand` query parameter that can be passed + to the endpoint. You can use the `expand` query parameter to unpack an + entity's relations and return them in the response. + + + For example, when you list customers you can also retrieve their groups by + passing to the `expand` query parameter the value `groups`. + + + You can expand more than one relation by separating the relations in the + `expand` query parameter with a comma. For example, to retrieve both the + orders and the groups of a customer, pass to the `expand` query parameter + the value `groups,orders`. + + + Please note that the parameters you pass to `expand` replace any relations + that are expanded by default. + + + ## Selecting Fields + + + In many endpoints you'll find a `fields` query parameter that can be passed + to the endpoint. You can use the `fields` query parameter to specify which + fields in the entity should be returned in the response. + + + You can pass more than one field by seperating the field names in the + `fields` query parameter with a comma. + + + Only the fields you pass to `field` will be retrieved and returned in the + response. Any fields that are returned by default will not be returned in + this case. This does not affect relations. + + + For example, to only select the `title` and `description` fields of a + product, pass to the `fields` query parameter the value `title,description`. + + + ## Pagination + + + ### Query Parameters + + + In listing endpoints, such as list customers or list products, you can + control the pagination using the query parameters `limit` and `offset`. + + + `limit` is used to specify the maximum number of items that can be return in + the response. `offset` is used to specify how many items to skip before + returning the resulting entities. + + + You can use the `offset` query parameter to change between pages. For + example, if the limit is 50, at page 1 the offset should be 0; at page 2 the + offset should be 50, and so on. + + + ### Response Fields + + + In listing fields, aside from the entities retrieved, there are three + pagination-related fields returned: `count`, `limit`, and `offset`. + + + Similarly to the query parameters, `limit` is the maximum number of items + that can be returned in the response, and `field` is the number of items + that were skipped before the entities in the result. + + + `count` is the total number of available items of this entity. It can be + used to determine how many pages are there. + + + For example, if the `count` is 100 and the `limit` is 50, you can divide the + `count` by the `limit` to get the number of pages: `100/50 = 2 pages`. license: name: MIT url: 'https://github.com/medusajs/medusa/blob/master/LICENSE' @@ -1589,40 +1672,163 @@ paths: $ref: '#/components/responses/invalid_request_error' '500': $ref: '#/components/responses/500_error' - /currencies: + /customers: + post: + operationId: PostCustomers + summary: Create a Customer + description: Creates a Customer. + x-authenticated: true + requestBody: + content: + application/json: + schema: + required: + - email + - first_name + - last_name + - password + properties: + email: + type: string + description: The customer's email. + format: email + first_name: + type: string + description: The customer's first name. + last_name: + type: string + description: The customer's last name. + password: + type: string + description: The customer's password. + format: password + phone: + type: string + description: The customer's phone number. + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Customer + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged in or use api token + + medusa.admin.customers.create({ + email: 'user@example.com', + first_name: 'Caterina', + last_name: 'Yost', + password: 'supersecret' + }) + + .then(({ customer }) => { + console.log(customer.id); + }); + - lang: Shell + label: cURL + source: > + curl --location --request POST + 'https://medusa-url.com/admin/customers' \ + + --header 'Authorization: Bearer {api_token}' \ + + --header 'Content-Type: application/json' \ + + --data-raw '{ + "email": "user@example.com", + "first_name": "Caterina", + "last_name": "Yost", + "password": "supersecret" + }' + security: + - api_token: [] + - cookie_auth: [] + responses: + '201': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' get: - operationId: GetCurrencies - summary: List Currency - description: Retrieves a list of Currency + operationId: GetCustomers + summary: List Customers + description: Retrieves a list of Customers. x-authenticated: true parameters: - in: query - name: code - description: Code of the currency to search for. + name: limit + description: The number of items to return. schema: - type: string - - in: query - name: includes_tax - description: Search for tax inclusive currencies. - schema: - type: boolean - - in: query - name: order - description: to retrieve products in. - schema: - type: string + type: integer + default: 50 - in: query name: offset - description: How many products to skip in the result. + description: The items to skip before result. + schema: + type: integer + default: 0 + - in: query + name: expand + description: (Comma separated) Which fields should be expanded in each customer. schema: type: string - in: query - name: limit - description: Limit the number of products returned. + name: q + description: 'a search term to search email, first_name, and last_name.' schema: type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged in or use api token + + medusa.admin.customers.list() + + .then(({ customers, limit, offset, count }) => { + console.log(customers.length); + }); + - lang: Shell + label: cURL + source: > + curl --location --request GET + 'https://medusa-url.com/admin/customers' \ + + --header 'Authorization: Bearer {api_token}' + security: + - api_token: [] + - cookie_auth: [] tags: - - Currency + - Customer responses: '200': description: OK @@ -1630,30 +1836,123 @@ paths: application/json: schema: properties: - count: - description: The number of Currency. - type: integer - offset: - description: The offset of the Currency query. - type: integer - limit: - description: The limit of the currency query. - type: integer - currencies: + customers: type: array items: - $ref: '#/components/schemas/currency' - '/currencies/{code}': - post: - operationId: PostCurrenciesCurrency - summary: Update a Currency - description: Update a Currency + $ref: '#/components/schemas/customer' + count: + type: integer + description: The total number of items available + offset: + type: integer + description: The number of items skipped before these items + limit: + type: integer + description: The number of items per page + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' + '/customers/{id}': + get: + operationId: GetCustomersCustomer + summary: Get a Customer + description: Retrieves a Customer. x-authenticated: true parameters: - in: path - name: code + name: id required: true - description: The code of the Currency. + description: The ID of the Customer. + schema: + type: string + - in: query + name: expand + description: (Comma separated) Which fields should be expanded in the customer. + schema: + type: string + - in: query + name: fields + description: (Comma separated) Which fields should be included in the customer. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged in or use api token + + medusa.admin.customers.retrieve(customer_id) + + .then(({ customer }) => { + console.log(customer.id); + }); + - lang: Shell + label: cURL + source: > + curl --location --request GET + 'https://medusa-url.com/admin/customers/{id}' \ + + --header 'Authorization: Bearer {api_token}' + security: + - api_token: [] + - cookie_auth: [] + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' + post: + operationId: PostCustomersCustomer + summary: Update a Customer + description: Updates a Customer. + x-authenticated: true + parameters: + - in: path + name: id + required: true + description: The ID of the Customer. + schema: + type: string + - in: query + name: expand + description: (Comma separated) Which fields should be expanded in each customer. + schema: + type: string + - in: query + name: fields + description: (Comma separated) Which fields should be retrieved in each customer. schema: type: string requestBody: @@ -1661,11 +1960,74 @@ paths: application/json: schema: properties: - includes_tax: - type: boolean - description: '[EXPERIMENTAL] Tax included in prices of currency.' + email: + type: string + description: The Customer's email. + format: email + first_name: + type: string + description: The Customer's first name. + last_name: + type: string + description: The Customer's last name. + phone: + type: string + description: The Customer's phone number. + password: + type: string + description: The Customer's password. + format: password + groups: + type: array + items: + required: + - id + properties: + id: + description: The ID of a customer group + type: string + description: A list of customer groups to which the customer belongs. + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged in or use api token + + medusa.admin.customers.update(customer_id, { + first_name: 'Dolly' + }) + + .then(({ customer }) => { + console.log(customer.id); + }); + - lang: Shell + label: cURL + source: > + curl --location --request POST + 'https://medusa-url.com/admin/customers/{id}' \ + + --header 'Authorization: Bearer {api_token}' \ + + --header 'Content-Type: application/json' \ + + --data-raw '{ + "first_name": "Dolly" + }' + security: + - api_token: [] + - cookie_auth: [] tags: - - Currency + - Customer responses: '200': description: OK @@ -1673,8 +2035,20 @@ paths: application/json: schema: properties: - currency: - $ref: '#/components/schemas/currency' + customer: + $ref: '#/components/schemas/customer' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' '/customer-groups/{id}/customers/batch': post: operationId: PostCustomerGroupsGroupCustomersBatch @@ -2422,163 +2796,40 @@ paths: $ref: '#/components/responses/invalid_request_error' '500': $ref: '#/components/responses/500_error' - /customers: - post: - operationId: PostCustomers - summary: Create a Customer - description: Creates a Customer. - x-authenticated: true - requestBody: - content: - application/json: - schema: - required: - - email - - first_name - - last_name - - password - properties: - email: - type: string - description: The customer's email. - format: email - first_name: - type: string - description: The customer's first name. - last_name: - type: string - description: The customer's last name. - password: - type: string - description: The customer's password. - format: password - phone: - type: string - description: The customer's phone number. - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Customer - x-codeSamples: - - lang: JavaScript - label: JS Client - source: > - import Medusa from "@medusajs/medusa-js" - - const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: - 3 }) - - // must be previously logged in or use api token - - medusa.admin.customers.create({ - email: 'user@example.com', - first_name: 'Caterina', - last_name: 'Yost', - password: 'supersecret' - }) - - .then(({ customer }) => { - console.log(customer.id); - }); - - lang: Shell - label: cURL - source: > - curl --location --request POST - 'https://medusa-url.com/admin/customers' \ - - --header 'Authorization: Bearer {api_token}' \ - - --header 'Content-Type: application/json' \ - - --data-raw '{ - "email": "user@example.com", - "first_name": "Caterina", - "last_name": "Yost", - "password": "supersecret" - }' - security: - - api_token: [] - - cookie_auth: [] - responses: - '201': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - '400': - $ref: '#/components/responses/400_error' - '401': - $ref: '#/components/responses/unauthorized' - '404': - $ref: '#/components/responses/not_found_error' - '409': - $ref: '#/components/responses/invalid_state_error' - '422': - $ref: '#/components/responses/invalid_request_error' - '500': - $ref: '#/components/responses/500_error' + /currencies: get: - operationId: GetCustomers - summary: List Customers - description: Retrieves a list of Customers. + operationId: GetCurrencies + summary: List Currency + description: Retrieves a list of Currency x-authenticated: true parameters: - in: query - name: limit - description: The number of items to return. + name: code + description: Code of the currency to search for. schema: - type: integer - default: 50 + type: string + - in: query + name: includes_tax + description: Search for tax inclusive currencies. + schema: + type: boolean + - in: query + name: order + description: to retrieve products in. + schema: + type: string - in: query name: offset - description: The items to skip before result. - schema: - type: integer - default: 0 - - in: query - name: expand - description: (Comma separated) Which fields should be expanded in each customer. + description: How many products to skip in the result. schema: type: string - in: query - name: q - description: 'a search term to search email, first_name, and last_name.' + name: limit + description: Limit the number of products returned. schema: type: string - x-codeSamples: - - lang: JavaScript - label: JS Client - source: > - import Medusa from "@medusajs/medusa-js" - - const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: - 3 }) - - // must be previously logged in or use api token - - medusa.admin.customers.list() - - .then(({ customers, limit, offset, count }) => { - console.log(customers.length); - }); - - lang: Shell - label: cURL - source: > - curl --location --request GET - 'https://medusa-url.com/admin/customers' \ - - --header 'Authorization: Bearer {api_token}' - security: - - api_token: [] - - cookie_auth: [] tags: - - Customer + - Currency responses: '200': description: OK @@ -2586,123 +2837,30 @@ paths: application/json: schema: properties: - customers: + count: + description: The number of Currency. + type: integer + offset: + description: The offset of the Currency query. + type: integer + limit: + description: The limit of the currency query. + type: integer + currencies: type: array items: - $ref: '#/components/schemas/customer' - count: - type: integer - description: The total number of items available - offset: - type: integer - description: The number of items skipped before these items - limit: - type: integer - description: The number of items per page - '400': - $ref: '#/components/responses/400_error' - '401': - $ref: '#/components/responses/unauthorized' - '404': - $ref: '#/components/responses/not_found_error' - '409': - $ref: '#/components/responses/invalid_state_error' - '422': - $ref: '#/components/responses/invalid_request_error' - '500': - $ref: '#/components/responses/500_error' - '/customers/{id}': - get: - operationId: GetCustomersCustomer - summary: Get a Customer - description: Retrieves a Customer. - x-authenticated: true - parameters: - - in: path - name: id - required: true - description: The ID of the Customer. - schema: - type: string - - in: query - name: expand - description: (Comma separated) Which fields should be expanded in the customer. - schema: - type: string - - in: query - name: fields - description: (Comma separated) Which fields should be included in the customer. - schema: - type: string - x-codeSamples: - - lang: JavaScript - label: JS Client - source: > - import Medusa from "@medusajs/medusa-js" - - const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: - 3 }) - - // must be previously logged in or use api token - - medusa.admin.customers.retrieve(customer_id) - - .then(({ customer }) => { - console.log(customer.id); - }); - - lang: Shell - label: cURL - source: > - curl --location --request GET - 'https://medusa-url.com/admin/customers/{id}' \ - - --header 'Authorization: Bearer {api_token}' - security: - - api_token: [] - - cookie_auth: [] - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - '400': - $ref: '#/components/responses/400_error' - '401': - $ref: '#/components/responses/unauthorized' - '404': - $ref: '#/components/responses/not_found_error' - '409': - $ref: '#/components/responses/invalid_state_error' - '422': - $ref: '#/components/responses/invalid_request_error' - '500': - $ref: '#/components/responses/500_error' + $ref: '#/components/schemas/currency' + '/currencies/{code}': post: - operationId: PostCustomersCustomer - summary: Update a Customer - description: Updates a Customer. + operationId: PostCurrenciesCurrency + summary: Update a Currency + description: Update a Currency x-authenticated: true parameters: - in: path - name: id + name: code required: true - description: The ID of the Customer. - schema: - type: string - - in: query - name: expand - description: (Comma separated) Which fields should be expanded in each customer. - schema: - type: string - - in: query - name: fields - description: (Comma separated) Which fields should be retrieved in each customer. + description: The code of the Currency. schema: type: string requestBody: @@ -2710,74 +2868,11 @@ paths: application/json: schema: properties: - email: - type: string - description: The Customer's email. - format: email - first_name: - type: string - description: The Customer's first name. - last_name: - type: string - description: The Customer's last name. - phone: - type: string - description: The Customer's phone number. - password: - type: string - description: The Customer's password. - format: password - groups: - type: array - items: - required: - - id - properties: - id: - description: The ID of a customer group - type: string - description: A list of customer groups to which the customer belongs. - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - x-codeSamples: - - lang: JavaScript - label: JS Client - source: > - import Medusa from "@medusajs/medusa-js" - - const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: - 3 }) - - // must be previously logged in or use api token - - medusa.admin.customers.update(customer_id, { - first_name: 'Dolly' - }) - - .then(({ customer }) => { - console.log(customer.id); - }); - - lang: Shell - label: cURL - source: > - curl --location --request POST - 'https://medusa-url.com/admin/customers/{id}' \ - - --header 'Authorization: Bearer {api_token}' \ - - --header 'Content-Type: application/json' \ - - --data-raw '{ - "first_name": "Dolly" - }' - security: - - api_token: [] - - cookie_auth: [] + includes_tax: + type: boolean + description: '[EXPERIMENTAL] Tax included in prices of currency.' tags: - - Customer + - Currency responses: '200': description: OK @@ -2785,20 +2880,8 @@ paths: application/json: schema: properties: - customer: - $ref: '#/components/schemas/customer' - '400': - $ref: '#/components/responses/400_error' - '401': - $ref: '#/components/responses/unauthorized' - '404': - $ref: '#/components/responses/not_found_error' - '409': - $ref: '#/components/responses/invalid_state_error' - '422': - $ref: '#/components/responses/invalid_request_error' - '500': - $ref: '#/components/responses/500_error' + currency: + $ref: '#/components/schemas/currency' '/discounts/{id}/regions/{region_id}': post: operationId: PostDiscountsDiscountRegionsRegion @@ -6490,6 +6573,689 @@ paths: $ref: '#/components/responses/invalid_request_error' '500': $ref: '#/components/responses/500_error' + '/order-edits/{id}/items': + post: + operationId: PostOrderEditsEditLineItems + summary: Add an line item to an order (edit) + description: Create an OrderEdit LineItem. + parameters: + - in: path + name: id + required: true + description: The ID of the Order Edit. + schema: + type: string + x-authenticated: true + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged in or use api token + + medusa.admin.orderEdit.addLineItem(order_edit_id, { variant_id, + quantity }) + .then(({ order_edit }) => { + console.log(order_edit.id) + }) + - lang: Shell + label: cURL + source: > + curl --location --request POST + 'https://medusa-url.com/admin/order-edits/{id}/items' \ + + --header 'Authorization: Bearer {api_token}' + + -d '{ "variant_id": "some_variant_id", "quantity": 3 }' + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: '#/components/schemas/order_edit' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' + '/order-edits/{id}/cancel': + post: + operationId: PostOrderEditsOrderEditCancel + summary: Cancel an OrderEdit + description: Cancels an OrderEdit. + x-authenticated: true + parameters: + - in: path + name: id + required: true + description: The ID of the OrderEdit. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged in or use api token + + medusa.admin.orderEdit.cancel(orderEditId) + .then(({ order_edit }) => { + console.log(order_edit.id) + }) + - lang: Shell + label: cURL + source: > + curl --location --request POST + 'https://medusa-url.com/admin/order-edits/:id/cancel' \ + + --header 'Authorization: Bearer {api_token}' + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: '#/components/schemas/order_edit' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '500': + $ref: '#/components/responses/500_error' + '/order-edits/{id}/confirm': + post: + operationId: PostOrderEditsOrderEditConfirm + summary: Confirms an OrderEdit + description: Confirms an OrderEdit. + x-authenticated: true + parameters: + - in: path + name: id + required: true + description: The ID of the order edit. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged in or use api token + + medusa.admin.orderEdit.confirm(orderEditId) + .then(({ order_edit }) => { + console.log(order_edit.id) + }) + - lang: Shell + label: cURL + source: > + curl --location --request POST + 'https://medusa-url.com/admin/order-edits/:id/confirm' \ + + --header 'Authorization: Bearer {api_token}' + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: '#/components/schemas/order_edit' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '500': + $ref: '#/components/responses/500_error' + /order-edits: + post: + operationId: PostOrderEdits + summary: Create an OrderEdit + description: Creates an OrderEdit. + x-authenticated: true + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged in or use api token + + medusa.admin.orderEdit.create({ order_id, internal_note }) + .then(({ order_edit }) => { + console.log(order_edit.id) + }) + - lang: Shell + label: cURL + source: > + curl --location --request POST + 'https://medusa-url.com/admin/order-edits' \ + + --header 'Authorization: Bearer {api_token}' + + -d '{ "order_id": "my_order_id", "internal_note": "my_optional_note" + }' + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: '#/components/schemas/order_edit' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' + '/order-edits/{id}/items/{item_id}': + delete: + operationId: DeleteOrderEditsOrderEditLineItemsLineItem + summary: Delete line items from an order edit and create change item + description: Delete line items from an order edit and create change item + x-authenticated: true + parameters: + - in: path + name: id + required: true + description: The ID of the Order Edit to delete from. + schema: + type: string + - in: path + name: item_id + required: true + description: The ID of the order edit item to delete from order. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged in or use api token + + medusa.admin.orderEdits.removeLineItem(order_edit_id, line_item_id) + .then(({ order_edit }) => { + console.log(order_edit.id) + }) + - lang: Shell + label: cURL + source: > + curl --location --request DELETE + 'https://medusa-url.com/admin/order-edits/{id}/items/{item_id}' \ + + --header 'Authorization: Bearer {api_token}' + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: '#/components/schemas/order_edit' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' + post: + operationId: PostOrderEditsEditLineItemsLineItem + summary: Create or update the order edit change holding the line item changes + description: Create or update the order edit change holding the line item changes + x-authenticated: true + parameters: + - in: path + name: id + required: true + description: The ID of the Order Edit to update. + schema: + type: string + - in: path + name: item_id + required: true + description: The ID of the order edit item to update. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged in or use api token + + medusa.admin.orderEdits.updateLineItem(order_edit_id, line_item_id) + .then(({ order_edit }) => { + console.log(order_edit.id) + }) + - lang: Shell + label: cURL + source: > + curl --location --request POST + 'https://medusa-url.com/admin/order-edits/{id}/items/{item_id}' \ + + --header 'Authorization: Bearer {api_token}' + + -d '{ "quantity": 5 }' + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: '#/components/schemas/order_edit' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' + '/order-edits/{id}/changes/{change_id}': + delete: + operationId: DeleteOrderEditsOrderEditItemChange + summary: Delete an Order Edit Item Change + description: Deletes an Order Edit Item Change + x-authenticated: true + parameters: + - in: path + name: id + required: true + description: The ID of the Order Edit to delete. + schema: + type: string + - in: path + name: change_id + required: true + description: The ID of the Order Edit Item Change to delete. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged in or use api token + + medusa.admin.orderEdits.deleteItemChange(item_change_id, + order_edit_id) + .then(({ id, object, deleted }) => { + console.log(id) + }) + - lang: Shell + label: cURL + source: > + curl --location --request DELETE + 'https://medusa-url.com/admin/order-edits/{id}/changes/{change_id}' + \ + + --header 'Authorization: Bearer {api_token}' + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + id: + type: string + description: The ID of the deleted Order Edit Item Change. + object: + type: string + description: The type of the object that was deleted. + format: item_change + deleted: + type: boolean + description: Whether or not the Order Edit Item Change was deleted. + default: true + '400': + $ref: '#/components/responses/400_error' + '/order-edits/{id}': + delete: + operationId: DeleteOrderEditsOrderEdit + summary: Delete an Order Edit + description: Deletes an Order Edit + x-authenticated: true + parameters: + - in: path + name: id + required: true + description: The ID of the Order Edit to delete. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged in or use api token + + medusa.admin.orderEdits.delete(edit_id) + .then(({ id, object, deleted }) => { + console.log(id) + }) + - lang: Shell + label: cURL + source: > + curl --location --request DELETE + 'https://medusa-url.com/admin/order-edits/{id}' \ + + --header 'Authorization: Bearer {api_token}' + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + id: + type: string + description: The ID of the deleted Order Edit. + object: + type: string + description: The type of the object that was deleted. + format: order_edit + deleted: + type: boolean + description: Whether or not the Order Edit was deleted. + default: true + '400': + $ref: '#/components/responses/400_error' + get: + operationId: GetOrderEditsOrderEdit + summary: Retrieve an OrderEdit + description: Retrieves a OrderEdit. + x-authenticated: true + parameters: + - in: path + name: id + required: true + description: The ID of the OrderEdit. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged in or use api token + + medusa.admin.orderEdit.retrieve(orderEditId) + .then(({ order_edit }) => { + console.log(order_edit.id) + }) + - lang: Shell + label: cURL + source: > + curl --location --request GET + 'https://medusa-url.com/admin/order-edits/{id}' \ + + --header 'Authorization: Bearer {api_token}' + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: '#/components/schemas/order_edit' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' + post: + operationId: PostOrderEditsOrderEdit + summary: Updates an OrderEdit + description: Updates a OrderEdit. + x-authenticated: true + parameters: + - in: path + name: id + required: true + description: The ID of the OrderEdit. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged in or use api token + + const params = {internal_note: "internal reason XY"} + + medusa.admin.orderEdit.update(orderEditId, params) + .then(({ order_edit }) => { + console.log(order_edit.id) + }) + - lang: Shell + label: cURL + source: > + curl --location --request POST + 'https://medusa-url.com/admin/order-edits/{id}' \ + + --header 'Authorization: Bearer {api_token}' + + --header 'Content-Type: application/json' \ + + --data-raw '{ + "internal_note": "internal reason XY" + }' + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: '#/components/schemas/order_edit' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' + '/order-edits/{id}/request': + post: + operationId: PostOrderEditsOrderEditRequest + summary: Request order edit confirmation + description: Request customer confirmation of an Order Edit + x-authenticated: true + parameters: + - in: path + name: id + required: true + description: The ID of the Order Edit to request confirmation from. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged in or use api token + + medusa.admin.orderEdits.requestConfirmation(edit_id) + .then({ order_edit }) => { + console.log(order_edit.id) + }) + - lang: Shell + label: cURL + source: > + curl --location --request POST + 'https://medusa-url.com/admin/order-edits/{id}/request' \ + + --header 'Authorization: Bearer {api_token}' + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: '#/components/schemas/order_edit' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '500': + $ref: '#/components/responses/500_error' '/orders/{id}/shipping-methods': post: operationId: PostOrdersOrderShippingMethods @@ -20630,6 +21396,17 @@ components: includes_tax: description: '[EXPERIMENTAL] Indicates if the line item unit_price include tax' type: boolean + original_item_id: + description: '[EXPERIMENTAL] The id of the original line item' + type: string + order_edit_id: + description: >- + [EXPERIMENTAL] The ID of the order edit to which a cloned item + belongs + type: string + order_edit: + description: '[EXPERIMENTAL] The order edit joined' + type: object created_at: type: string description: The date with timezone at which the resource was created. @@ -21035,12 +21812,24 @@ components: type: string subtotal: type: integer - description: The subtotal for line items computed from changes. + description: The total of subtotal example: 8000 discount_total: type: integer description: The total of discount example: 800 + shipping_total: + type: integer + description: The total of the shipping amount + example: 800 + gift_card_total: + type: integer + description: The total of the gift card amount + example: 800 + gift_card_tax_total: + type: integer + description: The total of the gift card tax amount + example: 800 tax_total: type: integer description: The total of tax diff --git a/docs/api/admin/code_samples/JavaScript/order-edits/postundefined b/docs/api/admin/code_samples/JavaScript/order-edits/postundefined new file mode 100644 index 0000000000..71e4b18f00 --- /dev/null +++ b/docs/api/admin/code_samples/JavaScript/order-edits/postundefined @@ -0,0 +1,7 @@ +import Medusa from "@medusajs/medusa-js" +const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) +// must be previously logged in or use api token +medusa.admin.orderEdit.create({ order_id, internal_note }) + .then(({ order_edit }) => { + console.log(order_edit.id) + }) diff --git a/docs/api/admin/code_samples/JavaScript/order-edits_{id}/deleteundefined b/docs/api/admin/code_samples/JavaScript/order-edits_{id}/deleteundefined new file mode 100644 index 0000000000..46359c7fae --- /dev/null +++ b/docs/api/admin/code_samples/JavaScript/order-edits_{id}/deleteundefined @@ -0,0 +1,7 @@ +import Medusa from "@medusajs/medusa-js" +const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) +// must be previously logged in or use api token +medusa.admin.orderEdits.delete(edit_id) + .then(({ id, object, deleted }) => { + console.log(id) + }) diff --git a/docs/api/admin/code_samples/JavaScript/order-edits_{id}/getundefined b/docs/api/admin/code_samples/JavaScript/order-edits_{id}/getundefined new file mode 100644 index 0000000000..4ce9358905 --- /dev/null +++ b/docs/api/admin/code_samples/JavaScript/order-edits_{id}/getundefined @@ -0,0 +1,7 @@ +import Medusa from "@medusajs/medusa-js" +const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) +// must be previously logged in or use api token +medusa.admin.orderEdit.retrieve(orderEditId) + .then(({ order_edit }) => { + console.log(order_edit.id) + }) diff --git a/docs/api/admin/code_samples/JavaScript/order-edits_{id}/postundefined b/docs/api/admin/code_samples/JavaScript/order-edits_{id}/postundefined new file mode 100644 index 0000000000..2440c42378 --- /dev/null +++ b/docs/api/admin/code_samples/JavaScript/order-edits_{id}/postundefined @@ -0,0 +1,8 @@ +import Medusa from "@medusajs/medusa-js" +const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) +// must be previously logged in or use api token +const params = {internal_note: "internal reason XY"} +medusa.admin.orderEdit.update(orderEditId, params) + .then(({ order_edit }) => { + console.log(order_edit.id) + }) diff --git a/docs/api/admin/code_samples/JavaScript/order-edits_{id}_cancel/postundefined b/docs/api/admin/code_samples/JavaScript/order-edits_{id}_cancel/postundefined new file mode 100644 index 0000000000..7c6b834206 --- /dev/null +++ b/docs/api/admin/code_samples/JavaScript/order-edits_{id}_cancel/postundefined @@ -0,0 +1,7 @@ +import Medusa from "@medusajs/medusa-js" +const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) +// must be previously logged in or use api token +medusa.admin.orderEdit.cancel(orderEditId) + .then(({ order_edit }) => { + console.log(order_edit.id) + }) diff --git a/docs/api/admin/code_samples/JavaScript/order-edits_{id}_changes_{change_id}/deleteundefined b/docs/api/admin/code_samples/JavaScript/order-edits_{id}_changes_{change_id}/deleteundefined new file mode 100644 index 0000000000..c1ef05c2f9 --- /dev/null +++ b/docs/api/admin/code_samples/JavaScript/order-edits_{id}_changes_{change_id}/deleteundefined @@ -0,0 +1,7 @@ +import Medusa from "@medusajs/medusa-js" +const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) +// must be previously logged in or use api token +medusa.admin.orderEdits.deleteItemChange(item_change_id, order_edit_id) + .then(({ id, object, deleted }) => { + console.log(id) + }) diff --git a/docs/api/admin/code_samples/JavaScript/order-edits_{id}_confirm/postundefined b/docs/api/admin/code_samples/JavaScript/order-edits_{id}_confirm/postundefined new file mode 100644 index 0000000000..ab9fc4f042 --- /dev/null +++ b/docs/api/admin/code_samples/JavaScript/order-edits_{id}_confirm/postundefined @@ -0,0 +1,7 @@ +import Medusa from "@medusajs/medusa-js" +const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) +// must be previously logged in or use api token +medusa.admin.orderEdit.confirm(orderEditId) + .then(({ order_edit }) => { + console.log(order_edit.id) + }) diff --git a/docs/api/admin/code_samples/JavaScript/order-edits_{id}_items/postundefined b/docs/api/admin/code_samples/JavaScript/order-edits_{id}_items/postundefined new file mode 100644 index 0000000000..d6569f3b5f --- /dev/null +++ b/docs/api/admin/code_samples/JavaScript/order-edits_{id}_items/postundefined @@ -0,0 +1,7 @@ +import Medusa from "@medusajs/medusa-js" +const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) +// must be previously logged in or use api token +medusa.admin.orderEdit.addLineItem(order_edit_id, { variant_id, quantity }) + .then(({ order_edit }) => { + console.log(order_edit.id) + }) diff --git a/docs/api/admin/code_samples/JavaScript/order-edits_{id}_items_{item_id}/deleteundefined b/docs/api/admin/code_samples/JavaScript/order-edits_{id}_items_{item_id}/deleteundefined new file mode 100644 index 0000000000..2c8990247c --- /dev/null +++ b/docs/api/admin/code_samples/JavaScript/order-edits_{id}_items_{item_id}/deleteundefined @@ -0,0 +1,7 @@ +import Medusa from "@medusajs/medusa-js" +const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) +// must be previously logged in or use api token +medusa.admin.orderEdits.removeLineItem(order_edit_id, line_item_id) + .then(({ order_edit }) => { + console.log(order_edit.id) + }) diff --git a/docs/api/admin/code_samples/JavaScript/order-edits_{id}_items_{item_id}/postundefined b/docs/api/admin/code_samples/JavaScript/order-edits_{id}_items_{item_id}/postundefined new file mode 100644 index 0000000000..fc95e5299a --- /dev/null +++ b/docs/api/admin/code_samples/JavaScript/order-edits_{id}_items_{item_id}/postundefined @@ -0,0 +1,7 @@ +import Medusa from "@medusajs/medusa-js" +const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) +// must be previously logged in or use api token +medusa.admin.orderEdits.updateLineItem(order_edit_id, line_item_id) + .then(({ order_edit }) => { + console.log(order_edit.id) + }) diff --git a/docs/api/admin/code_samples/JavaScript/order-edits_{id}_request/postundefined b/docs/api/admin/code_samples/JavaScript/order-edits_{id}_request/postundefined new file mode 100644 index 0000000000..37e5c1796a --- /dev/null +++ b/docs/api/admin/code_samples/JavaScript/order-edits_{id}_request/postundefined @@ -0,0 +1,7 @@ +import Medusa from "@medusajs/medusa-js" +const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) +// must be previously logged in or use api token +medusa.admin.orderEdits.requestConfirmation(edit_id) + .then({ order_edit }) => { + console.log(order_edit.id) + }) diff --git a/docs/api/admin/code_samples/Shell/order-edits/postundefined b/docs/api/admin/code_samples/Shell/order-edits/postundefined new file mode 100644 index 0000000000..29b1870d9c --- /dev/null +++ b/docs/api/admin/code_samples/Shell/order-edits/postundefined @@ -0,0 +1,3 @@ +curl --location --request POST 'https://medusa-url.com/admin/order-edits' \ +--header 'Authorization: Bearer {api_token}' +-d '{ "order_id": "my_order_id", "internal_note": "my_optional_note" }' diff --git a/docs/api/admin/code_samples/Shell/order-edits_{id}/deleteundefined b/docs/api/admin/code_samples/Shell/order-edits_{id}/deleteundefined new file mode 100644 index 0000000000..3cfa445f1e --- /dev/null +++ b/docs/api/admin/code_samples/Shell/order-edits_{id}/deleteundefined @@ -0,0 +1,2 @@ +curl --location --request DELETE 'https://medusa-url.com/admin/order-edits/{id}' \ +--header 'Authorization: Bearer {api_token}' diff --git a/docs/api/admin/code_samples/Shell/order-edits_{id}/getundefined b/docs/api/admin/code_samples/Shell/order-edits_{id}/getundefined new file mode 100644 index 0000000000..40f89d51a1 --- /dev/null +++ b/docs/api/admin/code_samples/Shell/order-edits_{id}/getundefined @@ -0,0 +1,2 @@ +curl --location --request GET 'https://medusa-url.com/admin/order-edits/{id}' \ +--header 'Authorization: Bearer {api_token}' diff --git a/docs/api/admin/code_samples/Shell/order-edits_{id}/postundefined b/docs/api/admin/code_samples/Shell/order-edits_{id}/postundefined new file mode 100644 index 0000000000..3fba5b2aa2 --- /dev/null +++ b/docs/api/admin/code_samples/Shell/order-edits_{id}/postundefined @@ -0,0 +1,6 @@ +curl --location --request POST 'https://medusa-url.com/admin/order-edits/{id}' \ +--header 'Authorization: Bearer {api_token}' +--header 'Content-Type: application/json' \ +--data-raw '{ + "internal_note": "internal reason XY" +}' diff --git a/docs/api/admin/code_samples/Shell/order-edits_{id}_cancel/postundefined b/docs/api/admin/code_samples/Shell/order-edits_{id}_cancel/postundefined new file mode 100644 index 0000000000..fdda792726 --- /dev/null +++ b/docs/api/admin/code_samples/Shell/order-edits_{id}_cancel/postundefined @@ -0,0 +1,2 @@ +curl --location --request POST 'https://medusa-url.com/admin/order-edits/:id/cancel' \ +--header 'Authorization: Bearer {api_token}' diff --git a/docs/api/admin/code_samples/Shell/order-edits_{id}_changes_{change_id}/deleteundefined b/docs/api/admin/code_samples/Shell/order-edits_{id}_changes_{change_id}/deleteundefined new file mode 100644 index 0000000000..ea0d3790f8 --- /dev/null +++ b/docs/api/admin/code_samples/Shell/order-edits_{id}_changes_{change_id}/deleteundefined @@ -0,0 +1,2 @@ +curl --location --request DELETE 'https://medusa-url.com/admin/order-edits/{id}/changes/{change_id}' \ +--header 'Authorization: Bearer {api_token}' diff --git a/docs/api/admin/code_samples/Shell/order-edits_{id}_confirm/postundefined b/docs/api/admin/code_samples/Shell/order-edits_{id}_confirm/postundefined new file mode 100644 index 0000000000..82c18df5dd --- /dev/null +++ b/docs/api/admin/code_samples/Shell/order-edits_{id}_confirm/postundefined @@ -0,0 +1,2 @@ +curl --location --request POST 'https://medusa-url.com/admin/order-edits/:id/confirm' \ +--header 'Authorization: Bearer {api_token}' diff --git a/docs/api/admin/code_samples/Shell/order-edits_{id}_items/postundefined b/docs/api/admin/code_samples/Shell/order-edits_{id}_items/postundefined new file mode 100644 index 0000000000..115265370d --- /dev/null +++ b/docs/api/admin/code_samples/Shell/order-edits_{id}_items/postundefined @@ -0,0 +1,3 @@ +curl --location --request POST 'https://medusa-url.com/admin/order-edits/{id}/items' \ +--header 'Authorization: Bearer {api_token}' +-d '{ "variant_id": "some_variant_id", "quantity": 3 }' diff --git a/docs/api/admin/code_samples/Shell/order-edits_{id}_items_{item_id}/deleteundefined b/docs/api/admin/code_samples/Shell/order-edits_{id}_items_{item_id}/deleteundefined new file mode 100644 index 0000000000..aaf8210567 --- /dev/null +++ b/docs/api/admin/code_samples/Shell/order-edits_{id}_items_{item_id}/deleteundefined @@ -0,0 +1,2 @@ +curl --location --request DELETE 'https://medusa-url.com/admin/order-edits/{id}/items/{item_id}' \ +--header 'Authorization: Bearer {api_token}' diff --git a/docs/api/admin/code_samples/Shell/order-edits_{id}_items_{item_id}/postundefined b/docs/api/admin/code_samples/Shell/order-edits_{id}_items_{item_id}/postundefined new file mode 100644 index 0000000000..0c72b1352f --- /dev/null +++ b/docs/api/admin/code_samples/Shell/order-edits_{id}_items_{item_id}/postundefined @@ -0,0 +1,3 @@ +curl --location --request POST 'https://medusa-url.com/admin/order-edits/{id}/items/{item_id}' \ +--header 'Authorization: Bearer {api_token}' +-d '{ "quantity": 5 }' diff --git a/docs/api/admin/code_samples/Shell/order-edits_{id}_request/postundefined b/docs/api/admin/code_samples/Shell/order-edits_{id}_request/postundefined new file mode 100644 index 0000000000..9c19766746 --- /dev/null +++ b/docs/api/admin/code_samples/Shell/order-edits_{id}_request/postundefined @@ -0,0 +1,2 @@ +curl --location --request POST 'https://medusa-url.com/admin/order-edits/{id}/request' \ +--header 'Authorization: Bearer {api_token}' diff --git a/docs/api/admin/components/schemas/line_item.yaml b/docs/api/admin/components/schemas/line_item.yaml index 32174752a2..cdb06694a9 100644 --- a/docs/api/admin/components/schemas/line_item.yaml +++ b/docs/api/admin/components/schemas/line_item.yaml @@ -160,6 +160,15 @@ properties: includes_tax: description: '[EXPERIMENTAL] Indicates if the line item unit_price include tax' type: boolean + original_item_id: + description: '[EXPERIMENTAL] The id of the original line item' + type: string + order_edit_id: + description: '[EXPERIMENTAL] The ID of the order edit to which a cloned item belongs' + type: string + order_edit: + description: '[EXPERIMENTAL] The order edit joined' + type: object created_at: type: string description: The date with timezone at which the resource was created. diff --git a/docs/api/admin/components/schemas/order_edit.yaml b/docs/api/admin/components/schemas/order_edit.yaml index b050c5a36d..fdcb17fccd 100644 --- a/docs/api/admin/components/schemas/order_edit.yaml +++ b/docs/api/admin/components/schemas/order_edit.yaml @@ -60,12 +60,24 @@ properties: type: string subtotal: type: integer - description: The subtotal for line items computed from changes. + description: The total of subtotal example: 8000 discount_total: type: integer description: The total of discount example: 800 + shipping_total: + type: integer + description: The total of the shipping amount + example: 800 + gift_card_total: + type: integer + description: The total of the gift card amount + example: 800 + gift_card_tax_total: + type: integer + description: The total of the gift card tax amount + example: 800 tax_total: type: integer description: The total of tax diff --git a/docs/api/admin/openapi.yaml b/docs/api/admin/openapi.yaml index fd909b8944..7b05bfc6a8 100644 --- a/docs/api/admin/openapi.yaml +++ b/docs/api/admin/openapi.yaml @@ -15,6 +15,89 @@ info: + + + ## Expanding Fields + + + In many endpoints you'll find an `expand` query parameter that can be passed + to the endpoint. You can use the `expand` query parameter to unpack an + entity's relations and return them in the response. + + + For example, when you list customers you can also retrieve their groups by + passing to the `expand` query parameter the value `groups`. + + + You can expand more than one relation by separating the relations in the + `expand` query parameter with a comma. For example, to retrieve both the + orders and the groups of a customer, pass to the `expand` query parameter + the value `groups,orders`. + + + Please note that the parameters you pass to `expand` replace any relations + that are expanded by default. + + + ## Selecting Fields + + + In many endpoints you'll find a `fields` query parameter that can be passed + to the endpoint. You can use the `fields` query parameter to specify which + fields in the entity should be returned in the response. + + + You can pass more than one field by seperating the field names in the + `fields` query parameter with a comma. + + + Only the fields you pass to `field` will be retrieved and returned in the + response. Any fields that are returned by default will not be returned in + this case. This does not affect relations. + + + For example, to only select the `title` and `description` fields of a + product, pass to the `fields` query parameter the value `title,description`. + + + ## Pagination + + + ### Query Parameters + + + In listing endpoints, such as list customers or list products, you can + control the pagination using the query parameters `limit` and `offset`. + + + `limit` is used to specify the maximum number of items that can be return in + the response. `offset` is used to specify how many items to skip before + returning the resulting entities. + + + You can use the `offset` query parameter to change between pages. For + example, if the limit is 50, at page 1 the offset should be 0; at page 2 the + offset should be 50, and so on. + + + ### Response Fields + + + In listing fields, aside from the entities retrieved, there are three + pagination-related fields returned: `count`, `limit`, and `offset`. + + + Similarly to the query parameters, `limit` is the maximum number of items + that can be returned in the response, and `field` is the number of items + that were skipped before the entities in the result. + + + `count` is the total number of available items of this entity. It can be + used to determine how many pages are there. + + + For example, if the `count` is 100 and the `limit` is 50, you can divide the + `count` by the `limit` to get the number of pages: `100/50 = 2 pages`. license: name: MIT url: https://github.com/medusajs/medusa/blob/master/LICENSE @@ -139,10 +222,10 @@ paths: $ref: paths/collections.yaml /collections/{id}: $ref: paths/collections_{id}.yaml - /currencies: - $ref: paths/currencies.yaml - /currencies/{code}: - $ref: paths/currencies_{code}.yaml + /customers: + $ref: paths/customers.yaml + /customers/{id}: + $ref: paths/customers_{id}.yaml /customer-groups/{id}/customers/batch: $ref: paths/customer-groups_{id}_customers_batch.yaml /customer-groups: @@ -151,10 +234,10 @@ paths: $ref: paths/customer-groups_{id}.yaml /customer-groups/{id}/customers: $ref: paths/customer-groups_{id}_customers.yaml - /customers: - $ref: paths/customers.yaml - /customers/{id}: - $ref: paths/customers_{id}.yaml + /currencies: + $ref: paths/currencies.yaml + /currencies/{code}: + $ref: paths/currencies_{code}.yaml /discounts/{id}/regions/{region_id}: $ref: paths/discounts_{id}_regions_{region_id}.yaml /discounts/{discount_id}/conditions: @@ -203,6 +286,22 @@ paths: $ref: paths/notifications.yaml /notifications/{id}/resend: $ref: paths/notifications_{id}_resend.yaml + /order-edits/{id}/items: + $ref: paths/order-edits_{id}_items.yaml + /order-edits/{id}/cancel: + $ref: paths/order-edits_{id}_cancel.yaml + /order-edits/{id}/confirm: + $ref: paths/order-edits_{id}_confirm.yaml + /order-edits: + $ref: paths/order-edits.yaml + /order-edits/{id}/items/{item_id}: + $ref: paths/order-edits_{id}_items_{item_id}.yaml + /order-edits/{id}/changes/{change_id}: + $ref: paths/order-edits_{id}_changes_{change_id}.yaml + /order-edits/{id}: + $ref: paths/order-edits_{id}.yaml + /order-edits/{id}/request: + $ref: paths/order-edits_{id}_request.yaml /orders/{id}/shipping-methods: $ref: paths/orders_{id}_shipping-methods.yaml /orders/{id}/archive: diff --git a/docs/api/admin/paths/order-edits.yaml b/docs/api/admin/paths/order-edits.yaml new file mode 100644 index 0000000000..f8034c1443 --- /dev/null +++ b/docs/api/admin/paths/order-edits.yaml @@ -0,0 +1,40 @@ +post: + operationId: PostOrderEdits + summary: Create an OrderEdit + description: Creates an OrderEdit. + x-authenticated: true + x-codeSamples: + - lang: JavaScript + label: JS Client + source: + $ref: ../code_samples/JavaScript/order-edits/postundefined + - lang: Shell + label: cURL + source: + $ref: ../code_samples/Shell/order-edits/postundefined + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: ../components/schemas/order_edit.yaml + '400': + $ref: ../components/responses/400_error.yaml + '401': + $ref: ../components/responses/unauthorized.yaml + '404': + $ref: ../components/responses/not_found_error.yaml + '409': + $ref: ../components/responses/invalid_state_error.yaml + '422': + $ref: ../components/responses/invalid_request_error.yaml + '500': + $ref: ../components/responses/500_error.yaml diff --git a/docs/api/admin/paths/order-edits_{id}.yaml b/docs/api/admin/paths/order-edits_{id}.yaml new file mode 100644 index 0000000000..86c87ffe26 --- /dev/null +++ b/docs/api/admin/paths/order-edits_{id}.yaml @@ -0,0 +1,140 @@ +delete: + operationId: DeleteOrderEditsOrderEdit + summary: Delete an Order Edit + description: Deletes an Order Edit + x-authenticated: true + parameters: + - in: path + name: id + required: true + description: The ID of the Order Edit to delete. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: + $ref: ../code_samples/JavaScript/order-edits_{id}/deleteundefined + - lang: Shell + label: cURL + source: + $ref: ../code_samples/Shell/order-edits_{id}/deleteundefined + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + id: + type: string + description: The ID of the deleted Order Edit. + object: + type: string + description: The type of the object that was deleted. + format: order_edit + deleted: + type: boolean + description: Whether or not the Order Edit was deleted. + default: true + '400': + $ref: ../components/responses/400_error.yaml +get: + operationId: GetOrderEditsOrderEdit + summary: Retrieve an OrderEdit + description: Retrieves a OrderEdit. + x-authenticated: true + parameters: + - in: path + name: id + required: true + description: The ID of the OrderEdit. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: + $ref: ../code_samples/JavaScript/order-edits_{id}/getundefined + - lang: Shell + label: cURL + source: + $ref: ../code_samples/Shell/order-edits_{id}/getundefined + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: ../components/schemas/order_edit.yaml + '400': + $ref: ../components/responses/400_error.yaml + '401': + $ref: ../components/responses/unauthorized.yaml + '404': + $ref: ../components/responses/not_found_error.yaml + '409': + $ref: ../components/responses/invalid_state_error.yaml + '422': + $ref: ../components/responses/invalid_request_error.yaml + '500': + $ref: ../components/responses/500_error.yaml +post: + operationId: PostOrderEditsOrderEdit + summary: Updates an OrderEdit + description: Updates a OrderEdit. + x-authenticated: true + parameters: + - in: path + name: id + required: true + description: The ID of the OrderEdit. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: + $ref: ../code_samples/JavaScript/order-edits_{id}/postundefined + - lang: Shell + label: cURL + source: + $ref: ../code_samples/Shell/order-edits_{id}/postundefined + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: ../components/schemas/order_edit.yaml + '400': + $ref: ../components/responses/400_error.yaml + '401': + $ref: ../components/responses/unauthorized.yaml + '404': + $ref: ../components/responses/not_found_error.yaml + '409': + $ref: ../components/responses/invalid_state_error.yaml + '422': + $ref: ../components/responses/invalid_request_error.yaml + '500': + $ref: ../components/responses/500_error.yaml diff --git a/docs/api/admin/paths/order-edits_{id}_cancel.yaml b/docs/api/admin/paths/order-edits_{id}_cancel.yaml new file mode 100644 index 0000000000..f69e665d76 --- /dev/null +++ b/docs/api/admin/paths/order-edits_{id}_cancel.yaml @@ -0,0 +1,43 @@ +post: + operationId: PostOrderEditsOrderEditCancel + summary: Cancel an OrderEdit + description: Cancels an OrderEdit. + x-authenticated: true + parameters: + - in: path + name: id + required: true + description: The ID of the OrderEdit. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: + $ref: ../code_samples/JavaScript/order-edits_{id}_cancel/postundefined + - lang: Shell + label: cURL + source: + $ref: ../code_samples/Shell/order-edits_{id}_cancel/postundefined + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: ../components/schemas/order_edit.yaml + '400': + $ref: ../components/responses/400_error.yaml + '401': + $ref: ../components/responses/unauthorized.yaml + '404': + $ref: ../components/responses/not_found_error.yaml + '500': + $ref: ../components/responses/500_error.yaml diff --git a/docs/api/admin/paths/order-edits_{id}_changes_{change_id}.yaml b/docs/api/admin/paths/order-edits_{id}_changes_{change_id}.yaml new file mode 100644 index 0000000000..4baa154fbd --- /dev/null +++ b/docs/api/admin/paths/order-edits_{id}_changes_{change_id}.yaml @@ -0,0 +1,54 @@ +delete: + operationId: DeleteOrderEditsOrderEditItemChange + summary: Delete an Order Edit Item Change + description: Deletes an Order Edit Item Change + x-authenticated: true + parameters: + - in: path + name: id + required: true + description: The ID of the Order Edit to delete. + schema: + type: string + - in: path + name: change_id + required: true + description: The ID of the Order Edit Item Change to delete. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: + $ref: >- + ../code_samples/JavaScript/order-edits_{id}_changes_{change_id}/deleteundefined + - lang: Shell + label: cURL + source: + $ref: >- + ../code_samples/Shell/order-edits_{id}_changes_{change_id}/deleteundefined + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + id: + type: string + description: The ID of the deleted Order Edit Item Change. + object: + type: string + description: The type of the object that was deleted. + format: item_change + deleted: + type: boolean + description: Whether or not the Order Edit Item Change was deleted. + default: true + '400': + $ref: ../components/responses/400_error.yaml diff --git a/docs/api/admin/paths/order-edits_{id}_confirm.yaml b/docs/api/admin/paths/order-edits_{id}_confirm.yaml new file mode 100644 index 0000000000..fad1889432 --- /dev/null +++ b/docs/api/admin/paths/order-edits_{id}_confirm.yaml @@ -0,0 +1,43 @@ +post: + operationId: PostOrderEditsOrderEditConfirm + summary: Confirms an OrderEdit + description: Confirms an OrderEdit. + x-authenticated: true + parameters: + - in: path + name: id + required: true + description: The ID of the order edit. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: + $ref: ../code_samples/JavaScript/order-edits_{id}_confirm/postundefined + - lang: Shell + label: cURL + source: + $ref: ../code_samples/Shell/order-edits_{id}_confirm/postundefined + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: ../components/schemas/order_edit.yaml + '400': + $ref: ../components/responses/400_error.yaml + '401': + $ref: ../components/responses/unauthorized.yaml + '404': + $ref: ../components/responses/not_found_error.yaml + '500': + $ref: ../components/responses/500_error.yaml diff --git a/docs/api/admin/paths/order-edits_{id}_items.yaml b/docs/api/admin/paths/order-edits_{id}_items.yaml new file mode 100644 index 0000000000..5588a9570a --- /dev/null +++ b/docs/api/admin/paths/order-edits_{id}_items.yaml @@ -0,0 +1,47 @@ +post: + operationId: PostOrderEditsEditLineItems + summary: Add an line item to an order (edit) + description: Create an OrderEdit LineItem. + parameters: + - in: path + name: id + required: true + description: The ID of the Order Edit. + schema: + type: string + x-authenticated: true + x-codeSamples: + - lang: JavaScript + label: JS Client + source: + $ref: ../code_samples/JavaScript/order-edits_{id}_items/postundefined + - lang: Shell + label: cURL + source: + $ref: ../code_samples/Shell/order-edits_{id}_items/postundefined + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: ../components/schemas/order_edit.yaml + '400': + $ref: ../components/responses/400_error.yaml + '401': + $ref: ../components/responses/unauthorized.yaml + '404': + $ref: ../components/responses/not_found_error.yaml + '409': + $ref: ../components/responses/invalid_state_error.yaml + '422': + $ref: ../components/responses/invalid_request_error.yaml + '500': + $ref: ../components/responses/500_error.yaml diff --git a/docs/api/admin/paths/order-edits_{id}_items_{item_id}.yaml b/docs/api/admin/paths/order-edits_{id}_items_{item_id}.yaml new file mode 100644 index 0000000000..95634fe383 --- /dev/null +++ b/docs/api/admin/paths/order-edits_{id}_items_{item_id}.yaml @@ -0,0 +1,108 @@ +delete: + operationId: DeleteOrderEditsOrderEditLineItemsLineItem + summary: Delete line items from an order edit and create change item + description: Delete line items from an order edit and create change item + x-authenticated: true + parameters: + - in: path + name: id + required: true + description: The ID of the Order Edit to delete from. + schema: + type: string + - in: path + name: item_id + required: true + description: The ID of the order edit item to delete from order. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: + $ref: >- + ../code_samples/JavaScript/order-edits_{id}_items_{item_id}/deleteundefined + - lang: Shell + label: cURL + source: + $ref: ../code_samples/Shell/order-edits_{id}_items_{item_id}/deleteundefined + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: ../components/schemas/order_edit.yaml + '400': + $ref: ../components/responses/400_error.yaml + '401': + $ref: ../components/responses/unauthorized.yaml + '404': + $ref: ../components/responses/not_found_error.yaml + '409': + $ref: ../components/responses/invalid_state_error.yaml + '422': + $ref: ../components/responses/invalid_request_error.yaml + '500': + $ref: ../components/responses/500_error.yaml +post: + operationId: PostOrderEditsEditLineItemsLineItem + summary: Create or update the order edit change holding the line item changes + description: Create or update the order edit change holding the line item changes + x-authenticated: true + parameters: + - in: path + name: id + required: true + description: The ID of the Order Edit to update. + schema: + type: string + - in: path + name: item_id + required: true + description: The ID of the order edit item to update. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: + $ref: >- + ../code_samples/JavaScript/order-edits_{id}_items_{item_id}/postundefined + - lang: Shell + label: cURL + source: + $ref: ../code_samples/Shell/order-edits_{id}_items_{item_id}/postundefined + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: ../components/schemas/order_edit.yaml + '400': + $ref: ../components/responses/400_error.yaml + '401': + $ref: ../components/responses/unauthorized.yaml + '404': + $ref: ../components/responses/not_found_error.yaml + '409': + $ref: ../components/responses/invalid_state_error.yaml + '422': + $ref: ../components/responses/invalid_request_error.yaml + '500': + $ref: ../components/responses/500_error.yaml diff --git a/docs/api/admin/paths/order-edits_{id}_request.yaml b/docs/api/admin/paths/order-edits_{id}_request.yaml new file mode 100644 index 0000000000..0b3d55e61d --- /dev/null +++ b/docs/api/admin/paths/order-edits_{id}_request.yaml @@ -0,0 +1,43 @@ +post: + operationId: PostOrderEditsOrderEditRequest + summary: Request order edit confirmation + description: Request customer confirmation of an Order Edit + x-authenticated: true + parameters: + - in: path + name: id + required: true + description: The ID of the Order Edit to request confirmation from. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: + $ref: ../code_samples/JavaScript/order-edits_{id}_request/postundefined + - lang: Shell + label: cURL + source: + $ref: ../code_samples/Shell/order-edits_{id}_request/postundefined + security: + - api_token: [] + - cookie_auth: [] + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: ../components/schemas/order_edit.yaml + '400': + $ref: ../components/responses/400_error.yaml + '401': + $ref: ../components/responses/unauthorized.yaml + '404': + $ref: ../components/responses/not_found_error.yaml + '500': + $ref: ../components/responses/500_error.yaml diff --git a/docs/api/store-spec3.json b/docs/api/store-spec3.json index 2981788b89..74920c6b91 100644 --- a/docs/api/store-spec3.json +++ b/docs/api/store-spec3.json @@ -15,6 +15,89 @@ info: + + + ## Expanding Fields + + + In many endpoints you'll find an `expand` query parameter that can be passed + to the endpoint. You can use the `expand` query parameter to unpack an + entity's relations and return them in the response. + + + For example, when you list customers you can also retrieve their groups by + passing to the `expand` query parameter the value `groups`. + + + You can expand more than one relation by separating the relations in the + `expand` query parameter with a comma. For example, to retrieve both the + orders and the groups of a customer, pass to the `expand` query parameter + the value `groups,orders`. + + + Please note that the parameters you pass to `expand` replace any relations + that are expanded by default. + + + ## Selecting Fields + + + In many endpoints you'll find a `fields` query parameter that can be passed + to the endpoint. You can use the `fields` query parameter to specify which + fields in the entity should be returned in the response. + + + You can pass more than one field by seperating the field names in the + `fields` query parameter with a comma. + + + Only the fields you pass to `field` will be retrieved and returned in the + response. Any fields that are returned by default will not be returned in + this case. This does not affect relations. + + + For example, to only select the `title` and `description` fields of a + product, pass to the `fields` query parameter the value `title,description`. + + + ## Pagination + + + ### Query Parameters + + + In listing endpoints, such as list customers or list products, you can + control the pagination using the query parameters `limit` and `offset`. + + + `limit` is used to specify the maximum number of items that can be return in + the response. `offset` is used to specify how many items to skip before + returning the resulting entities. + + + You can use the `offset` query parameter to change between pages. For + example, if the limit is 50, at page 1 the offset should be 0; at page 2 the + offset should be 50, and so on. + + + ### Response Fields + + + In listing fields, aside from the entities retrieved, there are three + pagination-related fields returned: `count`, `limit`, and `offset`. + + + Similarly to the query parameters, `limit` is the maximum number of items + that can be returned in the response, and `field` is the number of items + that were skipped before the entities in the result. + + + `count` is the total number of available items of this entity. It can be + used to determine how many pages are there. + + + For example, if the `count` is 100 and the `limit` is 50, you can divide the + `count` by the `limit` to get the number of pages: `100/50 = 2 pages`. license: name: MIT url: 'https://github.com/medusajs/medusa/blob/master/LICENSE' @@ -1527,6 +1610,58 @@ paths: $ref: '#/components/responses/invalid_request_error' '500': $ref: '#/components/responses/500_error' + '/gift-cards/{code}': + get: + operationId: GetGiftCardsCode + summary: Get Gift Card by Code + description: Retrieves a Gift Card by its associated unqiue code. + parameters: + - in: path + name: code + required: true + description: The unique Gift Card code. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + medusa.giftCards.retrieve(code) + + .then(({ gift_card }) => { + console.log(gift_card.id); + }); + - lang: Shell + label: cURL + source: > + curl --location --request GET + 'https://medusa-url.com/store/gift-cards/{code}' + tags: + - Gift Card + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + gift_card: + $ref: '#/components/schemas/gift_card' + '400': + $ref: '#/components/responses/400_error' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' /customers/me/addresses: post: operationId: PostCustomersCustomerAddresses @@ -2453,16 +2588,16 @@ paths: $ref: '#/components/responses/invalid_request_error' '500': $ref: '#/components/responses/500_error' - '/gift-cards/{code}': - get: - operationId: GetGiftCardsCode - summary: Get Gift Card by Code - description: Retrieves a Gift Card by its associated unqiue code. + '/order-edits/{id}/complete': + post: + operationId: PostOrderEditsOrderEditComplete + summary: Completes an OrderEdit + description: Completes an OrderEdit. parameters: - in: path - name: code + name: id required: true - description: The unique Gift Card code. + description: The ID of the Order Edit. schema: type: string x-codeSamples: @@ -2474,18 +2609,17 @@ paths: const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) - medusa.giftCards.retrieve(code) - - .then(({ gift_card }) => { - console.log(gift_card.id); - }); + medusa.orderEdit.complete(orderEditId) + .then(({ order_edit }) => { + console.log(order_edit.id) + }) - lang: Shell label: cURL source: > - curl --location --request GET - 'https://medusa-url.com/store/gift-cards/{code}' + curl --location --request POST + 'https://medusa-url.com/store/order-edits/{id}/complete' tags: - - Gift Card + - OrderEdit responses: '200': description: OK @@ -2493,10 +2627,119 @@ paths: application/json: schema: properties: - gift_card: - $ref: '#/components/schemas/gift_card' + order_edit: + $ref: '#/components/schemas/order_edit' '400': $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '500': + $ref: '#/components/responses/500_error' + '/order-edits/{id}/decline': + post: + operationId: PostOrderEditsOrderEditDecline + summary: Decline an OrderEdit + description: Declines an OrderEdit. + parameters: + - in: path + name: id + required: true + description: The ID of the OrderEdit. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + declined_reason: + type: string + description: The reason for declining the OrderEdit. + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + medusa.orderEdit.decline(orderEditId) + .then(({ order_edit }) => { + console.log(order_edit.id); + }) + - lang: Shell + label: cURL + source: > + curl --location --request POST + 'https://medusa-url.com/store/order-edits/{id}/decline' + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: '#/components/schemas/order_edit' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '500': + $ref: '#/components/responses/500_error' + '/order-edits/{id}': + get: + operationId: GetOrderEditsOrderEdit + summary: Retrieve an OrderEdit + description: Retrieves a OrderEdit. + parameters: + - in: path + name: id + required: true + description: The ID of the OrderEdit. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + medusa.orderEdit.retrieve(orderEditId) + + .then(({ order_edit }) => { + console.log(order_edit.id); + }); + - lang: Shell + label: cURL + source: > + curl --location --request GET + 'https://medusa-url.com/store/order-edits/{id}' + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: '#/components/schemas/order_edit' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' '404': $ref: '#/components/responses/not_found_error' '409': @@ -6174,6 +6417,17 @@ components: includes_tax: description: '[EXPERIMENTAL] Indicates if the line item unit_price include tax' type: boolean + original_item_id: + description: '[EXPERIMENTAL] The id of the original line item' + type: string + order_edit_id: + description: >- + [EXPERIMENTAL] The ID of the order edit to which a cloned item + belongs + type: string + order_edit: + description: '[EXPERIMENTAL] The order edit joined' + type: object created_at: type: string description: The date with timezone at which the resource was created. @@ -6579,12 +6833,24 @@ components: type: string subtotal: type: integer - description: The subtotal for line items computed from changes. + description: The total of subtotal example: 8000 discount_total: type: integer description: The total of discount example: 800 + shipping_total: + type: integer + description: The total of the shipping amount + example: 800 + gift_card_total: + type: integer + description: The total of the gift card amount + example: 800 + gift_card_tax_total: + type: integer + description: The total of the gift card tax amount + example: 800 tax_total: type: integer description: The total of tax diff --git a/docs/api/store-spec3.yaml b/docs/api/store-spec3.yaml index 2981788b89..c75370a997 100644 --- a/docs/api/store-spec3.yaml +++ b/docs/api/store-spec3.yaml @@ -15,6 +15,89 @@ info: + + + ## Expanding Fields + + + In many endpoints you'll find an `expand` query parameter that can be passed + to the endpoint. You can use the `expand` query parameter to unpack an + entity's relations and return them in the response. + + + For example, when you list customers you can also retrieve their groups by + passing to the `expand` query parameter the value `groups`. + + + You can expand more than one relation by separating the relations in the + `expand` query parameter with a comma. For example, to retrieve both the + orders and the groups of a customer, pass to the `expand` query parameter + the value `groups,orders`. + + + Please note that the parameters you pass to `expand` replace any relations + that are expanded by default. + + + ## Selecting Fields + + + In many endpoints you'll find a `fields` query parameter that can be passed + to the endpoint. You can use the `fields` query parameter to specify which + fields in the entity should be returned in the response. + + + You can pass more than one field by seperating the field names in the + `fields` query parameter with a comma. + + + Only the fields you pass to `field` will be retrieved and returned in the + response. Any fields that are returned by default will not be returned in + this case. This does not affect relations. + + + For example, to only select the `title` and `description` fields of a + product, pass to the `fields` query parameter the value `title,description`. + + + ## Pagination + + + ### Query Parameters + + + In listing endpoints, such as list customers or list products, you can + control the pagination using the query parameters `limit` and `offset`. + + + `limit` is used to specify the maximum number of items that can be return in + the response. `offset` is used to specify how many items to skip before + returning the resulting entities. + + + You can use the `offset` query parameter to change between pages. For + example, if the limit is 50, at page 1 the offset should be 0; at page 2 the + offset should be 50, and so on. + + + ### Response Fields + + + In listing fields, aside from the entities retrieved, there are three + pagination-related fields returned: `count`, `limit`, and `offset`. + + + Similarly to the query parameters, `limit` is the maximum number of items + that can be returned in the response, and `field` is the number of items + that were skipped before the entities in the result. + + + `count` is the total number of available items of this entity. It can be + used to determine how many pages are there. + + + For example, if the `count` is 100 and the `limit` is 50, you can divide the + `count` by the `limit` to get the number of pages: `100/50 = 2 pages`. license: name: MIT url: 'https://github.com/medusajs/medusa/blob/master/LICENSE' @@ -269,6 +352,1492 @@ paths: $ref: '#/components/responses/invalid_request_error' '500': $ref: '#/components/responses/500_error' + '/gift-cards/{code}': + get: + operationId: GetGiftCardsCode + summary: Get Gift Card by Code + description: Retrieves a Gift Card by its associated unqiue code. + parameters: + - in: path + name: code + required: true + description: The unique Gift Card code. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + medusa.giftCards.retrieve(code) + + .then(({ gift_card }) => { + console.log(gift_card.id); + }); + - lang: Shell + label: cURL + source: > + curl --location --request GET + 'https://medusa-url.com/store/gift-cards/{code}' + tags: + - Gift Card + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + gift_card: + $ref: '#/components/schemas/gift_card' + '400': + $ref: '#/components/responses/400_error' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' + '/collections/{id}': + get: + operationId: GetCollectionsCollection + summary: Get a Collection + description: Retrieves a Product Collection. + parameters: + - in: path + name: id + required: true + description: The id of the Product Collection + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + medusa.collections.retrieve(collection_id) + + .then(({ collection }) => { + console.log(collection.id); + }); + - lang: Shell + label: cURL + source: > + curl --location --request GET + 'https://medusa-url.com/store/collections/{id}' + tags: + - Collection + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + collection: + $ref: '#/components/schemas/product_collection' + '400': + $ref: '#/components/responses/400_error' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' + /collections: + get: + operationId: GetCollections + summary: List Collections + description: Retrieve a list of Product Collection. + parameters: + - in: query + name: offset + description: >- + The number of collections to skip before starting to collect the + collections set + schema: + type: integer + default: 0 + - in: query + name: limit + description: The number of collections to return + schema: + type: integer + default: 10 + - in: query + name: created_at + description: Date comparison for when resulting collections were created. + schema: + type: object + properties: + lt: + type: string + description: filter by dates less than this date + format: date + gt: + type: string + description: filter by dates greater than this date + format: date + lte: + type: string + description: filter by dates less than or equal to this date + format: date + gte: + type: string + description: filter by dates greater than or equal to this date + format: date + - in: query + name: updated_at + description: Date comparison for when resulting collections were updated. + schema: + type: object + properties: + lt: + type: string + description: filter by dates less than this date + format: date + gt: + type: string + description: filter by dates greater than this date + format: date + lte: + type: string + description: filter by dates less than or equal to this date + format: date + gte: + type: string + description: filter by dates greater than or equal to this date + format: date + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + medusa.collections.list() + + .then(({ collections, limit, offset, count }) => { + console.log(collections.length); + }); + - lang: Shell + label: cURL + source: > + curl --location --request GET + 'https://medusa-url.com/store/collections' + tags: + - Collection + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + collections: + type: array + items: + $ref: '#/components/schemas/product_collection' + count: + type: integer + description: The total number of items available + offset: + type: integer + description: The number of items skipped before these items + limit: + type: integer + description: The number of items per page + '400': + $ref: '#/components/responses/400_error' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' + /customers/me/addresses: + post: + operationId: PostCustomersCustomerAddresses + summary: Add a Shipping Address + description: Adds a Shipping Address to a Customer's saved addresses. + x-authenticated: true + requestBody: + content: + application/json: + schema: + required: + - address + properties: + address: + description: The Address to add to the Customer. + anyOf: + - $ref: '#/components/schemas/address' + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged + + medusa.customers.addresses.addAddress({ + address: { + first_name: 'Celia', + last_name: 'Schumm', + address_1: '225 Bednar Curve', + city: 'Danielville', + country_code: 'US', + postal_code: '85137', + phone: '981-596-6748 x90188', + company: 'Wyman LLC', + address_2: '', + province: 'Georgia', + metadata: {} + } + }) + + .then(({ customer }) => { + console.log(customer.id); + }); + - lang: Shell + label: cURL + source: > + curl --location --request POST + 'https://medusa-url.com/store/customers/me/addresses' \ + + --header 'Cookie: connect.sid={sid}' \ + + --header 'Content-Type: application/json' \ + + --data-raw '{ + "address": { + "first_name": "Celia", + "last_name": "Schumm", + "address_1": "225 Bednar Curve", + "city": "Danielville", + "country_code": "US", + "postal_code": "85137" + } + }' + security: + - cookie_auth: [] + tags: + - Customer + responses: + '200': + description: A successful response + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' + /customers: + post: + operationId: PostCustomers + summary: Create a Customer + description: Creates a Customer account. + requestBody: + content: + application/json: + schema: + required: + - first_name + - last_name + - email + - password + properties: + first_name: + description: The Customer's first name. + type: string + last_name: + description: The Customer's last name. + type: string + email: + description: The email of the customer. + type: string + format: email + password: + description: The Customer's password. + type: string + format: password + phone: + description: The Customer's phone number. + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + medusa.customers.create({ + first_name: 'Alec', + last_name: 'Reynolds', + email: 'user@example.com', + password: 'supersecret' + }) + + .then(({ customer }) => { + console.log(customer.id); + }); + - lang: Shell + label: cURL + source: > + curl --location --request POST + 'https://medusa-url.com/store/customers' \ + + --header 'Content-Type: application/json' \ + + --data-raw '{ + "first_name": "Alec", + "last_name": "Reynolds", + "email": "user@example.com", + "password": "supersecret" + }' + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + '400': + $ref: '#/components/responses/400_error' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + description: A customer with the same email exists + content: + application/json: + schema: + properties: + code: + type: string + description: The error code + type: + type: string + description: The type of error + message: + type: string + description: Human-readable message with details about the error + example: + code: invalid_request_error + type: duplicate_error + message: >- + A customer with the given email already has an account. Log in + instead + '500': + $ref: '#/components/responses/500_error' + '/customers/me/addresses/{address_id}': + delete: + operationId: DeleteCustomersCustomerAddressesAddress + summary: Delete an Address + description: Removes an Address from the Customer's saved addresses. + x-authenticated: true + parameters: + - in: path + name: address_id + required: true + description: The id of the Address to remove. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged + + medusa.customers.addresses.deleteAddress(address_id) + + .then(({ customer }) => { + console.log(customer.id); + }); + - lang: Shell + label: cURL + source: > + curl --location --request DELETE + 'https://medusa-url.com/store/customers/me/addresses/{address_id}' \ + + --header 'Cookie: connect.sid={sid}' + security: + - cookie_auth: [] + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' + post: + operationId: PostCustomersCustomerAddressesAddress + summary: Update a Shipping Address + description: Updates a Customer's saved Shipping Address. + x-authenticated: true + parameters: + - in: path + name: address_id + required: true + description: The id of the Address to update. + schema: + type: string + requestBody: + content: + application/json: + schema: + anyOf: + - $ref: '#/components/schemas/address' + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged + + medusa.customers.addresses.updateAddress(address_id, { + first_name: 'Gina' + }) + + .then(({ customer }) => { + console.log(customer.id); + }); + - lang: Shell + label: cURL + source: > + curl --location --request POST + 'https://medusa-url.com/store/customers/me/addresses/{address_id}' \ + + --header 'Cookie: connect.sid={sid}' \ + + --header 'Content-Type: application/json' \ + + --data-raw '{ + "first_name": "Gina" + }' + security: + - cookie_auth: [] + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' + /customers/me: + get: + operationId: GetCustomersCustomer + summary: Get a Customer + description: >- + Retrieves a Customer - the Customer must be logged in to retrieve their + details. + x-authenticated: true + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged + + medusa.customers.retrieve() + + .then(({ customer }) => { + console.log(customer.id); + }); + - lang: Shell + label: cURL + source: > + curl --location --request GET + 'https://medusa-url.com/store/customers/me' \ + + --header 'Cookie: connect.sid={sid}' + security: + - cookie_auth: [] + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' + post: + operationId: PostCustomersCustomer + summary: Update Customer + description: Updates a Customer's saved details. + x-authenticated: true + requestBody: + content: + application/json: + schema: + properties: + first_name: + description: The Customer's first name. + type: string + last_name: + description: The Customer's last name. + type: string + billing_address: + description: The Address to be used for billing purposes. + anyOf: + - $ref: '#/components/schemas/address' + description: The full billing address object + - type: string + description: The ID of an existing billing address + password: + description: The Customer's password. + type: string + phone: + description: The Customer's phone number. + type: string + email: + description: The email of the customer. + type: string + metadata: + description: Metadata about the customer. + type: object + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged + + medusa.customers.update({ + first_name: 'Laury' + }) + + .then(({ customer }) => { + console.log(customer.id); + }); + - lang: Shell + label: cURL + source: > + curl --location --request POST + 'https://medusa-url.com/store/customers/me' \ + + --header 'Cookie: connect.sid={sid}' \ + + --header 'Content-Type: application/json' \ + + --data-raw '{ + "first_name": "Laury" + }' + security: + - cookie_auth: [] + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' + /customers/me/payment-methods: + get: + operationId: GetCustomersCustomerPaymentMethods + summary: Get Payment Methods + description: >- + Retrieves a list of a Customer's saved payment methods. Payment methods + are saved with Payment Providers and it is their responsibility to fetch + saved methods. + x-authenticated: true + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged + + medusa.customers.paymentMethods.list() + + .then(({ payment_methods }) => { + console.log(payment_methods.length); + }); + - lang: Shell + label: cURL + source: > + curl --location --request GET + 'https://medusa-url.com/store/customers/me/payment-methods' \ + + --header 'Cookie: connect.sid={sid}' + security: + - cookie_auth: [] + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + payment_methods: + type: array + items: + properties: + provider_id: + type: string + description: >- + The id of the Payment Provider where the payment + method is saved. + data: + type: object + description: >- + The data needed for the Payment Provider to use the + saved payment method. + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' + /customers/me/orders: + get: + operationId: GetCustomersCustomerOrders + summary: List Orders + description: Retrieves a list of a Customer's Orders. + x-authenticated: true + parameters: + - in: query + name: q + description: Query used for searching orders. + schema: + type: string + - in: query + name: id + description: Id of the order to search for. + schema: + type: string + - in: query + name: status + style: form + explode: false + description: Status to search for. + schema: + type: array + items: + type: string + - in: query + name: fulfillment_status + style: form + explode: false + description: Fulfillment status to search for. + schema: + type: array + items: + type: string + - in: query + name: payment_status + style: form + explode: false + description: Payment status to search for. + schema: + type: array + items: + type: string + - in: query + name: display_id + description: Display id to search for. + schema: + type: string + - in: query + name: cart_id + description: to search for. + schema: + type: string + - in: query + name: email + description: to search for. + schema: + type: string + - in: query + name: region_id + description: to search for. + schema: + type: string + - in: query + name: currency_code + style: form + explode: false + description: The 3 character ISO currency code to set prices based on. + schema: + type: string + externalDocs: + url: 'https://en.wikipedia.org/wiki/ISO_4217#Active_codes' + description: See a list of codes. + - in: query + name: tax_rate + description: to search for. + schema: + type: string + - in: query + name: created_at + description: Date comparison for when resulting collections were created. + schema: + type: object + properties: + lt: + type: string + description: filter by dates less than this date + format: date + gt: + type: string + description: filter by dates greater than this date + format: date + lte: + type: string + description: filter by dates less than or equal to this date + format: date + gte: + type: string + description: filter by dates greater than or equal to this date + format: date + - in: query + name: updated_at + description: Date comparison for when resulting collections were updated. + schema: + type: object + properties: + lt: + type: string + description: filter by dates less than this date + format: date + gt: + type: string + description: filter by dates greater than this date + format: date + lte: + type: string + description: filter by dates less than or equal to this date + format: date + gte: + type: string + description: filter by dates greater than or equal to this date + format: date + - in: query + name: canceled_at + description: Date comparison for when resulting collections were canceled. + schema: + type: object + properties: + lt: + type: string + description: filter by dates less than this date + format: date + gt: + type: string + description: filter by dates greater than this date + format: date + lte: + type: string + description: filter by dates less than or equal to this date + format: date + gte: + type: string + description: filter by dates greater than or equal to this date + format: date + - in: query + name: limit + description: How many orders to return. + schema: + type: integer + default: 10 + - in: query + name: offset + description: The offset in the resulting orders. + schema: + type: integer + default: 0 + - in: query + name: fields + description: >- + (Comma separated string) Which fields should be included in the + resulting orders. + schema: + type: string + - in: query + name: expand + description: >- + (Comma separated string) Which relations should be expanded in the + resulting orders. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + // must be previously logged + + medusa.customers.listOrders() + + .then(({ orders, limit, offset, count }) => { + console.log(orders); + }); + - lang: Shell + label: cURL + source: > + curl --location --request GET + 'https://medusa-url.com/store/customers/me/orders' \ + + --header 'Cookie: connect.sid={sid}' + security: + - cookie_auth: [] + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + orders: + type: array + items: + $ref: '#/components/schemas/order' + count: + type: integer + description: The total number of items available + offset: + type: integer + description: The number of items skipped before these items + limit: + type: integer + description: The number of items per page + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' + /customers/password-token: + post: + operationId: PostCustomersCustomerPasswordToken + summary: Request Password Reset + description: >- + Creates a reset password token to be used in a subsequent + /reset-password request. The password token should be sent out of band + e.g. via email and will not be returned. + requestBody: + content: + application/json: + schema: + required: + - email + properties: + email: + description: The email of the customer. + type: string + format: email + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + medusa.customers.generatePasswordToken({ + email: 'user@example.com' + }) + + .then(() => { + // successful + }) + + .catch(() => { + // failed + }) + - lang: Shell + label: cURL + source: > + curl --location --request POST + 'https://medusa-url.com/store/customers/password-token' \ + + --header 'Content-Type: application/json' \ + + --data-raw '{ + "email": "user@example.com" + }' + tags: + - Customer + responses: + '204': + description: OK + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' + /customers/password-reset: + post: + operationId: PostCustomersResetPassword + summary: Reset Password + description: >- + Resets a Customer's password using a password token created by a + previous /password-token request. + requestBody: + content: + application/json: + schema: + required: + - email + - password + - token + properties: + email: + description: The email of the customer. + type: string + format: email + password: + description: The Customer's password. + type: string + format: password + token: + description: The reset password token + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + medusa.customers.resetPassword({ + email: 'user@example.com', + password: 'supersecret', + token: 'supersecrettoken' + }) + + .then(({ customer }) => { + console.log(customer.id); + }); + - lang: Shell + label: cURL + source: > + curl --location --request POST + 'https://medusa-url.com/store/customers/password-reset' \ + + --header 'Content-Type: application/json' \ + + --data-raw '{ + "email": "user@example.com", + "password": "supersecret", + "token": "supersecrettoken" + }' + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' + '/order-edits/{id}/complete': + post: + operationId: PostOrderEditsOrderEditComplete + summary: Completes an OrderEdit + description: Completes an OrderEdit. + parameters: + - in: path + name: id + required: true + description: The ID of the Order Edit. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + medusa.orderEdit.complete(orderEditId) + .then(({ order_edit }) => { + console.log(order_edit.id) + }) + - lang: Shell + label: cURL + source: > + curl --location --request POST + 'https://medusa-url.com/store/order-edits/{id}/complete' + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: '#/components/schemas/order_edit' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '500': + $ref: '#/components/responses/500_error' + '/order-edits/{id}/decline': + post: + operationId: PostOrderEditsOrderEditDecline + summary: Decline an OrderEdit + description: Declines an OrderEdit. + parameters: + - in: path + name: id + required: true + description: The ID of the OrderEdit. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + declined_reason: + type: string + description: The reason for declining the OrderEdit. + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + medusa.orderEdit.decline(orderEditId) + .then(({ order_edit }) => { + console.log(order_edit.id); + }) + - lang: Shell + label: cURL + source: > + curl --location --request POST + 'https://medusa-url.com/store/order-edits/{id}/decline' + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: '#/components/schemas/order_edit' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '500': + $ref: '#/components/responses/500_error' + '/order-edits/{id}': + get: + operationId: GetOrderEditsOrderEdit + summary: Retrieve an OrderEdit + description: Retrieves a OrderEdit. + parameters: + - in: path + name: id + required: true + description: The ID of the OrderEdit. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + medusa.orderEdit.retrieve(orderEditId) + + .then(({ order_edit }) => { + console.log(order_edit.id); + }); + - lang: Shell + label: cURL + source: > + curl --location --request GET + 'https://medusa-url.com/store/order-edits/{id}' + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: '#/components/schemas/order_edit' + '400': + $ref: '#/components/responses/400_error' + '401': + $ref: '#/components/responses/unauthorized' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' + '/orders/cart/{cart_id}': + get: + operationId: GetOrdersOrderCartId + summary: Get by Cart ID + description: >- + Retrieves an Order by the id of the Cart that was used to create the + Order. + parameters: + - in: path + name: cart_id + required: true + description: The ID of Cart. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + medusa.orders.retrieveByCartId(cart_id) + + .then(({ order }) => { + console.log(order.id); + }); + - lang: Shell + label: cURL + source: > + curl --location --request GET + 'https://medusa-url.com/store/orders/cart/{id}' + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '400': + $ref: '#/components/responses/400_error' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' + '/orders/{id}': + get: + operationId: GetOrdersOrder + summary: Get an Order + description: Retrieves an Order + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + medusa.orders.retrieve(order_id) + + .then(({ order }) => { + console.log(order.id); + }); + - lang: Shell + label: cURL + source: > + curl --location --request GET + 'https://medusa-url.com/store/orders/{id}' + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '400': + $ref: '#/components/responses/400_error' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' + /orders: + get: + operationId: GetOrders + summary: Look Up an Order + description: Look up an order using filters. + parameters: + - in: query + name: display_id + required: true + description: The display id given to the Order. + schema: + type: number + - in: query + name: email + style: form + explode: false + description: The email associated with this order. + required: true + schema: + type: string + format: email + - in: query + name: shipping_address + style: form + explode: false + description: The shipping address associated with this order. + schema: + type: object + properties: + postal_code: + type: string + description: The postal code of the shipping address + x-codeSamples: + - lang: JavaScript + label: JS Client + source: > + import Medusa from "@medusajs/medusa-js" + + const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: + 3 }) + + medusa.orders.lookupOrder({ + display_id: 1, + email: 'user@example.com' + }) + + .then(({ order }) => { + console.log(order.id); + }); + - lang: Shell + label: cURL + source: > + curl --location --request GET + 'https://medusa-url.com/store/orders?display_id=1&email=user@example.com' + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '400': + $ref: '#/components/responses/400_error' + '404': + $ref: '#/components/responses/not_found_error' + '409': + $ref: '#/components/responses/invalid_state_error' + '422': + $ref: '#/components/responses/invalid_request_error' + '500': + $ref: '#/components/responses/500_error' '/carts/{id}/shipping-methods': post: operationId: PostCartsCartShippingMethod @@ -1360,1332 +2929,6 @@ paths: provider_id: type: string description: The ID of the Payment Provider. - '/collections/{id}': - get: - operationId: GetCollectionsCollection - summary: Get a Collection - description: Retrieves a Product Collection. - parameters: - - in: path - name: id - required: true - description: The id of the Product Collection - schema: - type: string - x-codeSamples: - - lang: JavaScript - label: JS Client - source: > - import Medusa from "@medusajs/medusa-js" - - const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: - 3 }) - - medusa.collections.retrieve(collection_id) - - .then(({ collection }) => { - console.log(collection.id); - }); - - lang: Shell - label: cURL - source: > - curl --location --request GET - 'https://medusa-url.com/store/collections/{id}' - tags: - - Collection - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - collection: - $ref: '#/components/schemas/product_collection' - '400': - $ref: '#/components/responses/400_error' - '404': - $ref: '#/components/responses/not_found_error' - '409': - $ref: '#/components/responses/invalid_state_error' - '422': - $ref: '#/components/responses/invalid_request_error' - '500': - $ref: '#/components/responses/500_error' - /collections: - get: - operationId: GetCollections - summary: List Collections - description: Retrieve a list of Product Collection. - parameters: - - in: query - name: offset - description: >- - The number of collections to skip before starting to collect the - collections set - schema: - type: integer - default: 0 - - in: query - name: limit - description: The number of collections to return - schema: - type: integer - default: 10 - - in: query - name: created_at - description: Date comparison for when resulting collections were created. - schema: - type: object - properties: - lt: - type: string - description: filter by dates less than this date - format: date - gt: - type: string - description: filter by dates greater than this date - format: date - lte: - type: string - description: filter by dates less than or equal to this date - format: date - gte: - type: string - description: filter by dates greater than or equal to this date - format: date - - in: query - name: updated_at - description: Date comparison for when resulting collections were updated. - schema: - type: object - properties: - lt: - type: string - description: filter by dates less than this date - format: date - gt: - type: string - description: filter by dates greater than this date - format: date - lte: - type: string - description: filter by dates less than or equal to this date - format: date - gte: - type: string - description: filter by dates greater than or equal to this date - format: date - x-codeSamples: - - lang: JavaScript - label: JS Client - source: > - import Medusa from "@medusajs/medusa-js" - - const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: - 3 }) - - medusa.collections.list() - - .then(({ collections, limit, offset, count }) => { - console.log(collections.length); - }); - - lang: Shell - label: cURL - source: > - curl --location --request GET - 'https://medusa-url.com/store/collections' - tags: - - Collection - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - collections: - type: array - items: - $ref: '#/components/schemas/product_collection' - count: - type: integer - description: The total number of items available - offset: - type: integer - description: The number of items skipped before these items - limit: - type: integer - description: The number of items per page - '400': - $ref: '#/components/responses/400_error' - '404': - $ref: '#/components/responses/not_found_error' - '409': - $ref: '#/components/responses/invalid_state_error' - '422': - $ref: '#/components/responses/invalid_request_error' - '500': - $ref: '#/components/responses/500_error' - /customers/me/addresses: - post: - operationId: PostCustomersCustomerAddresses - summary: Add a Shipping Address - description: Adds a Shipping Address to a Customer's saved addresses. - x-authenticated: true - requestBody: - content: - application/json: - schema: - required: - - address - properties: - address: - description: The Address to add to the Customer. - anyOf: - - $ref: '#/components/schemas/address' - x-codeSamples: - - lang: JavaScript - label: JS Client - source: > - import Medusa from "@medusajs/medusa-js" - - const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: - 3 }) - - // must be previously logged - - medusa.customers.addresses.addAddress({ - address: { - first_name: 'Celia', - last_name: 'Schumm', - address_1: '225 Bednar Curve', - city: 'Danielville', - country_code: 'US', - postal_code: '85137', - phone: '981-596-6748 x90188', - company: 'Wyman LLC', - address_2: '', - province: 'Georgia', - metadata: {} - } - }) - - .then(({ customer }) => { - console.log(customer.id); - }); - - lang: Shell - label: cURL - source: > - curl --location --request POST - 'https://medusa-url.com/store/customers/me/addresses' \ - - --header 'Cookie: connect.sid={sid}' \ - - --header 'Content-Type: application/json' \ - - --data-raw '{ - "address": { - "first_name": "Celia", - "last_name": "Schumm", - "address_1": "225 Bednar Curve", - "city": "Danielville", - "country_code": "US", - "postal_code": "85137" - } - }' - security: - - cookie_auth: [] - tags: - - Customer - responses: - '200': - description: A successful response - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - '400': - $ref: '#/components/responses/400_error' - '401': - $ref: '#/components/responses/unauthorized' - '404': - $ref: '#/components/responses/not_found_error' - '409': - $ref: '#/components/responses/invalid_state_error' - '422': - $ref: '#/components/responses/invalid_request_error' - '500': - $ref: '#/components/responses/500_error' - /customers: - post: - operationId: PostCustomers - summary: Create a Customer - description: Creates a Customer account. - requestBody: - content: - application/json: - schema: - required: - - first_name - - last_name - - email - - password - properties: - first_name: - description: The Customer's first name. - type: string - last_name: - description: The Customer's last name. - type: string - email: - description: The email of the customer. - type: string - format: email - password: - description: The Customer's password. - type: string - format: password - phone: - description: The Customer's phone number. - type: string - x-codeSamples: - - lang: JavaScript - label: JS Client - source: > - import Medusa from "@medusajs/medusa-js" - - const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: - 3 }) - - medusa.customers.create({ - first_name: 'Alec', - last_name: 'Reynolds', - email: 'user@example.com', - password: 'supersecret' - }) - - .then(({ customer }) => { - console.log(customer.id); - }); - - lang: Shell - label: cURL - source: > - curl --location --request POST - 'https://medusa-url.com/store/customers' \ - - --header 'Content-Type: application/json' \ - - --data-raw '{ - "first_name": "Alec", - "last_name": "Reynolds", - "email": "user@example.com", - "password": "supersecret" - }' - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - '400': - $ref: '#/components/responses/400_error' - '404': - $ref: '#/components/responses/not_found_error' - '409': - $ref: '#/components/responses/invalid_state_error' - '422': - description: A customer with the same email exists - content: - application/json: - schema: - properties: - code: - type: string - description: The error code - type: - type: string - description: The type of error - message: - type: string - description: Human-readable message with details about the error - example: - code: invalid_request_error - type: duplicate_error - message: >- - A customer with the given email already has an account. Log in - instead - '500': - $ref: '#/components/responses/500_error' - '/customers/me/addresses/{address_id}': - delete: - operationId: DeleteCustomersCustomerAddressesAddress - summary: Delete an Address - description: Removes an Address from the Customer's saved addresses. - x-authenticated: true - parameters: - - in: path - name: address_id - required: true - description: The id of the Address to remove. - schema: - type: string - x-codeSamples: - - lang: JavaScript - label: JS Client - source: > - import Medusa from "@medusajs/medusa-js" - - const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: - 3 }) - - // must be previously logged - - medusa.customers.addresses.deleteAddress(address_id) - - .then(({ customer }) => { - console.log(customer.id); - }); - - lang: Shell - label: cURL - source: > - curl --location --request DELETE - 'https://medusa-url.com/store/customers/me/addresses/{address_id}' \ - - --header 'Cookie: connect.sid={sid}' - security: - - cookie_auth: [] - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - '400': - $ref: '#/components/responses/400_error' - '401': - $ref: '#/components/responses/unauthorized' - '404': - $ref: '#/components/responses/not_found_error' - '409': - $ref: '#/components/responses/invalid_state_error' - '422': - $ref: '#/components/responses/invalid_request_error' - '500': - $ref: '#/components/responses/500_error' - post: - operationId: PostCustomersCustomerAddressesAddress - summary: Update a Shipping Address - description: Updates a Customer's saved Shipping Address. - x-authenticated: true - parameters: - - in: path - name: address_id - required: true - description: The id of the Address to update. - schema: - type: string - requestBody: - content: - application/json: - schema: - anyOf: - - $ref: '#/components/schemas/address' - x-codeSamples: - - lang: JavaScript - label: JS Client - source: > - import Medusa from "@medusajs/medusa-js" - - const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: - 3 }) - - // must be previously logged - - medusa.customers.addresses.updateAddress(address_id, { - first_name: 'Gina' - }) - - .then(({ customer }) => { - console.log(customer.id); - }); - - lang: Shell - label: cURL - source: > - curl --location --request POST - 'https://medusa-url.com/store/customers/me/addresses/{address_id}' \ - - --header 'Cookie: connect.sid={sid}' \ - - --header 'Content-Type: application/json' \ - - --data-raw '{ - "first_name": "Gina" - }' - security: - - cookie_auth: [] - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - '400': - $ref: '#/components/responses/400_error' - '401': - $ref: '#/components/responses/unauthorized' - '404': - $ref: '#/components/responses/not_found_error' - '409': - $ref: '#/components/responses/invalid_state_error' - '422': - $ref: '#/components/responses/invalid_request_error' - '500': - $ref: '#/components/responses/500_error' - /customers/me: - get: - operationId: GetCustomersCustomer - summary: Get a Customer - description: >- - Retrieves a Customer - the Customer must be logged in to retrieve their - details. - x-authenticated: true - x-codeSamples: - - lang: JavaScript - label: JS Client - source: > - import Medusa from "@medusajs/medusa-js" - - const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: - 3 }) - - // must be previously logged - - medusa.customers.retrieve() - - .then(({ customer }) => { - console.log(customer.id); - }); - - lang: Shell - label: cURL - source: > - curl --location --request GET - 'https://medusa-url.com/store/customers/me' \ - - --header 'Cookie: connect.sid={sid}' - security: - - cookie_auth: [] - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - '400': - $ref: '#/components/responses/400_error' - '401': - $ref: '#/components/responses/unauthorized' - '404': - $ref: '#/components/responses/not_found_error' - '409': - $ref: '#/components/responses/invalid_state_error' - '422': - $ref: '#/components/responses/invalid_request_error' - '500': - $ref: '#/components/responses/500_error' - post: - operationId: PostCustomersCustomer - summary: Update Customer - description: Updates a Customer's saved details. - x-authenticated: true - requestBody: - content: - application/json: - schema: - properties: - first_name: - description: The Customer's first name. - type: string - last_name: - description: The Customer's last name. - type: string - billing_address: - description: The Address to be used for billing purposes. - anyOf: - - $ref: '#/components/schemas/address' - description: The full billing address object - - type: string - description: The ID of an existing billing address - password: - description: The Customer's password. - type: string - phone: - description: The Customer's phone number. - type: string - email: - description: The email of the customer. - type: string - metadata: - description: Metadata about the customer. - type: object - x-codeSamples: - - lang: JavaScript - label: JS Client - source: > - import Medusa from "@medusajs/medusa-js" - - const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: - 3 }) - - // must be previously logged - - medusa.customers.update({ - first_name: 'Laury' - }) - - .then(({ customer }) => { - console.log(customer.id); - }); - - lang: Shell - label: cURL - source: > - curl --location --request POST - 'https://medusa-url.com/store/customers/me' \ - - --header 'Cookie: connect.sid={sid}' \ - - --header 'Content-Type: application/json' \ - - --data-raw '{ - "first_name": "Laury" - }' - security: - - cookie_auth: [] - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - '400': - $ref: '#/components/responses/400_error' - '401': - $ref: '#/components/responses/unauthorized' - '404': - $ref: '#/components/responses/not_found_error' - '409': - $ref: '#/components/responses/invalid_state_error' - '422': - $ref: '#/components/responses/invalid_request_error' - '500': - $ref: '#/components/responses/500_error' - /customers/me/payment-methods: - get: - operationId: GetCustomersCustomerPaymentMethods - summary: Get Payment Methods - description: >- - Retrieves a list of a Customer's saved payment methods. Payment methods - are saved with Payment Providers and it is their responsibility to fetch - saved methods. - x-authenticated: true - x-codeSamples: - - lang: JavaScript - label: JS Client - source: > - import Medusa from "@medusajs/medusa-js" - - const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: - 3 }) - - // must be previously logged - - medusa.customers.paymentMethods.list() - - .then(({ payment_methods }) => { - console.log(payment_methods.length); - }); - - lang: Shell - label: cURL - source: > - curl --location --request GET - 'https://medusa-url.com/store/customers/me/payment-methods' \ - - --header 'Cookie: connect.sid={sid}' - security: - - cookie_auth: [] - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - payment_methods: - type: array - items: - properties: - provider_id: - type: string - description: >- - The id of the Payment Provider where the payment - method is saved. - data: - type: object - description: >- - The data needed for the Payment Provider to use the - saved payment method. - '400': - $ref: '#/components/responses/400_error' - '401': - $ref: '#/components/responses/unauthorized' - '404': - $ref: '#/components/responses/not_found_error' - '409': - $ref: '#/components/responses/invalid_state_error' - '422': - $ref: '#/components/responses/invalid_request_error' - '500': - $ref: '#/components/responses/500_error' - /customers/me/orders: - get: - operationId: GetCustomersCustomerOrders - summary: List Orders - description: Retrieves a list of a Customer's Orders. - x-authenticated: true - parameters: - - in: query - name: q - description: Query used for searching orders. - schema: - type: string - - in: query - name: id - description: Id of the order to search for. - schema: - type: string - - in: query - name: status - style: form - explode: false - description: Status to search for. - schema: - type: array - items: - type: string - - in: query - name: fulfillment_status - style: form - explode: false - description: Fulfillment status to search for. - schema: - type: array - items: - type: string - - in: query - name: payment_status - style: form - explode: false - description: Payment status to search for. - schema: - type: array - items: - type: string - - in: query - name: display_id - description: Display id to search for. - schema: - type: string - - in: query - name: cart_id - description: to search for. - schema: - type: string - - in: query - name: email - description: to search for. - schema: - type: string - - in: query - name: region_id - description: to search for. - schema: - type: string - - in: query - name: currency_code - style: form - explode: false - description: The 3 character ISO currency code to set prices based on. - schema: - type: string - externalDocs: - url: 'https://en.wikipedia.org/wiki/ISO_4217#Active_codes' - description: See a list of codes. - - in: query - name: tax_rate - description: to search for. - schema: - type: string - - in: query - name: created_at - description: Date comparison for when resulting collections were created. - schema: - type: object - properties: - lt: - type: string - description: filter by dates less than this date - format: date - gt: - type: string - description: filter by dates greater than this date - format: date - lte: - type: string - description: filter by dates less than or equal to this date - format: date - gte: - type: string - description: filter by dates greater than or equal to this date - format: date - - in: query - name: updated_at - description: Date comparison for when resulting collections were updated. - schema: - type: object - properties: - lt: - type: string - description: filter by dates less than this date - format: date - gt: - type: string - description: filter by dates greater than this date - format: date - lte: - type: string - description: filter by dates less than or equal to this date - format: date - gte: - type: string - description: filter by dates greater than or equal to this date - format: date - - in: query - name: canceled_at - description: Date comparison for when resulting collections were canceled. - schema: - type: object - properties: - lt: - type: string - description: filter by dates less than this date - format: date - gt: - type: string - description: filter by dates greater than this date - format: date - lte: - type: string - description: filter by dates less than or equal to this date - format: date - gte: - type: string - description: filter by dates greater than or equal to this date - format: date - - in: query - name: limit - description: How many orders to return. - schema: - type: integer - default: 10 - - in: query - name: offset - description: The offset in the resulting orders. - schema: - type: integer - default: 0 - - in: query - name: fields - description: >- - (Comma separated string) Which fields should be included in the - resulting orders. - schema: - type: string - - in: query - name: expand - description: >- - (Comma separated string) Which relations should be expanded in the - resulting orders. - schema: - type: string - x-codeSamples: - - lang: JavaScript - label: JS Client - source: > - import Medusa from "@medusajs/medusa-js" - - const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: - 3 }) - - // must be previously logged - - medusa.customers.listOrders() - - .then(({ orders, limit, offset, count }) => { - console.log(orders); - }); - - lang: Shell - label: cURL - source: > - curl --location --request GET - 'https://medusa-url.com/store/customers/me/orders' \ - - --header 'Cookie: connect.sid={sid}' - security: - - cookie_auth: [] - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - orders: - type: array - items: - $ref: '#/components/schemas/order' - count: - type: integer - description: The total number of items available - offset: - type: integer - description: The number of items skipped before these items - limit: - type: integer - description: The number of items per page - '400': - $ref: '#/components/responses/400_error' - '401': - $ref: '#/components/responses/unauthorized' - '404': - $ref: '#/components/responses/not_found_error' - '409': - $ref: '#/components/responses/invalid_state_error' - '422': - $ref: '#/components/responses/invalid_request_error' - '500': - $ref: '#/components/responses/500_error' - /customers/password-token: - post: - operationId: PostCustomersCustomerPasswordToken - summary: Request Password Reset - description: >- - Creates a reset password token to be used in a subsequent - /reset-password request. The password token should be sent out of band - e.g. via email and will not be returned. - requestBody: - content: - application/json: - schema: - required: - - email - properties: - email: - description: The email of the customer. - type: string - format: email - x-codeSamples: - - lang: JavaScript - label: JS Client - source: > - import Medusa from "@medusajs/medusa-js" - - const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: - 3 }) - - medusa.customers.generatePasswordToken({ - email: 'user@example.com' - }) - - .then(() => { - // successful - }) - - .catch(() => { - // failed - }) - - lang: Shell - label: cURL - source: > - curl --location --request POST - 'https://medusa-url.com/store/customers/password-token' \ - - --header 'Content-Type: application/json' \ - - --data-raw '{ - "email": "user@example.com" - }' - tags: - - Customer - responses: - '204': - description: OK - '400': - $ref: '#/components/responses/400_error' - '401': - $ref: '#/components/responses/unauthorized' - '404': - $ref: '#/components/responses/not_found_error' - '409': - $ref: '#/components/responses/invalid_state_error' - '422': - $ref: '#/components/responses/invalid_request_error' - '500': - $ref: '#/components/responses/500_error' - /customers/password-reset: - post: - operationId: PostCustomersResetPassword - summary: Reset Password - description: >- - Resets a Customer's password using a password token created by a - previous /password-token request. - requestBody: - content: - application/json: - schema: - required: - - email - - password - - token - properties: - email: - description: The email of the customer. - type: string - format: email - password: - description: The Customer's password. - type: string - format: password - token: - description: The reset password token - type: string - x-codeSamples: - - lang: JavaScript - label: JS Client - source: > - import Medusa from "@medusajs/medusa-js" - - const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: - 3 }) - - medusa.customers.resetPassword({ - email: 'user@example.com', - password: 'supersecret', - token: 'supersecrettoken' - }) - - .then(({ customer }) => { - console.log(customer.id); - }); - - lang: Shell - label: cURL - source: > - curl --location --request POST - 'https://medusa-url.com/store/customers/password-reset' \ - - --header 'Content-Type: application/json' \ - - --data-raw '{ - "email": "user@example.com", - "password": "supersecret", - "token": "supersecrettoken" - }' - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - '400': - $ref: '#/components/responses/400_error' - '401': - $ref: '#/components/responses/unauthorized' - '404': - $ref: '#/components/responses/not_found_error' - '409': - $ref: '#/components/responses/invalid_state_error' - '422': - $ref: '#/components/responses/invalid_request_error' - '500': - $ref: '#/components/responses/500_error' - '/gift-cards/{code}': - get: - operationId: GetGiftCardsCode - summary: Get Gift Card by Code - description: Retrieves a Gift Card by its associated unqiue code. - parameters: - - in: path - name: code - required: true - description: The unique Gift Card code. - schema: - type: string - x-codeSamples: - - lang: JavaScript - label: JS Client - source: > - import Medusa from "@medusajs/medusa-js" - - const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: - 3 }) - - medusa.giftCards.retrieve(code) - - .then(({ gift_card }) => { - console.log(gift_card.id); - }); - - lang: Shell - label: cURL - source: > - curl --location --request GET - 'https://medusa-url.com/store/gift-cards/{code}' - tags: - - Gift Card - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - gift_card: - $ref: '#/components/schemas/gift_card' - '400': - $ref: '#/components/responses/400_error' - '404': - $ref: '#/components/responses/not_found_error' - '409': - $ref: '#/components/responses/invalid_state_error' - '422': - $ref: '#/components/responses/invalid_request_error' - '500': - $ref: '#/components/responses/500_error' - '/orders/cart/{cart_id}': - get: - operationId: GetOrdersOrderCartId - summary: Get by Cart ID - description: >- - Retrieves an Order by the id of the Cart that was used to create the - Order. - parameters: - - in: path - name: cart_id - required: true - description: The ID of Cart. - schema: - type: string - x-codeSamples: - - lang: JavaScript - label: JS Client - source: > - import Medusa from "@medusajs/medusa-js" - - const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: - 3 }) - - medusa.orders.retrieveByCartId(cart_id) - - .then(({ order }) => { - console.log(order.id); - }); - - lang: Shell - label: cURL - source: > - curl --location --request GET - 'https://medusa-url.com/store/orders/cart/{id}' - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '400': - $ref: '#/components/responses/400_error' - '404': - $ref: '#/components/responses/not_found_error' - '409': - $ref: '#/components/responses/invalid_state_error' - '422': - $ref: '#/components/responses/invalid_request_error' - '500': - $ref: '#/components/responses/500_error' - '/orders/{id}': - get: - operationId: GetOrdersOrder - summary: Get an Order - description: Retrieves an Order - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - x-codeSamples: - - lang: JavaScript - label: JS Client - source: > - import Medusa from "@medusajs/medusa-js" - - const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: - 3 }) - - medusa.orders.retrieve(order_id) - - .then(({ order }) => { - console.log(order.id); - }); - - lang: Shell - label: cURL - source: > - curl --location --request GET - 'https://medusa-url.com/store/orders/{id}' - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '400': - $ref: '#/components/responses/400_error' - '404': - $ref: '#/components/responses/not_found_error' - '409': - $ref: '#/components/responses/invalid_state_error' - '422': - $ref: '#/components/responses/invalid_request_error' - '500': - $ref: '#/components/responses/500_error' - /orders: - get: - operationId: GetOrders - summary: Look Up an Order - description: Look up an order using filters. - parameters: - - in: query - name: display_id - required: true - description: The display id given to the Order. - schema: - type: number - - in: query - name: email - style: form - explode: false - description: The email associated with this order. - required: true - schema: - type: string - format: email - - in: query - name: shipping_address - style: form - explode: false - description: The shipping address associated with this order. - schema: - type: object - properties: - postal_code: - type: string - description: The postal code of the shipping address - x-codeSamples: - - lang: JavaScript - label: JS Client - source: > - import Medusa from "@medusajs/medusa-js" - - const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: - 3 }) - - medusa.orders.lookupOrder({ - display_id: 1, - email: 'user@example.com' - }) - - .then(({ order }) => { - console.log(order.id); - }); - - lang: Shell - label: cURL - source: > - curl --location --request GET - 'https://medusa-url.com/store/orders?display_id=1&email=user@example.com' - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '400': - $ref: '#/components/responses/400_error' - '404': - $ref: '#/components/responses/not_found_error' - '409': - $ref: '#/components/responses/invalid_state_error' - '422': - $ref: '#/components/responses/invalid_request_error' - '500': - $ref: '#/components/responses/500_error' '/products/{id}': get: operationId: GetProductsProduct @@ -6174,6 +6417,17 @@ components: includes_tax: description: '[EXPERIMENTAL] Indicates if the line item unit_price include tax' type: boolean + original_item_id: + description: '[EXPERIMENTAL] The id of the original line item' + type: string + order_edit_id: + description: >- + [EXPERIMENTAL] The ID of the order edit to which a cloned item + belongs + type: string + order_edit: + description: '[EXPERIMENTAL] The order edit joined' + type: object created_at: type: string description: The date with timezone at which the resource was created. @@ -6579,12 +6833,24 @@ components: type: string subtotal: type: integer - description: The subtotal for line items computed from changes. + description: The total of subtotal example: 8000 discount_total: type: integer description: The total of discount example: 800 + shipping_total: + type: integer + description: The total of the shipping amount + example: 800 + gift_card_total: + type: integer + description: The total of the gift card amount + example: 800 + gift_card_tax_total: + type: integer + description: The total of the gift card tax amount + example: 800 tax_total: type: integer description: The total of tax diff --git a/docs/api/store/code_samples/JavaScript/order-edits_{id}/getundefined b/docs/api/store/code_samples/JavaScript/order-edits_{id}/getundefined new file mode 100644 index 0000000000..f77c2b0a27 --- /dev/null +++ b/docs/api/store/code_samples/JavaScript/order-edits_{id}/getundefined @@ -0,0 +1,6 @@ +import Medusa from "@medusajs/medusa-js" +const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) +medusa.orderEdit.retrieve(orderEditId) +.then(({ order_edit }) => { + console.log(order_edit.id); +}); diff --git a/docs/api/store/code_samples/JavaScript/order-edits_{id}_complete/postundefined b/docs/api/store/code_samples/JavaScript/order-edits_{id}_complete/postundefined new file mode 100644 index 0000000000..ee0fa54b93 --- /dev/null +++ b/docs/api/store/code_samples/JavaScript/order-edits_{id}_complete/postundefined @@ -0,0 +1,6 @@ +import Medusa from "@medusajs/medusa-js" +const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) +medusa.orderEdit.complete(orderEditId) + .then(({ order_edit }) => { + console.log(order_edit.id) + }) diff --git a/docs/api/store/code_samples/JavaScript/order-edits_{id}_decline/postundefined b/docs/api/store/code_samples/JavaScript/order-edits_{id}_decline/postundefined new file mode 100644 index 0000000000..f3edf50fc7 --- /dev/null +++ b/docs/api/store/code_samples/JavaScript/order-edits_{id}_decline/postundefined @@ -0,0 +1,6 @@ +import Medusa from "@medusajs/medusa-js" +const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) +medusa.orderEdit.decline(orderEditId) + .then(({ order_edit }) => { + console.log(order_edit.id); + }) diff --git a/docs/api/store/code_samples/Shell/order-edits_{id}/getundefined b/docs/api/store/code_samples/Shell/order-edits_{id}/getundefined new file mode 100644 index 0000000000..10abf0b797 --- /dev/null +++ b/docs/api/store/code_samples/Shell/order-edits_{id}/getundefined @@ -0,0 +1 @@ +curl --location --request GET 'https://medusa-url.com/store/order-edits/{id}' diff --git a/docs/api/store/code_samples/Shell/order-edits_{id}_complete/postundefined b/docs/api/store/code_samples/Shell/order-edits_{id}_complete/postundefined new file mode 100644 index 0000000000..4fbcea1656 --- /dev/null +++ b/docs/api/store/code_samples/Shell/order-edits_{id}_complete/postundefined @@ -0,0 +1 @@ +curl --location --request POST 'https://medusa-url.com/store/order-edits/{id}/complete' diff --git a/docs/api/store/code_samples/Shell/order-edits_{id}_decline/postundefined b/docs/api/store/code_samples/Shell/order-edits_{id}_decline/postundefined new file mode 100644 index 0000000000..3fdbfd7094 --- /dev/null +++ b/docs/api/store/code_samples/Shell/order-edits_{id}_decline/postundefined @@ -0,0 +1 @@ +curl --location --request POST 'https://medusa-url.com/store/order-edits/{id}/decline' diff --git a/docs/api/store/components/schemas/line_item.yaml b/docs/api/store/components/schemas/line_item.yaml index 32174752a2..cdb06694a9 100644 --- a/docs/api/store/components/schemas/line_item.yaml +++ b/docs/api/store/components/schemas/line_item.yaml @@ -160,6 +160,15 @@ properties: includes_tax: description: '[EXPERIMENTAL] Indicates if the line item unit_price include tax' type: boolean + original_item_id: + description: '[EXPERIMENTAL] The id of the original line item' + type: string + order_edit_id: + description: '[EXPERIMENTAL] The ID of the order edit to which a cloned item belongs' + type: string + order_edit: + description: '[EXPERIMENTAL] The order edit joined' + type: object created_at: type: string description: The date with timezone at which the resource was created. diff --git a/docs/api/store/components/schemas/order_edit.yaml b/docs/api/store/components/schemas/order_edit.yaml index b050c5a36d..fdcb17fccd 100644 --- a/docs/api/store/components/schemas/order_edit.yaml +++ b/docs/api/store/components/schemas/order_edit.yaml @@ -60,12 +60,24 @@ properties: type: string subtotal: type: integer - description: The subtotal for line items computed from changes. + description: The total of subtotal example: 8000 discount_total: type: integer description: The total of discount example: 800 + shipping_total: + type: integer + description: The total of the shipping amount + example: 800 + gift_card_total: + type: integer + description: The total of the gift card amount + example: 800 + gift_card_tax_total: + type: integer + description: The total of the gift card tax amount + example: 800 tax_total: type: integer description: The total of tax diff --git a/docs/api/store/openapi.yaml b/docs/api/store/openapi.yaml index cdef601bef..f0d4669a0b 100644 --- a/docs/api/store/openapi.yaml +++ b/docs/api/store/openapi.yaml @@ -15,6 +15,89 @@ info: + + + ## Expanding Fields + + + In many endpoints you'll find an `expand` query parameter that can be passed + to the endpoint. You can use the `expand` query parameter to unpack an + entity's relations and return them in the response. + + + For example, when you list customers you can also retrieve their groups by + passing to the `expand` query parameter the value `groups`. + + + You can expand more than one relation by separating the relations in the + `expand` query parameter with a comma. For example, to retrieve both the + orders and the groups of a customer, pass to the `expand` query parameter + the value `groups,orders`. + + + Please note that the parameters you pass to `expand` replace any relations + that are expanded by default. + + + ## Selecting Fields + + + In many endpoints you'll find a `fields` query parameter that can be passed + to the endpoint. You can use the `fields` query parameter to specify which + fields in the entity should be returned in the response. + + + You can pass more than one field by seperating the field names in the + `fields` query parameter with a comma. + + + Only the fields you pass to `field` will be retrieved and returned in the + response. Any fields that are returned by default will not be returned in + this case. This does not affect relations. + + + For example, to only select the `title` and `description` fields of a + product, pass to the `fields` query parameter the value `title,description`. + + + ## Pagination + + + ### Query Parameters + + + In listing endpoints, such as list customers or list products, you can + control the pagination using the query parameters `limit` and `offset`. + + + `limit` is used to specify the maximum number of items that can be return in + the response. `offset` is used to specify how many items to skip before + returning the resulting entities. + + + You can use the `offset` query parameter to change between pages. For + example, if the limit is 50, at page 1 the offset should be 0; at page 2 the + offset should be 50, and so on. + + + ### Response Fields + + + In listing fields, aside from the entities retrieved, there are three + pagination-related fields returned: `count`, `limit`, and `offset`. + + + Similarly to the query parameters, `limit` is the maximum number of items + that can be returned in the response, and `field` is the number of items + that were skipped before the entities in the result. + + + `count` is the total number of available items of this entity. It can be + used to determine how many pages are there. + + + For example, if the `count` is 100 and the `limit` is 50, you can divide the + `count` by the `limit` to get the number of pages: `100/50 = 2 pages`. license: name: MIT url: https://github.com/medusajs/medusa/blob/master/LICENSE @@ -66,6 +149,40 @@ paths: $ref: paths/auth.yaml /auth/{email}: $ref: paths/auth_{email}.yaml + /gift-cards/{code}: + $ref: paths/gift-cards_{code}.yaml + /collections/{id}: + $ref: paths/collections_{id}.yaml + /collections: + $ref: paths/collections.yaml + /customers/me/addresses: + $ref: paths/customers_me_addresses.yaml + /customers: + $ref: paths/customers.yaml + /customers/me/addresses/{address_id}: + $ref: paths/customers_me_addresses_{address_id}.yaml + /customers/me: + $ref: paths/customers_me.yaml + /customers/me/payment-methods: + $ref: paths/customers_me_payment-methods.yaml + /customers/me/orders: + $ref: paths/customers_me_orders.yaml + /customers/password-token: + $ref: paths/customers_password-token.yaml + /customers/password-reset: + $ref: paths/customers_password-reset.yaml + /order-edits/{id}/complete: + $ref: paths/order-edits_{id}_complete.yaml + /order-edits/{id}/decline: + $ref: paths/order-edits_{id}_decline.yaml + /order-edits/{id}: + $ref: paths/order-edits_{id}.yaml + /orders/cart/{cart_id}: + $ref: paths/orders_cart_{cart_id}.yaml + /orders/{id}: + $ref: paths/orders_{id}.yaml + /orders: + $ref: paths/orders.yaml /carts/{id}/shipping-methods: $ref: paths/carts_{id}_shipping-methods.yaml /carts/{id}/taxes: @@ -90,34 +207,6 @@ paths: $ref: paths/carts_{id}_payment-sessions_{provider_id}_refresh.yaml /carts/{id}/payment-session: $ref: paths/carts_{id}_payment-session.yaml - /collections/{id}: - $ref: paths/collections_{id}.yaml - /collections: - $ref: paths/collections.yaml - /customers/me/addresses: - $ref: paths/customers_me_addresses.yaml - /customers: - $ref: paths/customers.yaml - /customers/me/addresses/{address_id}: - $ref: paths/customers_me_addresses_{address_id}.yaml - /customers/me: - $ref: paths/customers_me.yaml - /customers/me/payment-methods: - $ref: paths/customers_me_payment-methods.yaml - /customers/me/orders: - $ref: paths/customers_me_orders.yaml - /customers/password-token: - $ref: paths/customers_password-token.yaml - /customers/password-reset: - $ref: paths/customers_password-reset.yaml - /gift-cards/{code}: - $ref: paths/gift-cards_{code}.yaml - /orders/cart/{cart_id}: - $ref: paths/orders_cart_{cart_id}.yaml - /orders/{id}: - $ref: paths/orders_{id}.yaml - /orders: - $ref: paths/orders.yaml /products/{id}: $ref: paths/products_{id}.yaml /products: diff --git a/docs/api/store/paths/order-edits_{id}.yaml b/docs/api/store/paths/order-edits_{id}.yaml new file mode 100644 index 0000000000..e983c1a575 --- /dev/null +++ b/docs/api/store/paths/order-edits_{id}.yaml @@ -0,0 +1,43 @@ +get: + operationId: GetOrderEditsOrderEdit + summary: Retrieve an OrderEdit + description: Retrieves a OrderEdit. + parameters: + - in: path + name: id + required: true + description: The ID of the OrderEdit. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: + $ref: ../code_samples/JavaScript/order-edits_{id}/getundefined + - lang: Shell + label: cURL + source: + $ref: ../code_samples/Shell/order-edits_{id}/getundefined + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: ../components/schemas/order_edit.yaml + '400': + $ref: ../components/responses/400_error.yaml + '401': + $ref: ../components/responses/unauthorized.yaml + '404': + $ref: ../components/responses/not_found_error.yaml + '409': + $ref: ../components/responses/invalid_state_error.yaml + '422': + $ref: ../components/responses/invalid_request_error.yaml + '500': + $ref: ../components/responses/500_error.yaml diff --git a/docs/api/store/paths/order-edits_{id}_complete.yaml b/docs/api/store/paths/order-edits_{id}_complete.yaml new file mode 100644 index 0000000000..08c3a38bdb --- /dev/null +++ b/docs/api/store/paths/order-edits_{id}_complete.yaml @@ -0,0 +1,39 @@ +post: + operationId: PostOrderEditsOrderEditComplete + summary: Completes an OrderEdit + description: Completes an OrderEdit. + parameters: + - in: path + name: id + required: true + description: The ID of the Order Edit. + schema: + type: string + x-codeSamples: + - lang: JavaScript + label: JS Client + source: + $ref: ../code_samples/JavaScript/order-edits_{id}_complete/postundefined + - lang: Shell + label: cURL + source: + $ref: ../code_samples/Shell/order-edits_{id}_complete/postundefined + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: ../components/schemas/order_edit.yaml + '400': + $ref: ../components/responses/400_error.yaml + '401': + $ref: ../components/responses/unauthorized.yaml + '404': + $ref: ../components/responses/not_found_error.yaml + '500': + $ref: ../components/responses/500_error.yaml diff --git a/docs/api/store/paths/order-edits_{id}_decline.yaml b/docs/api/store/paths/order-edits_{id}_decline.yaml new file mode 100644 index 0000000000..2cc3593a92 --- /dev/null +++ b/docs/api/store/paths/order-edits_{id}_decline.yaml @@ -0,0 +1,47 @@ +post: + operationId: PostOrderEditsOrderEditDecline + summary: Decline an OrderEdit + description: Declines an OrderEdit. + parameters: + - in: path + name: id + required: true + description: The ID of the OrderEdit. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + declined_reason: + type: string + description: The reason for declining the OrderEdit. + x-codeSamples: + - lang: JavaScript + label: JS Client + source: + $ref: ../code_samples/JavaScript/order-edits_{id}_decline/postundefined + - lang: Shell + label: cURL + source: + $ref: ../code_samples/Shell/order-edits_{id}_decline/postundefined + tags: + - OrderEdit + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order_edit: + $ref: ../components/schemas/order_edit.yaml + '400': + $ref: ../components/responses/400_error.yaml + '401': + $ref: ../components/responses/unauthorized.yaml + '404': + $ref: ../components/responses/not_found_error.yaml + '500': + $ref: ../components/responses/500_error.yaml