diff --git a/api-specs/importapi/api.raml b/api-specs/importapi/api.raml
index 93e846130..cf2df0097 100644
--- a/api-specs/importapi/api.raml
+++ b/api-specs/importapi/api.raml
@@ -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:
@@ -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
@@ -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
diff --git a/api-specs/importapi/examples/discount-code-import-request.json b/api-specs/importapi/examples/discount-code-import-request.json
new file mode 100644
index 000000000..f2b879136
--- /dev/null
+++ b/api-specs/importapi/examples/discount-code-import-request.json
@@ -0,0 +1,17 @@
+{
+ "type": "discount-code",
+ "resources": [
+ {
+ "key": "discountCodeKey",
+ "code": "Save10",
+ "name": {
+ "en": "Save10"
+ },
+ "cartDiscounts": [
+ { "typeId": "cart-discount", "key": "cartDiscountKey" }
+ ],
+ "isActive": false,
+ "groups": []
+ }
+ ]
+}
diff --git a/api-specs/importapi/ruleset.xml b/api-specs/importapi/ruleset.xml
index ff3045d99..c4c04df7d 100644
--- a/api-specs/importapi/ruleset.xml
+++ b/api-specs/importapi/ruleset.xml
@@ -60,6 +60,7 @@
+
diff --git a/api-specs/importapi/types/common.raml b/api-specs/importapi/types/common.raml
index 3a7c5f02c..39680ffe1 100644
--- a/api-specs/importapi/types/common.raml
+++ b/api-specs/importapi/types/common.raml
@@ -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
@@ -294,6 +295,7 @@ types:
- product-variant-patch
- standalone-price
- type
+ - discount-code
ReferenceType:
description: |
The type of the referenced resource.
diff --git a/api-specs/importapi/types/discount-code-import.raml b/api-specs/importapi/types/discount-code-import.raml
new file mode 100644
index 000000000..0abd7838f
--- /dev/null
+++ b/api-specs/importapi/types/discount-code-import.raml
@@ -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
diff --git a/api-specs/importapi/types/import-request.raml b/api-specs/importapi/types/import-request.raml
index 00e8c85cf..8634f8ed3 100644
--- a/api-specs/importapi/types/import-request.raml
+++ b/api-specs/importapi/types/import-request.raml
@@ -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:
@@ -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