299 lines
9.8 KiB
YAML
299 lines
9.8 KiB
YAML
post:
|
|
operationId: PostDiscounts
|
|
summary: Creates a Discount
|
|
x-authenticated: true
|
|
description: >-
|
|
Creates a Discount with a given set of rules that define how the Discount
|
|
behaves.
|
|
parameters:
|
|
- 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:
|
|
content:
|
|
application/json:
|
|
schema:
|
|
required:
|
|
- code
|
|
- rule
|
|
properties:
|
|
code:
|
|
type: string
|
|
description: A unique code that will be used to redeem the Discount
|
|
is_dynamic:
|
|
type: boolean
|
|
description: >-
|
|
Whether the Discount should have multiple instances of itself,
|
|
each with a different code. This can be useful for automatically
|
|
generated codes that all have to follow a common set of rules.
|
|
default: false
|
|
rule:
|
|
description: The Discount Rule that defines how Discounts are calculated
|
|
type: object
|
|
required:
|
|
- type
|
|
- value
|
|
- allocation
|
|
properties:
|
|
description:
|
|
type: string
|
|
description: A short description of the discount
|
|
type:
|
|
type: string
|
|
description: >-
|
|
The type of the Discount, can be `fixed` for discounts that
|
|
reduce the price by a fixed amount, `percentage` for
|
|
percentage reductions or `free_shipping` for shipping
|
|
vouchers.
|
|
enum:
|
|
- fixed
|
|
- percentage
|
|
- free_shipping
|
|
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:
|
|
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.
|
|
default: false
|
|
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
|
|
regions:
|
|
description: >-
|
|
A list of Region ids representing the Regions in which the
|
|
Discount can be used.
|
|
type: array
|
|
items:
|
|
type: string
|
|
usage_limit:
|
|
type: number
|
|
description: Maximum times the discount can be used
|
|
metadata:
|
|
description: >-
|
|
An optional set of key-value pairs to hold additional
|
|
information.
|
|
type: object
|
|
x-codeSamples:
|
|
- lang: JavaScript
|
|
label: JS Client
|
|
source:
|
|
$ref: ../code_samples/JavaScript/discounts/postundefined
|
|
- lang: Shell
|
|
label: cURL
|
|
source:
|
|
$ref: ../code_samples/Shell/discounts/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
|
|
get:
|
|
operationId: GetDiscounts
|
|
summary: List Discounts
|
|
x-authenticated: true
|
|
description: Retrieves a list of Discounts
|
|
parameters:
|
|
- in: query
|
|
name: q
|
|
description: Search query applied on the code field.
|
|
schema:
|
|
type: string
|
|
- in: query
|
|
name: rule
|
|
description: Discount Rules filters to apply on the search
|
|
schema:
|
|
type: object
|
|
properties:
|
|
type:
|
|
type: string
|
|
enum:
|
|
- fixed
|
|
- percentage
|
|
- free_shipping
|
|
description: >-
|
|
The type of the Discount, can be `fixed` for discounts that reduce
|
|
the price by a fixed amount, `percentage` for percentage
|
|
reductions or `free_shipping` for shipping vouchers.
|
|
allocation:
|
|
type: string
|
|
enum:
|
|
- total
|
|
- item
|
|
description: >-
|
|
The value that the discount represents; this will depend on the
|
|
type of the discount
|
|
- in: query
|
|
name: is_dynamic
|
|
description: Return only dynamic discounts.
|
|
schema:
|
|
type: boolean
|
|
- in: query
|
|
name: is_disabled
|
|
description: Return only disabled discounts.
|
|
schema:
|
|
type: boolean
|
|
- in: query
|
|
name: limit
|
|
description: The number of items in the response
|
|
schema:
|
|
type: number
|
|
default: '20'
|
|
- in: query
|
|
name: offset
|
|
description: The offset of items in response
|
|
schema:
|
|
type: number
|
|
default: '0'
|
|
- in: query
|
|
name: expand
|
|
description: Comma separated list of relations to include in the results.
|
|
schema:
|
|
type: string
|
|
x-codeSamples:
|
|
- lang: JavaScript
|
|
label: JS Client
|
|
source:
|
|
$ref: ../code_samples/JavaScript/discounts/getundefined
|
|
- lang: Shell
|
|
label: cURL
|
|
source:
|
|
$ref: ../code_samples/Shell/discounts/getundefined
|
|
security:
|
|
- api_token: []
|
|
- cookie_auth: []
|
|
tags:
|
|
- Discount
|
|
responses:
|
|
'200':
|
|
description: OK
|
|
content:
|
|
application/json:
|
|
schema:
|
|
properties:
|
|
discounts:
|
|
type: array
|
|
items:
|
|
$ref: ../components/schemas/discount.yaml
|
|
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.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
|