Skip to content

Commit be4416d

Browse files
committed
docs(promotions): DEVDOCS-6407 split promotion models into Draft, Patch and Saved as each state has different expectations on what props are required
1 parent 9a5d198 commit be4416d

File tree

1 file changed

+167
-21
lines changed

1 file changed

+167
-21
lines changed

reference/promotions.v3.yml

Lines changed: 167 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ paths:
8383
application/json:
8484
schema:
8585
anyOf:
86-
- $ref: '#/components/schemas/PromotionCoupon'
87-
- $ref: '#/components/schemas/PromotionAutomatic'
86+
- $ref: '#/components/schemas/DraftCouponPromotion'
87+
- $ref: '#/components/schemas/DraftAutomaticPromotion'
8888
responses:
8989
'201':
9090
$ref: '#/components/responses/PromotionsResponse'
@@ -168,8 +168,8 @@ paths:
168168
application/json:
169169
schema:
170170
anyOf:
171-
- $ref: '#/components/schemas/PromotionCoupon'
172-
- $ref: '#/components/schemas/PromotionAutomatic'
171+
- $ref: '#/components/schemas/PatchCouponPromotion'
172+
- $ref: '#/components/schemas/PatchAutomaticPromotion'
173173
responses:
174174
'200':
175175
$ref: '#/components/responses/PromotionsResponse'
@@ -297,6 +297,13 @@ paths:
297297
content: {}
298298
components:
299299
schemas:
300+
CreatedFrom:
301+
enum:
302+
- react_ui
303+
- legacy_ui
304+
- api
305+
description: Describes which client originally created the promotion
306+
readOnly: true
300307
PromotionBase:
301308
title: PromotionBase
302309
type: object
@@ -382,31 +389,161 @@ components:
382389
$ref: '#/components/schemas/AddressMatcher'
383390
schedule:
384391
$ref: '#/components/schemas/AvailabilityByWeekDay'
385-
required:
386-
- name
387-
- rules
388-
PromotionCoupon:
389-
title: Coupon Promotion
392+
PatchCouponPromotion:
393+
title: Patch Coupon Promotion
394+
description: 'A Partial **Coupon Promotion** that contains properties to patch.'
395+
allOf:
396+
- $ref: '#/components/schemas/PromotionBase'
397+
- type: object
398+
properties:
399+
codes:
400+
$ref: '#/components/schemas/CouponCode'
401+
coupon_overrides_automatic_when_offering_higher_discounts:
402+
type: boolean
403+
example: false
404+
default: false
405+
description: |-
406+
This field only has effect when `can_be_used_with_other_promotions` is `false`:
407+
- When the property is set to `true`, the coupon will override the applied automatic promotions if it provides a greater discount.
408+
- When the property is set to `fasle`, the coupon will not be applied if automatic promotions are already applied.
409+
Trying to set the value of this field to `true` when `can_be_used_with_other_promotions` is `true` will yield a 422 error response.
410+
DraftCouponPromotion:
411+
allOf:
412+
- $ref: '#/components/schemas/PromotionBase'
413+
- title: Draft Coupon Promotion
414+
description: 'A draft **Coupon Promotion** to be created. A shopper must manually apply a *coupon promotion* to their cart.'
415+
type: object
416+
properties:
417+
codes:
418+
$ref: '#/components/schemas/CouponCode'
419+
coupon_overrides_automatic_when_offering_higher_discounts:
420+
type: boolean
421+
example: false
422+
default: false
423+
description: |-
424+
This field only has effect when `can_be_used_with_other_promotions` is `false`:
425+
- When the property is set to `true`, the coupon will override the applied automatic promotions if it provides a greater discount.
426+
- When the property is set to `fasle`, the coupon will not be applied if automatic promotions are already applied.
427+
Trying to set the value of this field when `can_be_used_with_other_promotions` is `true` will yield a 422 error response.
428+
redemption_type:
429+
type: string
430+
description: The type of the promotion. Promotions applied automatically have a value of `AUTOMATIC` whereas promotions requiring a coupon have a value of `COUPON`.
431+
enum:
432+
- COUPON
433+
required:
434+
- redemption_type
435+
- name
436+
- rules
437+
SavedCouponPromotion:
438+
title: Saved Coupon Promotion
390439
description: '**Coupon Promotion** A shopper must manually apply a *coupon promotion* to their cart.'
391440
allOf:
392441
- $ref: '#/components/schemas/PromotionBase'
393442
- type: object
394443
properties:
444+
id:
445+
type: integer
446+
description: An auto-generated unique identifier for the discount rule.
447+
example: 1
448+
readOnly: true
449+
created_from:
450+
$ref: '#/components/schemas/CreatedFrom'
451+
codes:
452+
$ref: '#/components/schemas/CouponCode'
395453
coupon_overrides_automatic_when_offering_higher_discounts:
396454
type: boolean
397455
example: false
398456
default: false
399457
description: |-
400458
This field only has effect when the `redemption_type` is `COUPON` and `can_be_used_with_other_promotions` is `false`:
401-
- When the property is set to "true", the coupon will override the applied automatic promotions if it provides a greater discount.
402-
- When the property is set to "false", the coupon will not be applied if automatic promotions are already applied.
459+
- When the property is set to `true`, the coupon will override the applied automatic promotions if it provides a greater discount.
460+
- When the property is set to `fasle`, the coupon will not be applied if automatic promotions are already applied.
403461
404-
Trying to set the value of this field to "true" when the `redemption_type` is not `COUPON`, or when `can_be_used_with_other_promotions` is `true` will yield a 422 error response.
405-
PromotionAutomatic:
406-
title: Automatic Promotion
462+
Trying to set the value of this field to `true` when the `redemption_type` is not `COUPON`, or when `can_be_used_with_other_promotions` is `true` will yield a 422 error response.
463+
redemption_type:
464+
type: string
465+
description: The type of the promotion. Promotions applied automatically have a value of `AUTOMATIC` whereas promotions requiring a coupon have a value of `COUPON`.
466+
enum:
467+
- COUPON
468+
multiple_codes:
469+
type: object
470+
properties:
471+
has_multiple_codes:
472+
type: boolean
473+
example: false
474+
default: false
475+
required:
476+
- id
477+
- name
478+
- channels
479+
- created_from
480+
- customer
481+
- rules
482+
- notifications
483+
- stop
484+
- currency_code
485+
- redemption_type
486+
- current_uses
487+
- start_date
488+
- status
489+
- can_be_used_with_other_promotions
490+
- coupon_overrides_automatic_when_offering_higher_discounts
491+
PatchAutomaticPromotion:
492+
title: Patch Automatic Promotion
493+
description: 'A Partial **Coupon Promotion** that contains properties to patch.'
494+
allOf:
495+
- $ref: '#/components/schemas/PromotionBase'
496+
DraftAutomaticPromotion:
497+
title: Draft Automatic Promotion
498+
description: 'A draft **Coupon Promotion** to be created. The store applies *automatic promotions* to a shopper’s cart once the promotion criteria are satisfied. The shopper cannot manually apply an *automatic promotion*.'
499+
allOf:
500+
- $ref: '#/components/schemas/PromotionBase'
501+
- type: object
502+
properties:
503+
redemption_type:
504+
type: string
505+
description: The type of the promotion. Promotions applied automatically have a value of `AUTOMATIC` whereas promotions requiring a coupon have a value of `COUPON`.
506+
enum:
507+
- AUTOMATIC
508+
required:
509+
- redemption_type
510+
- name
511+
- rules
512+
SavedAutomaticPromotion:
513+
title: Saved Automatic Promotion
407514
description: The store applies *automatic promotions* to a shopper’s cart once the promotion criteria are satisfied. The shopper cannot manually apply an *automatic promotion*.
408515
allOf:
409516
- $ref: '#/components/schemas/PromotionBase'
517+
- type: object
518+
properties:
519+
redemption_type:
520+
type: string
521+
description: The type of the promotion. Promotions applied automatically have a value of `AUTOMATIC` whereas promotions requiring a coupon have a value of `COUPON`.
522+
enum:
523+
- AUTOMATIC
524+
id:
525+
type: integer
526+
description: An auto-generated unique identifier for the discount rule.
527+
example: 1
528+
readOnly: true
529+
created_from:
530+
$ref: '#/components/schemas/CreatedFrom'
531+
required:
532+
- id
533+
- name
534+
- channels
535+
- created_from
536+
- customer
537+
- rules
538+
- notifications
539+
- stop
540+
- currency_code
541+
- redemption_type
542+
- current_uses
543+
- start_date
544+
- status
545+
- can_be_used_with_other_promotions
546+
410547
Customer:
411548
type: object
412549
description: |-
@@ -882,13 +1019,15 @@ components:
8821019
When a 'before' or 'after' cursor is provided, only the 'cursor_pagination' property will be present.
8831020
When a 'page' parameter is provided, only the offset based 'pagination' property will be present.
8841021
CollectionMeta:
1022+
required: [pagination]
8851023
title: Collection Meta
8861024
type: object
8871025
properties:
8881026
pagination:
8891027
$ref: '#/components/schemas/Pagination'
8901028
description: Contains data about the response including pagination and collection totals.
8911029
Pagination:
1030+
required: [total, count, per_page, current_page, total_pages, links]
8921031
title: Pagination
8931032
type: object
8941033
properties:
@@ -1145,8 +1284,8 @@ components:
11451284
type: string
11461285
example: "0439538491"
11471286
CouponCode:
1148-
type: object
11491287
description: A `CouponCode` object encapsulates attributes of a coupon code.
1288+
type: object
11501289
properties:
11511290
id:
11521291
type: integer
@@ -1177,6 +1316,9 @@ components:
11771316
format: date-time
11781317
example: '2019-01-20T22:00:00.000Z'
11791318
required:
1319+
- id
1320+
- current_uses
1321+
- created
11801322
- code
11811323
BulkActionResponseMeta:
11821324
title: Bulk Action Response Meta
@@ -1567,14 +1709,17 @@ components:
15671709
content:
15681710
application/json:
15691711
schema:
1712+
required:
1713+
- data
1714+
- meta
15701715
type: object
15711716
properties:
15721717
data:
15731718
type: array
15741719
items:
1575-
anyOf:
1576-
- $ref: '#/components/schemas/PromotionAutomatic'
1577-
- $ref: '#/components/schemas/PromotionCoupon'
1720+
oneOf:
1721+
- $ref: '#/components/schemas/SavedAutomaticPromotion'
1722+
- $ref: '#/components/schemas/SavedCouponPromotion'
15781723
meta:
15791724
$ref: '#/components/schemas/CollectionMeta'
15801725
examples:
@@ -1585,6 +1730,7 @@ components:
15851730
redemption_type: AUTOMATIC
15861731
name: Buy Product X Get Free Shipping
15871732
display_name: WOW!!! FREE SHIPPING for Product X
1733+
created_from: api
15881734
channels:
15891735
- id: 1
15901736
customer:
@@ -1657,9 +1803,9 @@ components:
16571803
type: object
16581804
properties:
16591805
data:
1660-
anyOf:
1661-
- $ref: '#/components/schemas/PromotionCoupon'
1662-
- $ref: '#/components/schemas/PromotionAutomatic'
1806+
oneOf:
1807+
- $ref: '#/components/schemas/SavedCouponPromotion'
1808+
- $ref: '#/components/schemas/SavedAutomaticPromotion'
16631809
meta:
16641810
type: object
16651811
description: 'Empty meta object, which may be used at a later time.'

0 commit comments

Comments
 (0)