Skip to content

Commit 291e256

Browse files
committed
Updated API from documentation release
1 parent ce10546 commit 291e256

File tree

8 files changed

+286
-12
lines changed

8 files changed

+286
-12
lines changed

api-specs/import/api.raml

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,27 @@ uses:
4444
postman: annotationTypes/postman.raml
4545

4646
error: types/error.raml
47+
common: types/common.raml
48+
custom-field: types/custom-field.raml
4749
import-operation: types/import-operation.raml
4850
import-container: types/import-container.raml
4951
import-summary: types/import-summary.raml
5052
import-request: types/import-request.raml
51-
price-import: types/price-import.raml
52-
standalone-price-import: types/standalone-price-import.raml
53-
product-import: types/product-import.raml
54-
product-draft-import: types/product-draft-import.raml
55-
product-type-import: types/product-type-import.raml
56-
product-variant-import: types/product-variant-import.raml
53+
business-unit-import: types/business-unit-import.raml
5754
category-import: types/category-import.raml
5855
customer-import: types/customer-import.raml
56+
discount-code-import: types/discount-code-import.raml
57+
inventory-import: types/inventory-import.raml
5958
order-import: types/order-import.raml
6059
order-patch-import: types/order-patch-import.raml
61-
inventory-import: types/inventory-import.raml
62-
type-import: types/type-import.raml
63-
custom-field: types/custom-field.raml
64-
common: types/common.raml
65-
discount-code-import: types/discount-code-import.raml
60+
price-import: types/price-import.raml
61+
product-draft-import: types/product-draft-import.raml
62+
product-import: types/product-import.raml
6663
product-selection-import: types/product-selection-import.raml
64+
product-type-import: types/product-type-import.raml
65+
product-variant-import: types/product-variant-import.raml
66+
standalone-price-import: types/standalone-price-import.raml
67+
type-import: types/type-import.raml
6768

6869
resourceTypes:
6970
base:
@@ -163,6 +164,12 @@ traits:
163164
scopes:
164165
- manage_product_selections:{projectKey}
165166
- view_product_selections:{projectKey}
167+
secured_by_manage_business_units:
168+
securedBy:
169+
- oauth_2_0:
170+
scopes:
171+
- manage_project:{projectKey}
172+
- manage_business_units:{projectKey}
166173

167174
/{projectKey}:
168175
displayName: Project
@@ -755,3 +762,29 @@ traits:
755762
description: The request was invalid.
756763
body:
757764
type: error.ErrorResponse
765+
/business-units:
766+
/import-containers:
767+
/{importContainerKey}:
768+
type: base
769+
uriParameters:
770+
importContainerKey:
771+
(postman.paramName): import-container-key
772+
description: |
773+
`key` of the [ImportContainer](ctp:import:type:ImportContainer) to send this ImportRequest.
774+
type: string
775+
post:
776+
description: Creates an Import Request for Business Units.
777+
is:
778+
- secured_by_manage_business_units
779+
body:
780+
type: import-request.BusinessUnitImportRequest
781+
example: !include examples/business-units-import-request.json
782+
responses:
783+
201:
784+
body:
785+
type: import-request.ImportResponse
786+
example: !include examples/import-response.json
787+
400:
788+
description: The request was invalid.
789+
body:
790+
type: error.ErrorResponse
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"key": "acme-business-unit",
3+
"name": "ACME Business Unit",
4+
"unitType": "Company"
5+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"key": "acme-business-unit-division-a",
3+
"name": "ACME Business Unit: Division A",
4+
"unitType": "Division",
5+
"parentUnit": {
6+
"key": "acme-business-unit",
7+
"typeId": "business-unit"
8+
}
9+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"type": "business-unit",
3+
"resources": [
4+
{
5+
"key": "acme-business-unit",
6+
"name": "ACME Business Unit",
7+
"unitType": "Company"
8+
},
9+
{
10+
"key": "acme-business-unit-division-a",
11+
"name": "ACME Business Unit: Division A",
12+
"unitType": "Division",
13+
"parentUnit": {
14+
"key": "acme-business-unit",
15+
"typeId": "business-unit"
16+
}
17+
}
18+
]
19+
}

api-specs/import/ruleset.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<name>com.commercetools.rmf.validators.StringPropertySingularRule</name>
1717
<options>
1818
<option type="exclude">taxCalculationMode</option>
19+
<option type="exclude">status</option>
1920
</options>
2021
</rule>
2122
<rule>
@@ -62,6 +63,7 @@
6263
<option type="exclude">TrackingData:isReturn</option>
6364
<option type="exclude">DiscountCodeImport:isActive</option>
6465
<option type="exclude">ProductSelectionImport:isActive</option>
66+
<option type="exclude">BusinessUnitImport:isActive</option>
6567
</options>
6668
</rule>
6769
</rules>
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
#%RAML 1.0 Library
2+
usage: Business Unit import types.
3+
(annotations.package): business-units
4+
5+
uses:
6+
common: common.raml
7+
custom-field: custom-field.raml
8+
annotations: ../annotationTypes/annotations.raml
9+
10+
types:
11+
AssociateRoleInheritanceMode:
12+
description: |
13+
Determines whether the AssociateRoleAssignment can be inherited by child Business Units.
14+
type: string
15+
enum: [Enabled, Disabled]
16+
17+
BusinessUnitStatus:
18+
description: Indicates whether the Business Unit can be used.
19+
type: string
20+
enum: [Active, Inactive]
21+
22+
BusinessUnitAssociateMode:
23+
enum:
24+
- Explicit
25+
- ExplicitAndFromParent
26+
(annotations.enumDescriptions):
27+
Explicit: |
28+
All Associates of a Business Unit must be explicitly assigned. The Business Unit cannot inherit Associates from a parent.
29+
ExplicitAndFromParent: |
30+
Associates of a Business Unit can be assigned explicitly and inherited from a parent.
31+
default: ExplicitAndFromParent
32+
33+
BusinessUnitApprovalRuleMode:
34+
description: |
35+
Determines whether a Business Unit can inherit [Approval Rules](/projects/approval-rules) from a parent. Only Business Units of type `Division` can use `ExplicitAndFromParent`.
36+
enum:
37+
- Explicit
38+
- ExplicitAndFromParent
39+
(annotations.enumDescriptions):
40+
Explicit: |
41+
Approval Rules of a Business Unit must be explicitly assigned. The Business Unit cannot inherit Approval Rules from a parent.
42+
ExplicitAndFromParent: |
43+
Approval Rules of a Business Unit are inherited from a parent and can also be explicitly assigned.
44+
45+
BusinessUnitStoreMode:
46+
type: string
47+
description: |
48+
Defines whether the Stores of the Business Unit are set directly on the Business Unit or are inherited from its parent unit.
49+
enum:
50+
- Explicit
51+
- FromParent
52+
(annotations.enumDescriptions):
53+
Explicit: |
54+
Stores are defined on the Business Unit.
55+
FromParent: |
56+
Stores are inherited from the closest parent in the hierarchy that has Stores defined.
57+
58+
BusinessUnitType:
59+
description: Defines the type of the Business Unit.
60+
type: string
61+
enum: [Company, Division]
62+
63+
AssociateRoleAssignmentDraft:
64+
description: The role of an Associate in a Business Unit.
65+
properties:
66+
associateRole:
67+
type: common.AssociateRoleKeyReference
68+
description: The role to assign to the Associate.
69+
inheritance:
70+
type: AssociateRoleInheritanceMode
71+
description: |
72+
Determines whether the AssociateRole is inherited. If `Disabled`, the AssociateRole is not inherited from a parent Business Unit.
73+
74+
AssociateDraft:
75+
description: Draft for an Associate in a Business Unit.
76+
properties:
77+
customer:
78+
type: common.CustomerKeyReference
79+
description: The Customer to be part of the Business Unit.
80+
associateRoleAssignments:
81+
type: AssociateRoleAssignmentDraft[]
82+
description: The roles to assign to the Associate.
83+
84+
BusinessUnitImport:
85+
description: |
86+
Represents the data used to import a BusinessUnit. Can be of type [Company](ctp:api:type:Company) or [Division](ctp:api:type:Division).
87+
type: object
88+
discriminator: unitType
89+
properties:
90+
unitType:
91+
type: BusinessUnitType
92+
description: The type of Business Unit.
93+
key:
94+
type: string
95+
description: User-defined unique identifier. If a [BusinessUnit](ctp:api:type:BusinessUnit) with this `key` exists, it is updated with the imported data.
96+
pattern: ^[A-Za-z0-9_-]+$
97+
minLength: 2
98+
maxLength: 256
99+
name:
100+
type: string
101+
description: The name of the Business Unit.
102+
status?:
103+
type: BusinessUnitStatus
104+
description: The status of the Business Unit.
105+
contactEmail?:
106+
type: string
107+
description: The contact email address for the Business Unit.
108+
associates?:
109+
type: AssociateDraft[]
110+
description: List of Associates to be assigned to the Business Unit.
111+
addresses?:
112+
type: common.Address[]
113+
description: The addresses for the Business Unit.
114+
shippingAddresses?:
115+
type: integer[]
116+
description: |
117+
The indices of the shipping addresses in the `addresses` array.
118+
defaultShippingAddress?:
119+
type: integer
120+
description: |
121+
The index of the default shipping address in the `addresses` array.
122+
billingAddresses?:
123+
type: integer[]
124+
description: |
125+
The indices of the billing addresses in the `addresses` array.
126+
defaultBillingAddress?:
127+
type: integer
128+
description: |
129+
The index of the default billing address in the `addresses` array.
130+
stores?:
131+
type: common.StoreKeyReference[]
132+
description: The Stores of the Business Unit.
133+
custom?:
134+
type: custom-field.Custom
135+
description: Custom fields for the Business Unit.
136+
137+
CompanyBusinessUnitImport:
138+
description: Represents a [Company](ctp:api:type:Company), the top-level of a business.
139+
type: BusinessUnitImport
140+
example: !include ../examples/business-units-company-import.json
141+
discriminatorValue: Company
142+
properties:
143+
storeMode?:
144+
type: BusinessUnitStoreMode
145+
default: Explicit
146+
147+
DivisionBusinessUnitImport:
148+
description: Represents a [Division](ctp:api:type:Division), a sub-unit of a [Company](ctp:api:type:Company) or another Division.
149+
type: BusinessUnitImport
150+
example: !include ../examples/business-units-division-import.json
151+
discriminatorValue: Division
152+
properties:
153+
storeMode?:
154+
type: BusinessUnitStoreMode
155+
default: FromParent
156+
description: |
157+
If `Explicit`, the `stores` field cannot be empty and the Business Unit is explicitly associated with the given Stores. If `FromParent`, the Business Unit inherits the Stores from its parent.
158+
parentUnit:
159+
type: common.BusinessUnitKeyReference
160+
description: The parent Business Unit of this Division.
161+
associateMode?:
162+
type: BusinessUnitAssociateMode
163+
default: ExplicitAndFromParent
164+
description: |
165+
If `Explicit`, Associates are not inherited from the parent. If `ExplicitAndFromParent`, Associates are inherited from the parent.
166+
approvalRuleMode?:
167+
type: BusinessUnitApprovalRuleMode
168+
default: ExplicitAndFromParent
169+
description: |
170+
If `Explicit`, approval rules are not inherited from the parent. If `ExplicitAndFromParent`, approval rules are inherited from the parent.

api-specs/import/types/common.raml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,22 @@ types:
295295
key:
296296
type: string
297297
description: User-defined unique identifier of the referenced Type.
298+
AssociateRoleKeyReference:
299+
description: References an Associate Role by its key.
300+
type: KeyReference
301+
discriminatorValue: associate-role
302+
properties:
303+
key:
304+
type: string
305+
description: User-defined unique identifier of the referenced Type.
306+
BusinessUnitKeyReference:
307+
description: References a business unit by its key.
308+
type: KeyReference
309+
discriminatorValue: business-unit
310+
properties:
311+
key:
312+
type: string
313+
description: User-defined unique identifier of the referenced Type.
298314
UnresolvedReferences:
299315
description: Contains a reference to a resource which does not exist. For example, if a Category is imported with a parent Category that does not exist, the reference to the parent Category is an unresolved reference.
300316
example: !include ../examples/unresolved-references.json
@@ -375,8 +391,9 @@ types:
375391
type: TypedMoney
376392
ImportResourceType:
377393
description: |
378-
The resource types that can be imported.
394+
The resource type that can be imported.
379395
(annotations.enumDescriptions):
396+
business-unit: The [Business Unit import](/import-export/import-resources#for-business-units) resource type.
380397
category: The [Category import](ctp:import:type:CategoryImport) resource type.
381398
customer: The [Customer import](ctp:import:type:CustomerImport) resource type.
382399
discount-code: The [Discount Code import](ctp:import:type:DiscountCodeImport) resource type.
@@ -394,6 +411,7 @@ types:
394411
type: The [Type import](ctp:import:type:TypeImport) resource type.
395412
type: string
396413
enum:
414+
- business-unit
397415
- category
398416
- customer
399417
- discount-code
@@ -413,6 +431,8 @@ types:
413431
description: |
414432
Type of referenced resource.
415433
(annotations.enumDescriptions):
434+
associate-role: References an associate role.
435+
business-unit: References a business unit.
416436
cart: References a cart.
417437
cart-discount: References a cart discount.
418438
category: References a category.
@@ -435,6 +455,8 @@ types:
435455
type: References a type.
436456
type: string
437457
enum:
458+
- associate-role
459+
- business-unit
438460
- cart
439461
- cart-discount
440462
- category

api-specs/import/types/import-request.raml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ uses:
77
import-operation: import-operation.raml
88
annotations: ../annotationTypes/annotations.raml
99

10+
business-unit-import: business-unit-import.raml
1011
category-import: category-import.raml
1112
customer-import: customer-import.raml
1213
discount-code-import: discount-code-import.raml
@@ -218,3 +219,16 @@ types:
218219
The Product Selection import resources of this request.
219220
type: product-selection-import.ProductSelectionImport[]
220221
maxItems: 20
222+
BusinessUnitImportRequest:
223+
example: !include ../examples/business-units-import-request.json
224+
description: |
225+
The request body to [import Business Units](ctp:import:endpoint:/{projectKey}/business-units/import-containers/{importContainerKey}:POST). Contains data for [Business Units](ctp:api:type:BusinessUnit) to be created or updated in a Project.
226+
type: ImportRequest
227+
discriminatorValue: business-unit
228+
properties:
229+
resources:
230+
description: |
231+
The Business Unit import resources of this request. Can contain [CompanyBusinessUnitImport](ctp:import:type:CompanyBusinessUnitImport) or [DivisionBusinessUnitImport](ctp:import:type:DivisionBusinessUnitImport).
232+
type: business-unit-import.BusinessUnitImport[]
233+
minItems: 1
234+
maxItems: 20

0 commit comments

Comments
 (0)