@51eat/sdk 0.0.45 → 0.0.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/README.md +12 -9
  2. package/dist/cjs/BaseClient.js +2 -2
  3. package/dist/cjs/Client.d.ts +3 -0
  4. package/dist/cjs/Client.js +15 -10
  5. package/dist/cjs/api/resources/businessProducts/client/Client.d.ts +62 -0
  6. package/dist/cjs/api/resources/businessProducts/client/Client.js +261 -0
  7. package/dist/cjs/api/resources/businessProducts/client/index.d.ts +1 -0
  8. package/dist/cjs/api/resources/businessProducts/client/index.js +17 -0
  9. package/dist/cjs/api/resources/businessProducts/client/requests/AdjustInventoryRequest.d.ts +34 -0
  10. package/dist/cjs/api/resources/businessProducts/client/requests/AdjustInventoryRequest.js +20 -0
  11. package/dist/cjs/api/resources/businessProducts/client/requests/GetProductInventorySummaryRequest.d.ts +10 -0
  12. package/dist/cjs/api/resources/businessProducts/client/requests/GetProductInventorySummaryRequest.js +3 -0
  13. package/dist/cjs/api/resources/businessProducts/client/requests/ListVariantInventoryHistoryRequest.d.ts +11 -0
  14. package/dist/cjs/api/resources/businessProducts/client/requests/ListVariantInventoryHistoryRequest.js +3 -0
  15. package/dist/cjs/api/resources/businessProducts/client/requests/index.d.ts +3 -0
  16. package/dist/cjs/api/resources/businessProducts/client/requests/index.js +5 -0
  17. package/dist/cjs/api/resources/businessProducts/exports.d.ts +2 -0
  18. package/dist/cjs/api/resources/businessProducts/exports.js +21 -0
  19. package/dist/cjs/api/resources/businessProducts/index.d.ts +2 -0
  20. package/dist/cjs/api/resources/businessProducts/index.js +18 -0
  21. package/dist/cjs/api/resources/businessProducts/types/AdjustVariantInventoryResponse.d.ts +4 -0
  22. package/dist/cjs/api/resources/businessProducts/types/AdjustVariantInventoryResponse.js +3 -0
  23. package/dist/cjs/api/resources/businessProducts/types/GetProductInventorySummaryResponse.d.ts +4 -0
  24. package/dist/cjs/api/resources/businessProducts/types/GetProductInventorySummaryResponse.js +3 -0
  25. package/dist/cjs/api/resources/businessProducts/types/ListVariantInventoryHistoryResponse.d.ts +4 -0
  26. package/dist/cjs/api/resources/businessProducts/types/ListVariantInventoryHistoryResponse.js +3 -0
  27. package/dist/cjs/api/resources/businessProducts/types/index.d.ts +3 -0
  28. package/dist/cjs/api/resources/businessProducts/types/index.js +19 -0
  29. package/dist/cjs/api/resources/customer/resources/cart/types/CreatePaymentIntentCartResponse.d.ts +1 -1
  30. package/dist/cjs/api/resources/index.d.ts +3 -0
  31. package/dist/cjs/api/resources/index.js +4 -1
  32. package/dist/cjs/api/types/BusinessInventoryLog.d.ts +15 -0
  33. package/dist/cjs/api/types/BusinessInventoryLog.js +3 -0
  34. package/dist/cjs/api/types/BusinessProductInventorySummary.d.ts +7 -0
  35. package/dist/cjs/api/types/BusinessProductInventorySummary.js +3 -0
  36. package/dist/cjs/api/types/CustomerCartItem.d.ts +1 -1
  37. package/dist/cjs/api/types/CustomerProductOrder.d.ts +5 -5
  38. package/dist/cjs/api/types/CustomerProductOrderItem.d.ts +2 -2
  39. package/dist/cjs/api/types/InternalServerErrorBody.d.ts +7 -1
  40. package/dist/cjs/api/types/InternalServerErrorBody.js +7 -0
  41. package/dist/cjs/api/types/index.d.ts +2 -0
  42. package/dist/cjs/api/types/index.js +2 -0
  43. package/dist/cjs/version.d.ts +1 -1
  44. package/dist/cjs/version.js +1 -1
  45. package/dist/esm/BaseClient.mjs +2 -2
  46. package/dist/esm/Client.d.mts +3 -0
  47. package/dist/esm/Client.mjs +5 -0
  48. package/dist/esm/api/resources/businessProducts/client/Client.d.mts +62 -0
  49. package/dist/esm/api/resources/businessProducts/client/Client.mjs +224 -0
  50. package/dist/esm/api/resources/businessProducts/client/index.d.mts +1 -0
  51. package/dist/esm/api/resources/businessProducts/client/index.mjs +1 -0
  52. package/dist/esm/api/resources/businessProducts/client/requests/AdjustInventoryRequest.d.mts +34 -0
  53. package/dist/esm/api/resources/businessProducts/client/requests/AdjustInventoryRequest.mjs +17 -0
  54. package/dist/esm/api/resources/businessProducts/client/requests/GetProductInventorySummaryRequest.d.mts +10 -0
  55. package/dist/esm/api/resources/businessProducts/client/requests/GetProductInventorySummaryRequest.mjs +2 -0
  56. package/dist/esm/api/resources/businessProducts/client/requests/ListVariantInventoryHistoryRequest.d.mts +11 -0
  57. package/dist/esm/api/resources/businessProducts/client/requests/ListVariantInventoryHistoryRequest.mjs +2 -0
  58. package/dist/esm/api/resources/businessProducts/client/requests/index.d.mts +3 -0
  59. package/dist/esm/api/resources/businessProducts/client/requests/index.mjs +1 -0
  60. package/dist/esm/api/resources/businessProducts/exports.d.mts +2 -0
  61. package/dist/esm/api/resources/businessProducts/exports.mjs +3 -0
  62. package/dist/esm/api/resources/businessProducts/index.d.mts +2 -0
  63. package/dist/esm/api/resources/businessProducts/index.mjs +2 -0
  64. package/dist/esm/api/resources/businessProducts/types/AdjustVariantInventoryResponse.d.mts +4 -0
  65. package/dist/esm/api/resources/businessProducts/types/AdjustVariantInventoryResponse.mjs +2 -0
  66. package/dist/esm/api/resources/businessProducts/types/GetProductInventorySummaryResponse.d.mts +4 -0
  67. package/dist/esm/api/resources/businessProducts/types/GetProductInventorySummaryResponse.mjs +2 -0
  68. package/dist/esm/api/resources/businessProducts/types/ListVariantInventoryHistoryResponse.d.mts +4 -0
  69. package/dist/esm/api/resources/businessProducts/types/ListVariantInventoryHistoryResponse.mjs +2 -0
  70. package/dist/esm/api/resources/businessProducts/types/index.d.mts +3 -0
  71. package/dist/esm/api/resources/businessProducts/types/index.mjs +3 -0
  72. package/dist/esm/api/resources/customer/resources/cart/types/CreatePaymentIntentCartResponse.d.mts +1 -1
  73. package/dist/esm/api/resources/index.d.mts +3 -0
  74. package/dist/esm/api/resources/index.mjs +3 -0
  75. package/dist/esm/api/types/BusinessInventoryLog.d.mts +15 -0
  76. package/dist/esm/api/types/BusinessInventoryLog.mjs +2 -0
  77. package/dist/esm/api/types/BusinessProductInventorySummary.d.mts +7 -0
  78. package/dist/esm/api/types/BusinessProductInventorySummary.mjs +2 -0
  79. package/dist/esm/api/types/CustomerCartItem.d.mts +1 -1
  80. package/dist/esm/api/types/CustomerProductOrder.d.mts +5 -5
  81. package/dist/esm/api/types/CustomerProductOrderItem.d.mts +2 -2
  82. package/dist/esm/api/types/InternalServerErrorBody.d.mts +7 -1
  83. package/dist/esm/api/types/InternalServerErrorBody.mjs +6 -1
  84. package/dist/esm/api/types/index.d.mts +2 -0
  85. package/dist/esm/api/types/index.mjs +2 -0
  86. package/dist/esm/version.d.mts +1 -1
  87. package/dist/esm/version.mjs +1 -1
  88. package/package.json +12 -1
  89. package/reference.md +157 -0
package/README.md CHANGED
@@ -45,8 +45,11 @@ Instantiate and use the client with the following:
45
45
  import { FiveOneEatClient } from "@51eat/sdk";
46
46
 
47
47
  const client = new FiveOneEatClient({ token: "YOUR_TOKEN" });
48
- await client.recordClick.adsRecordClick({
49
- advertisement: "advertisement"
48
+ await client.businessProducts.adjustVariantInventory({
49
+ variant: "variant",
50
+ type: "add",
51
+ quantity: 1,
52
+ reason: "restock"
50
53
  });
51
54
  ```
52
55
 
@@ -84,7 +87,7 @@ will be thrown.
84
87
  import { FiveOneEatError } from "@51eat/sdk";
85
88
 
86
89
  try {
87
- await client.recordClick.adsRecordClick(...);
90
+ await client.businessProducts.adjustVariantInventory(...);
88
91
  } catch (err) {
89
92
  if (err instanceof FiveOneEatError) {
90
93
  console.log(err.statusCode);
@@ -166,7 +169,7 @@ const client = new FiveOneEatClient({
166
169
  }
167
170
  });
168
171
 
169
- const response = await client.recordClick.adsRecordClick(..., {
172
+ const response = await client.businessProducts.adjustVariantInventory(..., {
170
173
  headers: {
171
174
  'X-Custom-Header': 'custom value'
172
175
  }
@@ -178,7 +181,7 @@ const response = await client.recordClick.adsRecordClick(..., {
178
181
  If you would like to send additional query string parameters as part of the request, use the `queryParams` request option.
179
182
 
180
183
  ```typescript
181
- const response = await client.recordClick.adsRecordClick(..., {
184
+ const response = await client.businessProducts.adjustVariantInventory(..., {
182
185
  queryParams: {
183
186
  'customQueryParamKey': 'custom query param value'
184
187
  }
@@ -200,7 +203,7 @@ A request is deemed retryable when any of the following HTTP status codes is ret
200
203
  Use the `maxRetries` request option to configure this behavior.
201
204
 
202
205
  ```typescript
203
- const response = await client.recordClick.adsRecordClick(..., {
206
+ const response = await client.businessProducts.adjustVariantInventory(..., {
204
207
  maxRetries: 0 // override maxRetries at the request level
205
208
  });
206
209
  ```
@@ -210,7 +213,7 @@ const response = await client.recordClick.adsRecordClick(..., {
210
213
  The SDK defaults to a 60 second timeout. Use the `timeoutInSeconds` option to configure this behavior.
211
214
 
212
215
  ```typescript
213
- const response = await client.recordClick.adsRecordClick(..., {
216
+ const response = await client.businessProducts.adjustVariantInventory(..., {
214
217
  timeoutInSeconds: 30 // override timeout to 30s
215
218
  });
216
219
  ```
@@ -221,7 +224,7 @@ The SDK allows users to abort requests at any point by passing in an abort signa
221
224
 
222
225
  ```typescript
223
226
  const controller = new AbortController();
224
- const response = await client.recordClick.adsRecordClick(..., {
227
+ const response = await client.businessProducts.adjustVariantInventory(..., {
225
228
  abortSignal: controller.signal
226
229
  });
227
230
  controller.abort(); // aborts the request
@@ -233,7 +236,7 @@ The SDK provides access to raw response data, including headers, through the `.w
233
236
  The `.withRawResponse()` method returns a promise that results to an object with a `data` and a `rawResponse` property.
234
237
 
235
238
  ```typescript
236
- const { data, rawResponse } = await client.recordClick.adsRecordClick(...).withRawResponse();
239
+ const { data, rawResponse } = await client.businessProducts.adjustVariantInventory(...).withRawResponse();
237
240
 
238
241
  console.log(data);
239
242
  console.log(rawResponse.headers['X-My-Header']);
@@ -43,8 +43,8 @@ function normalizeClientOptions(options) {
43
43
  const headers = (0, headers_js_1.mergeHeaders)({
44
44
  "X-Fern-Language": "JavaScript",
45
45
  "X-Fern-SDK-Name": "@51eat/sdk",
46
- "X-Fern-SDK-Version": "0.0.45",
47
- "User-Agent": "@51eat/sdk/0.0.45",
46
+ "X-Fern-SDK-Version": "0.0.46",
47
+ "User-Agent": "@51eat/sdk/0.0.46",
48
48
  "X-Fern-Runtime": core.RUNTIME.type,
49
49
  "X-Fern-Runtime-Version": core.RUNTIME.version,
50
50
  }, options === null || options === void 0 ? void 0 : options.headers);
@@ -1,5 +1,6 @@
1
1
  import { BusinessClient } from "./api/resources/business/client/Client.js";
2
2
  import { BusinessMessagingClient } from "./api/resources/businessMessaging/client/Client.js";
3
+ import { BusinessProductsClient } from "./api/resources/businessProducts/client/Client.js";
3
4
  import { CustomerClient } from "./api/resources/customer/client/Client.js";
4
5
  import { CustomerMessagingClient } from "./api/resources/customerMessaging/client/Client.js";
5
6
  import { CustomerMyAccountClient } from "./api/resources/customerMyAccount/client/Client.js";
@@ -16,6 +17,7 @@ export declare namespace FiveOneEatClient {
16
17
  export declare class FiveOneEatClient {
17
18
  protected readonly _options: NormalizedClientOptionsWithAuth<FiveOneEatClient.Options>;
18
19
  protected _businessMessaging: BusinessMessagingClient | undefined;
20
+ protected _businessProducts: BusinessProductsClient | undefined;
19
21
  protected _customerMessaging: CustomerMessagingClient | undefined;
20
22
  protected _customerMyAccount: CustomerMyAccountClient | undefined;
21
23
  protected _customer: CustomerClient | undefined;
@@ -24,6 +26,7 @@ export declare class FiveOneEatClient {
24
26
  protected _business: BusinessClient | undefined;
25
27
  constructor(options?: FiveOneEatClient.Options);
26
28
  get businessMessaging(): BusinessMessagingClient;
29
+ get businessProducts(): BusinessProductsClient;
27
30
  get customerMessaging(): CustomerMessagingClient;
28
31
  get customerMyAccount(): CustomerMyAccountClient;
29
32
  get customer(): CustomerClient;
@@ -46,11 +46,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
46
46
  exports.FiveOneEatClient = void 0;
47
47
  const Client_js_1 = require("./api/resources/business/client/Client.js");
48
48
  const Client_js_2 = require("./api/resources/businessMessaging/client/Client.js");
49
- const Client_js_3 = require("./api/resources/customer/client/Client.js");
50
- const Client_js_4 = require("./api/resources/customerMessaging/client/Client.js");
51
- const Client_js_5 = require("./api/resources/customerMyAccount/client/Client.js");
52
- const Client_js_6 = require("./api/resources/recordClick/client/Client.js");
53
- const Client_js_7 = require("./api/resources/serveAd/client/Client.js");
49
+ const Client_js_3 = require("./api/resources/businessProducts/client/Client.js");
50
+ const Client_js_4 = require("./api/resources/customer/client/Client.js");
51
+ const Client_js_5 = require("./api/resources/customerMessaging/client/Client.js");
52
+ const Client_js_6 = require("./api/resources/customerMyAccount/client/Client.js");
53
+ const Client_js_7 = require("./api/resources/recordClick/client/Client.js");
54
+ const Client_js_8 = require("./api/resources/serveAd/client/Client.js");
54
55
  const BaseClient_js_1 = require("./BaseClient.js");
55
56
  const core = __importStar(require("./core/index.js"));
56
57
  class FiveOneEatClient {
@@ -61,25 +62,29 @@ class FiveOneEatClient {
61
62
  var _a;
62
63
  return ((_a = this._businessMessaging) !== null && _a !== void 0 ? _a : (this._businessMessaging = new Client_js_2.BusinessMessagingClient(this._options)));
63
64
  }
65
+ get businessProducts() {
66
+ var _a;
67
+ return ((_a = this._businessProducts) !== null && _a !== void 0 ? _a : (this._businessProducts = new Client_js_3.BusinessProductsClient(this._options)));
68
+ }
64
69
  get customerMessaging() {
65
70
  var _a;
66
- return ((_a = this._customerMessaging) !== null && _a !== void 0 ? _a : (this._customerMessaging = new Client_js_4.CustomerMessagingClient(this._options)));
71
+ return ((_a = this._customerMessaging) !== null && _a !== void 0 ? _a : (this._customerMessaging = new Client_js_5.CustomerMessagingClient(this._options)));
67
72
  }
68
73
  get customerMyAccount() {
69
74
  var _a;
70
- return ((_a = this._customerMyAccount) !== null && _a !== void 0 ? _a : (this._customerMyAccount = new Client_js_5.CustomerMyAccountClient(this._options)));
75
+ return ((_a = this._customerMyAccount) !== null && _a !== void 0 ? _a : (this._customerMyAccount = new Client_js_6.CustomerMyAccountClient(this._options)));
71
76
  }
72
77
  get customer() {
73
78
  var _a;
74
- return ((_a = this._customer) !== null && _a !== void 0 ? _a : (this._customer = new Client_js_3.CustomerClient(this._options)));
79
+ return ((_a = this._customer) !== null && _a !== void 0 ? _a : (this._customer = new Client_js_4.CustomerClient(this._options)));
75
80
  }
76
81
  get recordClick() {
77
82
  var _a;
78
- return ((_a = this._recordClick) !== null && _a !== void 0 ? _a : (this._recordClick = new Client_js_6.RecordClickClient(this._options)));
83
+ return ((_a = this._recordClick) !== null && _a !== void 0 ? _a : (this._recordClick = new Client_js_7.RecordClickClient(this._options)));
79
84
  }
80
85
  get serveAd() {
81
86
  var _a;
82
- return ((_a = this._serveAd) !== null && _a !== void 0 ? _a : (this._serveAd = new Client_js_7.ServeAdClient(this._options)));
87
+ return ((_a = this._serveAd) !== null && _a !== void 0 ? _a : (this._serveAd = new Client_js_8.ServeAdClient(this._options)));
83
88
  }
84
89
  get business() {
85
90
  var _a;
@@ -0,0 +1,62 @@
1
+ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
2
+ import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js";
3
+ import * as core from "../../../../core/index.js";
4
+ import * as FiveOneEat from "../../../index.js";
5
+ export declare namespace BusinessProductsClient {
6
+ type Options = BaseClientOptions;
7
+ interface RequestOptions extends BaseRequestOptions {
8
+ }
9
+ }
10
+ export declare class BusinessProductsClient {
11
+ protected readonly _options: NormalizedClientOptionsWithAuth<BusinessProductsClient.Options>;
12
+ constructor(options?: BusinessProductsClient.Options);
13
+ /**
14
+ * @param {FiveOneEat.AdjustInventoryRequest} request
15
+ * @param {BusinessProductsClient.RequestOptions} requestOptions - Request-specific configuration.
16
+ *
17
+ * @throws {@link FiveOneEat.UnauthorizedError}
18
+ * @throws {@link FiveOneEat.ForbiddenError}
19
+ * @throws {@link FiveOneEat.NotFoundError}
20
+ * @throws {@link FiveOneEat.UnprocessableEntityError}
21
+ *
22
+ * @example
23
+ * await client.businessProducts.adjustVariantInventory({
24
+ * variant: "variant",
25
+ * type: "add",
26
+ * quantity: 1,
27
+ * reason: "restock"
28
+ * })
29
+ */
30
+ adjustVariantInventory(request: FiveOneEat.AdjustInventoryRequest, requestOptions?: BusinessProductsClient.RequestOptions): core.HttpResponsePromise<FiveOneEat.AdjustVariantInventoryResponse>;
31
+ private __adjustVariantInventory;
32
+ /**
33
+ * @param {FiveOneEat.ListVariantInventoryHistoryRequest} request
34
+ * @param {BusinessProductsClient.RequestOptions} requestOptions - Request-specific configuration.
35
+ *
36
+ * @throws {@link FiveOneEat.UnauthorizedError}
37
+ * @throws {@link FiveOneEat.ForbiddenError}
38
+ * @throws {@link FiveOneEat.NotFoundError}
39
+ *
40
+ * @example
41
+ * await client.businessProducts.listVariantInventoryHistory({
42
+ * variant: "variant"
43
+ * })
44
+ */
45
+ listVariantInventoryHistory(request: FiveOneEat.ListVariantInventoryHistoryRequest, requestOptions?: BusinessProductsClient.RequestOptions): core.HttpResponsePromise<FiveOneEat.ListVariantInventoryHistoryResponse>;
46
+ private __listVariantInventoryHistory;
47
+ /**
48
+ * @param {FiveOneEat.GetProductInventorySummaryRequest} request
49
+ * @param {BusinessProductsClient.RequestOptions} requestOptions - Request-specific configuration.
50
+ *
51
+ * @throws {@link FiveOneEat.UnauthorizedError}
52
+ * @throws {@link FiveOneEat.ForbiddenError}
53
+ * @throws {@link FiveOneEat.NotFoundError}
54
+ *
55
+ * @example
56
+ * await client.businessProducts.getProductInventorySummary({
57
+ * product: "product"
58
+ * })
59
+ */
60
+ getProductInventorySummary(request: FiveOneEat.GetProductInventorySummaryRequest, requestOptions?: BusinessProductsClient.RequestOptions): core.HttpResponsePromise<FiveOneEat.GetProductInventorySummaryResponse>;
61
+ private __getProductInventorySummary;
62
+ }
@@ -0,0 +1,261 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
+ return new (P || (P = Promise))(function (resolve, reject) {
39
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
43
+ });
44
+ };
45
+ var __rest = (this && this.__rest) || function (s, e) {
46
+ var t = {};
47
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
48
+ t[p] = s[p];
49
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
50
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
51
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
52
+ t[p[i]] = s[p[i]];
53
+ }
54
+ return t;
55
+ };
56
+ Object.defineProperty(exports, "__esModule", { value: true });
57
+ exports.BusinessProductsClient = void 0;
58
+ const BaseClient_js_1 = require("../../../../BaseClient.js");
59
+ const headers_js_1 = require("../../../../core/headers.js");
60
+ const core = __importStar(require("../../../../core/index.js"));
61
+ const environments = __importStar(require("../../../../environments.js"));
62
+ const handleNonStatusCodeError_js_1 = require("../../../../errors/handleNonStatusCodeError.js");
63
+ const errors = __importStar(require("../../../../errors/index.js"));
64
+ const FiveOneEat = __importStar(require("../../../index.js"));
65
+ class BusinessProductsClient {
66
+ constructor(options = {}) {
67
+ this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
68
+ }
69
+ /**
70
+ * @param {FiveOneEat.AdjustInventoryRequest} request
71
+ * @param {BusinessProductsClient.RequestOptions} requestOptions - Request-specific configuration.
72
+ *
73
+ * @throws {@link FiveOneEat.UnauthorizedError}
74
+ * @throws {@link FiveOneEat.ForbiddenError}
75
+ * @throws {@link FiveOneEat.NotFoundError}
76
+ * @throws {@link FiveOneEat.UnprocessableEntityError}
77
+ *
78
+ * @example
79
+ * await client.businessProducts.adjustVariantInventory({
80
+ * variant: "variant",
81
+ * type: "add",
82
+ * quantity: 1,
83
+ * reason: "restock"
84
+ * })
85
+ */
86
+ adjustVariantInventory(request, requestOptions) {
87
+ return core.HttpResponsePromise.fromPromise(this.__adjustVariantInventory(request, requestOptions));
88
+ }
89
+ __adjustVariantInventory(request, requestOptions) {
90
+ return __awaiter(this, void 0, void 0, function* () {
91
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
92
+ const { variant } = request, _body = __rest(request, ["variant"]);
93
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
94
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
95
+ const _response = yield core.fetcher({
96
+ url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.FiveOneEatEnvironment.Production, `business/products/variants/${core.url.encodePathParam(variant)}/inventory/adjust`),
97
+ method: "POST",
98
+ headers: _headers,
99
+ contentType: "application/json",
100
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
101
+ requestType: "json",
102
+ body: _body,
103
+ timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
104
+ maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
105
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
106
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
107
+ logging: this._options.logging,
108
+ });
109
+ if (_response.ok) {
110
+ return {
111
+ data: _response.body,
112
+ rawResponse: _response.rawResponse,
113
+ };
114
+ }
115
+ if (_response.error.reason === "status-code") {
116
+ switch (_response.error.statusCode) {
117
+ case 401:
118
+ throw new FiveOneEat.UnauthorizedError(_response.error.body, _response.rawResponse);
119
+ case 403:
120
+ throw new FiveOneEat.ForbiddenError(_response.error.body, _response.rawResponse);
121
+ case 404:
122
+ throw new FiveOneEat.NotFoundError(_response.error.body, _response.rawResponse);
123
+ case 422:
124
+ throw new FiveOneEat.UnprocessableEntityError(_response.error.body, _response.rawResponse);
125
+ default:
126
+ throw new errors.FiveOneEatError({
127
+ statusCode: _response.error.statusCode,
128
+ body: _response.error.body,
129
+ rawResponse: _response.rawResponse,
130
+ });
131
+ }
132
+ }
133
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/business/products/variants/{variant}/inventory/adjust");
134
+ });
135
+ }
136
+ /**
137
+ * @param {FiveOneEat.ListVariantInventoryHistoryRequest} request
138
+ * @param {BusinessProductsClient.RequestOptions} requestOptions - Request-specific configuration.
139
+ *
140
+ * @throws {@link FiveOneEat.UnauthorizedError}
141
+ * @throws {@link FiveOneEat.ForbiddenError}
142
+ * @throws {@link FiveOneEat.NotFoundError}
143
+ *
144
+ * @example
145
+ * await client.businessProducts.listVariantInventoryHistory({
146
+ * variant: "variant"
147
+ * })
148
+ */
149
+ listVariantInventoryHistory(request, requestOptions) {
150
+ return core.HttpResponsePromise.fromPromise(this.__listVariantInventoryHistory(request, requestOptions));
151
+ }
152
+ __listVariantInventoryHistory(request, requestOptions) {
153
+ return __awaiter(this, void 0, void 0, function* () {
154
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
155
+ const { variant, per_page: perPage } = request;
156
+ const _queryParams = {
157
+ per_page: perPage,
158
+ };
159
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
160
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
161
+ const _response = yield core.fetcher({
162
+ url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.FiveOneEatEnvironment.Production, `business/products/variants/${core.url.encodePathParam(variant)}/inventory/history`),
163
+ method: "GET",
164
+ headers: _headers,
165
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
166
+ queryString: core.url
167
+ .queryBuilder()
168
+ .addMany(_queryParams)
169
+ .mergeAdditional(requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams)
170
+ .build(),
171
+ timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
172
+ maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
173
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
174
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
175
+ logging: this._options.logging,
176
+ });
177
+ if (_response.ok) {
178
+ return {
179
+ data: _response.body,
180
+ rawResponse: _response.rawResponse,
181
+ };
182
+ }
183
+ if (_response.error.reason === "status-code") {
184
+ switch (_response.error.statusCode) {
185
+ case 401:
186
+ throw new FiveOneEat.UnauthorizedError(_response.error.body, _response.rawResponse);
187
+ case 403:
188
+ throw new FiveOneEat.ForbiddenError(_response.error.body, _response.rawResponse);
189
+ case 404:
190
+ throw new FiveOneEat.NotFoundError(_response.error.body, _response.rawResponse);
191
+ default:
192
+ throw new errors.FiveOneEatError({
193
+ statusCode: _response.error.statusCode,
194
+ body: _response.error.body,
195
+ rawResponse: _response.rawResponse,
196
+ });
197
+ }
198
+ }
199
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/business/products/variants/{variant}/inventory/history");
200
+ });
201
+ }
202
+ /**
203
+ * @param {FiveOneEat.GetProductInventorySummaryRequest} request
204
+ * @param {BusinessProductsClient.RequestOptions} requestOptions - Request-specific configuration.
205
+ *
206
+ * @throws {@link FiveOneEat.UnauthorizedError}
207
+ * @throws {@link FiveOneEat.ForbiddenError}
208
+ * @throws {@link FiveOneEat.NotFoundError}
209
+ *
210
+ * @example
211
+ * await client.businessProducts.getProductInventorySummary({
212
+ * product: "product"
213
+ * })
214
+ */
215
+ getProductInventorySummary(request, requestOptions) {
216
+ return core.HttpResponsePromise.fromPromise(this.__getProductInventorySummary(request, requestOptions));
217
+ }
218
+ __getProductInventorySummary(request, requestOptions) {
219
+ return __awaiter(this, void 0, void 0, function* () {
220
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
221
+ const { product } = request;
222
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
223
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
224
+ const _response = yield core.fetcher({
225
+ url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.FiveOneEatEnvironment.Production, `business/products/${core.url.encodePathParam(product)}/inventory`),
226
+ method: "GET",
227
+ headers: _headers,
228
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
229
+ timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
230
+ maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
231
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
232
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
233
+ logging: this._options.logging,
234
+ });
235
+ if (_response.ok) {
236
+ return {
237
+ data: _response.body,
238
+ rawResponse: _response.rawResponse,
239
+ };
240
+ }
241
+ if (_response.error.reason === "status-code") {
242
+ switch (_response.error.statusCode) {
243
+ case 401:
244
+ throw new FiveOneEat.UnauthorizedError(_response.error.body, _response.rawResponse);
245
+ case 403:
246
+ throw new FiveOneEat.ForbiddenError(_response.error.body, _response.rawResponse);
247
+ case 404:
248
+ throw new FiveOneEat.NotFoundError(_response.error.body, _response.rawResponse);
249
+ default:
250
+ throw new errors.FiveOneEatError({
251
+ statusCode: _response.error.statusCode,
252
+ body: _response.error.body,
253
+ rawResponse: _response.rawResponse,
254
+ });
255
+ }
256
+ }
257
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/business/products/{product}/inventory");
258
+ });
259
+ }
260
+ }
261
+ exports.BusinessProductsClient = BusinessProductsClient;
@@ -0,0 +1 @@
1
+ export * from "./requests/index.js";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./requests/index.js"), exports);
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * variant: "variant",
5
+ * type: "add",
6
+ * quantity: 1,
7
+ * reason: "restock"
8
+ * }
9
+ */
10
+ export interface AdjustInventoryRequest {
11
+ /** The variant ID */
12
+ variant: string;
13
+ type: AdjustInventoryRequest.Type;
14
+ quantity: number;
15
+ reason: AdjustInventoryRequest.Reason;
16
+ notes?: string | null;
17
+ }
18
+ export declare namespace AdjustInventoryRequest {
19
+ const Type: {
20
+ readonly Add: "add";
21
+ readonly Subtract: "subtract";
22
+ readonly Set: "set";
23
+ };
24
+ type Type = (typeof Type)[keyof typeof Type];
25
+ const Reason: {
26
+ readonly Restock: "restock";
27
+ readonly Damaged: "damaged";
28
+ readonly Shrinkage: "shrinkage";
29
+ readonly Returned: "returned";
30
+ readonly Correction: "correction";
31
+ readonly Other: "other";
32
+ };
33
+ type Reason = (typeof Reason)[keyof typeof Reason];
34
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.AdjustInventoryRequest = void 0;
5
+ var AdjustInventoryRequest;
6
+ (function (AdjustInventoryRequest) {
7
+ AdjustInventoryRequest.Type = {
8
+ Add: "add",
9
+ Subtract: "subtract",
10
+ Set: "set",
11
+ };
12
+ AdjustInventoryRequest.Reason = {
13
+ Restock: "restock",
14
+ Damaged: "damaged",
15
+ Shrinkage: "shrinkage",
16
+ Returned: "returned",
17
+ Correction: "correction",
18
+ Other: "other",
19
+ };
20
+ })(AdjustInventoryRequest || (exports.AdjustInventoryRequest = AdjustInventoryRequest = {}));
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * product: "product"
5
+ * }
6
+ */
7
+ export interface GetProductInventorySummaryRequest {
8
+ /** The product ID */
9
+ product: string;
10
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * variant: "variant"
5
+ * }
6
+ */
7
+ export interface ListVariantInventoryHistoryRequest {
8
+ /** The variant ID */
9
+ variant: string;
10
+ per_page?: number;
11
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ export { AdjustInventoryRequest } from "./AdjustInventoryRequest.js";
2
+ export type { GetProductInventorySummaryRequest } from "./GetProductInventorySummaryRequest.js";
3
+ export type { ListVariantInventoryHistoryRequest } from "./ListVariantInventoryHistoryRequest.js";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AdjustInventoryRequest = void 0;
4
+ var AdjustInventoryRequest_js_1 = require("./AdjustInventoryRequest.js");
5
+ Object.defineProperty(exports, "AdjustInventoryRequest", { enumerable: true, get: function () { return AdjustInventoryRequest_js_1.AdjustInventoryRequest; } });
@@ -0,0 +1,2 @@
1
+ export { BusinessProductsClient } from "./client/Client.js";
2
+ export * from "./client/index.js";
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.BusinessProductsClient = void 0;
19
+ var Client_js_1 = require("./client/Client.js");
20
+ Object.defineProperty(exports, "BusinessProductsClient", { enumerable: true, get: function () { return Client_js_1.BusinessProductsClient; } });
21
+ __exportStar(require("./client/index.js"), exports);
@@ -0,0 +1,2 @@
1
+ export * from "./client/index.js";
2
+ export * from "./types/index.js";