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AEA,MAAM,YAAA,CAAa,0BAAA,EAA+D,MAAA,EAAsC,OAAA,EAA8D;AACrL,IAAA,MAAM,2BAAA,GAA+B,2BAAwD,EAAA,IAAM,0BAAA;AACnG,IAAA,OAAO,IAAA,CAAK,SAAA,CAAU,KAAA,CAAkB,EAAE,IAAA,EAAM,cAAA,EAAe,EAAG,CAAA,6BAAA,EAAgC,2BAA2B,CAAA,aAAA,CAAA,EAAiB,MAAA,EAAQ,OAAO,CAAA;AAAA,EAC9J;AAAA,EAGA,2BAA2B,QAAA,EAAqD;AAC/E,IAAA,OAAO,QAAA,CAAS,IAAA,IAAS,QAAA,CAAS,IAAA,KAAS,0BAAA,CAA0B,IAAA;AAAA,EACtE;AAAA,EAGA,aAAa,EAAA,EAA6D;AACzE,IAAA,OAAO,KAAA,CAAM,qBAAkD,EAAE,CAAA;AAAA,EAClE;AAAA,EAEA,sBAAsB,GAAA,EAA8C;AACnE,IAAA,OAAO,KAAA,CAAM,qBAAA,CAAmD,GAAG,GAAG,CAAA;AAAA,EACvE;AAAA,EAGA,IAAA,GAAqC;AACpC,IAAA,OAAO,0BAAA,CAA0B,IAAA;AAAA,EAClC;AAED,CAAA;AAGA,IAAM,QAAA,GAAW,IAAI,yBAAA,EAA0B;AAC/C,IAAO,oCAAA,GAAQ","file":"chunk-5WUI6OHH.cjs","sourcesContent":["import { ApiResource } from '../resource'\nimport type { Resource, ResourceCreate, ResourceUpdate, ResourceId, ResourcesConfig, ResourceRel, ListResponse, ResourceSort, /* ResourceFilter */ } from '../resource'\nimport type { QueryParamsRetrieve, QueryParamsList } from '../query'\n\nimport type { Version } from './versions'\nimport type { EventStore } from './event_stores'\nimport type { PercentageDiscountPromotion, PercentageDiscountPromotionType } from './percentage_discount_promotions'\nimport type { FreeShippingPromotion, FreeShippingPromotionType } from './free_shipping_promotions'\nimport type { BuyXPayYPromotion, BuyXPayYPromotionType } from './buy_x_pay_y_promotions'\nimport type { FreeGiftPromotion, FreeGiftPromotionType } from './free_gift_promotions'\nimport type { FixedPricePromotion, FixedPricePromotionType } from './fixed_price_promotions'\nimport type { ExternalPromotion, ExternalPromotionType } from './external_promotions'\nimport type { FixedAmountPromotion, FixedAmountPromotionType } from './fixed_amount_promotions'\nimport type { FlexPromotion, FlexPromotionType } from './flex_promotions'\n\n\ntype OrderAmountPromotionRuleType = 'order_amount_promotion_rules'\ntype OrderAmountPromotionRuleRel = ResourceRel & { type: OrderAmountPromotionRuleType }\ntype PercentageDiscountPromotionRel = ResourceRel & { type: PercentageDiscountPromotionType }\ntype FreeShippingPromotionRel = ResourceRel & { type: FreeShippingPromotionType }\ntype BuyXPayYPromotionRel = ResourceRel & { type: BuyXPayYPromotionType }\ntype FreeGiftPromotionRel = ResourceRel & { type: FreeGiftPromotionType }\ntype FixedPricePromotionRel = ResourceRel & { type: FixedPricePromotionType }\ntype ExternalPromotionRel = ResourceRel & { type: ExternalPromotionType }\ntype FixedAmountPromotionRel = ResourceRel & { type: FixedAmountPromotionType }\ntype FlexPromotionRel = ResourceRel & { type: FlexPromotionType }\n\n\nexport type OrderAmountPromotionRuleSort = Pick<OrderAmountPromotionRule, 'id'> & ResourceSort\n// export type OrderAmountPromotionRuleFilter = Pick<OrderAmountPromotionRule, 'id'> & ResourceFilter\n\n\ninterface OrderAmountPromotionRule extends Resource {\n\t\n\treadonly type: OrderAmountPromotionRuleType\n\n\t/** \n\t * Apply the promotion only when order is over this amount, in cents.\n\t * @example ```1000```\n\t */\n\torder_amount_cents?: number | null\n\t/** \n\t * Apply the promotion only when order is over this amount, float.\n\t * @example ```10```\n\t */\n\torder_amount_float?: number | null\n\t/** \n\t * Apply the promotion only when order is over this amount, formatted.\n\t * @example ```\"€10,00\"```\n\t */\n\tformatted_order_amount?: string | null\n\t/** \n\t * Send this attribute if you want to compare the specified amount with order's subtotal (excluding discounts, if any).\n\t * @example ```true```\n\t */\n\tuse_subtotal?: boolean | null\n\n\tpromotion?: PercentageDiscountPromotion | FreeShippingPromotion | BuyXPayYPromotion | FreeGiftPromotion | FixedPricePromotion | ExternalPromotion | FixedAmountPromotion | FlexPromotion | null\n\tversions?: Version[] | null\n\tevent_stores?: EventStore[] | null\n\n}\n\n\ninterface OrderAmountPromotionRuleCreate extends ResourceCreate {\n\t\n\t/** \n\t * Apply the promotion only when order is over this amount, in cents.\n\t * @example ```1000```\n\t */\n\torder_amount_cents?: number | null\n\t/** \n\t * Send this attribute if you want to compare the specified amount with order's subtotal (excluding discounts, if any).\n\t * @example ```true```\n\t */\n\tuse_subtotal?: boolean | null\n\n\tpromotion: PercentageDiscountPromotionRel | FreeShippingPromotionRel | BuyXPayYPromotionRel | FreeGiftPromotionRel | FixedPricePromotionRel | ExternalPromotionRel | FixedAmountPromotionRel | FlexPromotionRel\n\n}\n\n\ninterface OrderAmountPromotionRuleUpdate extends ResourceUpdate {\n\t\n\t/** \n\t * Apply the promotion only when order is over this amount, in cents.\n\t * @example ```1000```\n\t */\n\torder_amount_cents?: number | null\n\t/** \n\t * Send this attribute if you want to compare the specified amount with order's subtotal (excluding discounts, if any).\n\t * @example ```true```\n\t */\n\tuse_subtotal?: boolean | null\n\n\tpromotion?: PercentageDiscountPromotionRel | FreeShippingPromotionRel | BuyXPayYPromotionRel | FreeGiftPromotionRel | FixedPricePromotionRel | ExternalPromotionRel | FixedAmountPromotionRel | FlexPromotionRel | null\n\n}\n\n\nclass OrderAmountPromotionRules extends ApiResource<OrderAmountPromotionRule> {\n\n\tstatic readonly TYPE: OrderAmountPromotionRuleType = 'order_amount_promotion_rules' as const\n\n\tasync create(resource: OrderAmountPromotionRuleCreate, params?: QueryParamsRetrieve<OrderAmountPromotionRule>, options?: ResourcesConfig): Promise<OrderAmountPromotionRule> {\n\t\treturn this.resources.create<OrderAmountPromotionRuleCreate, OrderAmountPromotionRule>({ ...resource, type: OrderAmountPromotionRules.TYPE }, params, options)\n\t}\n\n\tasync update(resource: OrderAmountPromotionRuleUpdate, params?: QueryParamsRetrieve<OrderAmountPromotionRule>, options?: ResourcesConfig): Promise<OrderAmountPromotionRule> {\n\t\treturn this.resources.update<OrderAmountPromotionRuleUpdate, OrderAmountPromotionRule>({ ...resource, type: OrderAmountPromotionRules.TYPE }, params, options)\n\t}\n\n\tasync delete(id: string | ResourceId, options?: ResourcesConfig): Promise<void> {\n\t\tawait this.resources.delete((typeof id === 'string')? { id, type: OrderAmountPromotionRules.TYPE } : id, options)\n\t}\n\n\tasync versions(orderAmountPromotionRuleId: string | OrderAmountPromotionRule, params?: QueryParamsList<Version>, options?: ResourcesConfig): Promise<ListResponse<Version>> {\n\t\tconst _orderAmountPromotionRuleId = (orderAmountPromotionRuleId as OrderAmountPromotionRule).id || orderAmountPromotionRuleId as string\n\t\treturn this.resources.fetch<Version>({ type: 'versions' }, `order_amount_promotion_rules/${_orderAmountPromotionRuleId}/versions`, params, options) as unknown as ListResponse<Version>\n\t}\n\n\tasync event_stores(orderAmountPromotionRuleId: string | OrderAmountPromotionRule, params?: QueryParamsList<EventStore>, options?: ResourcesConfig): Promise<ListResponse<EventStore>> {\n\t\tconst _orderAmountPromotionRuleId = (orderAmountPromotionRuleId as OrderAmountPromotionRule).id || orderAmountPromotionRuleId as string\n\t\treturn this.resources.fetch<EventStore>({ type: 'event_stores' }, `order_amount_promotion_rules/${_orderAmountPromotionRuleId}/event_stores`, params, options) as unknown as ListResponse<EventStore>\n\t}\n\n\n\tisOrderAmountPromotionRule(resource: any): resource is OrderAmountPromotionRule {\n\t\treturn resource.type && (resource.type === OrderAmountPromotionRules.TYPE)\n\t}\n\n\n\trelationship(id: string | ResourceId | null): OrderAmountPromotionRuleRel {\n\t\treturn super.relationshipOneToOne<OrderAmountPromotionRuleRel>(id)\n\t}\n\n\trelationshipToMany(...ids: string[]): OrderAmountPromotionRuleRel[] {\n\t\treturn super.relationshipOneToMany<OrderAmountPromotionRuleRel>(...ids)\n\t}\n\n\n\ttype(): OrderAmountPromotionRuleType {\n\t\treturn OrderAmountPromotionRules.TYPE\n\t}\n\n}\n\n\nconst instance = new OrderAmountPromotionRules()\nexport default instance\n\nexport type { OrderAmountPromotionRules, OrderAmountPromotionRule, OrderAmountPromotionRuleCreate, OrderAmountPromotionRuleUpdate, OrderAmountPromotionRuleType }\n"]}