Files
medusa-store/docs/api/admin/paths/discounts_{id}.yaml
2022-09-13 10:59:51 +03:00

294 lines
9.2 KiB
YAML

delete:
operationId: DeleteDiscountsDiscount
summary: Delete a Discount
description: Deletes a Discount.
x-authenticated: true
parameters:
- in: path
name: id
required: true
description: The ID of the Discount
schema:
type: string
x-codeSamples:
- lang: JavaScript
label: JS Client
source:
$ref: ../code_samples/JavaScript/discounts_{id}/deleteundefined
- lang: Shell
label: cURL
source:
$ref: ../code_samples/Shell/discounts_{id}/deleteundefined
security:
- api_token: []
- cookie_auth: []
tags:
- Discount
responses:
'200':
description: OK
content:
application/json:
schema:
properties:
id:
type: string
description: The ID of the deleted Discount
object:
type: string
description: The type of the object that was deleted.
default: discount
deleted:
type: boolean
description: Whether the discount was deleted successfully or not.
default: true
'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
get:
operationId: GetDiscountsDiscount
summary: Get a Discount
description: Retrieves a Discount
x-authenticated: true
parameters:
- in: path
name: id
required: true
description: The ID of the Discount
schema:
type: string
- in: query
name: expand
description: Comma separated list of relations to include in the results.
schema:
type: string
- in: query
name: fields
description: Comma separated list of fields to include in the results.
schema:
type: string
x-codeSamples:
- lang: JavaScript
label: JS Client
source:
$ref: ../code_samples/JavaScript/discounts_{id}/getundefined
- lang: Shell
label: cURL
source:
$ref: ../code_samples/Shell/discounts_{id}/getundefined
security:
- api_token: []
- cookie_auth: []
tags:
- Discount
responses:
'200':
description: OK
content:
application/json:
schema:
properties:
discount:
$ref: ../components/schemas/discount.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: PostDiscountsDiscount
summary: Update a Discount
description: >-
Updates a Discount with a given set of rules that define how the Discount
behaves.
x-authenticated: true
parameters:
- in: path
name: id
required: true
description: The ID of the Discount.
schema:
type: string
- in: query
name: expand
description: >-
(Comma separated) Which fields should be expanded in each item of the
result.
schema:
type: string
- in: query
name: fields
description: >-
(Comma separated) Which fields should be included in each item of the
result.
schema:
type: string
requestBody:
content:
application/json:
schema:
properties:
code:
type: string
description: A unique code that will be used to redeem the Discount
rule:
description: The Discount Rule that defines how Discounts are calculated
type: object
required:
- id
properties:
id:
type: string
description: The ID of the Rule
description:
type: string
description: A short description of the discount
value:
type: number
description: >-
The value that the discount represents; this will depend on
the type of the discount
allocation:
type: string
description: The scope that the discount should apply to.
enum:
- total
- item
conditions:
type: array
description: >-
A set of conditions that can be used to limit when the
discount can be used. Only one of `products`,
`product_types`, `product_collections`, `product_tags`, and
`customer_groups` should be provided.
items:
type: object
required:
- operator
properties:
id:
type: string
description: The ID of the Rule
operator:
type: string
description: Operator of the condition
enum:
- in
- not_in
products:
type: array
description: >-
list of product IDs if the condition is applied on
products.
items:
type: string
product_types:
type: array
description: >-
list of product type IDs if the condition is applied
on product types.
items:
type: string
product_collections:
type: array
description: >-
list of product collection IDs if the condition is
applied on product collections.
items:
type: string
product_tags:
type: array
description: >-
list of product tag IDs if the condition is applied on
product tags.
items:
type: string
customer_groups:
type: array
description: >-
list of customer group IDs if the condition is applied
on customer groups.
items:
type: string
is_disabled:
type: boolean
description: >-
Whether the Discount code is disabled on creation. You will have
to enable it later to make it available to Customers.
starts_at:
type: string
format: date-time
description: The time at which the Discount should be available.
ends_at:
type: string
format: date-time
description: The time at which the Discount should no longer be available.
valid_duration:
type: string
description: Duration the discount runs between
example: P3Y6M4DT12H30M5S
usage_limit:
type: number
description: Maximum times the discount can be used
regions:
description: >-
A list of Region ids representing the Regions in which the
Discount can be used.
type: array
items:
type: string
metadata:
description: An object containing metadata of the discount
type: object
x-codeSamples:
- lang: JavaScript
label: JS Client
source:
$ref: ../code_samples/JavaScript/discounts_{id}/postundefined
- lang: Shell
label: cURL
source:
$ref: ../code_samples/Shell/discounts_{id}/postundefined
security:
- api_token: []
- cookie_auth: []
tags:
- Discount
responses:
'200':
description: OK
content:
application/json:
schema:
properties:
discount:
$ref: ../components/schemas/discount.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