import { Request, Response } from "express"; import { DiscountConditionOperator } from "../../../../models"; import { AdminUpsertConditionsReq } from "../../../../types/discount"; import { FindParams } from "../../../../types/common"; /** * @oas [post] /admin/discounts/{discount_id}/conditions * operationId: "PostDiscountsDiscountConditions" * summary: "Create a Condition" * description: "Create a Discount Condition. Only one of `products`, `product_types`, `product_collections`, `product_tags`, and `customer_groups` should be provided, based on the type of discount condition. * For example, if the discount condition's type is `products`, the `products` field should be provided in the request body." * x-authenticated: true * parameters: * - (path) discount_id=* {string} The ID of the discount. * - (query) expand {string} Comma-separated relations that should be expanded in the returned discount. * - (query) fields {string} Comma-separated fields that should be included in the returned discount. * requestBody: * content: * application/json: * schema: * $ref: "#/components/schemas/AdminPostDiscountsDiscountConditions" * x-codegen: * method: createCondition * queryParams: AdminPostDiscountsDiscountConditionsParams * x-codeSamples: * - lang: JavaScript * label: JS Client * source: | * import Medusa from "@medusajs/medusa-js" * import { DiscountConditionOperator } from "@medusajs/medusa" * const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) * // must be previously logged in or use api token * medusa.admin.discounts.createCondition(discountId, { * operator: DiscountConditionOperator.IN * }) * .then(({ discount }) => { * console.log(discount.id); * }); * - lang: Shell * label: cURL * source: | * curl -X POST '{backend_url}/admin/discounts/{id}/conditions' \ * -H 'Authorization: Bearer {api_token}' \ * -H 'Content-Type: application/json' \ * --data-raw '{ * "operator": "in" * }' * security: * - api_token: [] * - cookie_auth: [] * tags: * - Discounts * responses: * 200: * description: OK * content: * application/json: * schema: * $ref: "#/components/schemas/AdminDiscountsRes" * "400": * $ref: "#/components/responses/400_error" * "401": * $ref: "#/components/responses/unauthorized" * "404": * $ref: "#/components/responses/not_found_error" * "409": * $ref: "#/components/responses/invalid_state_error" * "422": * $ref: "#/components/responses/invalid_request_error" * "500": * $ref: "#/components/responses/500_error" */ declare const _default: (req: Request, res: Response) => Promise; export default _default; /** * @schema AdminPostDiscountsDiscountConditions * type: object * required: * - operator * properties: * operator: * description: "Operator of the condition. `in` indicates that discountable resources are within the specified resources. `not_in` indicates that * discountable resources are everything but the specified resources." * type: string * enum: [in, not_in] * products: * type: array * description: list of product IDs if the condition's type is `products`. * items: * type: string * product_types: * type: array * description: list of product type IDs if the condition's type is `product_types`. * items: * type: string * product_collections: * type: array * description: list of product collection IDs if the condition's type is `product_collections`. * items: * type: string * product_tags: * type: array * description: list of product tag IDs if the condition's type is `product_tags`. * items: * type: string * customer_groups: * type: array * description: list of customer group IDs if the condition's type is `customer_groups`. * items: * type: string */ export declare class AdminPostDiscountsDiscountConditions extends AdminUpsertConditionsReq { operator: DiscountConditionOperator; } export declare class AdminPostDiscountsDiscountConditionsParams extends FindParams { }