@vertikalx/vtx-backend-client 1.0.0-dev.8 → 1.0.0-dev.80

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 (73) hide show
  1. package/LICENSE.md +11 -11
  2. package/package.json +16 -16
  3. package/src/api/api-call-headers.d.ts +3 -3
  4. package/src/api/api-call-headers.js +3 -3
  5. package/src/api/api-call-headers.js.map +1 -1
  6. package/src/api/backend-response.d.ts +7 -1
  7. package/src/api/backend-response.js +0 -0
  8. package/src/api/backend-response.js.map +0 -0
  9. package/src/api/domains.d.ts +3 -0
  10. package/src/api/domains.js +7 -0
  11. package/src/api/domains.js.map +1 -0
  12. package/src/api/response-builder.d.ts +4 -0
  13. package/src/api/response-builder.js +123 -0
  14. package/src/api/response-builder.js.map +1 -0
  15. package/src/api/types.d.ts +2 -0
  16. package/src/api/types.js +3 -0
  17. package/src/api/types.js.map +1 -0
  18. package/src/api/vtx-apikey-api.d.ts +0 -0
  19. package/src/api/vtx-apikey-api.js +0 -0
  20. package/src/api/vtx-apikey-api.js.map +0 -0
  21. package/src/api/vtx-base-api.d.ts +57 -4
  22. package/src/api/vtx-base-api.js +4474 -115
  23. package/src/api/vtx-base-api.js.map +1 -1
  24. package/src/api/vtx-mobile-api.d.ts +0 -0
  25. package/src/api/vtx-mobile-api.js +0 -0
  26. package/src/api/vtx-mobile-api.js.map +0 -0
  27. package/src/api/vtx-web-browser-api.d.ts +0 -0
  28. package/src/api/vtx-web-browser-api.js +2 -2
  29. package/src/api/vtx-web-browser-api.js.map +1 -1
  30. package/src/api/vtx-web-server-api.d.ts +0 -0
  31. package/src/api/vtx-web-server-api.js +0 -0
  32. package/src/api/vtx-web-server-api.js.map +0 -0
  33. package/src/client/index.d.ts +0 -0
  34. package/src/client/index.js +0 -0
  35. package/src/client/index.js.map +0 -0
  36. package/src/client/runtime/batcher.d.ts +0 -0
  37. package/src/client/runtime/batcher.js +0 -0
  38. package/src/client/runtime/batcher.js.map +0 -0
  39. package/src/client/runtime/createClient.d.ts +4 -10
  40. package/src/client/runtime/createClient.js +0 -0
  41. package/src/client/runtime/createClient.js.map +0 -0
  42. package/src/client/runtime/error.d.ts +0 -0
  43. package/src/client/runtime/error.js +0 -0
  44. package/src/client/runtime/error.js.map +0 -0
  45. package/src/client/runtime/fetcher.d.ts +0 -0
  46. package/src/client/runtime/fetcher.js +0 -0
  47. package/src/client/runtime/fetcher.js.map +0 -0
  48. package/src/client/runtime/generateGraphqlOperation.d.ts +1 -1
  49. package/src/client/runtime/generateGraphqlOperation.js +0 -0
  50. package/src/client/runtime/generateGraphqlOperation.js.map +0 -0
  51. package/src/client/runtime/index.d.ts +0 -0
  52. package/src/client/runtime/index.js +0 -0
  53. package/src/client/runtime/index.js.map +0 -0
  54. package/src/client/runtime/linkTypeMap.d.ts +0 -0
  55. package/src/client/runtime/linkTypeMap.js +0 -0
  56. package/src/client/runtime/linkTypeMap.js.map +0 -0
  57. package/src/client/runtime/typeSelection.d.ts +0 -0
  58. package/src/client/runtime/typeSelection.js +0 -0
  59. package/src/client/runtime/typeSelection.js.map +0 -0
  60. package/src/client/runtime/types.d.ts +0 -0
  61. package/src/client/runtime/types.js +0 -0
  62. package/src/client/runtime/types.js.map +0 -0
  63. package/src/client/schema.d.ts +2658 -163
  64. package/src/client/schema.graphql +1330 -61
  65. package/src/client/schema.js +577 -44
  66. package/src/client/schema.js.map +1 -1
  67. package/src/client/types.d.ts +1470 -93
  68. package/src/client/types.js +3844 -251
  69. package/src/client/types.js.map +1 -1
  70. package/src/index.d.ts +3 -0
  71. package/src/index.js +3 -0
  72. package/src/index.js.map +1 -1
  73. package/tsconfig.lib.tsbuildinfo +1 -1
@@ -4,11 +4,17 @@ exports.VTXBaseAPI = void 0;
4
4
  const package_json_1 = require("../../package.json");
5
5
  const client_1 = require("../client");
6
6
  const api_call_headers_1 = require("./api-call-headers");
7
+ const response_builder_1 = require("./response-builder");
8
+ const domains_1 = require("./domains");
9
+ const vtx_core_common_1 = require("@vertikalx/vtx-core-common");
7
10
  class VTXBaseAPI {
8
11
  constructor(headers, backendUrl) {
9
12
  this.headers = headers ?? api_call_headers_1.DEFAULT_HEADERS;
10
13
  this.backendUrl = backendUrl ?? VTXBaseAPI.getDefaultBackendUrl();
11
14
  }
15
+ setHeader(key, value) {
16
+ this.headers[key] = value;
17
+ }
12
18
  static getDefaultBackendUrl() {
13
19
  let retValue = api_call_headers_1.DEFAULT_PROD_URL;
14
20
  switch (process.env?.NODE_ENV) {
@@ -46,7 +52,7 @@ class VTXBaseAPI {
46
52
  }
47
53
  return false;
48
54
  }
49
- async findNonTenantedUserByEmail(email) {
55
+ async findUserByEmail(email) {
50
56
  const client = (0, client_1.createClient)({
51
57
  url: this.backendUrl + '/graphql',
52
58
  headers: this.headers,
@@ -55,61 +61,35 @@ class VTXBaseAPI {
55
61
  let retValue = {};
56
62
  try {
57
63
  const response = await client.query({
58
- nontenantedUserByEmail: {
64
+ findUserByEmail: {
59
65
  __args: {
60
66
  email: curatedEmail,
61
67
  },
62
68
  _id: true,
63
69
  loginEmail: true,
64
70
  suspended: true,
71
+ domains: {
72
+ _id: true,
73
+ name: true,
74
+ description: true
75
+ }
65
76
  },
66
77
  });
67
- console.log(JSON.stringify(response, null, 2));
68
- if (response?.nontenantedUserByEmail?._id) {
69
- try {
70
- retValue.data = response.nontenantedUserByEmail;
71
- }
72
- catch (casterr) {
73
- console.log('Error trying to cast to User');
74
- retValue.errors = ['Error: Obtained incorrect data from Backend'];
75
- }
76
- }
77
- else if (response?.errors) {
78
- if (Array.isArray(response.errors)) {
79
- retValue.errors = response.errors;
80
- }
81
- else {
82
- retValue.errors = [response.errors];
83
- }
84
- }
85
- else if (response?.error) {
86
- if (Array.isArray(response.error)) {
87
- retValue.errors = response.error;
88
- }
89
- else {
90
- retValue.errors = [response.error];
91
- }
92
- }
93
- else {
94
- retValue.errors = ['Error: Obtained incorrect data from Backend'];
95
- }
78
+ VTXBaseAPI.Logger.debug('findUserByEmail Response:');
79
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
80
+ retValue = (0, response_builder_1.buildResponse)(response, 'findUserByEmail', (r) => {
81
+ const isResponseOk = true && response?.findUserByEmail?._id;
82
+ return isResponseOk;
83
+ });
96
84
  }
97
85
  catch (err1) {
98
- try {
99
- console.log('ERROR trying to call server');
100
- console.log(JSON.stringify(err1, null, 2));
101
- }
102
- catch (ex) { }
103
- if (Array.isArray(err1)) {
104
- retValue.errors = err1;
105
- }
106
- else {
107
- retValue.errors = [err1];
108
- }
86
+ VTXBaseAPI.Logger.error('findUserByEmail err1:');
87
+ VTXBaseAPI.Logger.error(err1);
88
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
109
89
  }
110
90
  return retValue;
111
91
  }
112
- async createBackendToken_NT(loginEmail) {
92
+ async loginUserFromEmail(loginEmail, loginMethod = "") {
113
93
  const client = (0, client_1.createClient)({
114
94
  url: this.backendUrl + '/graphql',
115
95
  headers: this.headers,
@@ -118,57 +98,30 @@ class VTXBaseAPI {
118
98
  let retValue = {};
119
99
  try {
120
100
  const response = await client.mutation({
121
- createNonTenantUserTokenFromEmail: {
101
+ loginUserFromEmail: {
122
102
  __args: {
123
103
  email: curatedEmail,
104
+ loginMethod: loginMethod
124
105
  },
125
106
  actualToken: true,
126
107
  refreshToken: true,
127
108
  },
128
109
  });
129
- console.log(JSON.stringify(response, null, 2));
130
- if (response?.createNonTenantUserTokenFromEmail?.actualToken) {
131
- try {
132
- retValue.data =
133
- response.createNonTenantUserTokenFromEmail;
134
- }
135
- catch (casterr) {
136
- console.log('Error trying to cast to UserToken:');
137
- retValue.errors = ['Error: Obtained incorrect data from Backend'];
138
- }
139
- }
140
- else if (response?.errors) {
141
- if (Array.isArray(response.errors)) {
142
- retValue.errors = response.errors;
143
- }
144
- else {
145
- retValue.errors = [response.errors];
146
- }
147
- }
148
- else if (response?.error) {
149
- if (Array.isArray(response.error)) {
150
- retValue.errors = response.error;
151
- }
152
- else {
153
- retValue.errors = [response.error];
154
- }
155
- }
156
- else {
157
- retValue.errors = ['Error: Obtained incorrect data from Backend'];
158
- }
110
+ VTXBaseAPI.Logger.debug('loginUserFromEmail Response:');
111
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
112
+ retValue = (0, response_builder_1.buildResponse)(response, 'loginUserFromEmail', (r) => {
113
+ const isResponseOk = true && response?.loginUserFromEmail?.actualToken;
114
+ return isResponseOk;
115
+ });
159
116
  }
160
117
  catch (err1) {
161
- console.log(JSON.stringify(err1, null, 2));
162
- if (Array.isArray(err1)) {
163
- retValue.errors = err1;
164
- }
165
- else {
166
- retValue.errors = [err1];
167
- }
118
+ VTXBaseAPI.Logger.error('loginUserFromEmail err1:');
119
+ VTXBaseAPI.Logger.error(err1);
120
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
168
121
  }
169
122
  return retValue;
170
123
  }
171
- async registerNewUser_NT(loginEmail) {
124
+ async createUserAndLogin(loginEmail) {
172
125
  const client = (0, client_1.createClient)({
173
126
  url: this.backendUrl + "/graphql",
174
127
  headers: this.headers,
@@ -180,7 +133,7 @@ class VTXBaseAPI {
180
133
  let retValue = {};
181
134
  try {
182
135
  const response = await client.mutation({
183
- createNonTenantedUserWithLogin: {
136
+ createUserAndLogin: {
184
137
  __args: {
185
138
  user: payload
186
139
  },
@@ -193,56 +146,4462 @@ class VTXBaseAPI {
193
146
  }
194
147
  }
195
148
  });
196
- console.log(JSON.stringify(response, null, 2));
197
- if (response?.createNonTenantedUserWithLogin?._id) {
198
- try {
199
- retValue.data = response.createNonTenantedUserWithLogin;
149
+ VTXBaseAPI.Logger.debug('createUserAndLogin Response:');
150
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
151
+ retValue = (0, response_builder_1.buildResponse)(response, 'createUserAndLogin', (r) => {
152
+ const isResponseOk = true && response?.createUserAndLogin?._id;
153
+ return isResponseOk;
154
+ });
155
+ }
156
+ catch (err1) {
157
+ VTXBaseAPI.Logger.error('createUserAndLogin err1:');
158
+ VTXBaseAPI.Logger.error(err1);
159
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
160
+ }
161
+ return retValue;
162
+ }
163
+ async registerAthlete(payload) {
164
+ const client = (0, client_1.createClient)({
165
+ url: this.backendUrl + "/graphql",
166
+ headers: this.headers,
167
+ });
168
+ let retValue = {};
169
+ const fields = {
170
+ _id: true,
171
+ firstName: true,
172
+ lastName: true,
173
+ screenName: true,
174
+ dob: true,
175
+ lgbt: true,
176
+ competitionGender: true,
177
+ country: {
178
+ _id: true,
179
+ name: true
180
+ },
181
+ location: {
182
+ userProvidedLatitude: true,
183
+ userProvidedLongitude: true,
184
+ cityNameGeocode: true,
185
+ stateNameGeocode: true,
186
+ countryIso2CodeGeocode: true,
187
+ timeZoneGeocode: true,
188
+ latitudeGeocode: true,
189
+ longitudeGeocode: true,
190
+ city: {
191
+ _id: true,
192
+ name: true,
193
+ localizedName: true,
194
+ state: {
195
+ _id: true,
196
+ name: true,
197
+ country: {
198
+ _id: true,
199
+ name: true
200
+ }
201
+ },
202
+ latitude: true,
203
+ longitude: true,
204
+ timezone: true,
205
+ }
206
+ },
207
+ trainer: true,
208
+ trainerUrl: true,
209
+ aboutMe: true,
210
+ followStats: {
211
+ followers: true,
212
+ followed: true,
213
+ raves: true,
214
+ favorites: true
215
+ },
216
+ mainSport: {
217
+ _id: true,
218
+ name: true
219
+ },
220
+ mainSportLevel: {
221
+ _id: true,
222
+ label: true,
223
+ index: true
224
+ },
225
+ scores: {
226
+ vtxScore: true,
227
+ socialScore: true,
228
+ trainingScore: true,
229
+ competitionScore: true
230
+ },
231
+ rankings: {
232
+ worldRanking: {
233
+ scope: true,
234
+ scopeId: true,
235
+ scopeName: true,
236
+ position: true,
237
+ total: true
238
+ },
239
+ countryRanking: {
240
+ scope: true,
241
+ scopeId: true,
242
+ scopeName: true,
243
+ position: true,
244
+ total: true
245
+ },
246
+ stateRanking: {
247
+ scope: true,
248
+ scopeId: true,
249
+ scopeName: true,
250
+ position: true,
251
+ total: true
252
+ },
253
+ cityRanking: {
254
+ scope: true,
255
+ scopeId: true,
256
+ scopeName: true,
257
+ position: true,
258
+ total: true
259
+ },
260
+ },
261
+ allSports: {
262
+ _id: true,
263
+ name: true
264
+ },
265
+ teams: {
266
+ _id: true,
267
+ name: true,
268
+ description: true,
269
+ approved: true,
270
+ logo: {
271
+ _id: true,
272
+ name: true,
273
+ contentType: true,
274
+ size: true,
275
+ useType: true,
276
+ url: true,
277
+ key: true
278
+ },
279
+ banner: {
280
+ _id: true,
281
+ name: true,
282
+ contentType: true,
283
+ size: true,
284
+ useType: true,
285
+ url: true,
286
+ key: true
200
287
  }
201
- catch (casterr) {
202
- console.log('Error trying to cast to UserToken:');
203
- retValue.errors = ['Error: Obtained incorrect data from Backend'];
288
+ },
289
+ sponsorBrands: {
290
+ _id: true,
291
+ name: true,
292
+ slogan: true,
293
+ website: true,
294
+ description: true,
295
+ approved: true,
296
+ published: true,
297
+ logo: {
298
+ _id: true,
299
+ name: true,
300
+ contentType: true,
301
+ size: true,
302
+ useType: true,
303
+ url: true,
304
+ key: true
305
+ },
306
+ stats: {
307
+ campaigns: true,
308
+ sponsorships: true,
309
+ sports: true,
310
+ athletes: true
311
+ },
312
+ operatorIds: true,
313
+ },
314
+ competitions: {
315
+ _id: true,
316
+ event: {
317
+ _id: true,
318
+ name: true,
319
+ mainSport: {
320
+ _id: true,
321
+ name: true
322
+ },
323
+ eventWebSite: true,
324
+ startDate: true,
325
+ endDate: true,
326
+ verified: true,
327
+ banner: {
328
+ _id: true,
329
+ name: true,
330
+ contentType: true,
331
+ size: true,
332
+ useType: true,
333
+ url: true,
334
+ key: true
335
+ },
336
+ location: {
337
+ _id: true,
338
+ userProvidedLatitude: true,
339
+ userProvidedLongitude: true,
340
+ cityNameGeocode: true,
341
+ stateNameGeocode: true,
342
+ countryIso2CodeGeocode: true,
343
+ timeZoneGeocode: true,
344
+ latitudeGeocode: true,
345
+ longitudeGeocode: true,
346
+ city: {
347
+ _id: true,
348
+ name: true,
349
+ localizedName: true,
350
+ state: {
351
+ _id: true,
352
+ name: true,
353
+ country: {
354
+ _id: true,
355
+ name: true
356
+ }
357
+ },
358
+ latitude: true,
359
+ longitude: true,
360
+ timezone: true,
361
+ }
362
+ },
363
+ },
364
+ participationDate: true,
365
+ result: {
366
+ _id: true,
367
+ resultType: true,
368
+ position: true,
369
+ score: true,
370
+ finishTimeMS: true,
371
+ resultWebLink: true
204
372
  }
373
+ },
374
+ totalUpcomingCompetitions: true,
375
+ totalPastCompetitions: true,
376
+ profilePicture: {
377
+ _id: true,
378
+ name: true,
379
+ contentType: true,
380
+ size: true,
381
+ useType: true,
382
+ url: true,
383
+ key: true
384
+ },
385
+ cardPicture: {
386
+ _id: true,
387
+ name: true,
388
+ contentType: true,
389
+ size: true,
390
+ useType: true,
391
+ url: true,
392
+ key: true
393
+ },
394
+ preferences: {
395
+ _id: true,
396
+ showProfileHelper: true
205
397
  }
206
- else if (response?.errors) {
207
- if (Array.isArray(response.errors)) {
208
- retValue.errors = response.errors;
209
- }
210
- else {
211
- retValue.errors = [response.errors];
398
+ };
399
+ try {
400
+ const response = await client.mutation({
401
+ registerAthlete: {
402
+ __args: {
403
+ input: payload
404
+ },
405
+ ...fields
212
406
  }
407
+ });
408
+ VTXBaseAPI.Logger.debug('registerAthlete Response:');
409
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
410
+ retValue = (0, response_builder_1.buildResponse)(response, 'registerAthlete', (r) => {
411
+ const isResponseOk = true && response?.registerAthlete?._id;
412
+ return isResponseOk;
413
+ });
414
+ }
415
+ catch (err1) {
416
+ VTXBaseAPI.Logger.error('registerAthlete err1:');
417
+ VTXBaseAPI.Logger.error(err1);
418
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
419
+ }
420
+ return retValue;
421
+ }
422
+ async findBrandByName(name, translations = false) {
423
+ const client = (0, client_1.createClient)({
424
+ url: this.backendUrl + "/graphql",
425
+ headers: this.headers,
426
+ });
427
+ let retValue = {};
428
+ try {
429
+ let response = null;
430
+ if (translations) {
431
+ response = await client.query({
432
+ getBrandByName: {
433
+ __args: {
434
+ name: name,
435
+ translations: true
436
+ },
437
+ _id: true,
438
+ name: true,
439
+ slogan: true,
440
+ website: true,
441
+ description: true,
442
+ logo: {
443
+ name: true,
444
+ contentType: true,
445
+ size: true,
446
+ useType: true,
447
+ url: true,
448
+ key: true
449
+ },
450
+ banner: {
451
+ name: true,
452
+ contentType: true,
453
+ size: true,
454
+ useType: true,
455
+ url: true,
456
+ key: true
457
+ },
458
+ translations: {
459
+ name: true,
460
+ slogan: true,
461
+ description: true,
462
+ language: true
463
+ },
464
+ }
465
+ });
466
+ }
467
+ else {
468
+ response = await client.query({
469
+ getBrandByName: {
470
+ __args: {
471
+ name: name,
472
+ translations: false
473
+ },
474
+ _id: true,
475
+ name: true,
476
+ slogan: true,
477
+ website: true,
478
+ description: true,
479
+ logo: {
480
+ name: true,
481
+ contentType: true,
482
+ size: true,
483
+ useType: true,
484
+ url: true,
485
+ key: true
486
+ },
487
+ banner: {
488
+ name: true,
489
+ contentType: true,
490
+ size: true,
491
+ useType: true,
492
+ url: true,
493
+ key: true
494
+ }
495
+ }
496
+ });
213
497
  }
214
- else if (response?.error) {
215
- if (Array.isArray(response.error)) {
216
- retValue.errors = response.error;
498
+ VTXBaseAPI.Logger.debug('getBrandByName Response:');
499
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
500
+ retValue = (0, response_builder_1.buildResponse)(response, 'getBrandByName', (r) => {
501
+ const isResponseOk = true && response?.getBrandByName?._id;
502
+ return isResponseOk;
503
+ });
504
+ }
505
+ catch (err1) {
506
+ VTXBaseAPI.Logger.error('getBrandByName err1:');
507
+ VTXBaseAPI.Logger.error(err1);
508
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
509
+ }
510
+ return retValue;
511
+ }
512
+ async createBrand(dto, desiredFields) {
513
+ const client = (0, client_1.createClient)({
514
+ url: this.backendUrl + "/graphql",
515
+ headers: this.headers,
516
+ });
517
+ let retValue = {};
518
+ const fields = desiredFields ?? { _id: true };
519
+ try {
520
+ const response = await client.mutation({
521
+ createBrand: {
522
+ __args: {
523
+ input: dto
524
+ },
525
+ ...fields
217
526
  }
218
- else {
219
- retValue.errors = [response.error];
527
+ });
528
+ VTXBaseAPI.Logger.debug('createBrand Response:');
529
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
530
+ retValue = (0, response_builder_1.buildResponse)(response, 'createBrand', (r) => {
531
+ const isResponseOk = true && response?.createBrand?._id;
532
+ return isResponseOk;
533
+ });
534
+ }
535
+ catch (err1) {
536
+ VTXBaseAPI.Logger.error('createBrand err1:');
537
+ VTXBaseAPI.Logger.error(err1);
538
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
539
+ }
540
+ return retValue;
541
+ }
542
+ async createSponsorship(dto, desiredFields) {
543
+ const client = (0, client_1.createClient)({
544
+ url: this.backendUrl + "/graphql",
545
+ headers: this.headers,
546
+ });
547
+ let retValue = {};
548
+ const fields = desiredFields ?? { _id: true };
549
+ try {
550
+ const response = await client.mutation({
551
+ createSponsorship: {
552
+ __args: {
553
+ input: dto
554
+ },
555
+ ...fields
220
556
  }
221
- }
222
- else if (response?.data?._id) {
223
- try {
224
- retValue.data = response?.data;
557
+ });
558
+ VTXBaseAPI.Logger.debug('createSponsorship Response:');
559
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
560
+ retValue = (0, response_builder_1.buildResponse)(response, 'createSponsorship', (r) => {
561
+ const isResponseOk = true && response?.createSponsorship?._id;
562
+ return isResponseOk;
563
+ });
564
+ }
565
+ catch (err1) {
566
+ VTXBaseAPI.Logger.error('createSponsorship err1:');
567
+ VTXBaseAPI.Logger.error(err1);
568
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
569
+ }
570
+ return retValue;
571
+ }
572
+ async getS3UploadUrl(dto) {
573
+ const client = (0, client_1.createClient)({
574
+ url: this.backendUrl + "/graphql",
575
+ headers: this.headers,
576
+ });
577
+ let retValue = {};
578
+ const fields = {
579
+ uploadUrl: true,
580
+ fields: {
581
+ key: true,
582
+ value: true
583
+ },
584
+ downloadUrl: true,
585
+ bucket: true,
586
+ key: true
587
+ };
588
+ try {
589
+ const response = await client.query({
590
+ getUploadUrl: {
591
+ __args: {
592
+ input: dto
593
+ },
594
+ ...fields
225
595
  }
226
- catch (casterr) {
227
- console.log('Error trying to cast to UserWithToken:');
228
- retValue.errors = ['Error: Obtained incorrect data from Backend'];
596
+ });
597
+ VTXBaseAPI.Logger.debug('getUploadUrl Response:');
598
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
599
+ retValue = (0, response_builder_1.buildResponse)(response, 'getUploadUrl', (r) => {
600
+ const isResponseOk = true && ((response?.getUploadUrl?.uploadUrl !== undefined) && (response?.getUploadUrl?.uploadUrl !== null));
601
+ return isResponseOk;
602
+ });
603
+ }
604
+ catch (err1) {
605
+ VTXBaseAPI.Logger.error('createSponsorship err1:');
606
+ VTXBaseAPI.Logger.error(err1);
607
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
608
+ }
609
+ return retValue;
610
+ }
611
+ async refreshToken(currentToken, refreshToken) {
612
+ const client = (0, client_1.createClient)({
613
+ url: this.backendUrl + "/graphql",
614
+ headers: this.headers,
615
+ });
616
+ VTXBaseAPI.Logger.debug('HEADERS:');
617
+ VTXBaseAPI.Logger.debug(JSON.stringify(this.headers, null, 2));
618
+ const fields = {
619
+ actualToken: true,
620
+ refreshToken: true
621
+ };
622
+ const dto = {
623
+ refreshToken: refreshToken
624
+ };
625
+ let retValue;
626
+ try {
627
+ const response = await client.mutation({
628
+ refreshToken: {
629
+ __args: {
630
+ dto: dto
631
+ },
632
+ ...fields
229
633
  }
634
+ });
635
+ VTXBaseAPI.Logger.debug('refreshToken Response:');
636
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
637
+ retValue = (0, response_builder_1.buildResponse)(response, 'refreshToken', (r) => {
638
+ const isResponseOk = true && response?.refreshToken?.refreshToken;
639
+ return isResponseOk;
640
+ });
641
+ }
642
+ catch (err1) {
643
+ VTXBaseAPI.Logger.error('refreshToken err1:');
644
+ VTXBaseAPI.Logger.error(err1);
645
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
646
+ }
647
+ return retValue;
648
+ }
649
+ async registerNewDomainTenant(input) {
650
+ const client = (0, client_1.createClient)({
651
+ url: this.backendUrl + "/graphql",
652
+ headers: this.headers,
653
+ });
654
+ const fields = {
655
+ _id: true,
656
+ name: true,
657
+ email: true,
658
+ tenant_uri: true,
659
+ owner: {
660
+ _id: true,
661
+ loginEmail: true,
662
+ suspended: true
663
+ },
664
+ domain: {
665
+ _id: true,
666
+ name: true,
667
+ description: true
230
668
  }
231
- else {
232
- retValue.errors = ['Error: Obtained incorrect data from Backend'];
669
+ };
670
+ let retValue;
671
+ try {
672
+ const response = await client.mutation({
673
+ registerNewDomainTenant: {
674
+ __args: {
675
+ tenant: input
676
+ },
677
+ ...fields
678
+ }
679
+ });
680
+ VTXBaseAPI.Logger.debug('registerNewDomainTenant Response:');
681
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
682
+ retValue = (0, response_builder_1.buildResponse)(response, 'registerNewDomainTenant', (r) => {
683
+ const isResponseOk = true && response?.registerNewDomainTenant?._id;
684
+ return isResponseOk;
685
+ });
686
+ }
687
+ catch (err1) {
688
+ VTXBaseAPI.Logger.error('registerNewDomainTenant err1:');
689
+ VTXBaseAPI.Logger.error(err1);
690
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
691
+ }
692
+ return retValue;
693
+ }
694
+ async registerNewDomainTenantWithLogin(input) {
695
+ const client = (0, client_1.createClient)({
696
+ url: this.backendUrl + "/graphql",
697
+ headers: this.headers,
698
+ });
699
+ const fields = {
700
+ _id: true,
701
+ name: true,
702
+ email: true,
703
+ tenant_uri: true,
704
+ owner: {
705
+ _id: true,
706
+ loginEmail: true,
707
+ suspended: true
708
+ },
709
+ domain: {
710
+ _id: true,
711
+ name: true,
712
+ description: true
713
+ },
714
+ user: {
715
+ _id: true,
716
+ loginEmail: true,
717
+ suspended: true,
718
+ domains: {
719
+ _id: true,
720
+ name: true,
721
+ description: true
722
+ },
723
+ token: {
724
+ actualToken: true,
725
+ refreshToken: true
726
+ }
233
727
  }
728
+ };
729
+ let retValue;
730
+ try {
731
+ const response = await client.mutation({
732
+ registerNewDomainTenantWithLogin: {
733
+ __args: {
734
+ tenant: input
735
+ },
736
+ ...fields
737
+ }
738
+ });
739
+ VTXBaseAPI.Logger.debug('registerNewDomainTenant Response:');
740
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
741
+ retValue = (0, response_builder_1.buildResponse)(response, 'TenantWithUserLogin', (r) => {
742
+ const isResponseOk = true && response?.TenantWithUserLogin?._id;
743
+ return isResponseOk;
744
+ });
234
745
  }
235
746
  catch (err1) {
236
- console.log(JSON.stringify(err1, null, 2));
237
- if (Array.isArray(err1)) {
238
- retValue.errors = err1;
747
+ VTXBaseAPI.Logger.error('registerNewDomainTenantWithLogin err1:');
748
+ VTXBaseAPI.Logger.error(err1);
749
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
750
+ }
751
+ return retValue;
752
+ }
753
+ async registerUserToDomainFromEmail(input) {
754
+ const client = (0, client_1.createClient)({
755
+ url: this.backendUrl + "/graphql",
756
+ headers: this.headers,
757
+ });
758
+ const fields = {
759
+ _id: true,
760
+ loginEmail: true,
761
+ suspended: true,
762
+ domains: {
763
+ _id: true,
764
+ name: true,
765
+ description: true,
766
+ tenant: {
767
+ _id: true,
768
+ name: true,
769
+ tenant_uri: true
770
+ }
239
771
  }
240
- else {
241
- retValue.errors = [err1];
772
+ };
773
+ let retValue;
774
+ try {
775
+ const response = await client.mutation({
776
+ registerUserToDomainFromEmail: {
777
+ __args: {
778
+ input: input
779
+ },
780
+ ...fields
781
+ }
782
+ });
783
+ VTXBaseAPI.Logger.debug('registerUserToDomainFromEmail Response:');
784
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
785
+ retValue = (0, response_builder_1.buildResponse)(response, 'registerUserToDomainFromEmail', (r) => {
786
+ const isResponseOk = true && response?.registerUserToDomainFromEmail?.loginEmail;
787
+ return isResponseOk;
788
+ });
789
+ }
790
+ catch (err1) {
791
+ VTXBaseAPI.Logger.error('registerUserToDomainFromEmail err1:');
792
+ VTXBaseAPI.Logger.error(err1);
793
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
794
+ }
795
+ return retValue;
796
+ }
797
+ async getPublicSponsorships() {
798
+ const client = (0, client_1.createClient)({
799
+ url: this.backendUrl + "/graphql",
800
+ headers: this.headers,
801
+ });
802
+ const fields = {
803
+ _id: true,
804
+ title: true,
805
+ description: true,
806
+ cashValue: true,
807
+ otherValue: true,
808
+ brand: {
809
+ _id: true,
810
+ name: true,
811
+ slogan: true,
812
+ website: true,
813
+ description: true,
814
+ approved: true,
815
+ published: true,
816
+ logo: {
817
+ _id: true,
818
+ name: true,
819
+ contentType: true,
820
+ size: true,
821
+ useType: true,
822
+ url: true,
823
+ key: true
824
+ },
825
+ banner: {
826
+ _id: true,
827
+ name: true,
828
+ contentType: true,
829
+ size: true,
830
+ useType: true,
831
+ url: true,
832
+ key: true
833
+ },
834
+ stats: {
835
+ campaigns: true,
836
+ sponsorships: true,
837
+ sports: true,
838
+ athletes: true
839
+ },
840
+ operatorIds: true
841
+ },
842
+ banner: {
843
+ _id: true,
844
+ name: true,
845
+ contentType: true,
846
+ size: true,
847
+ useType: true,
848
+ url: true,
849
+ key: true
850
+ },
851
+ criteria: {
852
+ _id: true,
853
+ label: true,
854
+ qualifications: {
855
+ on_AgeQualification: {
856
+ type: true,
857
+ value: true,
858
+ operator: true
859
+ },
860
+ on_DistanceQualification: {
861
+ type: true,
862
+ maxDistance: true,
863
+ latitude: true,
864
+ longitude: true
865
+ },
866
+ on_GenderQualification: {
867
+ type: true,
868
+ operator: true,
869
+ values: true
870
+ },
871
+ on_LocationQualification: {
872
+ type: true,
873
+ operator: true,
874
+ countries: {
875
+ _id: true,
876
+ name: true
877
+ },
878
+ states: {
879
+ _id: true,
880
+ name: true,
881
+ country: {
882
+ _id: true,
883
+ name: true
884
+ }
885
+ },
886
+ cities: {
887
+ _id: true,
888
+ name: true,
889
+ localizedName: true,
890
+ state: {
891
+ _id: true,
892
+ name: true,
893
+ country: {
894
+ _id: true,
895
+ name: true
896
+ }
897
+ },
898
+ latitude: true,
899
+ longitude: true,
900
+ timezone: true
901
+ }
902
+ },
903
+ on_NationalityQualification: {
904
+ type: true,
905
+ operator: true,
906
+ countries: {
907
+ _id: true,
908
+ name: true
909
+ }
910
+ },
911
+ on_ScoreQualification: {
912
+ type: true,
913
+ scoreType: true,
914
+ operator: true,
915
+ value: true
916
+ },
917
+ on_SportsLevelQualification: {
918
+ type: true,
919
+ operator: true,
920
+ level: true
921
+ },
922
+ on_SportsQualification: {
923
+ type: true,
924
+ sports: true,
925
+ operator: true
926
+ }
927
+ }
928
+ },
929
+ sponsorshipItems: {
930
+ _id: true,
931
+ quantity: true,
932
+ title: true,
933
+ value: true,
934
+ type: true
935
+ },
936
+ deadline: true,
937
+ startDate: true,
938
+ duration: {
939
+ length: true,
940
+ unit: true
941
+ },
942
+ terms: true,
943
+ isPrivate: true,
944
+ stats: {
945
+ totalApplications: true,
946
+ newApplications: true,
947
+ discardedApplications: true,
948
+ selectedApplications: true,
949
+ approvedApplications: true,
950
+ grantedSponsorships: true,
951
+ remainingSponsorships: true
952
+ },
953
+ approved: true,
954
+ published: true
955
+ };
956
+ let retValue;
957
+ try {
958
+ const response = await client.query({
959
+ getPublicSponsorships: {
960
+ __args: {},
961
+ ...fields
962
+ }
963
+ });
964
+ VTXBaseAPI.Logger.debug('getPublicSponsorships Response:');
965
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
966
+ retValue = (0, response_builder_1.buildResponse)(response, 'getPublicSponsorships', (r) => {
967
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
968
+ const isResponseOk = true;
969
+ return isResponseOk;
970
+ });
971
+ }
972
+ catch (err1) {
973
+ VTXBaseAPI.Logger.error('getPublicSponsorships err1:');
974
+ VTXBaseAPI.Logger.error(err1);
975
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
976
+ }
977
+ return retValue;
978
+ }
979
+ async getTenantSponsorshipsFromUri(tenantUri, token) {
980
+ if ((!tenantUri) || (tenantUri.trim() === "")) {
981
+ return {
982
+ error: {
983
+ httpStatus: 400,
984
+ code: vtx_core_common_1.VTX_ERRORS.INVALID_TENANT_URI.code,
985
+ message: vtx_core_common_1.VTX_ERRORS.INVALID_TENANT_URI.description
986
+ }
987
+ };
988
+ }
989
+ const credential = token.domains.find(c => {
990
+ if (c.tenant) {
991
+ if ((c.tenant.tenant_uri == tenantUri) && (c._id == domains_1.DOMAIN_SPONSOR)) {
992
+ return true;
993
+ }
242
994
  }
995
+ return false;
996
+ });
997
+ if (!credential) {
998
+ return {
999
+ error: {
1000
+ httpStatus: 400,
1001
+ code: vtx_core_common_1.VTX_ERRORS.INVALID_TENANT_URI_FOR_SPONSOR.code,
1002
+ message: "Tenant in domain SPONSOR not found in domains with URI " + tenantUri
1003
+ }
1004
+ };
1005
+ }
1006
+ const tenantId = credential.tenant?._id ?? null;
1007
+ if ((!tenantId) || (tenantId == "ALL")) {
1008
+ return {
1009
+ error: {
1010
+ httpStatus: 400,
1011
+ code: vtx_core_common_1.VTX_ERRORS.INVALID_TENANT_ID.code,
1012
+ message: vtx_core_common_1.VTX_ERRORS.INVALID_TENANT_ID.description
1013
+ }
1014
+ };
1015
+ }
1016
+ return this.getTenantSponsorships(tenantId);
1017
+ }
1018
+ async getTenantSponsorships(tenantId) {
1019
+ const client = (0, client_1.createClient)({
1020
+ url: this.backendUrl + "/graphql",
1021
+ headers: this.headers,
1022
+ });
1023
+ const fields = {
1024
+ _id: true,
1025
+ title: true,
1026
+ description: true,
1027
+ cashValue: true,
1028
+ otherValue: true,
1029
+ brand: {
1030
+ _id: true,
1031
+ name: true,
1032
+ slogan: true,
1033
+ website: true,
1034
+ description: true,
1035
+ approved: true,
1036
+ published: true,
1037
+ logo: {
1038
+ _id: true,
1039
+ name: true,
1040
+ contentType: true,
1041
+ size: true,
1042
+ useType: true,
1043
+ url: true,
1044
+ key: true
1045
+ },
1046
+ banner: {
1047
+ _id: true,
1048
+ name: true,
1049
+ contentType: true,
1050
+ size: true,
1051
+ useType: true,
1052
+ url: true,
1053
+ key: true
1054
+ },
1055
+ stats: {
1056
+ campaigns: true,
1057
+ sponsorships: true,
1058
+ sports: true,
1059
+ athletes: true
1060
+ },
1061
+ operatorIds: true
1062
+ },
1063
+ banner: {
1064
+ _id: true,
1065
+ name: true,
1066
+ contentType: true,
1067
+ size: true,
1068
+ useType: true,
1069
+ url: true,
1070
+ key: true
1071
+ },
1072
+ criteria: {
1073
+ _id: true,
1074
+ label: true,
1075
+ qualifications: {
1076
+ on_AgeQualification: {
1077
+ type: true,
1078
+ value: true,
1079
+ operator: true
1080
+ },
1081
+ on_DistanceQualification: {
1082
+ type: true,
1083
+ maxDistance: true,
1084
+ latitude: true,
1085
+ longitude: true
1086
+ },
1087
+ on_GenderQualification: {
1088
+ type: true,
1089
+ operator: true,
1090
+ values: true
1091
+ },
1092
+ on_LocationQualification: {
1093
+ type: true,
1094
+ operator: true,
1095
+ countries: {
1096
+ _id: true,
1097
+ name: true
1098
+ },
1099
+ states: {
1100
+ _id: true,
1101
+ name: true,
1102
+ country: {
1103
+ _id: true,
1104
+ name: true
1105
+ }
1106
+ },
1107
+ cities: {
1108
+ _id: true,
1109
+ name: true,
1110
+ localizedName: true,
1111
+ state: {
1112
+ _id: true,
1113
+ name: true,
1114
+ country: {
1115
+ _id: true,
1116
+ name: true
1117
+ }
1118
+ },
1119
+ latitude: true,
1120
+ longitude: true,
1121
+ timezone: true
1122
+ }
1123
+ },
1124
+ on_NationalityQualification: {
1125
+ type: true,
1126
+ operator: true,
1127
+ countries: {
1128
+ _id: true,
1129
+ name: true
1130
+ }
1131
+ },
1132
+ on_ScoreQualification: {
1133
+ type: true,
1134
+ scoreType: true,
1135
+ operator: true,
1136
+ value: true
1137
+ },
1138
+ on_SportsLevelQualification: {
1139
+ type: true,
1140
+ operator: true,
1141
+ level: true
1142
+ },
1143
+ on_SportsQualification: {
1144
+ type: true,
1145
+ sports: true,
1146
+ operator: true
1147
+ }
1148
+ }
1149
+ },
1150
+ sponsorshipItems: {
1151
+ _id: true,
1152
+ quantity: true,
1153
+ title: true,
1154
+ value: true,
1155
+ type: true
1156
+ },
1157
+ deadline: true,
1158
+ startDate: true,
1159
+ duration: {
1160
+ length: true,
1161
+ unit: true
1162
+ },
1163
+ terms: true,
1164
+ isPrivate: true,
1165
+ stats: {
1166
+ totalApplications: true,
1167
+ newApplications: true,
1168
+ discardedApplications: true,
1169
+ selectedApplications: true,
1170
+ approvedApplications: true,
1171
+ grantedSponsorships: true,
1172
+ remainingSponsorships: true
1173
+ },
1174
+ approved: true,
1175
+ published: true
1176
+ };
1177
+ let retValue;
1178
+ try {
1179
+ const response = await client.query({
1180
+ getTenantSponsorships: {
1181
+ __args: {},
1182
+ ...fields
1183
+ }
1184
+ });
1185
+ VTXBaseAPI.Logger.debug('getTenantSponsorships Response:');
1186
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1187
+ retValue = (0, response_builder_1.buildResponse)(response, 'getTenantSponsorships', (r) => {
1188
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1189
+ const isResponseOk = true;
1190
+ return isResponseOk;
1191
+ });
1192
+ }
1193
+ catch (err1) {
1194
+ VTXBaseAPI.Logger.error('getTenantSponsorships err1:');
1195
+ VTXBaseAPI.Logger.error(err1);
1196
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1197
+ }
1198
+ return retValue;
1199
+ }
1200
+ async sendAthleteInvitations(input) {
1201
+ const client = (0, client_1.createClient)({
1202
+ url: this.backendUrl + "/graphql",
1203
+ headers: this.headers,
1204
+ });
1205
+ const fields = {
1206
+ _id: true,
1207
+ name: true,
1208
+ email: true,
1209
+ dateSent: true,
1210
+ sponsor: {
1211
+ _id: true,
1212
+ name: true,
1213
+ tenant: {
1214
+ _id: true,
1215
+ name: true,
1216
+ tenant_uri: true
1217
+ }
1218
+ },
1219
+ magicLink: {
1220
+ _id: true,
1221
+ code: true,
1222
+ type: true,
1223
+ url: true,
1224
+ expires: true,
1225
+ data: true,
1226
+ isExpired: true
1227
+ },
1228
+ brand: {
1229
+ _id: true,
1230
+ name: true,
1231
+ logo: {
1232
+ _id: true,
1233
+ name: true,
1234
+ contentType: true,
1235
+ url: true,
1236
+ useType: true
1237
+ },
1238
+ website: true
1239
+ },
1240
+ status: true
1241
+ };
1242
+ let retValue;
1243
+ try {
1244
+ const response = await client.mutation({
1245
+ sendAthleteInvitations: {
1246
+ __args: {
1247
+ input: input
1248
+ },
1249
+ ...fields
1250
+ }
1251
+ });
1252
+ VTXBaseAPI.Logger.debug('sendAthleteInvitations Response:');
1253
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1254
+ retValue = (0, response_builder_1.buildResponse)(response, 'sendAthleteInvitations', (r) => {
1255
+ const isResponseOk = true && Array.isArray(response?.sendAthleteInvitations);
1256
+ return isResponseOk;
1257
+ });
1258
+ }
1259
+ catch (err1) {
1260
+ VTXBaseAPI.Logger.error('sendAthleteInvitations err1:');
1261
+ VTXBaseAPI.Logger.error(err1);
1262
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1263
+ }
1264
+ return retValue;
1265
+ }
1266
+ async registerSponsorUser(input) {
1267
+ const client = (0, client_1.createClient)({
1268
+ url: this.backendUrl + "/graphql",
1269
+ headers: this.headers,
1270
+ });
1271
+ const fields = {
1272
+ _id: true,
1273
+ loginEmail: true,
1274
+ suspended: true,
1275
+ domains: {
1276
+ _id: true,
1277
+ name: true,
1278
+ description: true,
1279
+ tenant: {
1280
+ _id: true,
1281
+ name: true,
1282
+ tenant_uri: true,
1283
+ domain: {
1284
+ _id: true,
1285
+ name: true,
1286
+ description: true
1287
+ }
1288
+ }
1289
+ }
1290
+ };
1291
+ let retValue;
1292
+ try {
1293
+ const response = await client.mutation({
1294
+ registerSponsorUser: {
1295
+ __args: {
1296
+ input: input
1297
+ },
1298
+ ...fields
1299
+ }
1300
+ });
1301
+ VTXBaseAPI.Logger.debug('registerSponsorUser Response:');
1302
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1303
+ retValue = (0, response_builder_1.buildResponse)(response, 'registerSponsorUser', (r) => {
1304
+ const isResponseOk = true && response?.registerSponsorUser._id;
1305
+ return isResponseOk;
1306
+ });
1307
+ }
1308
+ catch (err1) {
1309
+ VTXBaseAPI.Logger.error('registerSponsorUser err1:');
1310
+ VTXBaseAPI.Logger.error(err1);
1311
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1312
+ }
1313
+ return retValue;
1314
+ }
1315
+ async registerAthleteUser(input) {
1316
+ const client = (0, client_1.createClient)({
1317
+ url: this.backendUrl + "/graphql",
1318
+ headers: this.headers,
1319
+ });
1320
+ const fields = {
1321
+ _id: true,
1322
+ loginEmail: true,
1323
+ suspended: true,
1324
+ domains: {
1325
+ _id: true,
1326
+ name: true,
1327
+ description: true,
1328
+ tenant: {
1329
+ _id: true,
1330
+ name: true,
1331
+ tenant_uri: true,
1332
+ domain: {
1333
+ _id: true,
1334
+ name: true,
1335
+ description: true
1336
+ }
1337
+ }
1338
+ }
1339
+ };
1340
+ let retValue;
1341
+ try {
1342
+ const response = await client.mutation({
1343
+ registerAthleteUser: {
1344
+ __args: {
1345
+ input: input
1346
+ },
1347
+ ...fields
1348
+ }
1349
+ });
1350
+ VTXBaseAPI.Logger.debug('registerAthleteUser Response:');
1351
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1352
+ retValue = (0, response_builder_1.buildResponse)(response, 'registerAthleteUser', (r) => {
1353
+ const isResponseOk = true && response?.registerAthleteUser._id;
1354
+ return isResponseOk;
1355
+ });
1356
+ }
1357
+ catch (err1) {
1358
+ VTXBaseAPI.Logger.error('registerAthleteUser err1:');
1359
+ VTXBaseAPI.Logger.error(err1);
1360
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1361
+ }
1362
+ return retValue;
1363
+ }
1364
+ async preRegisterAthleteUser(input) {
1365
+ const client = (0, client_1.createClient)({
1366
+ url: this.backendUrl + "/graphql",
1367
+ headers: this.headers,
1368
+ });
1369
+ const fields = {
1370
+ _id: true,
1371
+ type: true,
1372
+ recipient: true,
1373
+ expires: true,
1374
+ isExpired: true,
1375
+ createdDate: true
1376
+ };
1377
+ let retValue;
1378
+ try {
1379
+ const response = await client.mutation({
1380
+ preRegisterAthleteUser: {
1381
+ __args: {
1382
+ input: input
1383
+ },
1384
+ ...fields
1385
+ }
1386
+ });
1387
+ VTXBaseAPI.Logger.debug('preRegisterAthleteUser Response:');
1388
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1389
+ retValue = (0, response_builder_1.buildResponse)(response, 'preRegisterAthleteUser', (r) => {
1390
+ const isResponseOk = true && response?.preRegisterAthleteUser._id;
1391
+ return isResponseOk;
1392
+ });
1393
+ }
1394
+ catch (err1) {
1395
+ VTXBaseAPI.Logger.error('preRegisterAthleteUser err1:');
1396
+ VTXBaseAPI.Logger.error(err1);
1397
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1398
+ }
1399
+ return retValue;
1400
+ }
1401
+ async confirmAthleteUserRegistrationAndLogin(input) {
1402
+ const client = (0, client_1.createClient)({
1403
+ url: this.backendUrl + "/graphql",
1404
+ headers: this.headers,
1405
+ });
1406
+ const fields = {
1407
+ _id: true,
1408
+ loginEmail: true,
1409
+ suspended: true,
1410
+ domains: {
1411
+ _id: true,
1412
+ name: true,
1413
+ description: true,
1414
+ tenant: {
1415
+ _id: true,
1416
+ name: true,
1417
+ tenant_uri: true,
1418
+ domain: {
1419
+ _id: true,
1420
+ name: true,
1421
+ description: true
1422
+ }
1423
+ }
1424
+ },
1425
+ token: {
1426
+ actualToken: true,
1427
+ refreshToken: true
1428
+ }
1429
+ };
1430
+ let retValue;
1431
+ try {
1432
+ const response = await client.mutation({
1433
+ confirmAthleteUserRegistrationAndLogin: {
1434
+ __args: {
1435
+ input: input
1436
+ },
1437
+ ...fields
1438
+ }
1439
+ });
1440
+ VTXBaseAPI.Logger.debug('confirmAthleteUserRegistrationAndLogin Response:');
1441
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1442
+ retValue = (0, response_builder_1.buildResponse)(response, 'confirmAthleteUserRegistrationAndLogin', (r) => {
1443
+ const isResponseOk = true && response?.confirmAthleteUserRegistrationAndLogin._id;
1444
+ return isResponseOk;
1445
+ });
1446
+ }
1447
+ catch (err1) {
1448
+ VTXBaseAPI.Logger.error('confirmAthleteUserRegistrationAndLogin err1:');
1449
+ VTXBaseAPI.Logger.error(err1);
1450
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1451
+ }
1452
+ return retValue;
1453
+ }
1454
+ async confirmAthleteUserRegistration(input) {
1455
+ const client = (0, client_1.createClient)({
1456
+ url: this.backendUrl + "/graphql",
1457
+ headers: this.headers,
1458
+ });
1459
+ const fields = {
1460
+ _id: true,
1461
+ loginEmail: true,
1462
+ suspended: true,
1463
+ domains: {
1464
+ _id: true,
1465
+ name: true,
1466
+ description: true,
1467
+ tenant: {
1468
+ _id: true,
1469
+ name: true,
1470
+ tenant_uri: true,
1471
+ domain: {
1472
+ _id: true,
1473
+ name: true,
1474
+ description: true
1475
+ }
1476
+ }
1477
+ }
1478
+ };
1479
+ let retValue;
1480
+ try {
1481
+ const response = await client.mutation({
1482
+ confirmAthleteUserRegistration: {
1483
+ __args: {
1484
+ input: input
1485
+ },
1486
+ ...fields
1487
+ }
1488
+ });
1489
+ VTXBaseAPI.Logger.debug('confirmAthleteUserRegistration Response:');
1490
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1491
+ retValue = (0, response_builder_1.buildResponse)(response, 'confirmAthleteUserRegistration', (r) => {
1492
+ const isResponseOk = true && response?.confirmAthleteUserRegistration._id;
1493
+ return isResponseOk;
1494
+ });
1495
+ }
1496
+ catch (err1) {
1497
+ VTXBaseAPI.Logger.error('confirmAthleteUserRegistration err1:');
1498
+ VTXBaseAPI.Logger.error(err1);
1499
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1500
+ }
1501
+ return retValue;
1502
+ }
1503
+ async findSponsorAthleteInvitation(dto) {
1504
+ const client = (0, client_1.createClient)({
1505
+ url: this.backendUrl + "/graphql",
1506
+ headers: this.headers,
1507
+ });
1508
+ const fields = {
1509
+ _id: true,
1510
+ name: true,
1511
+ email: true,
1512
+ dateSent: true,
1513
+ sponsor: {
1514
+ _id: true,
1515
+ name: true,
1516
+ description: true,
1517
+ approved: true
1518
+ },
1519
+ magicLink: {
1520
+ _id: true,
1521
+ code: true,
1522
+ type: true,
1523
+ url: true,
1524
+ expires: true,
1525
+ isExpired: true
1526
+ },
1527
+ brand: {
1528
+ _id: true,
1529
+ name: true,
1530
+ slogan: true,
1531
+ website: true,
1532
+ description: true,
1533
+ approved: true,
1534
+ published: true,
1535
+ logo: {
1536
+ _id: true,
1537
+ name: true,
1538
+ contentType: true,
1539
+ size: true,
1540
+ useType: true,
1541
+ url: true,
1542
+ key: true
1543
+ },
1544
+ banner: {
1545
+ _id: true,
1546
+ name: true,
1547
+ contentType: true,
1548
+ size: true,
1549
+ useType: true,
1550
+ url: true,
1551
+ key: true
1552
+ }
1553
+ },
1554
+ status: true
1555
+ };
1556
+ let retValue;
1557
+ try {
1558
+ const response = await client.query({
1559
+ findSponsorAthleteInvitation: {
1560
+ __args: {
1561
+ input: dto
1562
+ },
1563
+ ...fields
1564
+ }
1565
+ });
1566
+ VTXBaseAPI.Logger.debug('findSponsorAthleteInvitation Response:');
1567
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1568
+ retValue = (0, response_builder_1.buildResponse)(response, 'findSponsorAthleteInvitation', (r) => {
1569
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1570
+ const isResponseOk = true && response?.findSponsorAthleteInvitation?._id;
1571
+ return isResponseOk;
1572
+ });
1573
+ }
1574
+ catch (err1) {
1575
+ VTXBaseAPI.Logger.error('findSponsorAthleteInvitation err1:');
1576
+ VTXBaseAPI.Logger.error(err1);
1577
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1578
+ }
1579
+ return retValue;
1580
+ }
1581
+ async findVtxUser(dto) {
1582
+ const client = (0, client_1.createClient)({
1583
+ url: this.backendUrl + "/graphql",
1584
+ headers: this.headers,
1585
+ });
1586
+ const fields = {
1587
+ _id: true,
1588
+ loginEmail: true,
1589
+ suspended: true,
1590
+ domains: {
1591
+ _id: true,
1592
+ name: true,
1593
+ description: true,
1594
+ tenant: {
1595
+ _id: true,
1596
+ name: true,
1597
+ tenant_uri: true,
1598
+ domain: {
1599
+ _id: true,
1600
+ name: true,
1601
+ description: true
1602
+ }
1603
+ }
1604
+ }
1605
+ };
1606
+ let retValue;
1607
+ try {
1608
+ const response = await client.query({
1609
+ findVtxUser: {
1610
+ __args: {
1611
+ input: dto
1612
+ },
1613
+ ...fields
1614
+ }
1615
+ });
1616
+ VTXBaseAPI.Logger.debug('findVtxUser Response:');
1617
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1618
+ retValue = (0, response_builder_1.buildResponse)(response, 'findVtxUser', (r) => {
1619
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1620
+ const isResponseOk = true && response?.findVtxUser?._id;
1621
+ return isResponseOk;
1622
+ });
1623
+ }
1624
+ catch (err1) {
1625
+ VTXBaseAPI.Logger.error('findVtxUser err1:');
1626
+ VTXBaseAPI.Logger.error(err1);
1627
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1628
+ }
1629
+ return retValue;
1630
+ }
1631
+ async findCitiesStartingWith(pattern) {
1632
+ const client = (0, client_1.createClient)({
1633
+ url: this.backendUrl + "/graphql",
1634
+ headers: this.headers,
1635
+ });
1636
+ const fields = {
1637
+ _id: true,
1638
+ name: true,
1639
+ localizedName: true,
1640
+ state: {
1641
+ _id: true,
1642
+ name: true,
1643
+ country: {
1644
+ _id: true,
1645
+ name: true
1646
+ }
1647
+ },
1648
+ latitude: true,
1649
+ longitude: true,
1650
+ timezone: true
1651
+ };
1652
+ let retValue;
1653
+ try {
1654
+ const response = await client.query({
1655
+ findCitiesStartingWith: {
1656
+ __args: {
1657
+ text: pattern
1658
+ },
1659
+ ...fields
1660
+ }
1661
+ });
1662
+ VTXBaseAPI.Logger.debug('findCitiesStartingWith Response:');
1663
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1664
+ retValue = (0, response_builder_1.buildResponse)(response, 'findCitiesStartingWith', (r) => {
1665
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1666
+ const isResponseOk = true && Array.isArray(response?.findCitiesStartingWith);
1667
+ return isResponseOk;
1668
+ });
1669
+ }
1670
+ catch (err1) {
1671
+ VTXBaseAPI.Logger.error('findCitiesStartingWith err1:');
1672
+ VTXBaseAPI.Logger.error(err1);
1673
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1674
+ }
1675
+ return retValue;
1676
+ }
1677
+ async findCityById(cityId) {
1678
+ const client = (0, client_1.createClient)({
1679
+ url: this.backendUrl + "/graphql",
1680
+ headers: this.headers,
1681
+ });
1682
+ const fields = {
1683
+ _id: true,
1684
+ name: true,
1685
+ localizedName: true,
1686
+ state: {
1687
+ _id: true,
1688
+ name: true,
1689
+ country: {
1690
+ _id: true,
1691
+ name: true
1692
+ }
1693
+ },
1694
+ latitude: true,
1695
+ longitude: true,
1696
+ timezone: true
1697
+ };
1698
+ let retValue;
1699
+ try {
1700
+ const response = await client.query({
1701
+ findCityById: {
1702
+ __args: {
1703
+ cityId: cityId
1704
+ },
1705
+ ...fields
1706
+ }
1707
+ });
1708
+ VTXBaseAPI.Logger.debug('findCityById Response:');
1709
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1710
+ retValue = (0, response_builder_1.buildResponse)(response, 'findCityById', (r) => {
1711
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1712
+ const isResponseOk = true && response?.findCityById?._id;
1713
+ return isResponseOk;
1714
+ });
1715
+ }
1716
+ catch (err1) {
1717
+ VTXBaseAPI.Logger.error('findCityById err1:');
1718
+ VTXBaseAPI.Logger.error(err1);
1719
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1720
+ }
1721
+ return retValue;
1722
+ }
1723
+ async getSportLevels() {
1724
+ const client = (0, client_1.createClient)({
1725
+ url: this.backendUrl + "/graphql",
1726
+ headers: this.headers,
1727
+ });
1728
+ const fields = {
1729
+ _id: true,
1730
+ label: true,
1731
+ index: true
1732
+ };
1733
+ let retValue;
1734
+ try {
1735
+ const response = await client.query({
1736
+ getSportLevels: {
1737
+ __args: {},
1738
+ ...fields
1739
+ }
1740
+ });
1741
+ VTXBaseAPI.Logger.debug('getSportLevels Response:');
1742
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1743
+ retValue = (0, response_builder_1.buildResponse)(response, 'getSportLevels', (r) => {
1744
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1745
+ const isResponseOk = true && Array.isArray(response?.getSportLevels);
1746
+ return isResponseOk;
1747
+ });
1748
+ }
1749
+ catch (err1) {
1750
+ VTXBaseAPI.Logger.error('getSportLevels err1:');
1751
+ VTXBaseAPI.Logger.error(err1);
1752
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1753
+ }
1754
+ return retValue;
1755
+ }
1756
+ async getSports() {
1757
+ const client = (0, client_1.createClient)({
1758
+ url: this.backendUrl + "/graphql",
1759
+ headers: this.headers,
1760
+ });
1761
+ const fields = {
1762
+ _id: true,
1763
+ name: true
1764
+ };
1765
+ let retValue;
1766
+ try {
1767
+ const response = await client.query({
1768
+ getSports: {
1769
+ __args: {},
1770
+ ...fields
1771
+ }
1772
+ });
1773
+ VTXBaseAPI.Logger.debug('getSports Response:');
1774
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1775
+ retValue = (0, response_builder_1.buildResponse)(response, 'getSports', (r) => {
1776
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1777
+ const isResponseOk = true && Array.isArray(response?.getSports);
1778
+ return isResponseOk;
1779
+ });
1780
+ }
1781
+ catch (err1) {
1782
+ VTXBaseAPI.Logger.error('getSports err1:');
1783
+ VTXBaseAPI.Logger.error(err1);
1784
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1785
+ }
1786
+ return retValue;
1787
+ }
1788
+ async loginUserFromCredentialsVtx(username, password) {
1789
+ const client = (0, client_1.createClient)({
1790
+ url: this.backendUrl + '/graphql',
1791
+ headers: this.headers,
1792
+ });
1793
+ const curatedEmail = username.trim().toLocaleLowerCase();
1794
+ let retValue = {};
1795
+ const fields = {
1796
+ _id: true,
1797
+ loginEmail: true,
1798
+ suspended: true,
1799
+ domains: {
1800
+ _id: true,
1801
+ name: true,
1802
+ description: true,
1803
+ tenant: {
1804
+ _id: true,
1805
+ name: true,
1806
+ tenant_uri: true,
1807
+ domain: {
1808
+ _id: true,
1809
+ name: true,
1810
+ description: true
1811
+ }
1812
+ }
1813
+ },
1814
+ loginMethods: true,
1815
+ token: {
1816
+ actualToken: true,
1817
+ refreshToken: true
1818
+ }
1819
+ };
1820
+ try {
1821
+ const response = await client.mutation({
1822
+ loginUserFromCredentialsVtx: {
1823
+ __args: {
1824
+ username: curatedEmail,
1825
+ password: password
1826
+ },
1827
+ ...fields
1828
+ },
1829
+ });
1830
+ VTXBaseAPI.Logger.debug('loginUserFromCredentialsVtx Response:');
1831
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1832
+ retValue = (0, response_builder_1.buildResponse)(response, 'loginUserFromCredentialsVtx', (r) => {
1833
+ const isResponseOk = true && response?.loginUserFromCredentialsVtx?.actualToken;
1834
+ return isResponseOk;
1835
+ });
1836
+ }
1837
+ catch (err1) {
1838
+ VTXBaseAPI.Logger.error('loginUserFromCredentialsVtx err1:');
1839
+ VTXBaseAPI.Logger.error(err1);
1840
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1841
+ }
1842
+ return retValue;
1843
+ }
1844
+ async validateUserCredentialsVtx(username, password) {
1845
+ const client = (0, client_1.createClient)({
1846
+ url: this.backendUrl + '/graphql',
1847
+ headers: this.headers,
1848
+ });
1849
+ const curatedEmail = username.trim().toLocaleLowerCase();
1850
+ let retValue = {};
1851
+ const fields = {
1852
+ _id: true,
1853
+ loginEmail: true,
1854
+ suspended: true,
1855
+ domains: {
1856
+ _id: true,
1857
+ name: true,
1858
+ description: true,
1859
+ tenant: {
1860
+ _id: true,
1861
+ name: true,
1862
+ tenant_uri: true,
1863
+ domain: {
1864
+ _id: true,
1865
+ name: true,
1866
+ description: true
1867
+ }
1868
+ }
1869
+ },
1870
+ loginMethods: true
1871
+ };
1872
+ try {
1873
+ const response = await client.query({
1874
+ validateUserCredentials: {
1875
+ __args: {
1876
+ username: curatedEmail,
1877
+ password: password
1878
+ },
1879
+ ...fields
1880
+ },
1881
+ });
1882
+ VTXBaseAPI.Logger.debug('validateUserCredentials Response:');
1883
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1884
+ retValue = (0, response_builder_1.buildResponse)(response, 'validateUserCredentials', (r) => {
1885
+ const isResponseOk = true && response?.validateUserCredentials?._id;
1886
+ return isResponseOk;
1887
+ });
1888
+ }
1889
+ catch (err1) {
1890
+ VTXBaseAPI.Logger.error('validateUserCredentials err1:');
1891
+ VTXBaseAPI.Logger.error(err1);
1892
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1893
+ }
1894
+ return retValue;
1895
+ }
1896
+ async findAthleteForUser(loginEmail) {
1897
+ const client = (0, client_1.createClient)({
1898
+ url: this.backendUrl + "/graphql",
1899
+ headers: this.headers,
1900
+ });
1901
+ let retValue = {};
1902
+ const fields = {
1903
+ _id: true,
1904
+ firstName: true,
1905
+ lastName: true,
1906
+ screenName: true,
1907
+ dob: true,
1908
+ lgbt: true,
1909
+ competitionGender: true,
1910
+ country: {
1911
+ _id: true,
1912
+ name: true
1913
+ },
1914
+ location: {
1915
+ userProvidedLatitude: true,
1916
+ userProvidedLongitude: true,
1917
+ cityNameGeocode: true,
1918
+ stateNameGeocode: true,
1919
+ countryIso2CodeGeocode: true,
1920
+ timeZoneGeocode: true,
1921
+ latitudeGeocode: true,
1922
+ longitudeGeocode: true,
1923
+ city: {
1924
+ _id: true,
1925
+ name: true,
1926
+ localizedName: true,
1927
+ state: {
1928
+ _id: true,
1929
+ name: true,
1930
+ country: {
1931
+ _id: true,
1932
+ name: true
1933
+ }
1934
+ },
1935
+ latitude: true,
1936
+ longitude: true,
1937
+ timezone: true,
1938
+ }
1939
+ },
1940
+ trainer: true,
1941
+ trainerUrl: true,
1942
+ aboutMe: true,
1943
+ followStats: {
1944
+ followers: true,
1945
+ followed: true,
1946
+ raves: true,
1947
+ favorites: true
1948
+ },
1949
+ mainSport: {
1950
+ _id: true,
1951
+ name: true
1952
+ },
1953
+ mainSportLevel: {
1954
+ _id: true,
1955
+ label: true,
1956
+ index: true
1957
+ },
1958
+ scores: {
1959
+ vtxScore: true,
1960
+ socialScore: true,
1961
+ trainingScore: true,
1962
+ competitionScore: true
1963
+ },
1964
+ rankings: {
1965
+ worldRanking: {
1966
+ scope: true,
1967
+ scopeId: true,
1968
+ scopeName: true,
1969
+ position: true,
1970
+ total: true
1971
+ },
1972
+ countryRanking: {
1973
+ scope: true,
1974
+ scopeId: true,
1975
+ scopeName: true,
1976
+ position: true,
1977
+ total: true
1978
+ },
1979
+ stateRanking: {
1980
+ scope: true,
1981
+ scopeId: true,
1982
+ scopeName: true,
1983
+ position: true,
1984
+ total: true
1985
+ },
1986
+ cityRanking: {
1987
+ scope: true,
1988
+ scopeId: true,
1989
+ scopeName: true,
1990
+ position: true,
1991
+ total: true
1992
+ },
1993
+ },
1994
+ allSports: {
1995
+ _id: true,
1996
+ name: true
1997
+ },
1998
+ teams: {
1999
+ _id: true,
2000
+ name: true,
2001
+ description: true,
2002
+ approved: true,
2003
+ logo: {
2004
+ _id: true,
2005
+ name: true,
2006
+ contentType: true,
2007
+ size: true,
2008
+ useType: true,
2009
+ url: true,
2010
+ key: true
2011
+ },
2012
+ banner: {
2013
+ _id: true,
2014
+ name: true,
2015
+ contentType: true,
2016
+ size: true,
2017
+ useType: true,
2018
+ url: true,
2019
+ key: true
2020
+ }
2021
+ },
2022
+ sponsorBrands: {
2023
+ _id: true,
2024
+ name: true,
2025
+ slogan: true,
2026
+ website: true,
2027
+ description: true,
2028
+ approved: true,
2029
+ published: true,
2030
+ logo: {
2031
+ _id: true,
2032
+ name: true,
2033
+ contentType: true,
2034
+ size: true,
2035
+ useType: true,
2036
+ url: true,
2037
+ key: true
2038
+ },
2039
+ stats: {
2040
+ campaigns: true,
2041
+ sponsorships: true,
2042
+ sports: true,
2043
+ athletes: true
2044
+ },
2045
+ operatorIds: true,
2046
+ },
2047
+ competitions: {
2048
+ _id: true,
2049
+ event: {
2050
+ _id: true,
2051
+ name: true,
2052
+ mainSport: {
2053
+ _id: true,
2054
+ name: true
2055
+ },
2056
+ eventWebSite: true,
2057
+ startDate: true,
2058
+ endDate: true,
2059
+ verified: true,
2060
+ location: {
2061
+ _id: true,
2062
+ userProvidedLatitude: true,
2063
+ userProvidedLongitude: true,
2064
+ cityNameGeocode: true,
2065
+ stateNameGeocode: true,
2066
+ countryIso2CodeGeocode: true,
2067
+ timeZoneGeocode: true,
2068
+ latitudeGeocode: true,
2069
+ longitudeGeocode: true,
2070
+ city: {
2071
+ _id: true,
2072
+ name: true,
2073
+ localizedName: true,
2074
+ state: {
2075
+ _id: true,
2076
+ name: true,
2077
+ country: {
2078
+ _id: true,
2079
+ name: true
2080
+ }
2081
+ },
2082
+ latitude: true,
2083
+ longitude: true,
2084
+ timezone: true,
2085
+ }
2086
+ },
2087
+ banner: {
2088
+ _id: true,
2089
+ name: true,
2090
+ contentType: true,
2091
+ size: true,
2092
+ useType: true,
2093
+ url: true,
2094
+ key: true
2095
+ }
2096
+ },
2097
+ participationDate: true,
2098
+ result: {
2099
+ _id: true,
2100
+ resultType: true,
2101
+ position: true,
2102
+ score: true,
2103
+ finishTimeMS: true,
2104
+ resultWebLink: true
2105
+ }
2106
+ },
2107
+ totalUpcomingCompetitions: true,
2108
+ totalPastCompetitions: true,
2109
+ profilePicture: {
2110
+ _id: true,
2111
+ name: true,
2112
+ contentType: true,
2113
+ size: true,
2114
+ useType: true,
2115
+ url: true,
2116
+ key: true
2117
+ },
2118
+ cardPicture: {
2119
+ _id: true,
2120
+ name: true,
2121
+ contentType: true,
2122
+ size: true,
2123
+ useType: true,
2124
+ url: true,
2125
+ key: true
2126
+ },
2127
+ preferences: {
2128
+ _id: true,
2129
+ showProfileHelper: true
2130
+ },
2131
+ currentCampaign: {
2132
+ _id: true,
2133
+ budgetMode: true,
2134
+ status: true,
2135
+ title: true,
2136
+ motivation: true,
2137
+ website: true,
2138
+ fundsRequired: true,
2139
+ initialFundsObtained: true,
2140
+ fundsObtained: true,
2141
+ location: {
2142
+ _id: true,
2143
+ userProvidedLatitude: true,
2144
+ userProvidedLongitude: true,
2145
+ cityNameGeocode: true,
2146
+ stateNameGeocode: true,
2147
+ countryIso2CodeGeocode: true,
2148
+ timeZoneGeocode: true,
2149
+ latitudeGeocode: true,
2150
+ longitudeGeocode: true,
2151
+ city: {
2152
+ _id: true,
2153
+ name: true,
2154
+ localizedName: true,
2155
+ state: {
2156
+ _id: true,
2157
+ name: true,
2158
+ country: {
2159
+ _id: true,
2160
+ name: true
2161
+ }
2162
+ },
2163
+ latitude: true,
2164
+ longitude: true,
2165
+ timezone: true,
2166
+ }
2167
+ },
2168
+ endingDate: true,
2169
+ budget: {
2170
+ _id: true,
2171
+ initialFunds: true,
2172
+ totalRequired: true,
2173
+ items: {
2174
+ _id: true,
2175
+ quantity: true,
2176
+ concept: true,
2177
+ itemCost: true
2178
+ }
2179
+ },
2180
+ competitions: {
2181
+ _id: true,
2182
+ event: {
2183
+ _id: true,
2184
+ name: true,
2185
+ mainSport: {
2186
+ _id: true,
2187
+ name: true
2188
+ },
2189
+ eventWebSite: true,
2190
+ startDate: true,
2191
+ endDate: true,
2192
+ verified: true,
2193
+ banner: {
2194
+ _id: true,
2195
+ name: true,
2196
+ contentType: true,
2197
+ size: true,
2198
+ useType: true,
2199
+ url: true,
2200
+ key: true
2201
+ },
2202
+ location: {
2203
+ _id: true,
2204
+ userProvidedLatitude: true,
2205
+ userProvidedLongitude: true,
2206
+ cityNameGeocode: true,
2207
+ stateNameGeocode: true,
2208
+ countryIso2CodeGeocode: true,
2209
+ timeZoneGeocode: true,
2210
+ latitudeGeocode: true,
2211
+ longitudeGeocode: true,
2212
+ city: {
2213
+ _id: true,
2214
+ name: true,
2215
+ localizedName: true,
2216
+ state: {
2217
+ _id: true,
2218
+ name: true,
2219
+ country: {
2220
+ _id: true,
2221
+ name: true
2222
+ }
2223
+ },
2224
+ latitude: true,
2225
+ longitude: true,
2226
+ timezone: true,
2227
+ }
2228
+ },
2229
+ },
2230
+ participationDate: true,
2231
+ result: {
2232
+ _id: true,
2233
+ resultType: true,
2234
+ position: true,
2235
+ score: true,
2236
+ finishTimeMS: true,
2237
+ resultWebLink: true
2238
+ }
2239
+ }
2240
+ }
2241
+ };
2242
+ try {
2243
+ let response = null;
2244
+ response = await client.query({
2245
+ findAthleteForUser: {
2246
+ __args: {
2247
+ loginEmail: loginEmail
2248
+ },
2249
+ ...fields
2250
+ }
2251
+ });
2252
+ VTXBaseAPI.Logger.debug('findAthleteForUser Response:');
2253
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
2254
+ retValue = (0, response_builder_1.buildResponse)(response, 'findAthleteForUser', (r) => {
2255
+ const isResponseOk = true && response?.findAthleteForUser?._id;
2256
+ return isResponseOk;
2257
+ });
2258
+ }
2259
+ catch (err1) {
2260
+ VTXBaseAPI.Logger.error('findAthleteForUser err1:');
2261
+ VTXBaseAPI.Logger.error(err1);
2262
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
2263
+ }
2264
+ return retValue;
2265
+ }
2266
+ async getBrands() {
2267
+ const client = (0, client_1.createClient)({
2268
+ url: this.backendUrl + "/graphql",
2269
+ headers: this.headers,
2270
+ });
2271
+ const fields = {
2272
+ _id: true,
2273
+ name: true,
2274
+ slogan: true,
2275
+ website: true,
2276
+ description: true,
2277
+ approved: true,
2278
+ published: true,
2279
+ logo: {
2280
+ _id: true,
2281
+ name: true,
2282
+ contentType: true,
2283
+ size: true,
2284
+ useType: true,
2285
+ url: true,
2286
+ key: true
2287
+ },
2288
+ banner: {
2289
+ _id: true,
2290
+ name: true,
2291
+ contentType: true,
2292
+ size: true,
2293
+ useType: true,
2294
+ url: true,
2295
+ key: true
2296
+ },
2297
+ stats: {
2298
+ campaigns: true,
2299
+ sponsorships: true,
2300
+ sports: true,
2301
+ athletes: true
2302
+ },
2303
+ operatorIds: true
2304
+ };
2305
+ let retValue;
2306
+ try {
2307
+ const response = await client.query({
2308
+ brands: {
2309
+ __args: {},
2310
+ ...fields
2311
+ }
2312
+ });
2313
+ VTXBaseAPI.Logger.debug('brands Response:');
2314
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
2315
+ retValue = (0, response_builder_1.buildResponse)(response, 'brands', (r) => {
2316
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
2317
+ const isResponseOk = true && Array.isArray(response?.brands);
2318
+ return isResponseOk;
2319
+ });
2320
+ }
2321
+ catch (err1) {
2322
+ VTXBaseAPI.Logger.error('brands err1:');
2323
+ VTXBaseAPI.Logger.error(err1);
2324
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
2325
+ }
2326
+ return retValue;
2327
+ }
2328
+ async getAthletes() {
2329
+ const client = (0, client_1.createClient)({
2330
+ url: this.backendUrl + "/graphql",
2331
+ headers: this.headers,
2332
+ });
2333
+ const fields = {
2334
+ _id: true,
2335
+ firstName: true,
2336
+ lastName: true,
2337
+ screenName: true,
2338
+ dob: true,
2339
+ lgbt: true,
2340
+ competitionGender: true,
2341
+ country: {
2342
+ _id: true,
2343
+ name: true
2344
+ },
2345
+ location: {
2346
+ userProvidedLatitude: true,
2347
+ userProvidedLongitude: true,
2348
+ cityNameGeocode: true,
2349
+ stateNameGeocode: true,
2350
+ countryIso2CodeGeocode: true,
2351
+ timeZoneGeocode: true,
2352
+ latitudeGeocode: true,
2353
+ longitudeGeocode: true,
2354
+ city: {
2355
+ _id: true,
2356
+ name: true,
2357
+ localizedName: true,
2358
+ state: {
2359
+ _id: true,
2360
+ name: true,
2361
+ country: {
2362
+ _id: true,
2363
+ name: true
2364
+ }
2365
+ },
2366
+ latitude: true,
2367
+ longitude: true,
2368
+ timezone: true,
2369
+ }
2370
+ },
2371
+ trainer: true,
2372
+ trainerUrl: true,
2373
+ aboutMe: true,
2374
+ followStats: {
2375
+ followers: true,
2376
+ followed: true,
2377
+ raves: true,
2378
+ favorites: true
2379
+ },
2380
+ mainSport: {
2381
+ _id: true,
2382
+ name: true
2383
+ },
2384
+ mainSportLevel: {
2385
+ _id: true,
2386
+ label: true,
2387
+ index: true
2388
+ },
2389
+ scores: {
2390
+ vtxScore: true,
2391
+ socialScore: true,
2392
+ trainingScore: true,
2393
+ competitionScore: true
2394
+ },
2395
+ rankings: {
2396
+ worldRanking: {
2397
+ scope: true,
2398
+ scopeId: true,
2399
+ scopeName: true,
2400
+ position: true,
2401
+ total: true
2402
+ },
2403
+ countryRanking: {
2404
+ scope: true,
2405
+ scopeId: true,
2406
+ scopeName: true,
2407
+ position: true,
2408
+ total: true
2409
+ },
2410
+ stateRanking: {
2411
+ scope: true,
2412
+ scopeId: true,
2413
+ scopeName: true,
2414
+ position: true,
2415
+ total: true
2416
+ },
2417
+ cityRanking: {
2418
+ scope: true,
2419
+ scopeId: true,
2420
+ scopeName: true,
2421
+ position: true,
2422
+ total: true
2423
+ },
2424
+ },
2425
+ allSports: {
2426
+ _id: true,
2427
+ name: true
2428
+ },
2429
+ teams: {
2430
+ _id: true,
2431
+ name: true,
2432
+ description: true,
2433
+ approved: true,
2434
+ logo: {
2435
+ _id: true,
2436
+ name: true,
2437
+ contentType: true,
2438
+ size: true,
2439
+ useType: true,
2440
+ url: true,
2441
+ key: true
2442
+ },
2443
+ banner: {
2444
+ _id: true,
2445
+ name: true,
2446
+ contentType: true,
2447
+ size: true,
2448
+ useType: true,
2449
+ url: true,
2450
+ key: true
2451
+ }
2452
+ },
2453
+ sponsorBrands: {
2454
+ _id: true,
2455
+ name: true,
2456
+ slogan: true,
2457
+ website: true,
2458
+ description: true,
2459
+ approved: true,
2460
+ published: true,
2461
+ logo: {
2462
+ _id: true,
2463
+ name: true,
2464
+ contentType: true,
2465
+ size: true,
2466
+ useType: true,
2467
+ url: true,
2468
+ key: true
2469
+ },
2470
+ stats: {
2471
+ campaigns: true,
2472
+ sponsorships: true,
2473
+ sports: true,
2474
+ athletes: true
2475
+ },
2476
+ operatorIds: true,
2477
+ },
2478
+ competitions: {
2479
+ _id: true,
2480
+ event: {
2481
+ _id: true,
2482
+ name: true,
2483
+ mainSport: {
2484
+ _id: true,
2485
+ name: true
2486
+ },
2487
+ eventWebSite: true,
2488
+ startDate: true,
2489
+ endDate: true,
2490
+ verified: true,
2491
+ banner: {
2492
+ _id: true,
2493
+ name: true,
2494
+ contentType: true,
2495
+ size: true,
2496
+ useType: true,
2497
+ url: true,
2498
+ key: true
2499
+ },
2500
+ location: {
2501
+ _id: true,
2502
+ userProvidedLatitude: true,
2503
+ userProvidedLongitude: true,
2504
+ cityNameGeocode: true,
2505
+ stateNameGeocode: true,
2506
+ countryIso2CodeGeocode: true,
2507
+ timeZoneGeocode: true,
2508
+ latitudeGeocode: true,
2509
+ longitudeGeocode: true,
2510
+ city: {
2511
+ _id: true,
2512
+ name: true,
2513
+ localizedName: true,
2514
+ state: {
2515
+ _id: true,
2516
+ name: true,
2517
+ country: {
2518
+ _id: true,
2519
+ name: true
2520
+ }
2521
+ },
2522
+ latitude: true,
2523
+ longitude: true,
2524
+ timezone: true,
2525
+ }
2526
+ },
2527
+ },
2528
+ participationDate: true,
2529
+ result: {
2530
+ _id: true,
2531
+ resultType: true,
2532
+ position: true,
2533
+ score: true,
2534
+ finishTimeMS: true,
2535
+ resultWebLink: true
2536
+ }
2537
+ },
2538
+ totalUpcomingCompetitions: true,
2539
+ totalPastCompetitions: true,
2540
+ profilePicture: {
2541
+ _id: true,
2542
+ name: true,
2543
+ contentType: true,
2544
+ size: true,
2545
+ useType: true,
2546
+ url: true,
2547
+ key: true
2548
+ },
2549
+ cardPicture: {
2550
+ _id: true,
2551
+ name: true,
2552
+ contentType: true,
2553
+ size: true,
2554
+ useType: true,
2555
+ url: true,
2556
+ key: true
2557
+ },
2558
+ preferences: {
2559
+ _id: true,
2560
+ showProfileHelper: true
2561
+ }
2562
+ };
2563
+ let retValue;
2564
+ try {
2565
+ const response = await client.query({
2566
+ getAthletes: {
2567
+ __args: {},
2568
+ ...fields
2569
+ }
2570
+ });
2571
+ VTXBaseAPI.Logger.debug('getAthletes Response:');
2572
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
2573
+ retValue = (0, response_builder_1.buildResponse)(response, 'getAthletes', (r) => {
2574
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
2575
+ const isResponseOk = true && Array.isArray(response?.getAthletes);
2576
+ return isResponseOk;
2577
+ });
2578
+ }
2579
+ catch (err1) {
2580
+ VTXBaseAPI.Logger.error('getAthletes err1:');
2581
+ VTXBaseAPI.Logger.error(err1);
2582
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
2583
+ }
2584
+ return retValue;
2585
+ }
2586
+ async searchAthletes(searchString) {
2587
+ const client = (0, client_1.createClient)({
2588
+ url: this.backendUrl + "/graphql",
2589
+ headers: this.headers,
2590
+ });
2591
+ const fields = {
2592
+ _id: true,
2593
+ firstName: true,
2594
+ lastName: true,
2595
+ screenName: true,
2596
+ dob: true,
2597
+ lgbt: true,
2598
+ competitionGender: true,
2599
+ country: {
2600
+ _id: true,
2601
+ name: true
2602
+ },
2603
+ location: {
2604
+ userProvidedLatitude: true,
2605
+ userProvidedLongitude: true,
2606
+ cityNameGeocode: true,
2607
+ stateNameGeocode: true,
2608
+ countryIso2CodeGeocode: true,
2609
+ timeZoneGeocode: true,
2610
+ latitudeGeocode: true,
2611
+ longitudeGeocode: true,
2612
+ city: {
2613
+ _id: true,
2614
+ name: true,
2615
+ localizedName: true,
2616
+ state: {
2617
+ _id: true,
2618
+ name: true,
2619
+ country: {
2620
+ _id: true,
2621
+ name: true
2622
+ }
2623
+ },
2624
+ latitude: true,
2625
+ longitude: true,
2626
+ timezone: true,
2627
+ }
2628
+ },
2629
+ trainer: true,
2630
+ trainerUrl: true,
2631
+ aboutMe: true,
2632
+ followStats: {
2633
+ followers: true,
2634
+ followed: true,
2635
+ raves: true,
2636
+ favorites: true
2637
+ },
2638
+ mainSport: {
2639
+ _id: true,
2640
+ name: true
2641
+ },
2642
+ mainSportLevel: {
2643
+ _id: true,
2644
+ label: true,
2645
+ index: true
2646
+ },
2647
+ scores: {
2648
+ vtxScore: true,
2649
+ socialScore: true,
2650
+ trainingScore: true,
2651
+ competitionScore: true
2652
+ },
2653
+ rankings: {
2654
+ worldRanking: {
2655
+ scope: true,
2656
+ scopeId: true,
2657
+ scopeName: true,
2658
+ position: true,
2659
+ total: true
2660
+ },
2661
+ countryRanking: {
2662
+ scope: true,
2663
+ scopeId: true,
2664
+ scopeName: true,
2665
+ position: true,
2666
+ total: true
2667
+ },
2668
+ stateRanking: {
2669
+ scope: true,
2670
+ scopeId: true,
2671
+ scopeName: true,
2672
+ position: true,
2673
+ total: true
2674
+ },
2675
+ cityRanking: {
2676
+ scope: true,
2677
+ scopeId: true,
2678
+ scopeName: true,
2679
+ position: true,
2680
+ total: true
2681
+ },
2682
+ },
2683
+ allSports: {
2684
+ _id: true,
2685
+ name: true
2686
+ },
2687
+ teams: {
2688
+ _id: true,
2689
+ name: true,
2690
+ description: true,
2691
+ approved: true,
2692
+ logo: {
2693
+ _id: true,
2694
+ name: true,
2695
+ contentType: true,
2696
+ size: true,
2697
+ useType: true,
2698
+ url: true,
2699
+ key: true
2700
+ },
2701
+ banner: {
2702
+ _id: true,
2703
+ name: true,
2704
+ contentType: true,
2705
+ size: true,
2706
+ useType: true,
2707
+ url: true,
2708
+ key: true
2709
+ }
2710
+ },
2711
+ sponsorBrands: {
2712
+ _id: true,
2713
+ name: true,
2714
+ slogan: true,
2715
+ website: true,
2716
+ description: true,
2717
+ approved: true,
2718
+ published: true,
2719
+ logo: {
2720
+ _id: true,
2721
+ name: true,
2722
+ contentType: true,
2723
+ size: true,
2724
+ useType: true,
2725
+ url: true,
2726
+ key: true
2727
+ },
2728
+ stats: {
2729
+ campaigns: true,
2730
+ sponsorships: true,
2731
+ sports: true,
2732
+ athletes: true
2733
+ },
2734
+ operatorIds: true,
2735
+ },
2736
+ competitions: {
2737
+ _id: true,
2738
+ event: {
2739
+ _id: true,
2740
+ name: true,
2741
+ mainSport: {
2742
+ _id: true,
2743
+ name: true
2744
+ },
2745
+ eventWebSite: true,
2746
+ startDate: true,
2747
+ endDate: true,
2748
+ verified: true,
2749
+ banner: {
2750
+ _id: true,
2751
+ name: true,
2752
+ contentType: true,
2753
+ size: true,
2754
+ useType: true,
2755
+ url: true,
2756
+ key: true
2757
+ },
2758
+ location: {
2759
+ _id: true,
2760
+ userProvidedLatitude: true,
2761
+ userProvidedLongitude: true,
2762
+ cityNameGeocode: true,
2763
+ stateNameGeocode: true,
2764
+ countryIso2CodeGeocode: true,
2765
+ timeZoneGeocode: true,
2766
+ latitudeGeocode: true,
2767
+ longitudeGeocode: true,
2768
+ city: {
2769
+ _id: true,
2770
+ name: true,
2771
+ localizedName: true,
2772
+ state: {
2773
+ _id: true,
2774
+ name: true,
2775
+ country: {
2776
+ _id: true,
2777
+ name: true
2778
+ }
2779
+ },
2780
+ latitude: true,
2781
+ longitude: true,
2782
+ timezone: true,
2783
+ }
2784
+ },
2785
+ },
2786
+ participationDate: true,
2787
+ result: {
2788
+ _id: true,
2789
+ resultType: true,
2790
+ position: true,
2791
+ score: true,
2792
+ finishTimeMS: true,
2793
+ resultWebLink: true
2794
+ }
2795
+ },
2796
+ totalUpcomingCompetitions: true,
2797
+ totalPastCompetitions: true,
2798
+ profilePicture: {
2799
+ _id: true,
2800
+ name: true,
2801
+ contentType: true,
2802
+ size: true,
2803
+ useType: true,
2804
+ url: true,
2805
+ key: true
2806
+ },
2807
+ cardPicture: {
2808
+ _id: true,
2809
+ name: true,
2810
+ contentType: true,
2811
+ size: true,
2812
+ useType: true,
2813
+ url: true,
2814
+ key: true
2815
+ },
2816
+ preferences: {
2817
+ _id: true,
2818
+ showProfileHelper: true
2819
+ }
2820
+ };
2821
+ let retValue;
2822
+ try {
2823
+ const response = await client.query({
2824
+ searchAthletes: {
2825
+ __args: {
2826
+ searchString: searchString
2827
+ },
2828
+ ...fields
2829
+ }
2830
+ });
2831
+ VTXBaseAPI.Logger.debug('searchAthletes Response:');
2832
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
2833
+ retValue = (0, response_builder_1.buildResponse)(response, 'searchAthletes', (r) => {
2834
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
2835
+ const isResponseOk = true && Array.isArray(response?.searchAthletes);
2836
+ return isResponseOk;
2837
+ });
2838
+ }
2839
+ catch (err1) {
2840
+ VTXBaseAPI.Logger.error('searchAthletes err1:');
2841
+ VTXBaseAPI.Logger.error(err1);
2842
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
2843
+ }
2844
+ return retValue;
2845
+ }
2846
+ async getRecommendedAthletes(loginEmail) {
2847
+ const client = (0, client_1.createClient)({
2848
+ url: this.backendUrl + "/graphql",
2849
+ headers: this.headers,
2850
+ });
2851
+ const fields = {
2852
+ _id: true,
2853
+ firstName: true,
2854
+ lastName: true,
2855
+ screenName: true,
2856
+ dob: true,
2857
+ lgbt: true,
2858
+ competitionGender: true,
2859
+ country: {
2860
+ _id: true,
2861
+ name: true
2862
+ },
2863
+ location: {
2864
+ userProvidedLatitude: true,
2865
+ userProvidedLongitude: true,
2866
+ cityNameGeocode: true,
2867
+ stateNameGeocode: true,
2868
+ countryIso2CodeGeocode: true,
2869
+ timeZoneGeocode: true,
2870
+ latitudeGeocode: true,
2871
+ longitudeGeocode: true,
2872
+ city: {
2873
+ _id: true,
2874
+ name: true,
2875
+ localizedName: true,
2876
+ state: {
2877
+ _id: true,
2878
+ name: true,
2879
+ country: {
2880
+ _id: true,
2881
+ name: true
2882
+ }
2883
+ },
2884
+ latitude: true,
2885
+ longitude: true,
2886
+ timezone: true,
2887
+ }
2888
+ },
2889
+ trainer: true,
2890
+ trainerUrl: true,
2891
+ aboutMe: true,
2892
+ followStats: {
2893
+ followers: true,
2894
+ followed: true,
2895
+ raves: true,
2896
+ favorites: true
2897
+ },
2898
+ mainSport: {
2899
+ _id: true,
2900
+ name: true
2901
+ },
2902
+ mainSportLevel: {
2903
+ _id: true,
2904
+ label: true,
2905
+ index: true
2906
+ },
2907
+ scores: {
2908
+ vtxScore: true,
2909
+ socialScore: true,
2910
+ trainingScore: true,
2911
+ competitionScore: true
2912
+ },
2913
+ rankings: {
2914
+ worldRanking: {
2915
+ scope: true,
2916
+ scopeId: true,
2917
+ scopeName: true,
2918
+ position: true,
2919
+ total: true
2920
+ },
2921
+ countryRanking: {
2922
+ scope: true,
2923
+ scopeId: true,
2924
+ scopeName: true,
2925
+ position: true,
2926
+ total: true
2927
+ },
2928
+ stateRanking: {
2929
+ scope: true,
2930
+ scopeId: true,
2931
+ scopeName: true,
2932
+ position: true,
2933
+ total: true
2934
+ },
2935
+ cityRanking: {
2936
+ scope: true,
2937
+ scopeId: true,
2938
+ scopeName: true,
2939
+ position: true,
2940
+ total: true
2941
+ },
2942
+ },
2943
+ allSports: {
2944
+ _id: true,
2945
+ name: true
2946
+ },
2947
+ teams: {
2948
+ _id: true,
2949
+ name: true,
2950
+ description: true,
2951
+ approved: true,
2952
+ logo: {
2953
+ _id: true,
2954
+ name: true,
2955
+ contentType: true,
2956
+ size: true,
2957
+ useType: true,
2958
+ url: true,
2959
+ key: true
2960
+ },
2961
+ banner: {
2962
+ _id: true,
2963
+ name: true,
2964
+ contentType: true,
2965
+ size: true,
2966
+ useType: true,
2967
+ url: true,
2968
+ key: true
2969
+ }
2970
+ },
2971
+ sponsorBrands: {
2972
+ _id: true,
2973
+ name: true,
2974
+ slogan: true,
2975
+ website: true,
2976
+ description: true,
2977
+ approved: true,
2978
+ published: true,
2979
+ logo: {
2980
+ _id: true,
2981
+ name: true,
2982
+ contentType: true,
2983
+ size: true,
2984
+ useType: true,
2985
+ url: true,
2986
+ key: true
2987
+ },
2988
+ stats: {
2989
+ campaigns: true,
2990
+ sponsorships: true,
2991
+ sports: true,
2992
+ athletes: true
2993
+ },
2994
+ operatorIds: true,
2995
+ },
2996
+ competitions: {
2997
+ _id: true,
2998
+ event: {
2999
+ _id: true,
3000
+ name: true,
3001
+ mainSport: {
3002
+ _id: true,
3003
+ name: true
3004
+ },
3005
+ eventWebSite: true,
3006
+ startDate: true,
3007
+ endDate: true,
3008
+ verified: true,
3009
+ banner: {
3010
+ _id: true,
3011
+ name: true,
3012
+ contentType: true,
3013
+ size: true,
3014
+ useType: true,
3015
+ url: true,
3016
+ key: true
3017
+ },
3018
+ location: {
3019
+ _id: true,
3020
+ userProvidedLatitude: true,
3021
+ userProvidedLongitude: true,
3022
+ cityNameGeocode: true,
3023
+ stateNameGeocode: true,
3024
+ countryIso2CodeGeocode: true,
3025
+ timeZoneGeocode: true,
3026
+ latitudeGeocode: true,
3027
+ longitudeGeocode: true,
3028
+ city: {
3029
+ _id: true,
3030
+ name: true,
3031
+ localizedName: true,
3032
+ state: {
3033
+ _id: true,
3034
+ name: true,
3035
+ country: {
3036
+ _id: true,
3037
+ name: true
3038
+ }
3039
+ },
3040
+ latitude: true,
3041
+ longitude: true,
3042
+ timezone: true,
3043
+ }
3044
+ },
3045
+ },
3046
+ participationDate: true,
3047
+ result: {
3048
+ _id: true,
3049
+ resultType: true,
3050
+ position: true,
3051
+ score: true,
3052
+ finishTimeMS: true,
3053
+ resultWebLink: true
3054
+ }
3055
+ },
3056
+ totalUpcomingCompetitions: true,
3057
+ totalPastCompetitions: true,
3058
+ profilePicture: {
3059
+ _id: true,
3060
+ name: true,
3061
+ contentType: true,
3062
+ size: true,
3063
+ useType: true,
3064
+ url: true,
3065
+ key: true
3066
+ },
3067
+ cardPicture: {
3068
+ _id: true,
3069
+ name: true,
3070
+ contentType: true,
3071
+ size: true,
3072
+ useType: true,
3073
+ url: true,
3074
+ key: true
3075
+ },
3076
+ preferences: {
3077
+ _id: true,
3078
+ showProfileHelper: true
3079
+ }
3080
+ };
3081
+ let retValue;
3082
+ try {
3083
+ const response = await client.query({
3084
+ getRecommendedAthletes: {
3085
+ __args: {
3086
+ loginEmail: loginEmail
3087
+ },
3088
+ ...fields
3089
+ }
3090
+ });
3091
+ VTXBaseAPI.Logger.debug('getRecommendedAthletes Response:');
3092
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
3093
+ retValue = (0, response_builder_1.buildResponse)(response, 'getRecommendedAthletes', (r) => {
3094
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
3095
+ const isResponseOk = true && Array.isArray(response?.getRecommendedAthletes);
3096
+ return isResponseOk;
3097
+ });
3098
+ }
3099
+ catch (err1) {
3100
+ VTXBaseAPI.Logger.error('getRecommendedAthletes err1:');
3101
+ VTXBaseAPI.Logger.error(err1);
3102
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
3103
+ }
3104
+ return retValue;
3105
+ }
3106
+ async getSponsorAthletesForTenant() {
3107
+ const client = (0, client_1.createClient)({
3108
+ url: this.backendUrl + "/graphql",
3109
+ headers: this.headers,
3110
+ });
3111
+ const fields = {
3112
+ _id: true,
3113
+ firstName: true,
3114
+ lastName: true,
3115
+ screenName: true,
3116
+ dob: true,
3117
+ lgbt: true,
3118
+ competitionGender: true,
3119
+ country: {
3120
+ _id: true,
3121
+ name: true
3122
+ },
3123
+ location: {
3124
+ userProvidedLatitude: true,
3125
+ userProvidedLongitude: true,
3126
+ cityNameGeocode: true,
3127
+ stateNameGeocode: true,
3128
+ countryIso2CodeGeocode: true,
3129
+ timeZoneGeocode: true,
3130
+ latitudeGeocode: true,
3131
+ longitudeGeocode: true,
3132
+ city: {
3133
+ _id: true,
3134
+ name: true,
3135
+ localizedName: true,
3136
+ state: {
3137
+ _id: true,
3138
+ name: true,
3139
+ country: {
3140
+ _id: true,
3141
+ name: true
3142
+ }
3143
+ },
3144
+ latitude: true,
3145
+ longitude: true,
3146
+ timezone: true,
3147
+ }
3148
+ },
3149
+ trainer: true,
3150
+ trainerUrl: true,
3151
+ aboutMe: true,
3152
+ followStats: {
3153
+ followers: true,
3154
+ followed: true,
3155
+ raves: true,
3156
+ favorites: true
3157
+ },
3158
+ mainSport: {
3159
+ _id: true,
3160
+ name: true
3161
+ },
3162
+ mainSportLevel: {
3163
+ _id: true,
3164
+ label: true,
3165
+ index: true
3166
+ },
3167
+ scores: {
3168
+ vtxScore: true,
3169
+ socialScore: true,
3170
+ trainingScore: true,
3171
+ competitionScore: true
3172
+ },
3173
+ rankings: {
3174
+ worldRanking: {
3175
+ scope: true,
3176
+ scopeId: true,
3177
+ scopeName: true,
3178
+ position: true,
3179
+ total: true
3180
+ },
3181
+ countryRanking: {
3182
+ scope: true,
3183
+ scopeId: true,
3184
+ scopeName: true,
3185
+ position: true,
3186
+ total: true
3187
+ },
3188
+ stateRanking: {
3189
+ scope: true,
3190
+ scopeId: true,
3191
+ scopeName: true,
3192
+ position: true,
3193
+ total: true
3194
+ },
3195
+ cityRanking: {
3196
+ scope: true,
3197
+ scopeId: true,
3198
+ scopeName: true,
3199
+ position: true,
3200
+ total: true
3201
+ },
3202
+ },
3203
+ allSports: {
3204
+ _id: true,
3205
+ name: true
3206
+ },
3207
+ teams: {
3208
+ _id: true,
3209
+ name: true,
3210
+ description: true,
3211
+ approved: true,
3212
+ logo: {
3213
+ _id: true,
3214
+ name: true,
3215
+ contentType: true,
3216
+ size: true,
3217
+ useType: true,
3218
+ url: true,
3219
+ key: true
3220
+ },
3221
+ banner: {
3222
+ _id: true,
3223
+ name: true,
3224
+ contentType: true,
3225
+ size: true,
3226
+ useType: true,
3227
+ url: true,
3228
+ key: true
3229
+ }
3230
+ },
3231
+ sponsorBrands: {
3232
+ _id: true,
3233
+ name: true,
3234
+ slogan: true,
3235
+ website: true,
3236
+ description: true,
3237
+ approved: true,
3238
+ published: true,
3239
+ logo: {
3240
+ _id: true,
3241
+ name: true,
3242
+ contentType: true,
3243
+ size: true,
3244
+ useType: true,
3245
+ url: true,
3246
+ key: true
3247
+ },
3248
+ stats: {
3249
+ campaigns: true,
3250
+ sponsorships: true,
3251
+ sports: true,
3252
+ athletes: true
3253
+ },
3254
+ operatorIds: true,
3255
+ },
3256
+ competitions: {
3257
+ _id: true,
3258
+ event: {
3259
+ _id: true,
3260
+ name: true,
3261
+ mainSport: {
3262
+ _id: true,
3263
+ name: true
3264
+ },
3265
+ eventWebSite: true,
3266
+ startDate: true,
3267
+ endDate: true,
3268
+ verified: true,
3269
+ banner: {
3270
+ _id: true,
3271
+ name: true,
3272
+ contentType: true,
3273
+ size: true,
3274
+ useType: true,
3275
+ url: true,
3276
+ key: true
3277
+ },
3278
+ location: {
3279
+ _id: true,
3280
+ userProvidedLatitude: true,
3281
+ userProvidedLongitude: true,
3282
+ cityNameGeocode: true,
3283
+ stateNameGeocode: true,
3284
+ countryIso2CodeGeocode: true,
3285
+ timeZoneGeocode: true,
3286
+ latitudeGeocode: true,
3287
+ longitudeGeocode: true,
3288
+ city: {
3289
+ _id: true,
3290
+ name: true,
3291
+ localizedName: true,
3292
+ state: {
3293
+ _id: true,
3294
+ name: true,
3295
+ country: {
3296
+ _id: true,
3297
+ name: true
3298
+ }
3299
+ },
3300
+ latitude: true,
3301
+ longitude: true,
3302
+ timezone: true,
3303
+ }
3304
+ },
3305
+ },
3306
+ participationDate: true,
3307
+ result: {
3308
+ _id: true,
3309
+ resultType: true,
3310
+ position: true,
3311
+ score: true,
3312
+ finishTimeMS: true,
3313
+ resultWebLink: true
3314
+ }
3315
+ },
3316
+ totalUpcomingCompetitions: true,
3317
+ totalPastCompetitions: true,
3318
+ profilePicture: {
3319
+ _id: true,
3320
+ name: true,
3321
+ contentType: true,
3322
+ size: true,
3323
+ useType: true,
3324
+ url: true,
3325
+ key: true
3326
+ },
3327
+ cardPicture: {
3328
+ _id: true,
3329
+ name: true,
3330
+ contentType: true,
3331
+ size: true,
3332
+ useType: true,
3333
+ url: true,
3334
+ key: true
3335
+ },
3336
+ preferences: {
3337
+ _id: true,
3338
+ showProfileHelper: true
3339
+ }
3340
+ };
3341
+ let retValue;
3342
+ try {
3343
+ const response = await client.query({
3344
+ getSponsorAthletesForTenant: {
3345
+ __args: {},
3346
+ ...fields
3347
+ }
3348
+ });
3349
+ VTXBaseAPI.Logger.debug('getSponsorAthletesForTenant Response:');
3350
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
3351
+ retValue = (0, response_builder_1.buildResponse)(response, 'getSponsorAthletesForTenant', (r) => {
3352
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
3353
+ const isResponseOk = true && Array.isArray(response?.getSponsorAthletesForTenant);
3354
+ return isResponseOk;
3355
+ });
3356
+ }
3357
+ catch (err1) {
3358
+ VTXBaseAPI.Logger.error('getSponsorAthletesForTenant err1:');
3359
+ VTXBaseAPI.Logger.error(err1);
3360
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
3361
+ }
3362
+ return retValue;
3363
+ }
3364
+ async getUserImagesFromEmail(loginEmail) {
3365
+ const client = (0, client_1.createClient)({
3366
+ url: this.backendUrl + "/graphql",
3367
+ headers: this.headers,
3368
+ });
3369
+ const fields = {
3370
+ profilePictureUrl: true,
3371
+ cardPictureUrl: true,
3372
+ bannerPictureUrl: true
3373
+ };
3374
+ let retValue;
3375
+ try {
3376
+ const response = await client.query({
3377
+ getUserImagesFromEmail: {
3378
+ __args: {
3379
+ loginEmail: loginEmail
3380
+ },
3381
+ ...fields
3382
+ }
3383
+ });
3384
+ VTXBaseAPI.Logger.debug('getUserImagesFromEmail Response:');
3385
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
3386
+ retValue = (0, response_builder_1.buildResponse)(response, 'getUserImagesFromEmail', (r) => {
3387
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
3388
+ const isResponseOk = true && response?.getUserImagesFromEmail;
3389
+ return isResponseOk;
3390
+ });
3391
+ }
3392
+ catch (err1) {
3393
+ VTXBaseAPI.Logger.error('getUserImagesFromEmail err1:');
3394
+ VTXBaseAPI.Logger.error(err1);
3395
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
3396
+ }
3397
+ return retValue;
3398
+ }
3399
+ async editAboutMe(newValue) {
3400
+ console.log('HEADERS:');
3401
+ console.log(JSON.stringify(this.headers, null, 2));
3402
+ const client = (0, client_1.createClient)({
3403
+ url: this.backendUrl + '/graphql',
3404
+ headers: this.headers,
3405
+ });
3406
+ let retValue = {};
3407
+ const fields = {
3408
+ field: true,
3409
+ oldValue: true,
3410
+ newValue: true,
3411
+ changed: true
3412
+ };
3413
+ const dto = {
3414
+ field: 'aboutMe',
3415
+ newValue: newValue
3416
+ };
3417
+ try {
3418
+ const response = await client.mutation({
3419
+ editProfileValue: {
3420
+ __args: {
3421
+ input: dto
3422
+ },
3423
+ ...fields
3424
+ },
3425
+ });
3426
+ VTXBaseAPI.Logger.debug('editProfileValue Response:');
3427
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
3428
+ retValue = (0, response_builder_1.buildResponse)(response, 'editProfileValue', (r) => {
3429
+ const isResponseOk = true && response?.editProfileValue?.field;
3430
+ return isResponseOk;
3431
+ });
3432
+ }
3433
+ catch (err1) {
3434
+ VTXBaseAPI.Logger.error('editProfileValue err1:');
3435
+ VTXBaseAPI.Logger.error(err1);
3436
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
3437
+ }
3438
+ return retValue;
3439
+ }
3440
+ async editProfileValue(newValue, field) {
3441
+ const client = (0, client_1.createClient)({
3442
+ url: this.backendUrl + '/graphql',
3443
+ headers: this.headers,
3444
+ });
3445
+ let retValue = {};
3446
+ const fields = {
3447
+ field: true,
3448
+ oldValue: true,
3449
+ newValue: true,
3450
+ changed: true
3451
+ };
3452
+ const dto = {
3453
+ field: field,
3454
+ newValue: newValue
3455
+ };
3456
+ try {
3457
+ const response = await client.mutation({
3458
+ editProfileValue: {
3459
+ __args: {
3460
+ input: dto
3461
+ },
3462
+ ...fields
3463
+ },
3464
+ });
3465
+ VTXBaseAPI.Logger.debug('editProfileValue Response:');
3466
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
3467
+ retValue = (0, response_builder_1.buildResponse)(response, 'editProfileValue', (r) => {
3468
+ const isResponseOk = true && response?.editProfileValue?.field;
3469
+ return isResponseOk;
3470
+ });
3471
+ }
3472
+ catch (err1) {
3473
+ VTXBaseAPI.Logger.error('editProfileValue err1:');
3474
+ VTXBaseAPI.Logger.error(err1);
3475
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
3476
+ }
3477
+ return retValue;
3478
+ }
3479
+ async addAthleteCompetition(dto) {
3480
+ console.log('HEADERS:');
3481
+ console.log(JSON.stringify(this.headers, null, 2));
3482
+ const client = (0, client_1.createClient)({
3483
+ url: this.backendUrl + '/graphql',
3484
+ headers: this.headers,
3485
+ });
3486
+ let retValue = {};
3487
+ const fields = {
3488
+ _id: true,
3489
+ event: {
3490
+ _id: true,
3491
+ name: true,
3492
+ mainSport: {
3493
+ _id: true,
3494
+ name: true
3495
+ },
3496
+ eventWebSite: true,
3497
+ startDate: true,
3498
+ endDate: true,
3499
+ verified: true,
3500
+ banner: {
3501
+ _id: true,
3502
+ name: true,
3503
+ contentType: true,
3504
+ size: true,
3505
+ useType: true,
3506
+ url: true,
3507
+ key: true
3508
+ },
3509
+ location: {
3510
+ _id: true,
3511
+ userProvidedLatitude: true,
3512
+ userProvidedLongitude: true,
3513
+ cityNameGeocode: true,
3514
+ stateNameGeocode: true,
3515
+ countryIso2CodeGeocode: true,
3516
+ timeZoneGeocode: true,
3517
+ latitudeGeocode: true,
3518
+ longitudeGeocode: true,
3519
+ city: {
3520
+ _id: true,
3521
+ name: true,
3522
+ localizedName: true,
3523
+ state: {
3524
+ _id: true,
3525
+ name: true,
3526
+ country: {
3527
+ _id: true,
3528
+ name: true
3529
+ }
3530
+ },
3531
+ latitude: true,
3532
+ longitude: true,
3533
+ timezone: true,
3534
+ }
3535
+ },
3536
+ },
3537
+ participationDate: true,
3538
+ competitionNumber: true,
3539
+ result: {
3540
+ resultType: true,
3541
+ position: true,
3542
+ score: true,
3543
+ finishTimeMS: true,
3544
+ resultWebLink: true
3545
+ },
3546
+ fundRaisingCampaignIds: true
3547
+ };
3548
+ try {
3549
+ const response = await client.mutation({
3550
+ addAthleteCompetition: {
3551
+ __args: {
3552
+ input: dto
3553
+ },
3554
+ ...fields
3555
+ },
3556
+ });
3557
+ VTXBaseAPI.Logger.debug('addAthleteCompetition Response:');
3558
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
3559
+ retValue = (0, response_builder_1.buildResponse)(response, 'addAthleteCompetition', (r) => {
3560
+ const isResponseOk = true && response?.addAthleteCompetition?._id;
3561
+ return isResponseOk;
3562
+ });
3563
+ }
3564
+ catch (err1) {
3565
+ VTXBaseAPI.Logger.error('addAthleteCompetition err1:');
3566
+ VTXBaseAPI.Logger.error(err1);
3567
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
3568
+ }
3569
+ return retValue;
3570
+ }
3571
+ async getSportsEvents(dto) {
3572
+ const client = (0, client_1.createClient)({
3573
+ url: this.backendUrl + "/graphql",
3574
+ headers: this.headers,
3575
+ });
3576
+ const fields = {
3577
+ _id: true,
3578
+ name: true,
3579
+ eventWebSite: true,
3580
+ mainSport: {
3581
+ _id: true,
3582
+ name: true
3583
+ },
3584
+ startDate: true,
3585
+ endDate: true,
3586
+ verified: true,
3587
+ banner: {
3588
+ _id: true,
3589
+ name: true,
3590
+ contentType: true,
3591
+ size: true,
3592
+ useType: true,
3593
+ url: true,
3594
+ key: true
3595
+ },
3596
+ location: {
3597
+ _id: true,
3598
+ userProvidedLatitude: true,
3599
+ userProvidedLongitude: true,
3600
+ cityNameGeocode: true,
3601
+ stateNameGeocode: true,
3602
+ countryIso2CodeGeocode: true,
3603
+ timeZoneGeocode: true,
3604
+ latitudeGeocode: true,
3605
+ longitudeGeocode: true,
3606
+ city: {
3607
+ _id: true,
3608
+ name: true,
3609
+ localizedName: true,
3610
+ state: {
3611
+ _id: true,
3612
+ name: true,
3613
+ country: {
3614
+ _id: true,
3615
+ name: true
3616
+ }
3617
+ },
3618
+ latitude: true,
3619
+ longitude: true,
3620
+ timezone: true,
3621
+ }
3622
+ }
3623
+ };
3624
+ let retValue;
3625
+ try {
3626
+ const response = await client.query({
3627
+ getSportsEvents: {
3628
+ __args: {
3629
+ input: dto
3630
+ },
3631
+ ...fields
3632
+ }
3633
+ });
3634
+ VTXBaseAPI.Logger.debug('getSportsEvents Response:');
3635
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
3636
+ retValue = (0, response_builder_1.buildResponse)(response, 'getSportsEvents', (r) => {
3637
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
3638
+ const isResponseOk = true && Array.isArray(response?.getSportsEvents);
3639
+ return isResponseOk;
3640
+ });
3641
+ }
3642
+ catch (err1) {
3643
+ VTXBaseAPI.Logger.error('getSportsEvents err1:');
3644
+ VTXBaseAPI.Logger.error(err1);
3645
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
3646
+ }
3647
+ return retValue;
3648
+ }
3649
+ async createSportsEvent(dto) {
3650
+ console.log('HEADERS:');
3651
+ console.log(JSON.stringify(this.headers, null, 2));
3652
+ const client = (0, client_1.createClient)({
3653
+ url: this.backendUrl + '/graphql',
3654
+ headers: this.headers,
3655
+ });
3656
+ let retValue = {};
3657
+ const fields = {
3658
+ _id: true,
3659
+ name: true,
3660
+ eventWebSite: true,
3661
+ mainSport: {
3662
+ _id: true,
3663
+ name: true
3664
+ },
3665
+ startDate: true,
3666
+ endDate: true,
3667
+ verified: true,
3668
+ banner: {
3669
+ _id: true,
3670
+ name: true,
3671
+ contentType: true,
3672
+ size: true,
3673
+ useType: true,
3674
+ url: true,
3675
+ key: true
3676
+ },
3677
+ location: {
3678
+ _id: true,
3679
+ userProvidedLatitude: true,
3680
+ userProvidedLongitude: true,
3681
+ cityNameGeocode: true,
3682
+ stateNameGeocode: true,
3683
+ countryIso2CodeGeocode: true,
3684
+ timeZoneGeocode: true,
3685
+ latitudeGeocode: true,
3686
+ longitudeGeocode: true,
3687
+ city: {
3688
+ _id: true,
3689
+ name: true,
3690
+ localizedName: true,
3691
+ state: {
3692
+ _id: true,
3693
+ name: true,
3694
+ country: {
3695
+ _id: true,
3696
+ name: true
3697
+ }
3698
+ },
3699
+ latitude: true,
3700
+ longitude: true,
3701
+ timezone: true,
3702
+ }
3703
+ }
3704
+ };
3705
+ try {
3706
+ const response = await client.mutation({
3707
+ createSportsEvent: {
3708
+ __args: {
3709
+ input: dto
3710
+ },
3711
+ ...fields
3712
+ },
3713
+ });
3714
+ VTXBaseAPI.Logger.debug('createSportsEvent Response:');
3715
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
3716
+ retValue = (0, response_builder_1.buildResponse)(response, 'createSportsEvent', (r) => {
3717
+ const isResponseOk = true && response?.createSportsEvent?._id;
3718
+ return isResponseOk;
3719
+ });
3720
+ }
3721
+ catch (err1) {
3722
+ VTXBaseAPI.Logger.error('createSportsEvent err1:');
3723
+ VTXBaseAPI.Logger.error(err1);
3724
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
3725
+ }
3726
+ return retValue;
3727
+ }
3728
+ async getAthleteCompetitions(dto) {
3729
+ const client = (0, client_1.createClient)({
3730
+ url: this.backendUrl + "/graphql",
3731
+ headers: this.headers,
3732
+ });
3733
+ const fields = {
3734
+ _id: true,
3735
+ event: {
3736
+ _id: true,
3737
+ name: true,
3738
+ mainSport: {
3739
+ _id: true,
3740
+ name: true
3741
+ },
3742
+ eventWebSite: true,
3743
+ startDate: true,
3744
+ endDate: true,
3745
+ verified: true,
3746
+ banner: {
3747
+ _id: true,
3748
+ name: true,
3749
+ contentType: true,
3750
+ size: true,
3751
+ useType: true,
3752
+ url: true,
3753
+ key: true
3754
+ },
3755
+ location: {
3756
+ _id: true,
3757
+ userProvidedLatitude: true,
3758
+ userProvidedLongitude: true,
3759
+ cityNameGeocode: true,
3760
+ stateNameGeocode: true,
3761
+ countryIso2CodeGeocode: true,
3762
+ timeZoneGeocode: true,
3763
+ latitudeGeocode: true,
3764
+ longitudeGeocode: true,
3765
+ city: {
3766
+ _id: true,
3767
+ name: true,
3768
+ localizedName: true,
3769
+ state: {
3770
+ _id: true,
3771
+ name: true,
3772
+ country: {
3773
+ _id: true,
3774
+ name: true
3775
+ }
3776
+ },
3777
+ latitude: true,
3778
+ longitude: true,
3779
+ timezone: true,
3780
+ }
3781
+ },
3782
+ },
3783
+ participationDate: true,
3784
+ competitionNumber: true,
3785
+ result: {
3786
+ resultType: true,
3787
+ position: true,
3788
+ score: true,
3789
+ finishTimeMS: true,
3790
+ resultWebLink: true
3791
+ },
3792
+ fundRaisingCampaignIds: true,
3793
+ budget: {
3794
+ _id: true,
3795
+ totalRequired: true,
3796
+ initialFunds: true,
3797
+ items: {
3798
+ _id: true,
3799
+ quantity: true,
3800
+ concept: true,
3801
+ itemCost: true
3802
+ }
3803
+ }
3804
+ };
3805
+ let retValue;
3806
+ try {
3807
+ const response = await client.query({
3808
+ getAthleteCompetitions: {
3809
+ __args: {
3810
+ input: dto
3811
+ },
3812
+ ...fields
3813
+ }
3814
+ });
3815
+ VTXBaseAPI.Logger.debug('getSportsEvents Response:');
3816
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
3817
+ retValue = (0, response_builder_1.buildResponse)(response, 'getAthleteCompetitions', (r) => {
3818
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
3819
+ const isResponseOk = true && Array.isArray(response?.getAthleteCompetitions);
3820
+ return isResponseOk;
3821
+ });
3822
+ }
3823
+ catch (err1) {
3824
+ VTXBaseAPI.Logger.error('getAthleteCompetitions err1:');
3825
+ VTXBaseAPI.Logger.error(err1);
3826
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
3827
+ }
3828
+ return retValue;
3829
+ }
3830
+ async getAthleteMemberships(athleteId) {
3831
+ const client = (0, client_1.createClient)({
3832
+ url: this.backendUrl + "/graphql",
3833
+ headers: this.headers,
3834
+ });
3835
+ const fields = {
3836
+ _id: true,
3837
+ organization: {
3838
+ _id: true,
3839
+ shortName: true,
3840
+ acronym: true,
3841
+ fullName: true,
3842
+ website: true,
3843
+ verified: true,
3844
+ logo: {
3845
+ _id: true,
3846
+ name: true,
3847
+ contentType: true,
3848
+ size: true,
3849
+ useType: true,
3850
+ url: true,
3851
+ key: true
3852
+ },
3853
+ country: {
3854
+ _id: true,
3855
+ name: true
3856
+ },
3857
+ sport: {
3858
+ _id: true,
3859
+ name: true
3860
+ }
3861
+ },
3862
+ athlete: {
3863
+ _id: true,
3864
+ firstName: true,
3865
+ lastName: true,
3866
+ screenName: true,
3867
+ dob: true,
3868
+ lgbt: true,
3869
+ competitionGender: true,
3870
+ country: {
3871
+ _id: true,
3872
+ name: true
3873
+ },
3874
+ location: {
3875
+ userProvidedLatitude: true,
3876
+ userProvidedLongitude: true,
3877
+ cityNameGeocode: true,
3878
+ stateNameGeocode: true,
3879
+ countryIso2CodeGeocode: true,
3880
+ timeZoneGeocode: true,
3881
+ latitudeGeocode: true,
3882
+ longitudeGeocode: true,
3883
+ city: {
3884
+ _id: true,
3885
+ name: true,
3886
+ localizedName: true,
3887
+ state: {
3888
+ _id: true,
3889
+ name: true,
3890
+ country: {
3891
+ _id: true,
3892
+ name: true
3893
+ }
3894
+ },
3895
+ latitude: true,
3896
+ longitude: true,
3897
+ timezone: true,
3898
+ }
3899
+ },
3900
+ trainer: true,
3901
+ trainerUrl: true,
3902
+ aboutMe: true,
3903
+ followStats: {
3904
+ followers: true,
3905
+ followed: true,
3906
+ raves: true,
3907
+ favorites: true
3908
+ },
3909
+ mainSport: {
3910
+ _id: true,
3911
+ name: true
3912
+ },
3913
+ mainSportLevel: {
3914
+ _id: true,
3915
+ label: true,
3916
+ index: true
3917
+ },
3918
+ scores: {
3919
+ vtxScore: true,
3920
+ socialScore: true,
3921
+ trainingScore: true,
3922
+ competitionScore: true
3923
+ },
3924
+ rankings: {
3925
+ worldRanking: {
3926
+ scope: true,
3927
+ scopeId: true,
3928
+ scopeName: true,
3929
+ position: true,
3930
+ total: true
3931
+ },
3932
+ countryRanking: {
3933
+ scope: true,
3934
+ scopeId: true,
3935
+ scopeName: true,
3936
+ position: true,
3937
+ total: true
3938
+ },
3939
+ stateRanking: {
3940
+ scope: true,
3941
+ scopeId: true,
3942
+ scopeName: true,
3943
+ position: true,
3944
+ total: true
3945
+ },
3946
+ cityRanking: {
3947
+ scope: true,
3948
+ scopeId: true,
3949
+ scopeName: true,
3950
+ position: true,
3951
+ total: true
3952
+ },
3953
+ },
3954
+ totalUpcomingCompetitions: true,
3955
+ totalPastCompetitions: true,
3956
+ profilePicture: {
3957
+ _id: true,
3958
+ name: true,
3959
+ contentType: true,
3960
+ size: true,
3961
+ useType: true,
3962
+ url: true,
3963
+ key: true
3964
+ },
3965
+ cardPicture: {
3966
+ _id: true,
3967
+ name: true,
3968
+ contentType: true,
3969
+ size: true,
3970
+ useType: true,
3971
+ url: true,
3972
+ key: true
3973
+ }
3974
+ },
3975
+ membershipNumber: true,
3976
+ membershipType: true,
3977
+ issueDate: true,
3978
+ expirationDate: true
3979
+ };
3980
+ let retValue;
3981
+ try {
3982
+ const response = await client.query({
3983
+ getAthleteMemberships: {
3984
+ __args: {
3985
+ athleteId: athleteId
3986
+ },
3987
+ ...fields
3988
+ }
3989
+ });
3990
+ VTXBaseAPI.Logger.debug('getAthleteMemberships Response:');
3991
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
3992
+ retValue = (0, response_builder_1.buildResponse)(response, 'getAthleteMemberships', (r) => {
3993
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
3994
+ const isResponseOk = true && Array.isArray(response?.getAthleteMemberships);
3995
+ return isResponseOk;
3996
+ });
3997
+ }
3998
+ catch (err1) {
3999
+ VTXBaseAPI.Logger.error('getAthleteMemberships err1:');
4000
+ VTXBaseAPI.Logger.error(err1);
4001
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
4002
+ }
4003
+ return retValue;
4004
+ }
4005
+ async deleteAthleteCompetition(dto) {
4006
+ console.log('HEADERS:');
4007
+ console.log(JSON.stringify(this.headers, null, 2));
4008
+ const client = (0, client_1.createClient)({
4009
+ url: this.backendUrl + '/graphql',
4010
+ headers: this.headers,
4011
+ });
4012
+ let retValue = {};
4013
+ const fields = {
4014
+ idToDelete: true,
4015
+ deleted: true,
4016
+ failureReason: {
4017
+ code: true,
4018
+ message: true
4019
+ }
4020
+ };
4021
+ try {
4022
+ const response = await client.mutation({
4023
+ deleteAthleteCompetition: {
4024
+ __args: {
4025
+ input: dto
4026
+ },
4027
+ ...fields
4028
+ },
4029
+ });
4030
+ VTXBaseAPI.Logger.debug('deleteAthleteCompetition Response:');
4031
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
4032
+ retValue = (0, response_builder_1.buildResponse)(response, 'deleteAthleteCompetition', (r) => {
4033
+ const isResponseOk = true && response?.deleteAthleteCompetition?.idToDelete;
4034
+ return isResponseOk;
4035
+ });
4036
+ }
4037
+ catch (err1) {
4038
+ VTXBaseAPI.Logger.error('deleteAthleteCompetition err1:');
4039
+ VTXBaseAPI.Logger.error(err1);
4040
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
4041
+ }
4042
+ return retValue;
4043
+ }
4044
+ async createFundingCampaign(dto) {
4045
+ console.log('HEADERS:');
4046
+ console.log(JSON.stringify(this.headers, null, 2));
4047
+ const client = (0, client_1.createClient)({
4048
+ url: this.backendUrl + '/graphql',
4049
+ headers: this.headers,
4050
+ });
4051
+ let retValue = {};
4052
+ const fields = {
4053
+ _id: true,
4054
+ budgetMode: true,
4055
+ status: true,
4056
+ title: true,
4057
+ motivation: true,
4058
+ website: true,
4059
+ fundsRequired: true,
4060
+ initialFundsObtained: true,
4061
+ fundsObtained: true,
4062
+ location: {
4063
+ userProvidedLatitude: true,
4064
+ userProvidedLongitude: true,
4065
+ cityNameGeocode: true,
4066
+ stateNameGeocode: true,
4067
+ countryIso2CodeGeocode: true,
4068
+ timeZoneGeocode: true,
4069
+ latitudeGeocode: true,
4070
+ longitudeGeocode: true,
4071
+ city: {
4072
+ _id: true,
4073
+ name: true,
4074
+ localizedName: true,
4075
+ state: {
4076
+ _id: true,
4077
+ name: true,
4078
+ country: {
4079
+ _id: true,
4080
+ name: true
4081
+ }
4082
+ },
4083
+ latitude: true,
4084
+ longitude: true,
4085
+ timezone: true,
4086
+ }
4087
+ },
4088
+ endingDate: true,
4089
+ budget: {
4090
+ initialFunds: true,
4091
+ totalRequired: true,
4092
+ items: {
4093
+ _id: true,
4094
+ quantity: true,
4095
+ concept: true,
4096
+ itemCost: true
4097
+ }
4098
+ },
4099
+ competitions: {
4100
+ _id: true,
4101
+ event: {
4102
+ _id: true,
4103
+ name: true,
4104
+ mainSport: {
4105
+ _id: true,
4106
+ name: true
4107
+ },
4108
+ eventWebSite: true,
4109
+ startDate: true,
4110
+ endDate: true,
4111
+ verified: true,
4112
+ banner: {
4113
+ _id: true,
4114
+ name: true,
4115
+ contentType: true,
4116
+ size: true,
4117
+ useType: true,
4118
+ url: true,
4119
+ key: true
4120
+ },
4121
+ location: {
4122
+ _id: true,
4123
+ userProvidedLatitude: true,
4124
+ userProvidedLongitude: true,
4125
+ cityNameGeocode: true,
4126
+ stateNameGeocode: true,
4127
+ countryIso2CodeGeocode: true,
4128
+ timeZoneGeocode: true,
4129
+ latitudeGeocode: true,
4130
+ longitudeGeocode: true,
4131
+ city: {
4132
+ _id: true,
4133
+ name: true,
4134
+ localizedName: true,
4135
+ state: {
4136
+ _id: true,
4137
+ name: true,
4138
+ country: {
4139
+ _id: true,
4140
+ name: true
4141
+ }
4142
+ },
4143
+ latitude: true,
4144
+ longitude: true,
4145
+ timezone: true,
4146
+ }
4147
+ },
4148
+ },
4149
+ participationDate: true,
4150
+ competitionNumber: true,
4151
+ result: {
4152
+ resultType: true,
4153
+ position: true,
4154
+ score: true,
4155
+ finishTimeMS: true,
4156
+ resultWebLink: true
4157
+ },
4158
+ fundRaisingCampaignIds: true
4159
+ }
4160
+ };
4161
+ try {
4162
+ const response = await client.mutation({
4163
+ createFundingCampaign: {
4164
+ __args: {
4165
+ input: dto
4166
+ },
4167
+ ...fields
4168
+ },
4169
+ });
4170
+ VTXBaseAPI.Logger.log("==================HERE=====================================");
4171
+ VTXBaseAPI.Logger.log('createFundingCampaign Response:');
4172
+ VTXBaseAPI.Logger.log(JSON.stringify(response, null, 2));
4173
+ VTXBaseAPI.Logger.log("==================DONE=====================================");
4174
+ retValue = (0, response_builder_1.buildResponse)(response, 'createFundingCampaign', (r) => {
4175
+ const isResponseOk = true && response?.createFundingCampaign?._id;
4176
+ return isResponseOk;
4177
+ });
4178
+ }
4179
+ catch (err1) {
4180
+ VTXBaseAPI.Logger.log("************** ERROR *******************************");
4181
+ VTXBaseAPI.Logger.log('createFundingCampaign err1:');
4182
+ VTXBaseAPI.Logger.log(err1);
4183
+ VTXBaseAPI.Logger.log("************** DONE ERROR **************************");
4184
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
4185
+ }
4186
+ return retValue;
4187
+ }
4188
+ async createMembershipOrganization(dto, desiredFields) {
4189
+ const client = (0, client_1.createClient)({
4190
+ url: this.backendUrl + "/graphql",
4191
+ headers: this.headers,
4192
+ });
4193
+ const fields = desiredFields ?? { _id: true };
4194
+ let retValue;
4195
+ try {
4196
+ const response = await client.mutation({
4197
+ createMembershipOrganization: {
4198
+ __args: {
4199
+ input: dto
4200
+ },
4201
+ ...fields
4202
+ }
4203
+ });
4204
+ VTXBaseAPI.Logger.debug('createMembershipOrganization Response:');
4205
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
4206
+ retValue = (0, response_builder_1.buildResponse)(response, 'createMembershipOrganization', (r) => {
4207
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
4208
+ const isResponseOk = true && response?.createMembershipOrganization?._id;
4209
+ return isResponseOk;
4210
+ });
4211
+ }
4212
+ catch (err1) {
4213
+ VTXBaseAPI.Logger.error('createMembershipOrganization err1:');
4214
+ VTXBaseAPI.Logger.error(err1);
4215
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
4216
+ }
4217
+ return retValue;
4218
+ }
4219
+ async getMembershipOrganizations() {
4220
+ const client = (0, client_1.createClient)({
4221
+ url: this.backendUrl + "/graphql",
4222
+ headers: this.headers,
4223
+ });
4224
+ const fields = {
4225
+ _id: true,
4226
+ shortName: true,
4227
+ acronym: true,
4228
+ fullName: true,
4229
+ website: true,
4230
+ verified: true,
4231
+ logo: {
4232
+ _id: true,
4233
+ name: true,
4234
+ contentType: true,
4235
+ size: true,
4236
+ useType: true,
4237
+ url: true,
4238
+ key: true
4239
+ },
4240
+ country: {
4241
+ _id: true,
4242
+ name: true
4243
+ },
4244
+ sport: {
4245
+ _id: true,
4246
+ name: true
4247
+ }
4248
+ };
4249
+ let retValue;
4250
+ try {
4251
+ const response = await client.query({
4252
+ getMembershipOrganizations: {
4253
+ __args: {},
4254
+ ...fields
4255
+ }
4256
+ });
4257
+ VTXBaseAPI.Logger.debug('getMembershipOrganizations Response:');
4258
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
4259
+ retValue = (0, response_builder_1.buildResponse)(response, 'getMembershipOrganizations', (r) => {
4260
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
4261
+ const isResponseOk = true && Array.isArray(response?.getMembershipOrganizations);
4262
+ return isResponseOk;
4263
+ });
4264
+ }
4265
+ catch (err1) {
4266
+ VTXBaseAPI.Logger.error('getMembershipOrganizations err1:');
4267
+ VTXBaseAPI.Logger.error(err1);
4268
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
4269
+ }
4270
+ return retValue;
4271
+ }
4272
+ async createAthleteMembershipAffilation(dto, desiredFields) {
4273
+ const client = (0, client_1.createClient)({
4274
+ url: this.backendUrl + "/graphql",
4275
+ headers: this.headers,
4276
+ });
4277
+ const fields = desiredFields ?? { _id: true };
4278
+ let retValue;
4279
+ try {
4280
+ const response = await client.mutation({
4281
+ createAthleteMembershipAffilation: {
4282
+ __args: {
4283
+ input: dto
4284
+ },
4285
+ ...fields
4286
+ }
4287
+ });
4288
+ VTXBaseAPI.Logger.debug('createAthleteMembershipAffilation Response:');
4289
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
4290
+ retValue = (0, response_builder_1.buildResponse)(response, 'createAthleteMembershipAffilation', (r) => {
4291
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
4292
+ const isResponseOk = true && response?.createAthleteMembershipAffilation?._id;
4293
+ return isResponseOk;
4294
+ });
4295
+ }
4296
+ catch (error1) {
4297
+ VTXBaseAPI.Logger.error('createAthleteMembershipAffilation err1:');
4298
+ VTXBaseAPI.Logger.error(error1);
4299
+ retValue = (0, response_builder_1.buildErrorResponse)(error1);
4300
+ }
4301
+ return retValue;
4302
+ }
4303
+ async queryAthleteFundingCampaigns(dto) {
4304
+ const client = (0, client_1.createClient)({
4305
+ url: this.backendUrl + "/graphql",
4306
+ headers: this.headers,
4307
+ });
4308
+ const fieldsAthlete = {
4309
+ _id: true,
4310
+ firstName: true,
4311
+ lastName: true,
4312
+ screenName: true,
4313
+ dob: true,
4314
+ lgbt: true,
4315
+ competitionGender: true,
4316
+ country: {
4317
+ _id: true,
4318
+ name: true
4319
+ },
4320
+ location: {
4321
+ userProvidedLatitude: true,
4322
+ userProvidedLongitude: true,
4323
+ cityNameGeocode: true,
4324
+ stateNameGeocode: true,
4325
+ countryIso2CodeGeocode: true,
4326
+ timeZoneGeocode: true,
4327
+ latitudeGeocode: true,
4328
+ longitudeGeocode: true,
4329
+ city: {
4330
+ _id: true,
4331
+ name: true,
4332
+ localizedName: true,
4333
+ state: {
4334
+ _id: true,
4335
+ name: true,
4336
+ country: {
4337
+ _id: true,
4338
+ name: true
4339
+ }
4340
+ },
4341
+ latitude: true,
4342
+ longitude: true,
4343
+ timezone: true,
4344
+ }
4345
+ },
4346
+ trainer: true,
4347
+ trainerUrl: true,
4348
+ aboutMe: true,
4349
+ mainSport: {
4350
+ _id: true,
4351
+ name: true
4352
+ },
4353
+ mainSportLevel: {
4354
+ _id: true,
4355
+ label: true,
4356
+ index: true
4357
+ },
4358
+ scores: {
4359
+ vtxScore: true,
4360
+ socialScore: true,
4361
+ trainingScore: true,
4362
+ competitionScore: true
4363
+ },
4364
+ competitions: {
4365
+ _id: true,
4366
+ event: {
4367
+ _id: true,
4368
+ name: true,
4369
+ mainSport: {
4370
+ _id: true,
4371
+ name: true
4372
+ },
4373
+ eventWebSite: true,
4374
+ startDate: true,
4375
+ endDate: true,
4376
+ verified: true,
4377
+ banner: {
4378
+ _id: true,
4379
+ name: true,
4380
+ contentType: true,
4381
+ size: true,
4382
+ useType: true,
4383
+ url: true,
4384
+ key: true
4385
+ },
4386
+ location: {
4387
+ _id: true,
4388
+ userProvidedLatitude: true,
4389
+ userProvidedLongitude: true,
4390
+ cityNameGeocode: true,
4391
+ stateNameGeocode: true,
4392
+ countryIso2CodeGeocode: true,
4393
+ timeZoneGeocode: true,
4394
+ latitudeGeocode: true,
4395
+ longitudeGeocode: true,
4396
+ city: {
4397
+ _id: true,
4398
+ name: true,
4399
+ localizedName: true,
4400
+ state: {
4401
+ _id: true,
4402
+ name: true,
4403
+ country: {
4404
+ _id: true,
4405
+ name: true
4406
+ }
4407
+ },
4408
+ latitude: true,
4409
+ longitude: true,
4410
+ timezone: true,
4411
+ }
4412
+ },
4413
+ },
4414
+ participationDate: true,
4415
+ result: {
4416
+ _id: true,
4417
+ resultType: true,
4418
+ position: true,
4419
+ score: true,
4420
+ finishTimeMS: true,
4421
+ resultWebLink: true
4422
+ }
4423
+ },
4424
+ totalUpcomingCompetitions: true,
4425
+ totalPastCompetitions: true,
4426
+ profilePicture: {
4427
+ _id: true,
4428
+ name: true,
4429
+ contentType: true,
4430
+ size: true,
4431
+ useType: true,
4432
+ url: true,
4433
+ key: true
4434
+ },
4435
+ cardPicture: {
4436
+ _id: true,
4437
+ name: true,
4438
+ contentType: true,
4439
+ size: true,
4440
+ useType: true,
4441
+ url: true,
4442
+ key: true
4443
+ },
4444
+ currentCampaign: {
4445
+ _id: true,
4446
+ budgetMode: true,
4447
+ status: true,
4448
+ title: true,
4449
+ motivation: true,
4450
+ website: true,
4451
+ fundsRequired: true,
4452
+ initialFundsObtained: true,
4453
+ fundsObtained: true,
4454
+ location: {
4455
+ _id: true,
4456
+ userProvidedLatitude: true,
4457
+ userProvidedLongitude: true,
4458
+ cityNameGeocode: true,
4459
+ stateNameGeocode: true,
4460
+ countryIso2CodeGeocode: true,
4461
+ timeZoneGeocode: true,
4462
+ latitudeGeocode: true,
4463
+ longitudeGeocode: true,
4464
+ city: {
4465
+ _id: true,
4466
+ name: true,
4467
+ localizedName: true,
4468
+ state: {
4469
+ _id: true,
4470
+ name: true,
4471
+ country: {
4472
+ _id: true,
4473
+ name: true
4474
+ }
4475
+ },
4476
+ latitude: true,
4477
+ longitude: true,
4478
+ timezone: true,
4479
+ }
4480
+ },
4481
+ endingDate: true,
4482
+ budget: {
4483
+ _id: true,
4484
+ initialFunds: true,
4485
+ totalRequired: true,
4486
+ items: {
4487
+ _id: true,
4488
+ quantity: true,
4489
+ concept: true,
4490
+ itemCost: true
4491
+ }
4492
+ },
4493
+ competitions: {
4494
+ _id: true,
4495
+ event: {
4496
+ _id: true,
4497
+ name: true,
4498
+ mainSport: {
4499
+ _id: true,
4500
+ name: true
4501
+ },
4502
+ eventWebSite: true,
4503
+ startDate: true,
4504
+ endDate: true,
4505
+ verified: true,
4506
+ banner: {
4507
+ _id: true,
4508
+ name: true,
4509
+ contentType: true,
4510
+ size: true,
4511
+ useType: true,
4512
+ url: true,
4513
+ key: true
4514
+ },
4515
+ location: {
4516
+ _id: true,
4517
+ userProvidedLatitude: true,
4518
+ userProvidedLongitude: true,
4519
+ cityNameGeocode: true,
4520
+ stateNameGeocode: true,
4521
+ countryIso2CodeGeocode: true,
4522
+ timeZoneGeocode: true,
4523
+ latitudeGeocode: true,
4524
+ longitudeGeocode: true,
4525
+ city: {
4526
+ _id: true,
4527
+ name: true,
4528
+ localizedName: true,
4529
+ state: {
4530
+ _id: true,
4531
+ name: true,
4532
+ country: {
4533
+ _id: true,
4534
+ name: true
4535
+ }
4536
+ },
4537
+ latitude: true,
4538
+ longitude: true,
4539
+ timezone: true,
4540
+ }
4541
+ },
4542
+ },
4543
+ participationDate: true,
4544
+ result: {
4545
+ _id: true,
4546
+ resultType: true,
4547
+ position: true,
4548
+ score: true,
4549
+ finishTimeMS: true,
4550
+ resultWebLink: true
4551
+ }
4552
+ }
4553
+ }
4554
+ };
4555
+ const fields = {
4556
+ athletes: fieldsAthlete,
4557
+ cursor: {
4558
+ sort: {
4559
+ sortField: true,
4560
+ order: true
4561
+ },
4562
+ initialCursorId: true,
4563
+ nextCursorId: true,
4564
+ initialCursorValue: true,
4565
+ nextCursorValue: true,
4566
+ limit: true,
4567
+ retrieved: true,
4568
+ isLastPage: true
4569
+ }
4570
+ };
4571
+ let retValue;
4572
+ try {
4573
+ const response = await client.query({
4574
+ queryAthleteFundingCampaigns: {
4575
+ __args: { input: dto },
4576
+ ...fields
4577
+ }
4578
+ });
4579
+ VTXBaseAPI.Logger.debug('queryAthleteFundingCampaigns Response:');
4580
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
4581
+ retValue = (0, response_builder_1.buildResponse)(response, 'queryAthleteFundingCampaigns', (r) => {
4582
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
4583
+ const isResponseOk = true && Array.isArray(response?.queryAthleteFundingCampaigns?.athletes);
4584
+ return isResponseOk;
4585
+ });
4586
+ }
4587
+ catch (err1) {
4588
+ VTXBaseAPI.Logger.error('queryAthleteFundingCampaigns err1:');
4589
+ VTXBaseAPI.Logger.error(err1);
4590
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
243
4591
  }
244
4592
  return retValue;
245
4593
  }
246
4594
  }
247
4595
  exports.VTXBaseAPI = VTXBaseAPI;
4596
+ VTXBaseAPI.Logger = {
4597
+ debug: (str) => {
4598
+ },
4599
+ log: (str) => {
4600
+ console.log(str);
4601
+ },
4602
+ warn: (str) => {
4603
+ },
4604
+ error: (str) => {
4605
+ },
4606
+ };
248
4607
  //# sourceMappingURL=vtx-base-api.js.map