1 /**
2 * @oas [post] /admin/promotions/{id}
3 * operationId: PostPromotionsId
4 * summary: Update a Promotion
5 * description: Update a promotion's details.
6 * x-authenticated: true
7 * parameters:
8 * - name: id
9 * in: path
10 * description: The promotion's ID.
11 * required: true
12 * schema:
13 * type: string
14 * - name: fields
15 * in: query
16 * description: Comma-separated fields that should be included in the returned data. if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default
17 * fields. without prefix it will replace the entire default fields.
18 * required: false
19 * schema:
20 * type: string
21 * title: fields
22 * description: Comma-separated fields that should be included in the returned data. if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default
23 * fields. without prefix it will replace the entire default fields.
24 * externalDocs:
25 * url: "#select-fields-and-relations"
26 * security:
27 * - api_token: []
28 * - cookie_auth: []
29 * - jwt_token: []
30 * requestBody:
31 * content:
32 * application/json:
33 * schema:
34 * allOf:
35 * - type: object
36 * description: The properties to update in a promotion.
37 * required:
38 * - campaign_id
39 * properties:
40 * code:
41 * type: string
42 * title: code
43 * description: The promotion's code.
44 * is_automatic:
45 * type: boolean
46 * title: is_automatic
47 * description: Whether the promotion is applied automatically.
48 * type:
49 * type: string
50 * description: The promotion's type.
51 * externalDocs:
52 * url: https://docs.medusajs.com/resources/commerce-modules/promotion/concepts#what-is-a-promotion
53 * enum:
54 * - standard
55 * - buyget
56 * campaign_id:
57 * type: string
58 * title: campaign_id
59 * description: The ID of the campaign that the promotion belongs to.
60 * application_method:
61 * type: object
62 * description: The properties to update in the application method.
63 * required:
64 * - id
65 * - description
66 * - max_quantity
67 * - currency_code
68 * - apply_to_quantity
69 * - buy_rules_min_quantity
70 * properties:
71 * id:
72 * type: string
73 * title: id
74 * description: The application method's ID.
75 * description:
76 * type: string
77 * title: description
78 * description: The application method's description.
79 * value:
80 * type: number
81 * title: value
82 * description: The discounted amount applied by the associated promotion based on the `type`.
83 * max_quantity:
84 * type: number
85 * title: max_quantity
86 * description: The max quantity allowed in the cart for the associated promotion to be applied.
87 * currency_code:
88 * type: string
89 * title: currency_code
90 * description: The application method's currency code.
91 * type:
92 * type: string
93 * description: The type of the application method indicating how the associated promotion is applied.
94 * enum:
95 * - fixed
96 * - percentage
97 * target_type:
98 * type: string
99 * description: The target type of the application method indicating whether the associated promotion is applied to the cart's items, shipping methods, or the whole order.
100 * enum:
101 * - order
102 * - shipping_methods
103 * - items
104 * allocation:
105 * type: string
106 * description: The allocation value that indicates whether the associated promotion is applied on each item in a cart or split between the items in the cart.
107 * enum:
108 * - each
109 * - across
110 * apply_to_quantity:
111 * type: number
112 * title: apply_to_quantity
113 * description: The quantity that results from matching the `buyget` promotion's condition. For example, if the promotion is a "Buy 2 shirts get 1 free", the value f this attribute is `1`.
114 * buy_rules_min_quantity:
115 * type: number
116 * title: buy_rules_min_quantity
117 * description: The minimum quantity required for a `buyget` promotion to be applied. For example, if the promotion is a "Buy 2 shirts get 1 free", the value of this attribute is `2`.
118 * - type: object
119 * description: The properties to update in a promotion.
120 * properties:
121 * additional_data:
122 * type: object
123 * description: Pass additional custom data to the API route. This data is passed to the underlying workflow under the `additional_data` parameter.
124 * description: The properties to update in a promotion.
125 * x-codeSamples:
126 * - lang: JavaScript
127 * label: JS SDK
128 * source: |-
129 * import Medusa from "@medusajs/js-sdk"
130 *
131 * export const sdk = new Medusa({
132 * baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
133 * debug: import.meta.env.DEV,
134 * auth: {
135 * type: "session",
136 * },
137 * })
138 *
139 * sdk.admin.promotion.update("promo_123", {
140 * code: "PROMO123",
141 * })
142 * .then(({ promotion }) => {
143 * console.log(promotion)
144 * })
145 * - lang: Shell
146 * label: cURL
147 * source: |-
148 * curl -X POST '{backend_url}/admin/promotions/{id}' \
149 * -H 'Authorization: Bearer {jwt_token}' \
150 * -H 'Content-Type: application/json' \
151 * --data-raw '{
152 * "campaign_id": "{value}"
153 * }'
154 * tags:
155 * - Promotions
156 * responses:
157 * "200":
158 * description: OK
159 * content:
160 * application/json:
161 * schema:
162 * $ref: "#/components/schemas/AdminPromotionResponse"
163 * "400":
164 * $ref: "#/components/responses/400_error"
165 * "401":
166 * $ref: "#/components/responses/unauthorized"
167 * "404":
168 * $ref: "#/components/responses/not_found_error"
169 * "409":
170 * $ref: "#/components/responses/invalid_state_error"
171 * "422":
172 * $ref: "#/components/responses/invalid_request_error"
173 * "500":
174 * $ref: "#/components/responses/500_error"
175 * x-workflow: updatePromotionsWorkflow
176 * x-events: []
177 *
178 */
179