chore: generate API reference (#2410)

This commit is contained in:
Shahed Nasser
2022-10-11 10:30:45 +03:00
committed by GitHub
parent 9aeda1b52d
commit 14d4b9d95c
49 changed files with 5045 additions and 1930 deletions

View File

@@ -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)
})

View File

@@ -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)
})

View File

@@ -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)
})

View File

@@ -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)
})

View File

@@ -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)
})

View File

@@ -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)
})

View File

@@ -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)
})

View File

@@ -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)
})

View File

@@ -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)
})

View File

@@ -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)
})

View File

@@ -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)
})

View File

@@ -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" }'

View File

@@ -0,0 +1,2 @@
curl --location --request DELETE 'https://medusa-url.com/admin/order-edits/{id}' \
--header 'Authorization: Bearer {api_token}'

View File

@@ -0,0 +1,2 @@
curl --location --request GET 'https://medusa-url.com/admin/order-edits/{id}' \
--header 'Authorization: Bearer {api_token}'

View File

@@ -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"
}'

View File

@@ -0,0 +1,2 @@
curl --location --request POST 'https://medusa-url.com/admin/order-edits/:id/cancel' \
--header 'Authorization: Bearer {api_token}'

View File

@@ -0,0 +1,2 @@
curl --location --request DELETE 'https://medusa-url.com/admin/order-edits/{id}/changes/{change_id}' \
--header 'Authorization: Bearer {api_token}'

View File

@@ -0,0 +1,2 @@
curl --location --request POST 'https://medusa-url.com/admin/order-edits/:id/confirm' \
--header 'Authorization: Bearer {api_token}'

View File

@@ -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 }'

View File

@@ -0,0 +1,2 @@
curl --location --request DELETE 'https://medusa-url.com/admin/order-edits/{id}/items/{item_id}' \
--header 'Authorization: Bearer {api_token}'

View File

@@ -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 }'

View File

@@ -0,0 +1,2 @@
curl --location --request POST 'https://medusa-url.com/admin/order-edits/{id}/request' \
--header 'Authorization: Bearer {api_token}'

View File

@@ -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.

View File

@@ -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

View File

@@ -15,6 +15,89 @@ info:
<!-- ReDoc-Inject: <SecurityDefinitions> -->
## 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:

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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