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 Apr 4, 2024
1 parent 9194bac commit cec3e86
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 0 deletions.
33 changes: 33 additions & 0 deletions api-specs/importapi/api.raml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ uses:
type-import: types/type-import.raml
custom-field: types/custom-field.raml
common: types/common.raml
discount-code-import: types/discount-code-import.raml

resourceTypes:
base:
Expand Down Expand Up @@ -139,6 +140,12 @@ traits:
scopes:
- manage_project:{projectKey}
- manage_types:{projectKey}
secured_by_manage_discount_codes:
securedBy:
- oauth_2_0:
scopes:
- manage_discount_codes:{projectKey}
- view_discount_codes:{projectKey}

/{projectKey}:
displayName: Project
Expand Down Expand Up @@ -641,3 +648,29 @@ traits:
description: The request was invalid.
body:
type: error.ErrorResponse
/discount-codes:
/import-containers:
/{importContainerKey}:
type: base
uriParameters:
importContainerKey:
(postman.paramName): import-container-key
description: The ImportContainer used to create the new resource
type: string
post:
description:
Creates a request for creating new Discount Codes or updating existing
ones.
is:
- secured_by_manage_discount_codes
body:
type: import-request.DiscountCodeImportRequest
example: !include examples/discount-code-import-request.json
responses:
201:
body:
type: import-request.ImportResponse
400:
description: The request was invalid.
body:
type: error.ErrorResponse
17 changes: 17 additions & 0 deletions api-specs/importapi/examples/discount-code-import-request.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"type": "discount-code",
"resources": [
{
"key": "discountCodeKey",
"code": "Save10",
"name": {
"en": "Save10"
},
"cartDiscounts": [
{ "typeId": "cart-discount", "key": "cartDiscountKey" }
],
"isActive": false,
"groups": []
}
]
}
1 change: 1 addition & 0 deletions api-specs/importapi/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<option type="exclude">CustomerImport:isEmailVerified</option>
<option type="exclude">CartClassificationTier:isMatching</option>
<option type="exclude">TrackingData:isReturn</option>
<option type="exclude">DiscountCodeImport:isActive</option>
</options>
</rule>
</rules>
Expand Down
2 changes: 2 additions & 0 deletions api-specs/importapi/types/common.raml
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ types:
product-variant-patch: The [Product Variant patch](ctp:import:type:ProductVariantPatch) resource type.
standalone-price: The [Standalone Price import](ctp:import:type:StandalonePriceImport) resource type.
type: The [Type import](ctp:import:type:TypeImport) resource type.
discount-code: The [Discount Code import](ctp:import:type:DiscountCodeImport) resource type.
type: string
enum:
- category
Expand All @@ -294,6 +295,7 @@ types:
- product-variant-patch
- standalone-price
- type
- discount-code
ReferenceType:
description: |
The type of the referenced resource.
Expand Down
72 changes: 72 additions & 0 deletions api-specs/importapi/types/discount-code-import.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#%RAML 1.0 Library
usage: Discount Code import types.
(annotations.package): discount-codes

uses:
common: common.raml
annotations: ../annotationTypes/annotations.raml
custom-field: custom-field.raml

types:
DiscountCodeImport:
description: |
The data representation for a Discount Code to be imported that is persisted as a [Discount Code](/../api/projects/discountCodes#discountcode) in the Project.
type: common.ImportResource
properties:
key:
description: |
User-defined unique identifier. If a [Discount Code](/../api/projects/discountCodes#discountcode) with this `key` exists, it will be updated with the imported data.
type: string
pattern: ^[A-Za-z0-9_-]+$
minLength: 2
maxLength: 256
name?:
description: |
Maps to `DiscountCode.name`.
type: common.LocalizedString
description?:
description: |
Maps to `DiscountCode.description`.
type: common.LocalizedString
code:
description: |
User-defined unique identifier of the DiscountCode that is used by the customer to apply the discount.
type: string
cartDiscounts:
description: |
Reference to CartDiscounts that can be applied to the Cart once the DiscountCode is applied.
type: common.CartDiscountKeyReference[]
cartPredicate?:
description: |
DiscountCode can only be applied to Carts that match this predicate.
type: string
isActive:
description: |
Indicates if the DiscountCode is active and can be applied to the Cart.
type: boolean
maxApplications?:
type: number
format: int64
description: |
Number of times the DiscountCode can be applied. DiscountCode application is counted at the time of Order creation or update. However, Order cancellation or deletion does not decrement the count.
maxApplicationsPerCustomer?:
type: number
format: int64
description: |
Number of times the DiscountCode can be applied per Customer (anonymous Carts are not supported). DiscountCode application is counted at the time of Order creation or update. However, Order cancellation or deletion does not decrement the count.
groups?:
description: |
Groups to which the DiscountCode belongs.
type: string[]
validFrom?:
description: |
Date and time (UTC) from which the DiscountCode is effective.
type: datetime
validUntil?:
description: |
Date and time (UTC) until which the DiscountCode is effective.
type: datetime
custom?:
description: |
Custom Fields of the DiscountCode.
type: custom-field.Custom
13 changes: 13 additions & 0 deletions api-specs/importapi/types/import-request.raml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ uses:
order-patch-import: order-patch-import.raml
inventory-import: inventory-import.raml
type-import: type-import.raml
discount-code-import: discount-code-import.raml

types:
ImportRequest:
Expand Down Expand Up @@ -189,3 +190,15 @@ types:
The type import resources of this request.
type: type-import.TypeImport[]
maxItems: 20
DiscountCodeImportRequest:
example: !include ../examples/discount-code-import-request.json
description: |
The request body to [import Discount Codes](#import-discount-codes). Contains data for [Discount Codes](/../api/projects/discountCodes#discountcode) to be created or updated in a Project.
type: ImportRequest
discriminatorValue: discount-code
properties:
resources:
description: |
The Discount Code import resources of this request.
type: discount-code-import.DiscountCodeImport[]
maxItems: 20

0 comments on commit cec3e86

Please sign in to comment.