You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Create a Custom API to store your location inventory data.
12
-
* Streamline your data import and sync processes using upserts and accessing entries with well-known identifiers.
13
12
* Ensure the accuracy of your inventory amounts using Conditional Updates to prevent lost updates and other data conistency issues.
14
13
15
14
## Prerequisites
@@ -35,13 +34,12 @@ curl -X POST "https://useast.api.elasticpath.com/v2/settings/extensions/custom-a
35
34
"api_type":"location-inventories_ext",
36
35
"name":"Location Inventories",
37
36
"description":"Inventory entries for all SKUs at all retail locations.",
38
-
"allow_upserts": true,
39
37
"type":"custom_api"
40
38
}
41
39
}
42
40
```
43
41
44
-
Make sure to take note of the Custom API ID [returned](/docs/api/commerce-extensions/create-a-custom-api#responses), you must replace `:customApiId` in the following step with the Custom API ID. In addition, notice that `data.allow_upserts` is set to `true`, this allows to perform [upserts](/guides/How-To/commerce-extensions/create-a-multilocation-inventories-resource#update-custom-api-entries) of Custom API Entries.
42
+
Make sure to take note of the Custom API ID [returned](/docs/api/commerce-extensions/create-a-custom-api#responses), you must replace `:customApiId` in the following step with the Custom API ID.
45
43
46
44
## Create Custom Fields
47
45
@@ -133,6 +131,7 @@ curl -X POST "https://useast.api.elasticpath.com/v2/settings/extensions/custom-a
133
131
}
134
132
}
135
133
```
134
+
136
135
Take note of `data.validation.string` in the step above, this field is restricted to only allow the following values:
137
136
* Paris
138
137
* London
@@ -185,25 +184,7 @@ curl -X PUT "https://useast.api.elasticpath.com/v2/extensions/location-inventori
185
184
}
186
185
```
187
186
188
-
Notice that the resource identifier in the request above is one that should be well-known to you and your processes and not a random UUID generated by the platform `/v2/extensions/location-inventories/:customApiEntryId`. Because [earlier](/guides/How-To/commerce-extensions/create-a-multilocation-inventories-resource#create-custom-field---slug) you made `sku` unique and case-insensive requests using a value like `tbl-din-6Wd-oak-0034` and every variation like it using different casing will update the same resource.
189
-
190
-
## Upsert Custom API Entries
191
-
192
-
To further simplify and optimize your data import and synchronization processes you can upsert Custom API Entries. Instead of first having to check whether a record exists and then deciding to create or update a Custom API Entries, you can upsert a record, if it exists it is updated, and if it doesn't, then it is inserted or created. This is made possible by your setting of `data.allow_upserts` when you [created this Custom API](/guides/How-To/commerce-extensions/create-a-multilocation-inventories-resource#create-a-new-custom-api---location-inventories).
193
-
194
-
```sh
195
-
curl -X PUT "https://useast.api.elasticpath.com/v2/extensions/location-inventories/FURN-SOFA-3S-LTH-BLK-0021" \
196
-
-H "Authorization: XXXX" \
197
-
-H "Content-Type: application/json" \
198
-
-d ${
199
-
"data": {
200
-
"sku":"FURN-SOFA-3S-LTH-BLK-0021",
201
-
"type":"location_inventory_ext",
202
-
"amount": 12,
203
-
"location-name":"Paris"
204
-
}
205
-
}
206
-
```
187
+
Notice that the resource identifier in the request above is one that should be well-known to you and your processes and not a random UUID generated by the platform `/v2/extensions/location-inventories/:customApiEntryId`. [Earlier](/guides/How-To/commerce-extensions/create-a-multilocation-inventories-resource#create-custom-field---slug) you made `sku` unique and case-insensive, so requests using a value like `tbl-din-6Wd-oak-0034` and similar varations using different casing will update, retrieve and potentially delete the same resource.
207
188
208
189
## Conditional Updates
209
190
@@ -247,4 +228,4 @@ curl -X GET "https://useast.api.elasticpath.com/v2/extensions/location-inventori
247
228
-H "Authorization: XXXX" \
248
229
```
249
230
250
-
For more information, see [Filtering](/docs/api/commerce-extensions/get-all-custom-entries#filtering).
231
+
For more information, see [Filtering](/docs/api/commerce-extensions/get-all-custom-entries#filtering).
0 commit comments