forked from vtex/openapi-schemas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VTEX - Pricing Hub.json
429 lines (429 loc) · 21.1 KB
/
VTEX - Pricing Hub.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
{
"openapi": "3.0.0",
"info": {
"title": "Pricing Hub",
"description": "> This feature is in closed beta, available only for selected customers. If you have any questions, contact our [Support](https:\/\/support.vtex.com\/hc\/en-us\/requests). \r\n\r\n In the B2B scenario, it is common for stores to have personalized prices per customer and complex pricing systems that require external integrations. Pricing Hub is a system developed for the B2B context that works as an intermediary between VTEX and external pricing systems.\r\n\r\n In VTEX, B2B stores have the option to use our internal pricing system or an external one. If the store chooses to operate with an external pricing system, Pricing Hub will query an external price calculation API. The external API should then respond with the price for all items in the shopping cart according to its predefined tax rules.\r\n\r\n![Pricing hub protocal diagram](https:\/\/user-images.githubusercontent.com\/77292838\/211634260-e4f7a516-91df-416e-ab43-d9c79d56bc91.png)\r\n\r\n## Implementation\r\n\r\nTo connect with external pricing systems using Pricing Hub, it is necessary to build a VTEX IO middleware app. We offer two reference implementation templates to simplify this process:\r\n\r\n- [C# template](https:\/\/github.com\/vtex-apps\/external-prices-app)\r\n- [Node template](https:\/\/github.com\/vtex-apps\/external-prices-node)\r\n\r\nRead the documentation on each repository to learn more about the required steps to use and customize the app.\r\n\r\n> The app used by Pricing Hub to connect must be a `major 0`. \r\n\r\n### Index\r\n- [POST - Retrieve prices](https:\/\/developers.vtex.com\/docs\/api-reference\/pricing-hub#post-\/api\/pricing-hub\/prices?endpoint=post-\/api\/pricing-hub\/prices)\r\n- [PUT - Configure External Price Source](https:\/\/developers.vtex.com\/docs\/api-reference\/pricing-hub#put-\/api\/pricing-hub\/prices\/config)\n\n## Common parameters in the documentation\r\n\r\n| Parameter name | Description |\r\n| - | - |\r\n| `{{accountName}}` | Store account name. |\r\n| `{{environment}}` | The environment that will be called. |\r\n| `{{X-VTEX-API-AppKey}}` | Located in the headers of the requests, user authentication key. |\r\n| `{{X-VTEX-API-AppToken}}` | Located in the headers of the requests, authentication password. |",
"contact": {},
"version": "1.0"
},
"servers": [
{
"url": "https://prchub.{environment}.com.br",
"description": "VTEX server URL.",
"variables": {
"environment": {
"description": "Environment to use. Used as part of the URL.",
"enum": [
"vtexcommercestable"
],
"default": "vtexcommercestable"
}
}
}
],
"paths": {
"/api/pricing-hub/prices": {
"post": {
"tags": [
"Pricing Hub Prices"
],
"summary": "Retrieve prices",
"description": "This route retrieves and applies prices for the items that are passed in the request. Pricing Hub will select the pricing method that will be used for each item and will fetch their respective price from the selected pricing method. \r\n\r\n>ℹ️ This feature is in closed beta, available only for selected customers. If you have any questions, contact our [Support](https://support.vtex.com/hc/en-us/requests). ",
"parameters": [
{
"name": "an",
"in": "query",
"required": true,
"description": "Name of the VTEX account. Used as part of the URL.",
"schema": {
"type": "string",
"example": "apiexamples"
}
},
{
"name": "Accept",
"in": "header",
"required": true,
"description": "HTTP Client Negotiation Accept Header. Indicates the types of responses the client can understand.",
"style": "simple",
"schema": {
"type": "string",
"default": "application/json"
}
},
{
"name": "Content-Type",
"in": "header",
"description": "Describes the type of the content being sent.",
"required": true,
"style": "simple",
"schema": {
"type": "string",
"default": "application/json"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GetPricesRequestObject"
},
"example": {
"items": [
{
"index": 0,
"skuId": "13",
"quantity": 1,
"brandId": "2000000",
"sellerId": "1",
"priceTableIds": [],
"categoriesIds": [
"1"
]
}
],
"UtmSource": "facebook",
"UtmMedium": "social",
"UtmCampaign": "summer",
"UtmInternalCampaign": "sale",
"salesChannel": "1",
"email": "[email protected]"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/response2"
},
"example": {
"items": [
{
"index": 0,
"skuId": "14",
"price": 1875,
"costPrice": 750,
"listPrice": 2500,
"priceTable": "1",
"priceValidUntil": "2022-03-24T14:57:19Z"
},
{
"index": 0,
"skuId": "14",
"price": 200,
"costPrice": 200,
"listPrice": 200,
"priceTable": "1",
"priceValidUntil": "2022-03-04T20:00:18Z"
}
]
}
}
}
}
},
"deprecated": false
}
},
"/api/pricing-hub/prices/config": {
"put": {
"tags": [
"Pricing Hub Prices"
],
"summary": "Configure external price source",
"description": "This route facilitates setting up an external price source in Pricing Hub. It also allows you to activate or deactivate that source in a given account. \r\n\r\n>ℹ️ This feature is in closed beta, available only for selected customers. If you have any questions, contact our [Support](https://support.vtex.com/hc/en-us/requests). ",
"operationId": "ConfigExternalPriceSource",
"parameters": [
{
"name": "an",
"in": "query",
"description": "Name of the VTEX account.",
"required": false,
"schema": {
"type": "string",
"example": "apiexamples"
}
},
{
"name": "Accept",
"in": "header",
"required": true,
"description": "HTTP Client Negotiation Accept Header. Indicates the types of responses the client can understand.",
"style": "simple",
"schema": {
"type": "string",
"default": "application/json"
}
},
{
"name": "Content-Type",
"in": "header",
"description": "Describes the type of the content being sent.",
"required": true,
"style": "simple",
"schema": {
"type": "string",
"default": "application/json"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ConfigExternalPriceSourceRequest"
},
"example": {
"active": true,
"appName": "apiexamples_app_name"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK"
}
}
}
}
},
"components": {
"schemas": {
"GetPricesRequestObject": {
"required": [
"items",
"salesChannel",
"email"
],
"type": "object",
"properties": {
"items": {
"$ref": "#/components/schemas/items"
},
"UtmSource": {
"type": "string",
"example": "facebook",
"description": "Traffic source, which indicates where the traffic originated from according to the `utm_source` value in the URL that led to the order. If there is no value, use `null`.",
"nullable": true
},
"UtmMedium": {
"type": "string",
"example": "social",
"description": "Medium that indicates what type of traffic the customer originated from, represented by the `utm_medium` value in the URL that led to the order. If there is no value, use `null`.",
"nullable": true
},
"UtmCampaign": {
"type": "string",
"example": "summer",
"description": "Campaign name, represented by the `utm_campaign` value in the URL that led to the order. If there is no value, use `null`."
},
"UtmInternalCampaign": {
"type": "string",
"example": "sale",
"description": "Internal campaign name, represented by the `utmi_cp` value in the URL that led to the order. If there is no value, use `null`.",
"nullable": true
},
"salesChannel": {
"type": "string",
"example": "1",
"description": "Represents Checkout's sales channel."
},
"email": {
"type": "string",
"example": "[email protected]",
"description": "Customer's email address. If there is no value, use an empty string."
}
}
},
"items": {
"required": [
"itemsObject"
],
"type": "array",
"description": "List of items to be priced by Pricing Hub.",
"items": {
"type": "object",
"description": "Each item to be priced by Pricing Hub.",
"required": [
"index",
"skuId",
"quantity",
"brandId",
"sellerId",
"priceTableIds",
"categoriesIds"
],
"properties": {
"index": {
"description": "Index of the item at Checkout's cart. It has to be unique in the items array.",
"type": "integer",
"example": 0
},
"skuId": {
"description": "ID of the SKU that will be priced.",
"type": "string",
"example": "13"
},
"quantity": {
"description": "This is the amount of items that will be priced. It is possible to have a volume discount for many repeated items. Hence, the price may not be the quantity of the item multiplied by the unitary price.",
"type": "integer",
"example": 1
},
"brandId": {
"description": "Brand ID for the item.",
"type": "string",
"example": "2000000"
},
"sellerId": {
"description": "Seller ID for the item.",
"type": "string",
"example": "1"
},
"priceTableIds": {
"description": "IDs of the price tables that will be used to compute the price. More than one price table might be passed to the array. The final price rule might be more complex than the lowest or the highest price.",
"type": "array",
"items": {
"type": "string",
"example": "1",
"description": "ID of a price table that will be used to compute the price."
},
"default": [
"1"
]
},
"categoriesIds": {
"description": "ID of the categories that will be used to compute the price.",
"type": "array",
"items": {
"type": "string",
"example": "1",
"description": "ID of a category that will be used to compute the price."
},
"default": [
"1"
]
}
}
}
},
"response2": {
"required": [
"items"
],
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Item1"
},
"description": "List of items and their respective prices applied by Pricing Hub."
}
}
},
"Item1": {
"required": [
"index",
"skuId",
"price",
"costPrice",
"listPrice",
"priceTable",
"priceValidUntil"
],
"type": "object",
"description": "Each price item.",
"properties": {
"index": {
"type": "integer",
"description": "The same index referring to Checkout's cart that was passed to the API."
},
"skuId": {
"type": "string",
"description": "The same skuId that was passed to the API."
},
"price": {
"type": "number",
"description": "The price returned by the pricing API that was used by Pricing Hub. It is measured in cents, so 5000 means 50,00 in local currency."
},
"costPrice": {
"type": "number",
"description": "The cost price returned by the pricing API that was used by Pricing Hub. It is measured in cents, so 5000 means 50,00 in local currency."
},
"listPrice": {
"type": "number",
"description": "The list price returned by the pricing API that was used by Pricing Hub. It is measured in cents, so 5000 means 50,00 in local currency."
},
"priceTable": {
"type": "string",
"description": "The price table that was used to price the item."
},
"priceValidUntil": {
"type": "string",
"description": "The moment up until the price is valid. After that moment, it will be necessary to call the pricing API again. The format of the string is in RFC3339."
}
}
},
"ConfigExternalPriceSourceRequest": {
"required": [
"appName"
],
"type": "object",
"properties": {
"active": {
"type": "boolean",
"example": false,
"description": "Defines if the external price source is active (`true`) or not (`false`). If not set, the default value will be `false`."
},
"appName": {
"type": "string",
"description": "Name of the app that communicates with the external pricing source.",
"example": "apiexamples_app_name"
}
}
}
},
"securitySchemes": {
"appKey": {
"type": "apiKey",
"in": "header",
"name": "X-VTEX-API-AppKey",
"description": "Unique identifier of the [application key](https://developers.vtex.com/docs/guides/api-authentication-using-application-keys)."
},
"appToken": {
"type": "apiKey",
"in": "header",
"name": "X-VTEX-API-AppToken",
"description": "Secret token of the [application key](https://developers.vtex.com/docs/guides/api-authentication-using-application-keys)."
},
"VtexIdclientAutCookie": {
"type": "apiKey",
"in": "header",
"name": "VtexIdclientAutCookie",
"description": "[User token](https://developers.vtex.com/docs/guides/api-authentication-using-user-tokens), valid for 24 hours."
}
}
},
"tags": [
{
"name": "Pricing Hub Prices"
}
],
"security": [
{
"appKey": [],
"appToken": []
},
{
"VtexIdclientAutCookie": []
}
]
}