Skip to content

Commit

Permalink
Updated API from documentation release
Browse files Browse the repository at this point in the history
  • Loading branch information
ct-sdks[bot] committed Dec 17, 2024
1 parent 9c2f053 commit 175b7fc
Show file tree
Hide file tree
Showing 20 changed files with 274 additions and 11 deletions.
2 changes: 2 additions & 0 deletions api-specs/api/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
<option type="exclude">assetOrder</option>
<option type="exclude">lineItemOrder</option>
<option type="exclude">textLineItemOrder</option>
<option type="exclude">triggerPattern</option>
<option type="exclude">targetPattern</option>
<option type="exclude">syncInfo</option>
<option type="exclude">localeProjection</option>
<option type="exclude">returnInfo</option>
Expand Down
37 changes: 37 additions & 0 deletions api-specs/api/types/cart-discount/CartDiscountPatternTarget.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#%RAML 1.0 DataType
(package): 'CartDiscount'
type: CartDiscountTarget
displayName: CartDiscountPatternTarget
discriminatorValue: pattern
description: |
Pattern targets can be used to model Buy and Get discounts.
Unlike [CartDiscountLineItemsTarget](#cartdiscountlineitemstarget) and [CartDiscountCustomLineItemsTarget](#cartdiscountcustomlineitemstarget), it does not apply to a (Custom) Line Item as a whole, but to individual units of a (Custom) Line Item. The discounts can apply multiple times on the same cart, but each unit can be discounted only once.
properties:
triggerPattern?:
type: array
items: PatternComponent
description: |
Units of a (Custom) Line Item that trigger a discount application.
Based on the availability of matching units, the `triggerPattern` can match multiple times, effecting the number of times the discount will be applied.
To further limit the discount application, set the `maxOccurrence`.
If empty or not set, the Discount will apply indefinitely.
targetPattern:
type: array
items: PatternComponent
description: |
Units of (Custom) Line Items on which the Discount is applied.
Based on the availability of matching units and the limits from the `triggerPattern` or `maxOccurence`, the `targetPattern` can match multiple times.
maxOccurrence?:
type: integer
description: |
Maximum number of times the Discount can apply on a Cart.
If empty or not set, the Discount will apply indefinitely.
selectionMode:
type: SelectionMode
description: |
Determines which of the matching units of (Custom) Line Items are discounted.
7 changes: 7 additions & 0 deletions api-specs/api/types/cart-discount/CartDiscountValueFixed.raml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,10 @@ properties:
type: TypedMoney[]
description: |
Money values in [cent precision](ctp:api:type:CentPrecisionMoney) or [high precision](ctp:api:type:HighPrecisionMoney) of different currencies.
applicationMode?:
type: DiscountApplicationMode
description: |
Indicates how the discount is applied on [CartDiscountLineItemTarget](ctp:api:type:CartDiscountLineItemsTarget) or [CartDiscountCustomLineItemTarget](ctp:api:type:CartDiscountCustomLineItemsTarget).
For [CartDiscountPatternTarget](ctp:api:type:CartDiscountPatternTarget), the mode can also be `ProportionateDistribution` or `EvenDistribution`.
default: IndividualApplication
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,10 @@ properties:
A fixed Cart Discount will match a price only if the array contains a value with the same currency. For example, if it contains 10€ and 15$, the matching € price will be discounted by 10€ and the matching $ price will be discounted to 15$. If the array has multiple values of the same currency, the API returns an [InvalidOperation](ctp:api:type:InvalidOperationError) error.
If the array is empty, the discount does not apply.
applicationMode?:
type: DiscountApplicationMode
description: |
Determines how the discount applies on [CartDiscountLineItemTarget](ctp:api:type:CartDiscountLineItemsTarget) or [CartDiscountCustomLineItemTarget](ctp:api:type:CartDiscountCustomLineItemsTarget).
For [CartDiscountPatternTarget](ctp:api:type:CartDiscountPatternTarget), you can also set the mode to `ProportionateDistribution` or `EvenDistribution`.
default: IndividualApplication
37 changes: 37 additions & 0 deletions api-specs/api/types/cart-discount/CountOnCustomLineItemUnits.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#%RAML 1.0 DataType
(package): CartDiscount
type: PatternComponent
(beta): true
displayName: CountOnCustomLineItemUnits
discriminatorValue: CountOnCustomLineItemUnits
properties:
predicate:
type: string
description: |
Valid [CustomLineItem predicate](/../api/projects/predicates#customlineitem-field-identifiers) that determines the units participating in the Discount.
minCount?:
type: integer
description: |
Minimum number of units of a Custom Line Item that match the predicate.
minimum: 0
default: 1
maxCount?:
type: integer
description: |
Maximum number of units of a Custom Line Item that match the predicate.
There might be more units matching the predicate, but they will not be participating to the resulting set.
The value must be greater than or equal to `minCount`.
If not provided, the component will match all units that satisfy the predicate.
minimum: 1
excludeCount?:
type: integer
description: |
Number of units of a Custom Line Item to exclude on every application of the Discount.
Set only when configuring the `targetPattern`.
The units matched first (satisfying the pattern component) will be excluded from the resulting set.
The `minCount`and `maxCount` are considered only after the exclusion. Pattern components are matched only if any further units satisfying the pattern component exist.
For example, if 5 jeans are required but only 3 should be discounted, the `excludeCount` value must be 2.
default: 0
37 changes: 37 additions & 0 deletions api-specs/api/types/cart-discount/CountOnLineItemUnits.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#%RAML 1.0 DataType
(package): CartDiscount
type: PatternComponent
(beta): true
displayName: CountOnLineItemUnits
discriminatorValue: CountOnLineItemUnits
properties:
predicate:
type: string
description: |
Valid [LineItem predicate](/../api/projects/predicates#lineitem-field-identifiers) that determines the units participating in the Discount.
minCount?:
type: integer
description: |
Minimum number of units of a Line Item that match the predicate.
minimum: 0
default: 1
maxCount?:
type: integer
description: |
Maximum number of units of a Line Item that match the predicate.
There might be more units matching the predicate, but they will not be participating to the resulting set.
The value must be greater than or equal to `minCount`.
If not provided, the component will match all units that satisfy the predicate.
minimum: 1
excludeCount?:
type: integer
description: |
Number of units of a Line Item to exclude on every application of the Discount.
Set only when configuring the `targetPattern`.
The units matched first (satisfying the pattern component) will be excluded from the resulting set.
The `minCount`and `maxCount` are considered only after the exclusion. Pattern components are matched only if any further units satisfying the pattern component exist.
For example, if 5 jeans are required but only 3 should be discounted, the `excludeCount` value must be 2.
default: 0
11 changes: 11 additions & 0 deletions api-specs/api/types/cart-discount/PatternComponent.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#%RAML 1.0 DataType
(package): CartDiscount
type: object
(beta): true
displayName: PatternComponent
discriminator: type
description: |
The pattern component it used to define a set of units based on some criteria. The criteria depends on the type of component used.
properties:
type:
type: string
2 changes: 1 addition & 1 deletion api-specs/api/types/cart/CustomLineItem.raml
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ properties:
priceMode:
type: CustomLineItemPriceMode
description: |
Indicates whether Cart Discounts with a matching [CartDiscountCustomLineItemsTarget](ctp:api:type:CartDiscountCustomLineItemsTarget) are applied to the Custom Line Item.
Indicates whether Cart Discounts with a matching [CartDiscountCustomLineItemsTarget](ctp:api:type:CartDiscountCustomLineItemsTarget), [MultiBuyCustomLineItemsTarget](ctp:api:type:MultiBuyCustomLineItemsTarget), or [CartDiscountPatternTarget](ctp:api:type:CartDiscountPatternTarget) are applied to the Custom Line Item.
3 changes: 1 addition & 2 deletions api-specs/api/types/cart/CustomLineItemDraft.raml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ properties:
priceMode?:
type: CustomLineItemPriceMode
description: |
- If `Standard`, Cart Discounts with a matching [CartDiscountCustomLineItemsTarget](ctp:api:type:CartDiscountCustomLineItemsTarget)
are applied to the Custom Line Item.
- If `Standard`, Cart Discounts with a matching [CartDiscountCustomLineItemsTarget](ctp:api:type:CartDiscountCustomLineItemsTarget), [MultiBuyCustomLineItemsTarget](ctp:api:type:MultiBuyCustomLineItemsTarget), or [CartDiscountPatternTarget](ctp:api:type:CartDiscountPatternTarget) are applied to the Custom Line Item.
- If `External`, Cart Discounts are not considered on the Custom Line Item.
default: Standard
2 changes: 1 addition & 1 deletion api-specs/api/types/cart/CustomLineItemPriceMode.raml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ enum:
This is the default mode for backwards compatibility.
External: |
Deactivates application of Cart Discounts for the Custom Line Item, despite a matching [CartDiscountCustomLineItemsTarget](ctp:api:type:CartDiscountCustomLineItemsTarget) and [MultiBuyCustomLineItemsTarget](ctp:api:type:MultiBuyCustomLineItemsTarget).
Deactivates application of Cart Discounts for the Custom Line Item despite a matching [CartDiscountCustomLineItemsTarget](ctp:api:type:CartDiscountCustomLineItemsTarget), [MultiBuyCustomLineItemsTarget](ctp:api:type:MultiBuyCustomLineItemsTarget), or [CartDiscountPatternTarget](ctp:api:type:CartDiscountPatternTarget).
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ properties:
priceMode?:
type: CustomLineItemPriceMode
description: |
- If `Standard`, Cart Discounts with a matching [CartDiscountCustomLineItemsTarget](ctp:api:type:CartDiscountCustomLineItemsTarget)
are applied to the Custom Line Item.
- If `Standard`, Cart Discounts with a matching [CartDiscountCustomLineItemsTarget](ctp:api:type:CartDiscountCustomLineItemsTarget), [MultiBuyCustomLineItemsTarget](ctp:api:type:MultiBuyCustomLineItemsTarget), or [CartDiscountPatternTarget](ctp:api:type:CartDiscountPatternTarget) are applied to the Custom Line Item.
- If `External`, Cart Discounts are not considered on the Custom Line Item.
default: Standard
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ properties:
priceMode?:
type: CustomLineItemPriceMode
description: |
- If `Standard`, Cart Discounts with a matching [CartDiscountCustomLineItemsTarget](ctp:api:type:CartDiscountCustomLineItemsTarget)
are applied to the Custom Line Item.
- If `Standard`, Cart Discounts with a matching [CartDiscountCustomLineItemsTarget](ctp:api:type:CartDiscountCustomLineItemsTarget), [MultiBuyCustomLineItemsTarget](ctp:api:type:MultiBuyCustomLineItemsTarget), or [CartDiscountPatternTarget](ctp:api:type:CartDiscountPatternTarget) are applied to the Custom Line Item.
- If `External`, Cart Discounts are not considered on the Custom Line Item.
default: Standard
custom?:
Expand Down
3 changes: 1 addition & 2 deletions api-specs/api/types/order/CustomLineItemImportDraft.raml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ properties:
type: CustomLineItemPriceMode
default: Standard
description: |
- If `Standard`, Cart Discounts with a matching [CartDiscountCustomLineItemsTarget](ctp:api:type:CartDiscountCustomLineItemsTarget)
are applied to the Custom Line Item.
- If `Standard`, Cart Discounts with a matching [CartDiscountCustomLineItemsTarget](ctp:api:type:CartDiscountCustomLineItemsTarget), [MultiBuyCustomLineItemsTarget](ctp:api:type:MultiBuyCustomLineItemsTarget), or [CartDiscountPatternTarget](ctp:api:type:CartDiscountPatternTarget) are applied to the Custom Line Item.
- If `External`, Cart Discounts are not considered on the Custom Line Item.
shippingDetails?:
type: ItemShippingDetailsDraft
Expand Down
4 changes: 4 additions & 0 deletions api-specs/api/types/types.raml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ CartDiscountCustomLineItemsTarget: !include cart-discount/CartDiscountCustomLine
CartDiscountDraft: !include cart-discount/CartDiscountDraft.raml
CartDiscountLineItemsTarget: !include cart-discount/CartDiscountLineItemsTarget.raml
CartDiscountPagedQueryResponse: !include cart-discount/CartDiscountPagedQueryResponse.raml
CartDiscountPatternTarget: !include cart-discount/CartDiscountPatternTarget.raml
CartDiscountReference: !include cart-discount/CartDiscountReference.raml
CartDiscountResourceIdentifier: !include cart-discount/CartDiscountResourceIdentifier.raml
CartDiscountShippingCostTarget: !include cart-discount/CartDiscountShippingCostTarget.raml
Expand All @@ -146,9 +147,12 @@ CartDiscountValueGiftLineItem: !include cart-discount/CartDiscountValueGiftLineI
CartDiscountValueGiftLineItemDraft: !include cart-discount/CartDiscountValueGiftLineItemDraft.raml
CartDiscountValueRelative: !include cart-discount/CartDiscountValueRelative.raml
CartDiscountValueRelativeDraft: !include cart-discount/CartDiscountValueRelativeDraft.raml
CountOnCustomLineItemUnits: !include cart-discount/CountOnCustomLineItemUnits.raml
CountOnLineItemUnits: !include cart-discount/CountOnLineItemUnits.raml
DiscountApplicationMode: !include cart-discount/DiscountApplicationMode.raml
MultiBuyCustomLineItemsTarget: !include cart-discount/MultiBuyCustomLineItemsTarget.raml
MultiBuyLineItemsTarget: !include cart-discount/MultiBuyLineItemsTarget.raml
PatternComponent: !include cart-discount/PatternComponent.raml
SelectionMode: !include cart-discount/SelectionMode.raml
StackingMode: !include cart-discount/StackingMode.raml
CartDiscountAddStoreAction: !include cart-discount/updates/CartDiscountAddStoreAction.raml
Expand Down
79 changes: 79 additions & 0 deletions api-specs/graphql/schema.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -1827,6 +1827,23 @@ type CartDiscountLimitsProjection {
totalActiveWithoutDiscountCodes: CartDiscountLimitWithCurrent!
}

"BETA: This feature can be subject to change and should be used carefully in production. https://docs.commercetools.com/api/contract#public-beta"
type CartDiscountPatternTarget implements CartDiscountTarget {
triggerPattern: [PatternComponent!]!
targetPattern: [PatternComponent!]!
maxOccurrence: Int
selectionMode: SelectionMode!
type: String!
}

"BETA: This feature can be subject to change and should be used carefully in production. https://docs.commercetools.com/api/contract#public-beta"
input CartDiscountPatternTargetInput {
triggerPattern: [PatternComponentInput!]!
targetPattern: [PatternComponentInput!]!
maxOccurrence: Int
selectionMode: SelectionMode
}

"Fields to access cartDiscounts. Includes direct access to a single cartDiscount and searching for cartDiscounts."
interface CartDiscountQueryInterface {
cartDiscount(
Expand Down Expand Up @@ -1875,6 +1892,9 @@ input CartDiscountTargetInput {
multiBuyLineItems: MultiBuyLineItemsTargetInput
multiBuyCustomLineItems: MultiBuyCustomLineItemsTargetInput
totalPrice: CartDiscountTotalPriceTargetInput

"BETA: This feature can be subject to change and should be used carefully in production. https://docs.commercetools.com/api/contract#public-beta"
pattern: CartDiscountPatternTargetInput
}

type CartDiscountTotalPriceTarget implements CartDiscountTarget {
Expand Down Expand Up @@ -1921,11 +1941,13 @@ input CartDiscountValueBaseMoneyInput {
centAmount: Long
}


input CartDiscountValueInput {
relative: RelativeDiscountValueInput
absolute: AbsoluteDiscountValueInput
absoluteCart: AbsoluteCartDiscountValueInput
fixed: FixedPriceDiscountValueInput
fixedCart: FixedPriceCartDiscountValueInput
giftLineItem: GiftLineItemValueInput
}

Expand Down Expand Up @@ -3063,6 +3085,41 @@ input ConfluentCloudDestinationInput {
key: String
}


"BETA: This feature can be subject to change and should be used carefully in production. https://docs.commercetools.com/api/contract#public-beta"
type CountOnCustomLineItemUnits implements PatternComponent {
predicate: String!
minCount: Int
maxCount: Int
excludeCount: Int
type: String!
}

"BETA: This feature can be subject to change and should be used carefully in production. https://docs.commercetools.com/api/contract#public-beta"
input CountOnCustomLineItemUnitsInput {
predicate: String!
minCount: Int = 1
maxCount: Int
excludeCount: Int
}

"BETA: This feature can be subject to change and should be used carefully in production. https://docs.commercetools.com/api/contract#public-beta"
type CountOnLineItemUnits implements PatternComponent {
predicate: String!
minCount: Int
maxCount: Int
excludeCount: Int
type: String!
}

"BETA: This feature can be subject to change and should be used carefully in production. https://docs.commercetools.com/api/contract#public-beta"
input CountOnLineItemUnitsInput {
predicate: String!
minCount: Int = 1
maxCount: Int
excludeCount: Int
}

"[ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) country code."
scalar Country

Expand Down Expand Up @@ -4447,6 +4504,17 @@ input FieldTypeSetTypeDraft {
elementType: FieldTypeSetElementTypeDraft!
}

type FixedPriceCartDiscountValue implements CartDiscountValue {
type: String!
money: [BaseMoney!]!
applicationMode: DiscountApplicationMode!
}

input FixedPriceCartDiscountValueInput {
money: [CartDiscountValueBaseMoneyInputType!]!
applicationMode: DiscountApplicationMode!
}

type FixedPriceDiscountValue implements CartDiscountValue {
type: String!
money: [BaseMoney!]!
Expand Down Expand Up @@ -7283,6 +7351,17 @@ type ParcelTrackingDataUpdated implements MessagePayload & OrderMessagePayload {
type: String!
}

"BETA: This feature can be subject to change and should be used carefully in production. https://docs.commercetools.com/api/contract#public-beta"
interface PatternComponent {
type: String!
}

"BETA: This feature can be subject to change and should be used carefully in production. https://docs.commercetools.com/api/contract#public-beta"
input PatternComponentInput {
CountOnLineItemUnits: CountOnLineItemUnitsInput
CountOnCustomLineItemUnits: CountOnCustomLineItemUnitsInput
}

"""
Payments hold information about the current state of receiving and/or refunding money.
[documentation](https://docs.commercetools.com/api/projects/payments)
Expand Down
2 changes: 2 additions & 0 deletions api-specs/history/api.raml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ annotationTypes:
package:
type: string
allowedTargets: TypeDeclaration
beta:
type: boolean
enumDescriptions:
description: |
Describes the values of an enum type.
Expand Down
4 changes: 3 additions & 1 deletion api-specs/history/ruleset.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/commercetools/rmf-codegen/main/ctp-validators/src/main/resources/ruleset.xsd">
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/commercetools/rmf-codegen/main/ctp-validators/src/main/resources/ruleset.xsd">
<name>default</name>
<apply set="default"/>
<rules>
Expand Down Expand Up @@ -53,6 +53,8 @@
<option type="exclude">value</option>
<option type="exclude">nextValue</option>
<option type="exclude">previousValue</option>
<option type="exclude">triggerPattern</option>
<option type="exclude">targetPattern</option>
</options>
</rule>
<rule>
Expand Down
Loading

0 comments on commit 175b7fc

Please sign in to comment.