220 lines
6.0 KiB
YAML
220 lines
6.0 KiB
YAML
get:
|
|
operationId: GetDiscounts
|
|
summary: List Discounts
|
|
x-authenticated: true
|
|
description: >-
|
|
Retrieve a list of Discounts. The discounts can be filtered by fields such
|
|
as `rule` or `is_dynamic`. The discounts can also be paginated.
|
|
parameters:
|
|
- in: query
|
|
name: q
|
|
description: term to search discounts' code field.
|
|
schema:
|
|
type: string
|
|
- in: query
|
|
name: rule
|
|
description: Filter discounts by rule fields.
|
|
schema:
|
|
type: object
|
|
properties:
|
|
type:
|
|
type: string
|
|
enum:
|
|
- fixed
|
|
- percentage
|
|
- free_shipping
|
|
description: Filter discounts by type.
|
|
allocation:
|
|
type: string
|
|
enum:
|
|
- total
|
|
- item
|
|
description: Filter discounts by allocation type.
|
|
- in: query
|
|
name: is_dynamic
|
|
description: Filter discounts by whether they're dynamic or not.
|
|
schema:
|
|
type: boolean
|
|
- in: query
|
|
name: is_disabled
|
|
description: Filter discounts by whether they're disabled or not.
|
|
schema:
|
|
type: boolean
|
|
- in: query
|
|
name: limit
|
|
description: The number of discounts to return
|
|
schema:
|
|
type: number
|
|
default: '20'
|
|
- in: query
|
|
name: offset
|
|
description: The number of discounts to skip when retrieving the discounts.
|
|
schema:
|
|
type: number
|
|
default: '0'
|
|
- in: query
|
|
name: expand
|
|
description: >-
|
|
Comma-separated relations that should be expanded in each returned
|
|
discount.
|
|
schema:
|
|
type: string
|
|
- in: query
|
|
name: order
|
|
description: A discount field to sort-order the retrieved discounts by.
|
|
schema:
|
|
type: string
|
|
- in: query
|
|
name: created_at
|
|
description: Filter by a creation date range.
|
|
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: Filter by an update date range.
|
|
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-codegen:
|
|
method: list
|
|
queryParams: AdminGetDiscountsParams
|
|
x-codeSamples:
|
|
- lang: JavaScript
|
|
label: JS Client
|
|
source:
|
|
$ref: ../code_samples/JavaScript/admin_discounts/get.js
|
|
- lang: tsx
|
|
label: Medusa React
|
|
source:
|
|
$ref: ../code_samples/tsx/admin_discounts/get.tsx
|
|
- lang: Shell
|
|
label: cURL
|
|
source:
|
|
$ref: ../code_samples/Shell/admin_discounts/get.sh
|
|
security:
|
|
- api_token: []
|
|
- cookie_auth: []
|
|
- jwt_token: []
|
|
tags:
|
|
- Discounts
|
|
responses:
|
|
'200':
|
|
description: OK
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: ../components/schemas/AdminDiscountsListRes.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: PostDiscounts
|
|
summary: Create a Discount
|
|
x-authenticated: true
|
|
description: >-
|
|
Create a Discount with a given set of rules that defines how the Discount is
|
|
applied.
|
|
parameters:
|
|
- in: query
|
|
name: expand
|
|
description: >-
|
|
Comma-separated relations that should be expanded in the returned
|
|
discount.
|
|
schema:
|
|
type: string
|
|
- in: query
|
|
name: fields
|
|
description: >-
|
|
Comma-separated fields that should be retrieved in the returned
|
|
discount.
|
|
schema:
|
|
type: string
|
|
requestBody:
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: ../components/schemas/AdminPostDiscountsReq.yaml
|
|
x-codegen:
|
|
method: create
|
|
queryParams: AdminPostDiscountsParams
|
|
x-codeSamples:
|
|
- lang: JavaScript
|
|
label: JS Client
|
|
source:
|
|
$ref: ../code_samples/JavaScript/admin_discounts/post.js
|
|
- lang: tsx
|
|
label: Medusa React
|
|
source:
|
|
$ref: ../code_samples/tsx/admin_discounts/post.tsx
|
|
- lang: Shell
|
|
label: cURL
|
|
source:
|
|
$ref: ../code_samples/Shell/admin_discounts/post.sh
|
|
security:
|
|
- api_token: []
|
|
- cookie_auth: []
|
|
- jwt_token: []
|
|
tags:
|
|
- Discounts
|
|
responses:
|
|
'200':
|
|
description: OK
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: ../components/schemas/AdminDiscountsRes.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
|