@gofynd/fdk-client-javascript 1.3.3 → 1.3.4-beta.1

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.
package/README.md CHANGED
@@ -214,7 +214,7 @@ console.log("Active Theme: ", response.information.name);
214
214
  The above code will log the curl command in the console
215
215
 
216
216
  ```bash
217
- curl --request GET "https://api.fynd.com/service/application/theme/v1.0/applied-theme" --header 'authorization: Bearer <authorization-token>' --header 'x-fp-sdk-version: 1.3.3' --header 'x-fp-date: 20230222T115108Z' --header 'x-fp-signature: v1.1:1e3ab3b02b5bc626e3c32a37ee844266ade02bbcbaafc28fc7a0e46a76a7a1a8'
217
+ curl --request GET "https://api.fynd.com/service/application/theme/v1.0/applied-theme" --header 'authorization: Bearer <authorization-token>' --header 'x-fp-sdk-version: 1.3.4-beta.1' --header 'x-fp-date: 20230222T115108Z' --header 'x-fp-signature: v1.1:1e3ab3b02b5bc626e3c32a37ee844266ade02bbcbaafc28fc7a0e46a76a7a1a8'
218
218
  Active Theme: Emerge
219
219
  ```
220
220
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gofynd/fdk-client-javascript",
3
- "version": "1.3.3",
3
+ "version": "1.3.4-beta.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -136,6 +136,11 @@ fdkAxios.interceptors.response.use(
136
136
  level: "ERROR",
137
137
  message: error.response.data || error.message,
138
138
  stack: error.response.data.stack || error.stack,
139
+ request: {
140
+ method: error.config.method,
141
+ url: error.config.url,
142
+ headers: error.config.headers,
143
+ },
139
144
  });
140
145
  throw new FDKServerResponseError(
141
146
  error.response.data.message || error.message,
@@ -150,6 +155,11 @@ fdkAxios.interceptors.response.use(
150
155
  level: "ERROR",
151
156
  message: error.data || error.message,
152
157
  stack: error.data.stack || error.stack,
158
+ request: {
159
+ method: error.config.method,
160
+ url: error.config.url,
161
+ headers: error.config.headers,
162
+ },
153
163
  });
154
164
  throw new FDKServerResponseError(
155
165
  error.message,
@@ -29,11 +29,9 @@ class PartnerConfig {
29
29
  this.domain = config.domain || "https://api.fynd.com";
30
30
  this.apiKey = config.apiKey;
31
31
  this.apiSecret = config.apiSecret;
32
- (this.scope = config.scope),
33
- (this.useAutoRenewTimer =
34
- config.useAutoRenewTimer !== undefined
35
- ? config.useAutoRenewTimer
36
- : true);
32
+ this.scope = config.scope;
33
+ this.useAutoRenewTimer =
34
+ config.useAutoRenewTimer !== undefined ? config.useAutoRenewTimer : true;
37
35
  this.oauthClient = new OauthClient(this);
38
36
  this.logLevel = config.logLevel || "ERROR";
39
37
  this.setLogLevel(this.logLevel);
@@ -181,6 +181,18 @@ declare class User {
181
181
  * @description: Use this API to update an existing user Group - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/platform/user/updateUserGroup/).
182
182
  */
183
183
  updateUserGroup({ groupId, body, requestHeaders }?: UserPlatformApplicationValidator.UpdateUserGroupParam, { responseHeaders }?: object): Promise<UserPlatformModel.UserGroupResponseSchema>;
184
+ /**
185
+ * @param {UserPlatformApplicationValidator.UpdateUserGroupPartiallyParam} arg
186
+ * - Arg object
187
+ *
188
+ * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
189
+ * @param {import("../PlatformAPIClient").Options} - Options
190
+ * @returns {Promise<UserPlatformModel.UserGroupResponseSchema>} - Success response
191
+ * @name updateUserGroupPartially
192
+ * @summary: Add or Remove an user from particular user group and update user group details
193
+ * @description: Use this API to update user group details and add or remove an user to the user group. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/platform/user/updateUserGroupPartially/).
194
+ */
195
+ updateUserGroupPartially({ groupId, body, requestHeaders }?: UserPlatformApplicationValidator.UpdateUserGroupPartiallyParam, { responseHeaders }?: object): Promise<UserPlatformModel.UserGroupResponseSchema>;
184
196
  }
185
197
  import UserPlatformApplicationValidator = require("./UserPlatformApplicationValidator");
186
198
  import UserPlatformModel = require("./UserPlatformModel");
@@ -1316,6 +1316,85 @@ class User {
1316
1316
 
1317
1317
  return response;
1318
1318
  }
1319
+
1320
+ /**
1321
+ * @param {UserPlatformApplicationValidator.UpdateUserGroupPartiallyParam} arg
1322
+ * - Arg object
1323
+ *
1324
+ * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
1325
+ * @param {import("../PlatformAPIClient").Options} - Options
1326
+ * @returns {Promise<UserPlatformModel.UserGroupResponseSchema>} - Success response
1327
+ * @name updateUserGroupPartially
1328
+ * @summary: Add or Remove an user from particular user group and update user group details
1329
+ * @description: Use this API to update user group details and add or remove an user to the user group. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/platform/user/updateUserGroupPartially/).
1330
+ */
1331
+ async updateUserGroupPartially(
1332
+ { groupId, body, requestHeaders } = { requestHeaders: {} },
1333
+ { responseHeaders } = { responseHeaders: false }
1334
+ ) {
1335
+ const {
1336
+ error,
1337
+ } = UserPlatformApplicationValidator.updateUserGroupPartially().validate(
1338
+ {
1339
+ groupId,
1340
+ body,
1341
+ },
1342
+ { abortEarly: false, allowUnknown: true }
1343
+ );
1344
+ if (error) {
1345
+ return Promise.reject(new FDKClientValidationError(error));
1346
+ }
1347
+
1348
+ // Showing warrnings if extra unknown parameters are found
1349
+ const {
1350
+ error: warrning,
1351
+ } = UserPlatformApplicationValidator.updateUserGroupPartially().validate(
1352
+ {
1353
+ groupId,
1354
+ body,
1355
+ },
1356
+ { abortEarly: false, allowUnknown: false }
1357
+ );
1358
+ if (warrning) {
1359
+ Logger({
1360
+ level: "WARN",
1361
+ message: `Parameter Validation warrnings for platform > User > updateUserGroupPartially \n ${warrning}`,
1362
+ });
1363
+ }
1364
+
1365
+ const query_params = {};
1366
+
1367
+ const response = await PlatformAPIClient.execute(
1368
+ this.config,
1369
+ "patch",
1370
+ `/service/platform/user/v1.0/company/${this.config.companyId}/application/${this.applicationId}/user_group/${groupId}`,
1371
+ query_params,
1372
+ body,
1373
+ requestHeaders,
1374
+ { responseHeaders }
1375
+ );
1376
+
1377
+ let responseData = response;
1378
+ if (responseHeaders) {
1379
+ responseData = response[0];
1380
+ }
1381
+
1382
+ const {
1383
+ error: res_error,
1384
+ } = UserPlatformModel.UserGroupResponseSchema().validate(responseData, {
1385
+ abortEarly: false,
1386
+ allowUnknown: false,
1387
+ });
1388
+
1389
+ if (res_error) {
1390
+ Logger({
1391
+ level: "WARN",
1392
+ message: `Response Validation Warnnings for platform > User > updateUserGroupPartially \n ${res_error}`,
1393
+ });
1394
+ }
1395
+
1396
+ return response;
1397
+ }
1319
1398
  }
1320
1399
 
1321
1400
  module.exports = User;
@@ -80,6 +80,11 @@ export = UserPlatformApplicationValidator;
80
80
  * @property {string} groupId - Numeric ID allotted to a User Group
81
81
  * @property {UserPlatformModel.UpdateUserGroupSchema} body
82
82
  */
83
+ /**
84
+ * @typedef UpdateUserGroupPartiallyParam
85
+ * @property {string} groupId - Numeric ID allotted to a User Group
86
+ * @property {UserPlatformModel.PartialUserGroupUpdateSchema} body
87
+ */
83
88
  declare class UserPlatformApplicationValidator {
84
89
  /** @returns {ArchiveUserParam} */
85
90
  static archiveUser(): ArchiveUserParam;
@@ -115,9 +120,11 @@ declare class UserPlatformApplicationValidator {
115
120
  static updateUser(): UpdateUserParam;
116
121
  /** @returns {UpdateUserGroupParam} */
117
122
  static updateUserGroup(): UpdateUserGroupParam;
123
+ /** @returns {UpdateUserGroupPartiallyParam} */
124
+ static updateUserGroupPartially(): UpdateUserGroupPartiallyParam;
118
125
  }
119
126
  declare namespace UserPlatformApplicationValidator {
120
- export { ArchiveUserParam, BlockOrUnblockUsersParam, CreateUserParam, CreateUserGroupParam, CreateUserSessionParam, DeleteActiveSessionsParam, DeleteSessionParam, GetActiveSessionsParam, GetCustomersParam, GetPlatformConfigParam, GetUserGroupByIdParam, GetUserGroupsParam, SearchUsersParam, UnDeleteUserParam, UpdatePlatformConfigParam, UpdateUserParam, UpdateUserGroupParam };
127
+ export { ArchiveUserParam, BlockOrUnblockUsersParam, CreateUserParam, CreateUserGroupParam, CreateUserSessionParam, DeleteActiveSessionsParam, DeleteSessionParam, GetActiveSessionsParam, GetCustomersParam, GetPlatformConfigParam, GetUserGroupByIdParam, GetUserGroupsParam, SearchUsersParam, UnDeleteUserParam, UpdatePlatformConfigParam, UpdateUserParam, UpdateUserGroupParam, UpdateUserGroupPartiallyParam };
121
128
  }
122
129
  type ArchiveUserParam = {
123
130
  body: UserPlatformModel.ArchiveUserRequestSchema;
@@ -240,5 +247,12 @@ type UpdateUserGroupParam = {
240
247
  groupId: string;
241
248
  body: UserPlatformModel.UpdateUserGroupSchema;
242
249
  };
250
+ type UpdateUserGroupPartiallyParam = {
251
+ /**
252
+ * - Numeric ID allotted to a User Group
253
+ */
254
+ groupId: string;
255
+ body: UserPlatformModel.PartialUserGroupUpdateSchema;
256
+ };
243
257
  type GetPlatformConfigParam = any;
244
258
  import UserPlatformModel = require("./UserPlatformModel");
@@ -100,6 +100,12 @@ const UserPlatformModel = require("./UserPlatformModel");
100
100
  * @property {UserPlatformModel.UpdateUserGroupSchema} body
101
101
  */
102
102
 
103
+ /**
104
+ * @typedef UpdateUserGroupPartiallyParam
105
+ * @property {string} groupId - Numeric ID allotted to a User Group
106
+ * @property {UserPlatformModel.PartialUserGroupUpdateSchema} body
107
+ */
108
+
103
109
  class UserPlatformApplicationValidator {
104
110
  /** @returns {ArchiveUserParam} */
105
111
  static archiveUser() {
@@ -229,6 +235,14 @@ class UserPlatformApplicationValidator {
229
235
  body: UserPlatformModel.UpdateUserGroupSchema().required(),
230
236
  }).required();
231
237
  }
238
+
239
+ /** @returns {UpdateUserGroupPartiallyParam} */
240
+ static updateUserGroupPartially() {
241
+ return Joi.object({
242
+ groupId: Joi.string().allow("").required(),
243
+ body: UserPlatformModel.PartialUserGroupUpdateSchema().required(),
244
+ }).required();
245
+ }
232
246
  }
233
247
 
234
248
  module.exports = UserPlatformApplicationValidator;
@@ -117,6 +117,20 @@ export = UserPlatformModel;
117
117
  * @property {number} [size]
118
118
  * @property {string} [type]
119
119
  */
120
+ /**
121
+ * @typedef PartialUserGroupUpdateSchema
122
+ * @property {string} [description]
123
+ * @property {string} [file_url] - Required property when passed type file_url.
124
+ * Internet reachable csv file url which will be used to fetch download data.
125
+ * It must have one of columns from `phone_number``, `email`, `user_id` and
126
+ * must have `action` column. `action` column can have `add` or `remove` value.
127
+ * @property {string} [name]
128
+ * @property {string} [type] - Source of update to be used to update individual
129
+ * users. Default value is considered file_url if not passed.
130
+ * @property {UserGroupUpdateData[]} [user_data] - Required property when passed
131
+ * type json. Array of user data. Must have `action` field and one of
132
+ * `phone_number`, `email` or `user_id` field in object
133
+ */
120
134
  /**
121
135
  * @typedef PhoneNumber
122
136
  * @property {boolean} [active]
@@ -269,6 +283,13 @@ export = UserPlatformModel;
269
283
  * @property {string} [status]
270
284
  * @property {number} [uid]
271
285
  */
286
+ /**
287
+ * @typedef UserGroupUpdateData
288
+ * @property {string} action
289
+ * @property {string} [email] - Email of registered user
290
+ * @property {string} [phone_number] - Phone number of registered user
291
+ * @property {string} [user_id] - Must be valid mongodb objectid of existing user
292
+ */
272
293
  /**
273
294
  * @typedef UserPhoneNumbers
274
295
  * @property {boolean} [active]
@@ -303,7 +324,7 @@ export = UserPlatformModel;
303
324
  declare class UserPlatformModel {
304
325
  }
305
326
  declare namespace UserPlatformModel {
306
- export { Accountkit, ArchiveUserRequestSchema, ArchiveUserSuccess, AuthenticationApiErrorSchema, BlockUserRequestSchema, BlockUserSuccess, CreateUserGroupSchema, CreateUserRequestSchema, CreateUserResponseSchema, CreateUserSessionRequestSchema, CreateUserSessionResponseSchema, CustomerListResponseSchema, DeleteAccountConsent, DeleteAccountReasons, Email, Facebook, FlashCard, Google, Login, LookAndFeel, MetaSchema, PaginationSchema, PhoneNumber, PlatformEmail, PlatformMobile, PlatformSchema, RegisterRequiredFields, RegisterRequiredFieldsEmail, RegisterRequiredFieldsMobile, RequiredFields, SessionDeleteResponseSchema, SessionExpiry, SessionListResponseInfo, SessionListResponseSchema, Social, SocialTokens, UnDeleteUserRequestSchema, UnDeleteUserSuccess, UpdateUserGroupSchema, UpdateUserRequestSchema, UserEmails, UserGroupListResponseSchema, UserGroupResponseSchema, UserPhoneNumbers, UserSchema, UserSearchResponseSchema };
327
+ export { Accountkit, ArchiveUserRequestSchema, ArchiveUserSuccess, AuthenticationApiErrorSchema, BlockUserRequestSchema, BlockUserSuccess, CreateUserGroupSchema, CreateUserRequestSchema, CreateUserResponseSchema, CreateUserSessionRequestSchema, CreateUserSessionResponseSchema, CustomerListResponseSchema, DeleteAccountConsent, DeleteAccountReasons, Email, Facebook, FlashCard, Google, Login, LookAndFeel, MetaSchema, PaginationSchema, PartialUserGroupUpdateSchema, PhoneNumber, PlatformEmail, PlatformMobile, PlatformSchema, RegisterRequiredFields, RegisterRequiredFieldsEmail, RegisterRequiredFieldsMobile, RequiredFields, SessionDeleteResponseSchema, SessionExpiry, SessionListResponseInfo, SessionListResponseSchema, Social, SocialTokens, UnDeleteUserRequestSchema, UnDeleteUserSuccess, UpdateUserGroupSchema, UpdateUserRequestSchema, UserEmails, UserGroupListResponseSchema, UserGroupResponseSchema, UserGroupUpdateData, UserPhoneNumbers, UserSchema, UserSearchResponseSchema };
307
328
  }
308
329
  /** @returns {Accountkit} */
309
330
  declare function Accountkit(): Accountkit;
@@ -445,6 +466,30 @@ type PaginationSchema = {
445
466
  size?: number;
446
467
  type?: string;
447
468
  };
469
+ /** @returns {PartialUserGroupUpdateSchema} */
470
+ declare function PartialUserGroupUpdateSchema(): PartialUserGroupUpdateSchema;
471
+ type PartialUserGroupUpdateSchema = {
472
+ description?: string;
473
+ /**
474
+ * - Required property when passed type file_url.
475
+ * Internet reachable csv file url which will be used to fetch download data.
476
+ * It must have one of columns from `phone_number``, `email`, `user_id` and
477
+ * must have `action` column. `action` column can have `add` or `remove` value.
478
+ */
479
+ file_url?: string;
480
+ name?: string;
481
+ /**
482
+ * - Source of update to be used to update individual
483
+ * users. Default value is considered file_url if not passed.
484
+ */
485
+ type?: string;
486
+ /**
487
+ * - Required property when passed
488
+ * type json. Array of user data. Must have `action` field and one of
489
+ * `phone_number`, `email` or `user_id` field in object
490
+ */
491
+ user_data?: UserGroupUpdateData[];
492
+ };
448
493
  /** @returns {PhoneNumber} */
449
494
  declare function PhoneNumber(): PhoneNumber;
450
495
  type PhoneNumber = {
@@ -618,6 +663,23 @@ type UserGroupResponseSchema = {
618
663
  status?: string;
619
664
  uid?: number;
620
665
  };
666
+ /** @returns {UserGroupUpdateData} */
667
+ declare function UserGroupUpdateData(): UserGroupUpdateData;
668
+ type UserGroupUpdateData = {
669
+ action: string;
670
+ /**
671
+ * - Email of registered user
672
+ */
673
+ email?: string;
674
+ /**
675
+ * - Phone number of registered user
676
+ */
677
+ phone_number?: string;
678
+ /**
679
+ * - Must be valid mongodb objectid of existing user
680
+ */
681
+ user_id?: string;
682
+ };
621
683
  /** @returns {UserPhoneNumbers} */
622
684
  declare function UserPhoneNumbers(): UserPhoneNumbers;
623
685
  type UserPhoneNumbers = {
@@ -140,6 +140,21 @@ const Joi = require("joi");
140
140
  * @property {string} [type]
141
141
  */
142
142
 
143
+ /**
144
+ * @typedef PartialUserGroupUpdateSchema
145
+ * @property {string} [description]
146
+ * @property {string} [file_url] - Required property when passed type file_url.
147
+ * Internet reachable csv file url which will be used to fetch download data.
148
+ * It must have one of columns from `phone_number``, `email`, `user_id` and
149
+ * must have `action` column. `action` column can have `add` or `remove` value.
150
+ * @property {string} [name]
151
+ * @property {string} [type] - Source of update to be used to update individual
152
+ * users. Default value is considered file_url if not passed.
153
+ * @property {UserGroupUpdateData[]} [user_data] - Required property when passed
154
+ * type json. Array of user data. Must have `action` field and one of
155
+ * `phone_number`, `email` or `user_id` field in object
156
+ */
157
+
143
158
  /**
144
159
  * @typedef PhoneNumber
145
160
  * @property {boolean} [active]
@@ -313,6 +328,14 @@ const Joi = require("joi");
313
328
  * @property {number} [uid]
314
329
  */
315
330
 
331
+ /**
332
+ * @typedef UserGroupUpdateData
333
+ * @property {string} action
334
+ * @property {string} [email] - Email of registered user
335
+ * @property {string} [phone_number] - Phone number of registered user
336
+ * @property {string} [user_id] - Must be valid mongodb objectid of existing user
337
+ */
338
+
316
339
  /**
317
340
  * @typedef UserPhoneNumbers
318
341
  * @property {boolean} [active]
@@ -532,6 +555,17 @@ class UserPlatformModel {
532
555
  });
533
556
  }
534
557
 
558
+ /** @returns {PartialUserGroupUpdateSchema} */
559
+ static PartialUserGroupUpdateSchema() {
560
+ return Joi.object({
561
+ description: Joi.string().allow(""),
562
+ file_url: Joi.string().allow(""),
563
+ name: Joi.string().allow(""),
564
+ type: Joi.string().allow(""),
565
+ user_data: Joi.array().items(UserPlatformModel.UserGroupUpdateData()),
566
+ });
567
+ }
568
+
535
569
  /** @returns {PhoneNumber} */
536
570
  static PhoneNumber() {
537
571
  return Joi.object({
@@ -749,6 +783,16 @@ class UserPlatformModel {
749
783
  });
750
784
  }
751
785
 
786
+ /** @returns {UserGroupUpdateData} */
787
+ static UserGroupUpdateData() {
788
+ return Joi.object({
789
+ action: Joi.string().allow("").required(),
790
+ email: Joi.string().allow(""),
791
+ phone_number: Joi.string().allow(""),
792
+ user_id: Joi.string().allow(""),
793
+ });
794
+ }
795
+
752
796
  /** @returns {UserPhoneNumbers} */
753
797
  static UserPhoneNumbers() {
754
798
  return Joi.object({