1 /**
2 * @oas [post] /admin/shipping-options/{id}
3 * operationId: PostShippingOptionsId
4 * summary: Update a Shipping Option
5 * description: |
6 * Update a shipping option's details.
7 *
8 * When you provide the `prices` array, it replaces the shipping option's existing flat-rate prices:
9 *
10 * - A price with a matching `id` is updated.
11 * - A price without an `id` is created
12 * - Any existing price whose `id` isn't included in the array is deleted.
13 *
14 * The `rules` you provide for a price similarly replace that price's existing rules, so omit a rule to remove it.
15 *
16 * Omitting the `prices` property entirely leaves the existing prices unchanged, whereas setting `price_type` to `calculated` removes all flat-rate prices.
17 * x-authenticated: true
18 * parameters:
19 * - name: id
20 * in: path
21 * description: The shipping option's ID.
22 * required: true
23 * schema:
24 * type: string
25 * - name: fields
26 * in: query
27 * 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
28 * fields. Without prefix it will replace the entire default fields.
29 * required: false
30 * schema:
31 * type: string
32 * title: fields
33 * 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
34 * fields. Without prefix it will replace the entire default fields.
35 * externalDocs:
36 * url: "#select-fields-and-relations"
37 * security:
38 * - api_token: []
39 * - cookie_auth: []
40 * - jwt_token: []
41 * requestBody:
42 * content:
43 * application/json:
44 * schema:
45 * $ref: "#/components/schemas/AdminUpdateShippingOption"
46 * x-codeSamples:
47 * - lang: JavaScript
48 * label: JS SDK
49 * source: |-
50 * import Medusa from "@medusajs/js-sdk"
51 *
52 * export const sdk = new Medusa({
53 * baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
54 * debug: import.meta.env.DEV,
55 * auth: {
56 * type: "session",
57 * },
58 * })
59 *
60 * sdk.admin.shippingOption.update("so_123", {
61 * name: "Standard Shipping",
62 * })
63 * .then(({ shipping_option }) => {
64 * console.log(shipping_option)
65 * })
66 * - lang: Shell
67 * label: cURL
68 * source: |-
69 * curl -X POST '{backend_url}/admin/shipping-options/{id}' \
70 * -H 'Authorization: Bearer {access_token}'
71 * tags:
72 * - Shipping Options
73 * responses:
74 * "200":
75 * description: OK
76 * content:
77 * application/json:
78 * schema:
79 * $ref: "#/components/schemas/AdminShippingOptionResponse"
80 * "400":
81 * $ref: "#/components/responses/400_error"
82 * "401":
83 * $ref: "#/components/responses/unauthorized"
84 * "404":
85 * $ref: "#/components/responses/not_found_error"
86 * "409":
87 * $ref: "#/components/responses/invalid_state_error"
88 * "422":
89 * $ref: "#/components/responses/invalid_request_error"
90 * "500":
91 * $ref: "#/components/responses/500_error"
92 * x-workflow: updateShippingOptionsWorkflow
93 * x-events:
94 * - name: shipping-option.updated
95 * payload: |-
96 * ```ts
97 * {
98 * id, // The ID of the shipping option
99 * }
100 * ```
101 * description: Emitted when shipping options are updated.
102 * deprecated: false
103 * since: 2.12.4
104 *
105 */
106