@gofynd/fdk-client-javascript 1.1.2 → 1.1.3

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 (117) hide show
  1. package/README.md +1 -2
  2. package/index.d.ts +4 -7
  3. package/index.js +5 -12
  4. package/package.json +1 -1
  5. package/sdk/application/ApplicationClient.d.ts +20 -20
  6. package/sdk/application/ApplicationClient.js +26 -26
  7. package/sdk/application/Cart/CartApplicationClient.d.ts +36 -6
  8. package/sdk/application/Cart/CartApplicationClient.js +105 -10
  9. package/sdk/application/Cart/CartApplicationModel.d.ts +9 -0
  10. package/sdk/application/Cart/CartApplicationModel.js +105 -1
  11. package/sdk/application/Cart/CartApplicationValidator.d.ts +1 -0
  12. package/sdk/application/Cart/CartApplicationValidator.js +15 -1
  13. package/sdk/application/Catalog/CatalogApplicationModel.d.ts +1 -0
  14. package/sdk/application/Catalog/CatalogApplicationModel.js +13 -0
  15. package/sdk/application/Configuration/ConfigurationApplicationClient.d.ts +14 -10
  16. package/sdk/application/Configuration/ConfigurationApplicationClient.js +16 -10
  17. package/sdk/application/Configuration/ConfigurationApplicationModel.js +1 -0
  18. package/sdk/application/Configuration/ConfigurationApplicationValidator.js +1 -0
  19. package/sdk/application/Content/ContentApplicationModel.js +3 -1
  20. package/sdk/application/Logistic/LogisticApplicationModel.js +3 -2
  21. package/sdk/application/Order/OrderApplicationClient.d.ts +2 -2
  22. package/sdk/application/Order/OrderApplicationClient.js +2 -2
  23. package/sdk/application/Order/OrderApplicationModel.js +18 -8
  24. package/sdk/application/Payment/PaymentApplicationClient.d.ts +35 -0
  25. package/sdk/application/Payment/PaymentApplicationClient.js +200 -0
  26. package/sdk/application/Payment/PaymentApplicationModel.d.ts +4 -0
  27. package/sdk/application/Payment/PaymentApplicationModel.js +58 -7
  28. package/sdk/application/Payment/PaymentApplicationValidator.d.ts +3 -0
  29. package/sdk/application/Payment/PaymentApplicationValidator.js +19 -0
  30. package/sdk/application/PosCart/PosCartApplicationClient.d.ts +16 -3
  31. package/sdk/application/PosCart/PosCartApplicationClient.js +39 -6
  32. package/sdk/application/PosCart/PosCartApplicationModel.d.ts +6 -0
  33. package/sdk/application/PosCart/PosCartApplicationModel.js +63 -1
  34. package/sdk/application/PosCart/PosCartApplicationValidator.js +6 -0
  35. package/sdk/application/index.d.ts +10 -10
  36. package/sdk/application/index.js +13 -13
  37. package/sdk/common/Constant.d.ts +5 -0
  38. package/sdk/common/Constant.js +5 -0
  39. package/sdk/platform/Billing/BillingPlatformModel.js +6 -1
  40. package/sdk/platform/Cart/CartPlatformApplicationClient.d.ts +459 -2
  41. package/sdk/platform/Cart/CartPlatformApplicationClient.js +2480 -340
  42. package/sdk/platform/Cart/CartPlatformApplicationValidator.d.ts +29 -0
  43. package/sdk/platform/Cart/CartPlatformApplicationValidator.js +250 -0
  44. package/sdk/platform/Cart/CartPlatformModel.d.ts +52 -0
  45. package/sdk/platform/Cart/CartPlatformModel.js +580 -2
  46. package/sdk/platform/Catalog/CatalogPlatformApplicationClient.d.ts +8 -2
  47. package/sdk/platform/Catalog/CatalogPlatformApplicationClient.js +10 -0
  48. package/sdk/platform/Catalog/CatalogPlatformApplicationValidator.js +1 -0
  49. package/sdk/platform/Catalog/CatalogPlatformClient.js +2 -2
  50. package/sdk/platform/Catalog/CatalogPlatformModel.d.ts +1 -0
  51. package/sdk/platform/Catalog/CatalogPlatformModel.js +41 -29
  52. package/sdk/platform/Communication/CommunicationPlatformModel.d.ts +1 -0
  53. package/sdk/platform/Communication/CommunicationPlatformModel.js +9 -0
  54. package/sdk/platform/CompanyProfile/CompanyProfilePlatformClient.d.ts +2 -2
  55. package/sdk/platform/CompanyProfile/CompanyProfilePlatformClient.js +2 -2
  56. package/sdk/platform/CompanyProfile/CompanyProfilePlatformModel.js +5 -4
  57. package/sdk/platform/Configuration/ConfigurationPlatformApplicationClient.d.ts +99 -78
  58. package/sdk/platform/Configuration/ConfigurationPlatformApplicationClient.js +99 -78
  59. package/sdk/platform/Configuration/ConfigurationPlatformClient.d.ts +87 -71
  60. package/sdk/platform/Configuration/ConfigurationPlatformClient.js +87 -71
  61. package/sdk/platform/Configuration/ConfigurationPlatformModel.d.ts +2 -0
  62. package/sdk/platform/Configuration/ConfigurationPlatformModel.js +26 -0
  63. package/sdk/platform/Content/ContentPlatformModel.js +3 -1
  64. package/sdk/platform/Finance/FinancePlatformClient.d.ts +135 -0
  65. package/sdk/platform/Finance/FinancePlatformClient.js +853 -0
  66. package/sdk/platform/Finance/FinancePlatformModel.d.ts +51 -0
  67. package/sdk/platform/Finance/FinancePlatformModel.js +342 -0
  68. package/sdk/platform/Finance/FinancePlatformValidator.d.ts +16 -0
  69. package/sdk/platform/Finance/FinancePlatformValidator.js +84 -0
  70. package/sdk/platform/Order/OrderPlatformApplicationClient.d.ts +11 -1
  71. package/sdk/platform/Order/OrderPlatformApplicationClient.js +66 -2
  72. package/sdk/platform/Order/OrderPlatformApplicationValidator.d.ts +1 -0
  73. package/sdk/platform/Order/OrderPlatformApplicationValidator.js +6 -0
  74. package/sdk/platform/Order/OrderPlatformClient.d.ts +159 -79
  75. package/sdk/platform/Order/OrderPlatformClient.js +541 -114
  76. package/sdk/platform/Order/OrderPlatformModel.d.ts +42 -6
  77. package/sdk/platform/Order/OrderPlatformModel.js +569 -159
  78. package/sdk/platform/Order/OrderPlatformValidator.d.ts +6 -0
  79. package/sdk/platform/Order/OrderPlatformValidator.js +51 -9
  80. package/sdk/platform/Partner/PartnerPlatformApplicationClient.d.ts +22 -0
  81. package/sdk/platform/Partner/PartnerPlatformApplicationClient.js +127 -0
  82. package/sdk/platform/Partner/PartnerPlatformApplicationValidator.d.ts +2 -0
  83. package/sdk/platform/Partner/PartnerPlatformApplicationValidator.js +13 -0
  84. package/sdk/platform/Partner/PartnerPlatformClient.d.ts +145 -0
  85. package/sdk/platform/Partner/PartnerPlatformClient.js +799 -0
  86. package/sdk/platform/Partner/PartnerPlatformModel.d.ts +39 -0
  87. package/sdk/platform/Partner/PartnerPlatformModel.js +367 -0
  88. package/sdk/platform/Partner/PartnerPlatformValidator.d.ts +14 -0
  89. package/sdk/platform/Partner/PartnerPlatformValidator.js +87 -0
  90. package/sdk/platform/Payment/PaymentPlatformApplicationClient.d.ts +221 -0
  91. package/sdk/platform/Payment/PaymentPlatformApplicationClient.js +1476 -190
  92. package/sdk/platform/Payment/PaymentPlatformApplicationValidator.d.ts +20 -0
  93. package/sdk/platform/Payment/PaymentPlatformApplicationValidator.js +126 -0
  94. package/sdk/platform/Payment/PaymentPlatformModel.d.ts +44 -0
  95. package/sdk/platform/Payment/PaymentPlatformModel.js +410 -0
  96. package/sdk/platform/PlatformApplicationClient.d.ts +1149 -938
  97. package/sdk/platform/PlatformApplicationClient.js +1259 -1035
  98. package/sdk/platform/PlatformClient.d.ts +9888 -8286
  99. package/sdk/platform/PlatformClient.js +10960 -9038
  100. package/sdk/platform/index.d.ts +15 -14
  101. package/sdk/platform/index.js +20 -18
  102. package/sdk/public/PublicClient.d.ts +2 -2
  103. package/sdk/public/PublicClient.js +4 -4
  104. package/sdk/public/index.d.ts +1 -1
  105. package/sdk/public/index.js +2 -2
  106. package/partner.d.ts +0 -4
  107. package/partner.js +0 -7
  108. package/sdk/partner/OAuthClient.d.ts +0 -14
  109. package/sdk/partner/OAuthClient.js +0 -112
  110. package/sdk/partner/PartnerAPIClient.d.ts +0 -12
  111. package/sdk/partner/PartnerAPIClient.js +0 -42
  112. package/sdk/partner/PartnerClient.d.ts +0 -6
  113. package/sdk/partner/PartnerClient.js +0 -17
  114. package/sdk/partner/PartnerConfig.d.ts +0 -30
  115. package/sdk/partner/PartnerConfig.js +0 -39
  116. package/sdk/partner/index.d.ts +0 -3
  117. package/sdk/partner/index.js +0 -5
@@ -1,25 +1,26 @@
1
1
  export const PlatformConfig: typeof import("./PlatformConfig");
2
2
  export const PlatformClient: typeof import("./PlatformClient");
3
3
  export namespace PlatformModel {
4
- const CommonPlatformModel: typeof import("./Common/CommonPlatformModel");
5
- const LeadPlatformModel: typeof import("./Lead/LeadPlatformModel");
6
- const ThemePlatformModel: typeof import("./Theme/ThemePlatformModel");
7
- const UserPlatformModel: typeof import("./User/UserPlatformModel");
8
- const ContentPlatformModel: typeof import("./Content/ContentPlatformModel");
4
+ const AuditTrailPlatformModel: typeof import("./AuditTrail/AuditTrailPlatformModel");
9
5
  const BillingPlatformModel: typeof import("./Billing/BillingPlatformModel");
10
- const CommunicationPlatformModel: typeof import("./Communication/CommunicationPlatformModel");
11
- const PaymentPlatformModel: typeof import("./Payment/PaymentPlatformModel");
12
- const OrderPlatformModel: typeof import("./Order/OrderPlatformModel");
6
+ const CartPlatformModel: typeof import("./Cart/CartPlatformModel");
13
7
  const CatalogPlatformModel: typeof import("./Catalog/CatalogPlatformModel");
8
+ const CommonPlatformModel: typeof import("./Common/CommonPlatformModel");
9
+ const CommunicationPlatformModel: typeof import("./Communication/CommunicationPlatformModel");
14
10
  const CompanyProfilePlatformModel: typeof import("./CompanyProfile/CompanyProfilePlatformModel");
15
- const FileStoragePlatformModel: typeof import("./FileStorage/FileStoragePlatformModel");
16
- const SharePlatformModel: typeof import("./Share/SharePlatformModel");
17
- const InventoryPlatformModel: typeof import("./Inventory/InventoryPlatformModel");
18
11
  const ConfigurationPlatformModel: typeof import("./Configuration/ConfigurationPlatformModel");
19
- const CartPlatformModel: typeof import("./Cart/CartPlatformModel");
20
- const RewardsPlatformModel: typeof import("./Rewards/RewardsPlatformModel");
12
+ const ContentPlatformModel: typeof import("./Content/ContentPlatformModel");
21
13
  const DiscountPlatformModel: typeof import("./Discount/DiscountPlatformModel");
14
+ const FileStoragePlatformModel: typeof import("./FileStorage/FileStoragePlatformModel");
15
+ const FinancePlatformModel: typeof import("./Finance/FinancePlatformModel");
16
+ const InventoryPlatformModel: typeof import("./Inventory/InventoryPlatformModel");
17
+ const LeadPlatformModel: typeof import("./Lead/LeadPlatformModel");
18
+ const OrderPlatformModel: typeof import("./Order/OrderPlatformModel");
22
19
  const PartnerPlatformModel: typeof import("./Partner/PartnerPlatformModel");
20
+ const PaymentPlatformModel: typeof import("./Payment/PaymentPlatformModel");
21
+ const RewardsPlatformModel: typeof import("./Rewards/RewardsPlatformModel");
22
+ const SharePlatformModel: typeof import("./Share/SharePlatformModel");
23
+ const ThemePlatformModel: typeof import("./Theme/ThemePlatformModel");
24
+ const UserPlatformModel: typeof import("./User/UserPlatformModel");
23
25
  const WebhookPlatformModel: typeof import("./Webhook/WebhookPlatformModel");
24
- const AuditTrailPlatformModel: typeof import("./AuditTrail/AuditTrailPlatformModel");
25
26
  }
@@ -2,46 +2,48 @@ module.exports = {
2
2
  PlatformConfig: require("./PlatformConfig"),
3
3
  PlatformClient: require("./PlatformClient"),
4
4
  PlatformModel: {
5
- CommonPlatformModel: require("./Common/CommonPlatformModel"),
6
-
7
- LeadPlatformModel: require("./Lead/LeadPlatformModel"),
5
+ AuditTrailPlatformModel: require("./AuditTrail/AuditTrailPlatformModel"),
8
6
 
9
- ThemePlatformModel: require("./Theme/ThemePlatformModel"),
7
+ BillingPlatformModel: require("./Billing/BillingPlatformModel"),
10
8
 
11
- UserPlatformModel: require("./User/UserPlatformModel"),
9
+ CartPlatformModel: require("./Cart/CartPlatformModel"),
12
10
 
13
- ContentPlatformModel: require("./Content/ContentPlatformModel"),
11
+ CatalogPlatformModel: require("./Catalog/CatalogPlatformModel"),
14
12
 
15
- BillingPlatformModel: require("./Billing/BillingPlatformModel"),
13
+ CommonPlatformModel: require("./Common/CommonPlatformModel"),
16
14
 
17
15
  CommunicationPlatformModel: require("./Communication/CommunicationPlatformModel"),
18
16
 
19
- PaymentPlatformModel: require("./Payment/PaymentPlatformModel"),
17
+ CompanyProfilePlatformModel: require("./CompanyProfile/CompanyProfilePlatformModel"),
20
18
 
21
- OrderPlatformModel: require("./Order/OrderPlatformModel"),
19
+ ConfigurationPlatformModel: require("./Configuration/ConfigurationPlatformModel"),
22
20
 
23
- CatalogPlatformModel: require("./Catalog/CatalogPlatformModel"),
21
+ ContentPlatformModel: require("./Content/ContentPlatformModel"),
24
22
 
25
- CompanyProfilePlatformModel: require("./CompanyProfile/CompanyProfilePlatformModel"),
23
+ DiscountPlatformModel: require("./Discount/DiscountPlatformModel"),
26
24
 
27
25
  FileStoragePlatformModel: require("./FileStorage/FileStoragePlatformModel"),
28
26
 
29
- SharePlatformModel: require("./Share/SharePlatformModel"),
27
+ FinancePlatformModel: require("./Finance/FinancePlatformModel"),
30
28
 
31
29
  InventoryPlatformModel: require("./Inventory/InventoryPlatformModel"),
32
30
 
33
- ConfigurationPlatformModel: require("./Configuration/ConfigurationPlatformModel"),
31
+ LeadPlatformModel: require("./Lead/LeadPlatformModel"),
34
32
 
35
- CartPlatformModel: require("./Cart/CartPlatformModel"),
33
+ OrderPlatformModel: require("./Order/OrderPlatformModel"),
34
+
35
+ PartnerPlatformModel: require("./Partner/PartnerPlatformModel"),
36
+
37
+ PaymentPlatformModel: require("./Payment/PaymentPlatformModel"),
36
38
 
37
39
  RewardsPlatformModel: require("./Rewards/RewardsPlatformModel"),
38
40
 
39
- DiscountPlatformModel: require("./Discount/DiscountPlatformModel"),
41
+ SharePlatformModel: require("./Share/SharePlatformModel"),
40
42
 
41
- PartnerPlatformModel: require("./Partner/PartnerPlatformModel"),
43
+ ThemePlatformModel: require("./Theme/ThemePlatformModel"),
42
44
 
43
- WebhookPlatformModel: require("./Webhook/WebhookPlatformModel"),
45
+ UserPlatformModel: require("./User/UserPlatformModel"),
44
46
 
45
- AuditTrailPlatformModel: require("./AuditTrail/AuditTrailPlatformModel"),
47
+ WebhookPlatformModel: require("./Webhook/WebhookPlatformModel"),
46
48
  },
47
49
  };
@@ -3,10 +3,10 @@ declare class PublicClient {
3
3
  constructor(config: any);
4
4
  config: any;
5
5
  configuration: Configuration;
6
- webhook: Webhook;
7
6
  inventory: Inventory;
7
+ webhook: Webhook;
8
8
  setExtraHeaders(header: any): void;
9
9
  }
10
10
  import Configuration = require("./Configuration/ConfigurationPublicClient");
11
- import Webhook = require("./Webhook/WebhookPublicClient");
12
11
  import Inventory = require("./Inventory/InventoryPublicClient");
12
+ import Webhook = require("./Webhook/WebhookPublicClient");
@@ -1,9 +1,9 @@
1
1
  const Configuration = require("./Configuration/ConfigurationPublicClient");
2
2
 
3
- const Webhook = require("./Webhook/WebhookPublicClient");
4
-
5
3
  const Inventory = require("./Inventory/InventoryPublicClient");
6
4
 
5
+ const Webhook = require("./Webhook/WebhookPublicClient");
6
+
7
7
  const { FDKClientValidationError } = require("../common/FDKError");
8
8
 
9
9
  class PublicClient {
@@ -12,9 +12,9 @@ class PublicClient {
12
12
 
13
13
  this.configuration = new Configuration(config);
14
14
 
15
- this.webhook = new Webhook(config);
16
-
17
15
  this.inventory = new Inventory(config);
16
+
17
+ this.webhook = new Webhook(config);
18
18
  }
19
19
 
20
20
  setExtraHeaders(header) {
@@ -2,6 +2,6 @@ export const PublicConfig: typeof import("./PublicConfig");
2
2
  export const PublicClient: typeof import("./PublicClient");
3
3
  export namespace PublicModel {
4
4
  const ConfigurationPublicModel: typeof import("./Configuration/ConfigurationPublicModel");
5
- const WebhookPublicModel: typeof import("./Webhook/WebhookPublicModel");
6
5
  const InventoryPublicModel: typeof import("./Inventory/InventoryPublicModel");
6
+ const WebhookPublicModel: typeof import("./Webhook/WebhookPublicModel");
7
7
  }
@@ -4,8 +4,8 @@ module.exports = {
4
4
  PublicModel: {
5
5
  ConfigurationPublicModel: require("./Configuration/ConfigurationPublicModel"),
6
6
 
7
- WebhookPublicModel: require("./Webhook/WebhookPublicModel"),
8
-
9
7
  InventoryPublicModel: require("./Inventory/InventoryPublicModel"),
8
+
9
+ WebhookPublicModel: require("./Webhook/WebhookPublicModel"),
10
10
  },
11
11
  };
package/partner.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import { PartnerConfig } from "./sdk/partner";
2
- import { PartnerClient } from "./sdk/partner";
3
- import { PartnerModel } from "./sdk/partner";
4
- export { PartnerConfig, PartnerClient, PartnerModel };
package/partner.js DELETED
@@ -1,7 +0,0 @@
1
- const {PartnerConfig, PartnerClient, PartnerModel } = require('./sdk/partner');
2
-
3
- module.exports = {
4
- PartnerConfig: PartnerConfig,
5
- PartnerClient: PartnerClient,
6
- PartnerModel: PartnerModel
7
- };
@@ -1,14 +0,0 @@
1
- export = OAuthClient;
2
- declare class OAuthClient extends BaseOAuthClient {
3
- startAuthorization(options: any): string;
4
- verifyCallback(query: any): Promise<void>;
5
- renewAccessToken(isOfflineToken?: boolean): Promise<any>;
6
- getNewAccessToken(): Promise<any>;
7
- getAccesstokenObj({ grant_type, client_id, client_secret, scope }: {
8
- grant_type: any;
9
- client_id: any;
10
- client_secret: any;
11
- scope: any;
12
- }): Promise<any>;
13
- }
14
- import BaseOAuthClient = require("../common/BaseOAuthClient");
@@ -1,112 +0,0 @@
1
- const { fdkAxios } = require("../common/AxiosHelper");
2
- const { FDKTokenIssueError } = require("../common/FDKError");
3
- const { Logger } = require("../common/Logger");
4
- const BaseOAuthClient = require("../common/BaseOAuthClient");
5
- const querystring = require("querystring");
6
- const { sign } = require("../common/RequestSigner");
7
-
8
- class OAuthClient extends BaseOAuthClient {
9
- constructor(config) {
10
- super(config);
11
- }
12
-
13
- startAuthorization(options) {
14
- Logger({ type: "DEBUG", message: "Starting Authorization" });
15
- let query = {
16
- client_id: this.config.apiKey,
17
- scope: options.scope.join(","),
18
- redirect_uri: options.redirectUri,
19
- state: options.state,
20
- access_mode: options.access_mode,
21
- response_type: "code",
22
- extension_id: this.config.extensionId,
23
- };
24
- const queryString = querystring.stringify(query);
25
-
26
- let reqPath = `/service/panel/authentication/v1.0/organization/${this.config.organizationId}/oauth/authorize?${queryString}`;
27
- let signingOptions = {
28
- method: "GET",
29
- host: new URL(this.config.domain).host,
30
- path: reqPath,
31
- body: null,
32
- headers: {},
33
- signQuery: true,
34
- };
35
- signingOptions = sign(signingOptions);
36
- Logger({ type: "DEBUG", message: "Authorization successful" });
37
-
38
- return `${this.config.domain}${signingOptions.path}`;
39
- }
40
-
41
- async verifyCallback(query) {
42
- if (query.error) {
43
- throw new FDKOAuthCodeError(query.error_description, {
44
- error: query.error,
45
- });
46
- }
47
-
48
- try {
49
- let res = await this.getAccesstokenObj({
50
- grant_type: "authorization_code",
51
- code: query.code,
52
- });
53
- res.expires_at =
54
- res.expires_at || new Date().getTime() + res.expires_in * 1000;
55
- this.setToken(res);
56
- } catch (error) {
57
- if (error.isAxiosError) {
58
- throw new FDKTokenIssueError(error.message);
59
- }
60
- throw error;
61
- }
62
- }
63
-
64
- async renewAccessToken(isOfflineToken = true) {
65
- if (isOfflineToken) {
66
- await this.getNewAccessToken();
67
- } else {
68
- res = await this.getAccesstokenObj({
69
- grant_type: "refresh_token",
70
- refresh_token: this.refreshToken,
71
- });
72
- res.expires_at =
73
- res.expires_at || new Date().getTime() + res.expires_in * 1000;
74
- this.setToken(res);
75
- return res;
76
- }
77
- }
78
-
79
- async getNewAccessToken() {
80
- try {
81
- let res = await this.getAccesstokenObj({
82
- grant_type: "client_credentials",
83
- client_id: this.config.apiKey,
84
- client_secret: this.config.apiSecret,
85
- scope: this.config.scope,
86
- });
87
- res.expires_at =
88
- res.expires_at || new Date().getTime() + res.expires_in * 1000;
89
- this.setToken(res);
90
- return this.token;
91
- } catch (error) {
92
- if (error.isAxiosError) {
93
- throw new FDKTokenIssueError(error.message);
94
- }
95
- throw error;
96
- }
97
- }
98
-
99
- async getAccesstokenObj({ grant_type, client_id, client_secret, scope }) {
100
- Logger({ type: "DEBUG", message: "Processing Access token object..." });
101
- let reqData = {
102
- grant_type: grant_type,
103
- client_id,
104
- client_secret,
105
- scope,
106
- };
107
- let url = `${this.config.domain}/service/panel/authentication/v1.0/organization/${this.config.organizationId}/oauth/token`;
108
- return fdkAxios.post(url, reqData);
109
- }
110
- }
111
-
112
- module.exports = OAuthClient;
@@ -1,12 +0,0 @@
1
- export = APIClient;
2
- declare class APIClient {
3
- /**
4
- * @param {object} conf
5
- * @param {string} method
6
- * @param {string} url
7
- * @param {object} query
8
- * @param {object} body
9
- */
10
- static execute(conf: object, method: string, url: string, query: object, body: object): Promise<any>;
11
- get(url: any, config: any): Promise<any>;
12
- }
@@ -1,42 +0,0 @@
1
- const { fdkAxios } = require("../common/AxiosHelper");
2
-
3
- class APIClient {
4
- /**
5
- * @param {object} conf
6
- * @param {string} method
7
- * @param {string} url
8
- * @param {object} query
9
- * @param {object} body
10
- */
11
- static async execute(conf, method, url, query, body) {
12
- const token = await conf.oauthClient.getNewAccessToken();
13
-
14
- const extraHeaders = conf.extraHeaders.reduce((acc, curr) => {
15
- acc = { ...acc, ...curr };
16
- return acc;
17
- }, {});
18
-
19
- const rawRequest = {
20
- baseURL: conf.domain,
21
- method: method,
22
- url: url,
23
- params: query,
24
- data: body,
25
- headers: {
26
- Authorization: "Bearer " + token,
27
- ...extraHeaders,
28
- },
29
- };
30
-
31
- return fdkAxios.request(rawRequest);
32
- }
33
-
34
- async get(url, config) {
35
- let access_token = await this.configuration.getAccessToken();
36
- config = config || {};
37
- config.headers = config.headers || {};
38
- config.headers.Authorization = "Bearer " + access_token;
39
- return axios.get(url);
40
- }
41
- }
42
- module.exports = APIClient;
@@ -1,6 +0,0 @@
1
- export = PartnerClient;
2
- declare class PartnerClient {
3
- constructor(config: any);
4
- config: any;
5
- setExtraHeaders(header: any): void;
6
- }
@@ -1,17 +0,0 @@
1
- const { FDKClientValidationError } = require("../common/FDKError");
2
-
3
- class PartnerClient {
4
- constructor(config) {
5
- this.config = config;
6
- }
7
-
8
- setExtraHeaders(header) {
9
- if (typeof header === "object") {
10
- this.config.extraHeaders.push(header);
11
- } else {
12
- throw new FDKClientValidationError("Context value should be an object");
13
- }
14
- }
15
- }
16
-
17
- module.exports = PartnerClient;
@@ -1,30 +0,0 @@
1
- export = PartnerConfig;
2
- declare class PartnerConfig {
3
- /**
4
- * @param {Object} config
5
- * @param {string} config.companyId
6
- * @param {string} config.domain
7
- * @param {string} config.apiKey
8
- * @param {string} config.apiSecret
9
- * @param {boolean} config.useAutoRenewTimer
10
- */
11
- constructor(config: {
12
- companyId: string;
13
- domain: string;
14
- apiKey: string;
15
- apiSecret: string;
16
- useAutoRenewTimer: boolean;
17
- });
18
- organizationId: any;
19
- domain: string;
20
- apiKey: string;
21
- apiSecret: string;
22
- scope: any;
23
- useAutoRenewTimer: boolean;
24
- oauthClient: OauthClient;
25
- logLevel: any;
26
- extraHeaders: any[];
27
- setLogLevel(level: any): void;
28
- getAccessToken(): Promise<any>;
29
- }
30
- import OauthClient = require("./OAuthClient");
@@ -1,39 +0,0 @@
1
- const OauthClient = require("./OAuthClient");
2
- const { setLoggerLevel } = require("../common/Logger");
3
-
4
- class PartnerConfig {
5
- /**
6
- * @param {Object} config
7
- * @param {string} config.companyId
8
- * @param {string} config.domain
9
- * @param {string} config.apiKey
10
- * @param {string} config.apiSecret
11
- * @param {boolean} config.useAutoRenewTimer
12
- */
13
- constructor(config) {
14
- this.organizationId = config.organizationId;
15
- this.domain = config.domain || "https://api.fynd.com";
16
- this.apiKey = config.apiKey;
17
- this.apiSecret = config.apiSecret;
18
- (this.scope = config.scope),
19
- (this.useAutoRenewTimer =
20
- config.useAutoRenewTimer !== undefined
21
- ? config.useAutoRenewTimer
22
- : true);
23
- this.oauthClient = new OauthClient(this);
24
- this.logLevel = config.logLevel || "ERROR";
25
- this.setLogLevel(this.logLevel);
26
- this.extraHeaders = [];
27
- }
28
-
29
- setLogLevel(level) {
30
- setLoggerLevel(level);
31
- }
32
-
33
- async getAccessToken() {
34
- let token = await this.oauthClient.getAccessToken();
35
- return token.access_token;
36
- }
37
- }
38
-
39
- module.exports = PartnerConfig;
@@ -1,3 +0,0 @@
1
- export const PartnerConfig: typeof import("./PartnerConfig");
2
- export const PartnerClient: typeof import("./PartnerClient");
3
- export const PartnerModel: {};
@@ -1,5 +0,0 @@
1
- module.exports = {
2
- PartnerConfig: require("./PartnerConfig"),
3
- PartnerClient: require("./PartnerClient"),
4
- PartnerModel: {},
5
- };