@vertikalx/vtx-backend-client 1.0.0-dev.7 → 1.0.0-dev.71

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.
@@ -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,3183 @@ 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
+ eventWebSite: true,
320
+ startDate: true,
321
+ endDate: true,
322
+ verified: true,
323
+ banner: {
324
+ _id: true,
325
+ name: true,
326
+ contentType: true,
327
+ size: true,
328
+ useType: true,
329
+ url: true,
330
+ key: true
331
+ }
332
+ },
333
+ participationDate: true,
334
+ result: {
335
+ _id: true,
336
+ resultType: true,
337
+ position: true,
338
+ score: true,
339
+ finishTimeMS: true,
340
+ resultWebLink: true
204
341
  }
342
+ },
343
+ totalUpcomingCompetitions: true,
344
+ totalPastCompetitions: true,
345
+ profilePicture: {
346
+ _id: true,
347
+ name: true,
348
+ contentType: true,
349
+ size: true,
350
+ useType: true,
351
+ url: true,
352
+ key: true
353
+ },
354
+ cardPicture: {
355
+ _id: true,
356
+ name: true,
357
+ contentType: true,
358
+ size: true,
359
+ useType: true,
360
+ url: true,
361
+ key: true
205
362
  }
206
- else if (response?.errors) {
207
- if (Array.isArray(response.errors)) {
208
- retValue.errors = response.errors;
209
- }
210
- else {
211
- retValue.errors = [response.errors];
363
+ };
364
+ try {
365
+ const response = await client.mutation({
366
+ registerAthlete: {
367
+ __args: {
368
+ input: payload
369
+ },
370
+ ...fields
212
371
  }
372
+ });
373
+ VTXBaseAPI.Logger.debug('registerAthlete Response:');
374
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
375
+ retValue = (0, response_builder_1.buildResponse)(response, 'registerAthlete', (r) => {
376
+ const isResponseOk = true && response?.registerAthlete?._id;
377
+ return isResponseOk;
378
+ });
379
+ }
380
+ catch (err1) {
381
+ VTXBaseAPI.Logger.error('registerAthlete err1:');
382
+ VTXBaseAPI.Logger.error(err1);
383
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
384
+ }
385
+ return retValue;
386
+ }
387
+ async findBrandByName(name, translations = false) {
388
+ const client = (0, client_1.createClient)({
389
+ url: this.backendUrl + "/graphql",
390
+ headers: this.headers,
391
+ });
392
+ let retValue = {};
393
+ try {
394
+ let response = null;
395
+ if (translations) {
396
+ response = await client.query({
397
+ getBrandByName: {
398
+ __args: {
399
+ name: name,
400
+ translations: true
401
+ },
402
+ _id: true,
403
+ name: true,
404
+ slogan: true,
405
+ website: true,
406
+ description: true,
407
+ logo: {
408
+ name: true,
409
+ contentType: true,
410
+ size: true,
411
+ useType: true,
412
+ url: true,
413
+ key: true
414
+ },
415
+ banner: {
416
+ name: true,
417
+ contentType: true,
418
+ size: true,
419
+ useType: true,
420
+ url: true,
421
+ key: true
422
+ },
423
+ translations: {
424
+ name: true,
425
+ slogan: true,
426
+ description: true,
427
+ language: true
428
+ },
429
+ }
430
+ });
431
+ }
432
+ else {
433
+ response = await client.query({
434
+ getBrandByName: {
435
+ __args: {
436
+ name: name,
437
+ translations: false
438
+ },
439
+ _id: true,
440
+ name: true,
441
+ slogan: true,
442
+ website: true,
443
+ description: true,
444
+ logo: {
445
+ name: true,
446
+ contentType: true,
447
+ size: true,
448
+ useType: true,
449
+ url: true,
450
+ key: true
451
+ },
452
+ banner: {
453
+ name: true,
454
+ contentType: true,
455
+ size: true,
456
+ useType: true,
457
+ url: true,
458
+ key: true
459
+ }
460
+ }
461
+ });
213
462
  }
214
- else if (response?.error) {
215
- if (Array.isArray(response.error)) {
216
- retValue.errors = response.error;
463
+ VTXBaseAPI.Logger.debug('getBrandByName Response:');
464
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
465
+ retValue = (0, response_builder_1.buildResponse)(response, 'getBrandByName', (r) => {
466
+ const isResponseOk = true && response?.getBrandByName?._id;
467
+ return isResponseOk;
468
+ });
469
+ }
470
+ catch (err1) {
471
+ VTXBaseAPI.Logger.error('getBrandByName err1:');
472
+ VTXBaseAPI.Logger.error(err1);
473
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
474
+ }
475
+ return retValue;
476
+ }
477
+ async createBrand(dto, desiredFields) {
478
+ const client = (0, client_1.createClient)({
479
+ url: this.backendUrl + "/graphql",
480
+ headers: this.headers,
481
+ });
482
+ let retValue = {};
483
+ const fields = desiredFields ?? { _id: true };
484
+ try {
485
+ const response = await client.mutation({
486
+ createBrand: {
487
+ __args: {
488
+ input: dto
489
+ },
490
+ ...fields
217
491
  }
218
- else {
219
- retValue.errors = [response.error];
492
+ });
493
+ VTXBaseAPI.Logger.debug('createBrand Response:');
494
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
495
+ retValue = (0, response_builder_1.buildResponse)(response, 'createBrand', (r) => {
496
+ const isResponseOk = true && response?.createBrand?._id;
497
+ return isResponseOk;
498
+ });
499
+ }
500
+ catch (err1) {
501
+ VTXBaseAPI.Logger.error('createBrand err1:');
502
+ VTXBaseAPI.Logger.error(err1);
503
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
504
+ }
505
+ return retValue;
506
+ }
507
+ async createSponsorship(dto, desiredFields) {
508
+ const client = (0, client_1.createClient)({
509
+ url: this.backendUrl + "/graphql",
510
+ headers: this.headers,
511
+ });
512
+ let retValue = {};
513
+ const fields = desiredFields ?? { _id: true };
514
+ try {
515
+ const response = await client.mutation({
516
+ createSponsorship: {
517
+ __args: {
518
+ input: dto
519
+ },
520
+ ...fields
220
521
  }
221
- }
222
- else if (response?.data?._id) {
223
- try {
224
- retValue.data = response?.data;
522
+ });
523
+ VTXBaseAPI.Logger.debug('createSponsorship Response:');
524
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
525
+ retValue = (0, response_builder_1.buildResponse)(response, 'createSponsorship', (r) => {
526
+ const isResponseOk = true && response?.createSponsorship?._id;
527
+ return isResponseOk;
528
+ });
529
+ }
530
+ catch (err1) {
531
+ VTXBaseAPI.Logger.error('createSponsorship err1:');
532
+ VTXBaseAPI.Logger.error(err1);
533
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
534
+ }
535
+ return retValue;
536
+ }
537
+ async getS3UploadUrl(dto) {
538
+ const client = (0, client_1.createClient)({
539
+ url: this.backendUrl + "/graphql",
540
+ headers: this.headers,
541
+ });
542
+ let retValue = {};
543
+ const fields = {
544
+ uploadUrl: true,
545
+ fields: {
546
+ key: true,
547
+ value: true
548
+ },
549
+ downloadUrl: true,
550
+ bucket: true,
551
+ key: true
552
+ };
553
+ try {
554
+ const response = await client.query({
555
+ getUploadUrl: {
556
+ __args: {
557
+ input: dto
558
+ },
559
+ ...fields
225
560
  }
226
- catch (casterr) {
227
- console.log('Error trying to cast to UserWithToken:');
228
- retValue.errors = ['Error: Obtained incorrect data from Backend'];
561
+ });
562
+ VTXBaseAPI.Logger.debug('getUploadUrl Response:');
563
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
564
+ retValue = (0, response_builder_1.buildResponse)(response, 'getUploadUrl', (r) => {
565
+ const isResponseOk = true && ((response?.getUploadUrl?.uploadUrl !== undefined) && (response?.getUploadUrl?.uploadUrl !== null));
566
+ return isResponseOk;
567
+ });
568
+ }
569
+ catch (err1) {
570
+ VTXBaseAPI.Logger.error('createSponsorship err1:');
571
+ VTXBaseAPI.Logger.error(err1);
572
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
573
+ }
574
+ return retValue;
575
+ }
576
+ async refreshToken(currentToken, refreshToken) {
577
+ const client = (0, client_1.createClient)({
578
+ url: this.backendUrl + "/graphql",
579
+ headers: this.headers,
580
+ });
581
+ VTXBaseAPI.Logger.debug('HEADERS:');
582
+ VTXBaseAPI.Logger.debug(JSON.stringify(this.headers, null, 2));
583
+ const fields = {
584
+ actualToken: true,
585
+ refreshToken: true
586
+ };
587
+ const dto = {
588
+ refreshToken: refreshToken
589
+ };
590
+ let retValue;
591
+ try {
592
+ const response = await client.mutation({
593
+ refreshToken: {
594
+ __args: {
595
+ dto: dto
596
+ },
597
+ ...fields
229
598
  }
599
+ });
600
+ VTXBaseAPI.Logger.debug('refreshToken Response:');
601
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
602
+ retValue = (0, response_builder_1.buildResponse)(response, 'refreshToken', (r) => {
603
+ const isResponseOk = true && response?.refreshToken?.refreshToken;
604
+ return isResponseOk;
605
+ });
606
+ }
607
+ catch (err1) {
608
+ VTXBaseAPI.Logger.error('refreshToken err1:');
609
+ VTXBaseAPI.Logger.error(err1);
610
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
611
+ }
612
+ return retValue;
613
+ }
614
+ async registerNewDomainTenant(input) {
615
+ const client = (0, client_1.createClient)({
616
+ url: this.backendUrl + "/graphql",
617
+ headers: this.headers,
618
+ });
619
+ const fields = {
620
+ _id: true,
621
+ name: true,
622
+ email: true,
623
+ tenant_uri: true,
624
+ owner: {
625
+ _id: true,
626
+ loginEmail: true,
627
+ suspended: true
628
+ },
629
+ domain: {
630
+ _id: true,
631
+ name: true,
632
+ description: true
230
633
  }
231
- else {
232
- retValue.errors = ['Error: Obtained incorrect data from Backend'];
634
+ };
635
+ let retValue;
636
+ try {
637
+ const response = await client.mutation({
638
+ registerNewDomainTenant: {
639
+ __args: {
640
+ tenant: input
641
+ },
642
+ ...fields
643
+ }
644
+ });
645
+ VTXBaseAPI.Logger.debug('registerNewDomainTenant Response:');
646
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
647
+ retValue = (0, response_builder_1.buildResponse)(response, 'registerNewDomainTenant', (r) => {
648
+ const isResponseOk = true && response?.registerNewDomainTenant?._id;
649
+ return isResponseOk;
650
+ });
651
+ }
652
+ catch (err1) {
653
+ VTXBaseAPI.Logger.error('registerNewDomainTenant err1:');
654
+ VTXBaseAPI.Logger.error(err1);
655
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
656
+ }
657
+ return retValue;
658
+ }
659
+ async registerNewDomainTenantWithLogin(input) {
660
+ const client = (0, client_1.createClient)({
661
+ url: this.backendUrl + "/graphql",
662
+ headers: this.headers,
663
+ });
664
+ const fields = {
665
+ _id: true,
666
+ name: true,
667
+ email: true,
668
+ tenant_uri: true,
669
+ owner: {
670
+ _id: true,
671
+ loginEmail: true,
672
+ suspended: true
673
+ },
674
+ domain: {
675
+ _id: true,
676
+ name: true,
677
+ description: true
678
+ },
679
+ user: {
680
+ _id: true,
681
+ loginEmail: true,
682
+ suspended: true,
683
+ domains: {
684
+ _id: true,
685
+ name: true,
686
+ description: true
687
+ },
688
+ token: {
689
+ actualToken: true,
690
+ refreshToken: true
691
+ }
233
692
  }
693
+ };
694
+ let retValue;
695
+ try {
696
+ const response = await client.mutation({
697
+ registerNewDomainTenantWithLogin: {
698
+ __args: {
699
+ tenant: input
700
+ },
701
+ ...fields
702
+ }
703
+ });
704
+ VTXBaseAPI.Logger.debug('registerNewDomainTenant Response:');
705
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
706
+ retValue = (0, response_builder_1.buildResponse)(response, 'TenantWithUserLogin', (r) => {
707
+ const isResponseOk = true && response?.TenantWithUserLogin?._id;
708
+ return isResponseOk;
709
+ });
234
710
  }
235
711
  catch (err1) {
236
- console.log(JSON.stringify(err1, null, 2));
237
- if (Array.isArray(err1)) {
238
- retValue.errors = err1;
712
+ VTXBaseAPI.Logger.error('registerNewDomainTenantWithLogin err1:');
713
+ VTXBaseAPI.Logger.error(err1);
714
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
715
+ }
716
+ return retValue;
717
+ }
718
+ async registerUserToDomainFromEmail(input) {
719
+ const client = (0, client_1.createClient)({
720
+ url: this.backendUrl + "/graphql",
721
+ headers: this.headers,
722
+ });
723
+ const fields = {
724
+ _id: true,
725
+ loginEmail: true,
726
+ suspended: true,
727
+ domains: {
728
+ _id: true,
729
+ name: true,
730
+ description: true,
731
+ tenant: {
732
+ _id: true,
733
+ name: true,
734
+ tenant_uri: true
735
+ }
239
736
  }
240
- else {
241
- retValue.errors = [err1];
737
+ };
738
+ let retValue;
739
+ try {
740
+ const response = await client.mutation({
741
+ registerUserToDomainFromEmail: {
742
+ __args: {
743
+ input: input
744
+ },
745
+ ...fields
746
+ }
747
+ });
748
+ VTXBaseAPI.Logger.debug('registerUserToDomainFromEmail Response:');
749
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
750
+ retValue = (0, response_builder_1.buildResponse)(response, 'registerUserToDomainFromEmail', (r) => {
751
+ const isResponseOk = true && response?.registerUserToDomainFromEmail?.loginEmail;
752
+ return isResponseOk;
753
+ });
754
+ }
755
+ catch (err1) {
756
+ VTXBaseAPI.Logger.error('registerUserToDomainFromEmail err1:');
757
+ VTXBaseAPI.Logger.error(err1);
758
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
759
+ }
760
+ return retValue;
761
+ }
762
+ async getPublicSponsorships() {
763
+ const client = (0, client_1.createClient)({
764
+ url: this.backendUrl + "/graphql",
765
+ headers: this.headers,
766
+ });
767
+ const fields = {
768
+ _id: true,
769
+ title: true,
770
+ description: true,
771
+ cashValue: true,
772
+ otherValue: true,
773
+ brand: {
774
+ _id: true,
775
+ name: true,
776
+ slogan: true,
777
+ website: true,
778
+ description: true,
779
+ approved: true,
780
+ published: true,
781
+ logo: {
782
+ _id: true,
783
+ name: true,
784
+ contentType: true,
785
+ size: true,
786
+ useType: true,
787
+ url: true,
788
+ key: true
789
+ },
790
+ banner: {
791
+ _id: true,
792
+ name: true,
793
+ contentType: true,
794
+ size: true,
795
+ useType: true,
796
+ url: true,
797
+ key: true
798
+ },
799
+ stats: {
800
+ campaigns: true,
801
+ sponsorships: true,
802
+ sports: true,
803
+ athletes: true
804
+ },
805
+ operatorIds: true
806
+ },
807
+ banner: {
808
+ _id: true,
809
+ name: true,
810
+ contentType: true,
811
+ size: true,
812
+ useType: true,
813
+ url: true,
814
+ key: true
815
+ },
816
+ criteria: {
817
+ _id: true,
818
+ label: true,
819
+ qualifications: {
820
+ on_AgeQualification: {
821
+ type: true,
822
+ value: true,
823
+ operator: true
824
+ },
825
+ on_DistanceQualification: {
826
+ type: true,
827
+ maxDistance: true,
828
+ latitude: true,
829
+ longitude: true
830
+ },
831
+ on_GenderQualification: {
832
+ type: true,
833
+ operator: true,
834
+ values: true
835
+ },
836
+ on_LocationQualification: {
837
+ type: true,
838
+ operator: true,
839
+ countries: {
840
+ _id: true,
841
+ name: true
842
+ },
843
+ states: {
844
+ _id: true,
845
+ name: true,
846
+ country: {
847
+ _id: true,
848
+ name: true
849
+ }
850
+ },
851
+ cities: {
852
+ _id: true,
853
+ name: true,
854
+ localizedName: true,
855
+ state: {
856
+ _id: true,
857
+ name: true,
858
+ country: {
859
+ _id: true,
860
+ name: true
861
+ }
862
+ },
863
+ latitude: true,
864
+ longitude: true,
865
+ timezone: true
866
+ }
867
+ },
868
+ on_NationalityQualification: {
869
+ type: true,
870
+ operator: true,
871
+ countries: {
872
+ _id: true,
873
+ name: true
874
+ }
875
+ },
876
+ on_ScoreQualification: {
877
+ type: true,
878
+ scoreType: true,
879
+ operator: true,
880
+ value: true
881
+ },
882
+ on_SportsLevelQualification: {
883
+ type: true,
884
+ operator: true,
885
+ level: true
886
+ },
887
+ on_SportsQualification: {
888
+ type: true,
889
+ sports: true,
890
+ operator: true
891
+ }
892
+ }
893
+ },
894
+ sponsorshipItems: {
895
+ _id: true,
896
+ quantity: true,
897
+ title: true,
898
+ value: true,
899
+ type: true
900
+ },
901
+ deadline: true,
902
+ startDate: true,
903
+ duration: {
904
+ length: true,
905
+ unit: true
906
+ },
907
+ terms: true,
908
+ isPrivate: true,
909
+ stats: {
910
+ totalApplications: true,
911
+ newApplications: true,
912
+ discardedApplications: true,
913
+ selectedApplications: true,
914
+ approvedApplications: true,
915
+ grantedSponsorships: true,
916
+ remainingSponsorships: true
917
+ },
918
+ approved: true,
919
+ published: true
920
+ };
921
+ let retValue;
922
+ try {
923
+ const response = await client.query({
924
+ getPublicSponsorships: {
925
+ __args: {},
926
+ ...fields
927
+ }
928
+ });
929
+ VTXBaseAPI.Logger.debug('getPublicSponsorships Response:');
930
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
931
+ retValue = (0, response_builder_1.buildResponse)(response, 'getPublicSponsorships', (r) => {
932
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
933
+ const isResponseOk = true;
934
+ return isResponseOk;
935
+ });
936
+ }
937
+ catch (err1) {
938
+ VTXBaseAPI.Logger.error('getPublicSponsorships err1:');
939
+ VTXBaseAPI.Logger.error(err1);
940
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
941
+ }
942
+ return retValue;
943
+ }
944
+ async getTenantSponsorshipsFromUri(tenantUri, token) {
945
+ if ((!tenantUri) || (tenantUri.trim() === "")) {
946
+ return {
947
+ error: {
948
+ httpStatus: 400,
949
+ code: vtx_core_common_1.VTX_ERRORS.INVALID_TENANT_URI.code,
950
+ message: vtx_core_common_1.VTX_ERRORS.INVALID_TENANT_URI.description
951
+ }
952
+ };
953
+ }
954
+ const credential = token.domains.find(c => {
955
+ if (c.tenant) {
956
+ if ((c.tenant.tenant_uri == tenantUri) && (c._id == domains_1.DOMAIN_SPONSOR)) {
957
+ return true;
958
+ }
242
959
  }
960
+ return false;
961
+ });
962
+ if (!credential) {
963
+ return {
964
+ error: {
965
+ httpStatus: 400,
966
+ code: vtx_core_common_1.VTX_ERRORS.INVALID_TENANT_URI_FOR_SPONSOR.code,
967
+ message: "Tenant in domain SPONSOR not found in domains with URI " + tenantUri
968
+ }
969
+ };
970
+ }
971
+ const tenantId = credential.tenant?._id ?? null;
972
+ if ((!tenantId) || (tenantId == "ALL")) {
973
+ return {
974
+ error: {
975
+ httpStatus: 400,
976
+ code: vtx_core_common_1.VTX_ERRORS.INVALID_TENANT_ID.code,
977
+ message: vtx_core_common_1.VTX_ERRORS.INVALID_TENANT_ID.description
978
+ }
979
+ };
980
+ }
981
+ return this.getTenantSponsorships(tenantId);
982
+ }
983
+ async getTenantSponsorships(tenantId) {
984
+ const client = (0, client_1.createClient)({
985
+ url: this.backendUrl + "/graphql",
986
+ headers: this.headers,
987
+ });
988
+ const fields = {
989
+ _id: true,
990
+ title: true,
991
+ description: true,
992
+ cashValue: true,
993
+ otherValue: true,
994
+ brand: {
995
+ _id: true,
996
+ name: true,
997
+ slogan: true,
998
+ website: true,
999
+ description: true,
1000
+ approved: true,
1001
+ published: true,
1002
+ logo: {
1003
+ _id: true,
1004
+ name: true,
1005
+ contentType: true,
1006
+ size: true,
1007
+ useType: true,
1008
+ url: true,
1009
+ key: true
1010
+ },
1011
+ banner: {
1012
+ _id: true,
1013
+ name: true,
1014
+ contentType: true,
1015
+ size: true,
1016
+ useType: true,
1017
+ url: true,
1018
+ key: true
1019
+ },
1020
+ stats: {
1021
+ campaigns: true,
1022
+ sponsorships: true,
1023
+ sports: true,
1024
+ athletes: true
1025
+ },
1026
+ operatorIds: true
1027
+ },
1028
+ banner: {
1029
+ _id: true,
1030
+ name: true,
1031
+ contentType: true,
1032
+ size: true,
1033
+ useType: true,
1034
+ url: true,
1035
+ key: true
1036
+ },
1037
+ criteria: {
1038
+ _id: true,
1039
+ label: true,
1040
+ qualifications: {
1041
+ on_AgeQualification: {
1042
+ type: true,
1043
+ value: true,
1044
+ operator: true
1045
+ },
1046
+ on_DistanceQualification: {
1047
+ type: true,
1048
+ maxDistance: true,
1049
+ latitude: true,
1050
+ longitude: true
1051
+ },
1052
+ on_GenderQualification: {
1053
+ type: true,
1054
+ operator: true,
1055
+ values: true
1056
+ },
1057
+ on_LocationQualification: {
1058
+ type: true,
1059
+ operator: true,
1060
+ countries: {
1061
+ _id: true,
1062
+ name: true
1063
+ },
1064
+ states: {
1065
+ _id: true,
1066
+ name: true,
1067
+ country: {
1068
+ _id: true,
1069
+ name: true
1070
+ }
1071
+ },
1072
+ cities: {
1073
+ _id: true,
1074
+ name: true,
1075
+ localizedName: true,
1076
+ state: {
1077
+ _id: true,
1078
+ name: true,
1079
+ country: {
1080
+ _id: true,
1081
+ name: true
1082
+ }
1083
+ },
1084
+ latitude: true,
1085
+ longitude: true,
1086
+ timezone: true
1087
+ }
1088
+ },
1089
+ on_NationalityQualification: {
1090
+ type: true,
1091
+ operator: true,
1092
+ countries: {
1093
+ _id: true,
1094
+ name: true
1095
+ }
1096
+ },
1097
+ on_ScoreQualification: {
1098
+ type: true,
1099
+ scoreType: true,
1100
+ operator: true,
1101
+ value: true
1102
+ },
1103
+ on_SportsLevelQualification: {
1104
+ type: true,
1105
+ operator: true,
1106
+ level: true
1107
+ },
1108
+ on_SportsQualification: {
1109
+ type: true,
1110
+ sports: true,
1111
+ operator: true
1112
+ }
1113
+ }
1114
+ },
1115
+ sponsorshipItems: {
1116
+ _id: true,
1117
+ quantity: true,
1118
+ title: true,
1119
+ value: true,
1120
+ type: true
1121
+ },
1122
+ deadline: true,
1123
+ startDate: true,
1124
+ duration: {
1125
+ length: true,
1126
+ unit: true
1127
+ },
1128
+ terms: true,
1129
+ isPrivate: true,
1130
+ stats: {
1131
+ totalApplications: true,
1132
+ newApplications: true,
1133
+ discardedApplications: true,
1134
+ selectedApplications: true,
1135
+ approvedApplications: true,
1136
+ grantedSponsorships: true,
1137
+ remainingSponsorships: true
1138
+ },
1139
+ approved: true,
1140
+ published: true
1141
+ };
1142
+ let retValue;
1143
+ try {
1144
+ const response = await client.query({
1145
+ getTenantSponsorships: {
1146
+ __args: {},
1147
+ ...fields
1148
+ }
1149
+ });
1150
+ VTXBaseAPI.Logger.debug('getTenantSponsorships Response:');
1151
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1152
+ retValue = (0, response_builder_1.buildResponse)(response, 'getTenantSponsorships', (r) => {
1153
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1154
+ const isResponseOk = true;
1155
+ return isResponseOk;
1156
+ });
1157
+ }
1158
+ catch (err1) {
1159
+ VTXBaseAPI.Logger.error('getTenantSponsorships err1:');
1160
+ VTXBaseAPI.Logger.error(err1);
1161
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1162
+ }
1163
+ return retValue;
1164
+ }
1165
+ async sendAthleteInvitations(input) {
1166
+ const client = (0, client_1.createClient)({
1167
+ url: this.backendUrl + "/graphql",
1168
+ headers: this.headers,
1169
+ });
1170
+ const fields = {
1171
+ _id: true,
1172
+ name: true,
1173
+ email: true,
1174
+ dateSent: true,
1175
+ sponsor: {
1176
+ _id: true,
1177
+ name: true,
1178
+ tenant: {
1179
+ _id: true,
1180
+ name: true,
1181
+ tenant_uri: true
1182
+ }
1183
+ },
1184
+ magicLink: {
1185
+ _id: true,
1186
+ code: true,
1187
+ type: true,
1188
+ url: true,
1189
+ expires: true,
1190
+ data: true,
1191
+ isExpired: true
1192
+ },
1193
+ brand: {
1194
+ _id: true,
1195
+ name: true,
1196
+ logo: {
1197
+ _id: true,
1198
+ name: true,
1199
+ contentType: true,
1200
+ url: true,
1201
+ useType: true
1202
+ },
1203
+ website: true
1204
+ },
1205
+ status: true
1206
+ };
1207
+ let retValue;
1208
+ try {
1209
+ const response = await client.mutation({
1210
+ sendAthleteInvitations: {
1211
+ __args: {
1212
+ input: input
1213
+ },
1214
+ ...fields
1215
+ }
1216
+ });
1217
+ VTXBaseAPI.Logger.debug('sendAthleteInvitations Response:');
1218
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1219
+ retValue = (0, response_builder_1.buildResponse)(response, 'sendAthleteInvitations', (r) => {
1220
+ const isResponseOk = true && Array.isArray(response?.sendAthleteInvitations);
1221
+ return isResponseOk;
1222
+ });
1223
+ }
1224
+ catch (err1) {
1225
+ VTXBaseAPI.Logger.error('sendAthleteInvitations err1:');
1226
+ VTXBaseAPI.Logger.error(err1);
1227
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1228
+ }
1229
+ return retValue;
1230
+ }
1231
+ async registerSponsorUser(input) {
1232
+ const client = (0, client_1.createClient)({
1233
+ url: this.backendUrl + "/graphql",
1234
+ headers: this.headers,
1235
+ });
1236
+ const fields = {
1237
+ _id: true,
1238
+ loginEmail: true,
1239
+ suspended: true,
1240
+ domains: {
1241
+ _id: true,
1242
+ name: true,
1243
+ description: true,
1244
+ tenant: {
1245
+ _id: true,
1246
+ name: true,
1247
+ tenant_uri: true,
1248
+ domain: {
1249
+ _id: true,
1250
+ name: true,
1251
+ description: true
1252
+ }
1253
+ }
1254
+ }
1255
+ };
1256
+ let retValue;
1257
+ try {
1258
+ const response = await client.mutation({
1259
+ registerSponsorUser: {
1260
+ __args: {
1261
+ input: input
1262
+ },
1263
+ ...fields
1264
+ }
1265
+ });
1266
+ VTXBaseAPI.Logger.debug('registerSponsorUser Response:');
1267
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1268
+ retValue = (0, response_builder_1.buildResponse)(response, 'registerSponsorUser', (r) => {
1269
+ const isResponseOk = true && response?.registerSponsorUser._id;
1270
+ return isResponseOk;
1271
+ });
1272
+ }
1273
+ catch (err1) {
1274
+ VTXBaseAPI.Logger.error('registerSponsorUser err1:');
1275
+ VTXBaseAPI.Logger.error(err1);
1276
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1277
+ }
1278
+ return retValue;
1279
+ }
1280
+ async registerAthleteUser(input) {
1281
+ const client = (0, client_1.createClient)({
1282
+ url: this.backendUrl + "/graphql",
1283
+ headers: this.headers,
1284
+ });
1285
+ const fields = {
1286
+ _id: true,
1287
+ loginEmail: true,
1288
+ suspended: true,
1289
+ domains: {
1290
+ _id: true,
1291
+ name: true,
1292
+ description: true,
1293
+ tenant: {
1294
+ _id: true,
1295
+ name: true,
1296
+ tenant_uri: true,
1297
+ domain: {
1298
+ _id: true,
1299
+ name: true,
1300
+ description: true
1301
+ }
1302
+ }
1303
+ }
1304
+ };
1305
+ let retValue;
1306
+ try {
1307
+ const response = await client.mutation({
1308
+ registerAthleteUser: {
1309
+ __args: {
1310
+ input: input
1311
+ },
1312
+ ...fields
1313
+ }
1314
+ });
1315
+ VTXBaseAPI.Logger.debug('registerAthleteUser Response:');
1316
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1317
+ retValue = (0, response_builder_1.buildResponse)(response, 'registerAthleteUser', (r) => {
1318
+ const isResponseOk = true && response?.registerAthleteUser._id;
1319
+ return isResponseOk;
1320
+ });
1321
+ }
1322
+ catch (err1) {
1323
+ VTXBaseAPI.Logger.error('registerAthleteUser err1:');
1324
+ VTXBaseAPI.Logger.error(err1);
1325
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1326
+ }
1327
+ return retValue;
1328
+ }
1329
+ async preRegisterAthleteUser(input) {
1330
+ const client = (0, client_1.createClient)({
1331
+ url: this.backendUrl + "/graphql",
1332
+ headers: this.headers,
1333
+ });
1334
+ const fields = {
1335
+ _id: true,
1336
+ type: true,
1337
+ recipient: true,
1338
+ expires: true,
1339
+ isExpired: true,
1340
+ createdDate: true
1341
+ };
1342
+ let retValue;
1343
+ try {
1344
+ const response = await client.mutation({
1345
+ preRegisterAthleteUser: {
1346
+ __args: {
1347
+ input: input
1348
+ },
1349
+ ...fields
1350
+ }
1351
+ });
1352
+ VTXBaseAPI.Logger.debug('preRegisterAthleteUser Response:');
1353
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1354
+ retValue = (0, response_builder_1.buildResponse)(response, 'preRegisterAthleteUser', (r) => {
1355
+ const isResponseOk = true && response?.preRegisterAthleteUser._id;
1356
+ return isResponseOk;
1357
+ });
1358
+ }
1359
+ catch (err1) {
1360
+ VTXBaseAPI.Logger.error('preRegisterAthleteUser err1:');
1361
+ VTXBaseAPI.Logger.error(err1);
1362
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1363
+ }
1364
+ return retValue;
1365
+ }
1366
+ async confirmAthleteUserRegistrationAndLogin(input) {
1367
+ const client = (0, client_1.createClient)({
1368
+ url: this.backendUrl + "/graphql",
1369
+ headers: this.headers,
1370
+ });
1371
+ const fields = {
1372
+ _id: true,
1373
+ loginEmail: true,
1374
+ suspended: true,
1375
+ domains: {
1376
+ _id: true,
1377
+ name: true,
1378
+ description: true,
1379
+ tenant: {
1380
+ _id: true,
1381
+ name: true,
1382
+ tenant_uri: true,
1383
+ domain: {
1384
+ _id: true,
1385
+ name: true,
1386
+ description: true
1387
+ }
1388
+ }
1389
+ },
1390
+ token: {
1391
+ actualToken: true,
1392
+ refreshToken: true
1393
+ }
1394
+ };
1395
+ let retValue;
1396
+ try {
1397
+ const response = await client.mutation({
1398
+ confirmAthleteUserRegistrationAndLogin: {
1399
+ __args: {
1400
+ input: input
1401
+ },
1402
+ ...fields
1403
+ }
1404
+ });
1405
+ VTXBaseAPI.Logger.debug('confirmAthleteUserRegistrationAndLogin Response:');
1406
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1407
+ retValue = (0, response_builder_1.buildResponse)(response, 'confirmAthleteUserRegistrationAndLogin', (r) => {
1408
+ const isResponseOk = true && response?.confirmAthleteUserRegistrationAndLogin._id;
1409
+ return isResponseOk;
1410
+ });
1411
+ }
1412
+ catch (err1) {
1413
+ VTXBaseAPI.Logger.error('confirmAthleteUserRegistrationAndLogin err1:');
1414
+ VTXBaseAPI.Logger.error(err1);
1415
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1416
+ }
1417
+ return retValue;
1418
+ }
1419
+ async confirmAthleteUserRegistration(input) {
1420
+ const client = (0, client_1.createClient)({
1421
+ url: this.backendUrl + "/graphql",
1422
+ headers: this.headers,
1423
+ });
1424
+ const fields = {
1425
+ _id: true,
1426
+ loginEmail: true,
1427
+ suspended: true,
1428
+ domains: {
1429
+ _id: true,
1430
+ name: true,
1431
+ description: true,
1432
+ tenant: {
1433
+ _id: true,
1434
+ name: true,
1435
+ tenant_uri: true,
1436
+ domain: {
1437
+ _id: true,
1438
+ name: true,
1439
+ description: true
1440
+ }
1441
+ }
1442
+ }
1443
+ };
1444
+ let retValue;
1445
+ try {
1446
+ const response = await client.mutation({
1447
+ confirmAthleteUserRegistration: {
1448
+ __args: {
1449
+ input: input
1450
+ },
1451
+ ...fields
1452
+ }
1453
+ });
1454
+ VTXBaseAPI.Logger.debug('confirmAthleteUserRegistration Response:');
1455
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1456
+ retValue = (0, response_builder_1.buildResponse)(response, 'confirmAthleteUserRegistration', (r) => {
1457
+ const isResponseOk = true && response?.confirmAthleteUserRegistration._id;
1458
+ return isResponseOk;
1459
+ });
1460
+ }
1461
+ catch (err1) {
1462
+ VTXBaseAPI.Logger.error('confirmAthleteUserRegistration err1:');
1463
+ VTXBaseAPI.Logger.error(err1);
1464
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1465
+ }
1466
+ return retValue;
1467
+ }
1468
+ async findSponsorAthleteInvitation(dto) {
1469
+ const client = (0, client_1.createClient)({
1470
+ url: this.backendUrl + "/graphql",
1471
+ headers: this.headers,
1472
+ });
1473
+ const fields = {
1474
+ _id: true,
1475
+ name: true,
1476
+ email: true,
1477
+ dateSent: true,
1478
+ sponsor: {
1479
+ _id: true,
1480
+ name: true,
1481
+ description: true,
1482
+ approved: true
1483
+ },
1484
+ magicLink: {
1485
+ _id: true,
1486
+ code: true,
1487
+ type: true,
1488
+ url: true,
1489
+ expires: true,
1490
+ isExpired: true
1491
+ },
1492
+ brand: {
1493
+ _id: true,
1494
+ name: true,
1495
+ slogan: true,
1496
+ website: true,
1497
+ description: true,
1498
+ approved: true,
1499
+ published: true,
1500
+ logo: {
1501
+ _id: true,
1502
+ name: true,
1503
+ contentType: true,
1504
+ size: true,
1505
+ useType: true,
1506
+ url: true,
1507
+ key: true
1508
+ },
1509
+ banner: {
1510
+ _id: true,
1511
+ name: true,
1512
+ contentType: true,
1513
+ size: true,
1514
+ useType: true,
1515
+ url: true,
1516
+ key: true
1517
+ }
1518
+ },
1519
+ status: true
1520
+ };
1521
+ let retValue;
1522
+ try {
1523
+ const response = await client.query({
1524
+ findSponsorAthleteInvitation: {
1525
+ __args: {
1526
+ input: dto
1527
+ },
1528
+ ...fields
1529
+ }
1530
+ });
1531
+ VTXBaseAPI.Logger.debug('findSponsorAthleteInvitation Response:');
1532
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1533
+ retValue = (0, response_builder_1.buildResponse)(response, 'findSponsorAthleteInvitation', (r) => {
1534
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1535
+ const isResponseOk = true && response?.findSponsorAthleteInvitation?._id;
1536
+ return isResponseOk;
1537
+ });
1538
+ }
1539
+ catch (err1) {
1540
+ VTXBaseAPI.Logger.error('findSponsorAthleteInvitation err1:');
1541
+ VTXBaseAPI.Logger.error(err1);
1542
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1543
+ }
1544
+ return retValue;
1545
+ }
1546
+ async findVtxUser(dto) {
1547
+ const client = (0, client_1.createClient)({
1548
+ url: this.backendUrl + "/graphql",
1549
+ headers: this.headers,
1550
+ });
1551
+ const fields = {
1552
+ _id: true,
1553
+ loginEmail: true,
1554
+ suspended: true,
1555
+ domains: {
1556
+ _id: true,
1557
+ name: true,
1558
+ description: true,
1559
+ tenant: {
1560
+ _id: true,
1561
+ name: true,
1562
+ tenant_uri: true,
1563
+ domain: {
1564
+ _id: true,
1565
+ name: true,
1566
+ description: true
1567
+ }
1568
+ }
1569
+ }
1570
+ };
1571
+ let retValue;
1572
+ try {
1573
+ const response = await client.query({
1574
+ findVtxUser: {
1575
+ __args: {
1576
+ input: dto
1577
+ },
1578
+ ...fields
1579
+ }
1580
+ });
1581
+ VTXBaseAPI.Logger.debug('findVtxUser Response:');
1582
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1583
+ retValue = (0, response_builder_1.buildResponse)(response, 'findVtxUser', (r) => {
1584
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1585
+ const isResponseOk = true && response?.findVtxUser?._id;
1586
+ return isResponseOk;
1587
+ });
1588
+ }
1589
+ catch (err1) {
1590
+ VTXBaseAPI.Logger.error('findVtxUser err1:');
1591
+ VTXBaseAPI.Logger.error(err1);
1592
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1593
+ }
1594
+ return retValue;
1595
+ }
1596
+ async findCitiesStartingWith(pattern) {
1597
+ const client = (0, client_1.createClient)({
1598
+ url: this.backendUrl + "/graphql",
1599
+ headers: this.headers,
1600
+ });
1601
+ const fields = {
1602
+ _id: true,
1603
+ name: true,
1604
+ localizedName: true,
1605
+ state: {
1606
+ _id: true,
1607
+ name: true,
1608
+ country: {
1609
+ _id: true,
1610
+ name: true
1611
+ }
1612
+ },
1613
+ latitude: true,
1614
+ longitude: true,
1615
+ timezone: true
1616
+ };
1617
+ let retValue;
1618
+ try {
1619
+ const response = await client.query({
1620
+ findCitiesStartingWith: {
1621
+ __args: {
1622
+ text: pattern
1623
+ },
1624
+ ...fields
1625
+ }
1626
+ });
1627
+ VTXBaseAPI.Logger.debug('findCitiesStartingWith Response:');
1628
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1629
+ retValue = (0, response_builder_1.buildResponse)(response, 'findCitiesStartingWith', (r) => {
1630
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1631
+ const isResponseOk = true && Array.isArray(response?.findCitiesStartingWith);
1632
+ return isResponseOk;
1633
+ });
1634
+ }
1635
+ catch (err1) {
1636
+ VTXBaseAPI.Logger.error('findCitiesStartingWith err1:');
1637
+ VTXBaseAPI.Logger.error(err1);
1638
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1639
+ }
1640
+ return retValue;
1641
+ }
1642
+ async findCityById(cityId) {
1643
+ const client = (0, client_1.createClient)({
1644
+ url: this.backendUrl + "/graphql",
1645
+ headers: this.headers,
1646
+ });
1647
+ const fields = {
1648
+ _id: true,
1649
+ name: true,
1650
+ localizedName: true,
1651
+ state: {
1652
+ _id: true,
1653
+ name: true,
1654
+ country: {
1655
+ _id: true,
1656
+ name: true
1657
+ }
1658
+ },
1659
+ latitude: true,
1660
+ longitude: true,
1661
+ timezone: true
1662
+ };
1663
+ let retValue;
1664
+ try {
1665
+ const response = await client.query({
1666
+ findCityById: {
1667
+ __args: {
1668
+ cityId: cityId
1669
+ },
1670
+ ...fields
1671
+ }
1672
+ });
1673
+ VTXBaseAPI.Logger.debug('findCityById Response:');
1674
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1675
+ retValue = (0, response_builder_1.buildResponse)(response, 'findCityById', (r) => {
1676
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1677
+ const isResponseOk = true && response?.findCityById?._id;
1678
+ return isResponseOk;
1679
+ });
1680
+ }
1681
+ catch (err1) {
1682
+ VTXBaseAPI.Logger.error('findCityById err1:');
1683
+ VTXBaseAPI.Logger.error(err1);
1684
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1685
+ }
1686
+ return retValue;
1687
+ }
1688
+ async getSportLevels() {
1689
+ const client = (0, client_1.createClient)({
1690
+ url: this.backendUrl + "/graphql",
1691
+ headers: this.headers,
1692
+ });
1693
+ const fields = {
1694
+ _id: true,
1695
+ label: true,
1696
+ index: true
1697
+ };
1698
+ let retValue;
1699
+ try {
1700
+ const response = await client.query({
1701
+ getSportLevels: {
1702
+ __args: {},
1703
+ ...fields
1704
+ }
1705
+ });
1706
+ VTXBaseAPI.Logger.debug('getSportLevels Response:');
1707
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1708
+ retValue = (0, response_builder_1.buildResponse)(response, 'getSportLevels', (r) => {
1709
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1710
+ const isResponseOk = true && Array.isArray(response?.getSportLevels);
1711
+ return isResponseOk;
1712
+ });
1713
+ }
1714
+ catch (err1) {
1715
+ VTXBaseAPI.Logger.error('getSportLevels err1:');
1716
+ VTXBaseAPI.Logger.error(err1);
1717
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1718
+ }
1719
+ return retValue;
1720
+ }
1721
+ async getSports() {
1722
+ const client = (0, client_1.createClient)({
1723
+ url: this.backendUrl + "/graphql",
1724
+ headers: this.headers,
1725
+ });
1726
+ const fields = {
1727
+ _id: true,
1728
+ name: true
1729
+ };
1730
+ let retValue;
1731
+ try {
1732
+ const response = await client.query({
1733
+ getSports: {
1734
+ __args: {},
1735
+ ...fields
1736
+ }
1737
+ });
1738
+ VTXBaseAPI.Logger.debug('getSports Response:');
1739
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1740
+ retValue = (0, response_builder_1.buildResponse)(response, 'getSports', (r) => {
1741
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1742
+ const isResponseOk = true && Array.isArray(response?.getSports);
1743
+ return isResponseOk;
1744
+ });
1745
+ }
1746
+ catch (err1) {
1747
+ VTXBaseAPI.Logger.error('getSports err1:');
1748
+ VTXBaseAPI.Logger.error(err1);
1749
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1750
+ }
1751
+ return retValue;
1752
+ }
1753
+ async loginUserFromCredentialsVtx(username, password) {
1754
+ const client = (0, client_1.createClient)({
1755
+ url: this.backendUrl + '/graphql',
1756
+ headers: this.headers,
1757
+ });
1758
+ const curatedEmail = username.trim().toLocaleLowerCase();
1759
+ let retValue = {};
1760
+ const fields = {
1761
+ _id: true,
1762
+ loginEmail: true,
1763
+ suspended: true,
1764
+ domains: {
1765
+ _id: true,
1766
+ name: true,
1767
+ description: true,
1768
+ tenant: {
1769
+ _id: true,
1770
+ name: true,
1771
+ tenant_uri: true,
1772
+ domain: {
1773
+ _id: true,
1774
+ name: true,
1775
+ description: true
1776
+ }
1777
+ }
1778
+ },
1779
+ loginMethods: true,
1780
+ token: {
1781
+ actualToken: true,
1782
+ refreshToken: true
1783
+ }
1784
+ };
1785
+ try {
1786
+ const response = await client.mutation({
1787
+ loginUserFromCredentialsVtx: {
1788
+ __args: {
1789
+ username: curatedEmail,
1790
+ password: password
1791
+ },
1792
+ ...fields
1793
+ },
1794
+ });
1795
+ VTXBaseAPI.Logger.debug('loginUserFromCredentialsVtx Response:');
1796
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1797
+ retValue = (0, response_builder_1.buildResponse)(response, 'loginUserFromCredentialsVtx', (r) => {
1798
+ const isResponseOk = true && response?.loginUserFromCredentialsVtx?.actualToken;
1799
+ return isResponseOk;
1800
+ });
1801
+ }
1802
+ catch (err1) {
1803
+ VTXBaseAPI.Logger.error('loginUserFromCredentialsVtx err1:');
1804
+ VTXBaseAPI.Logger.error(err1);
1805
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1806
+ }
1807
+ return retValue;
1808
+ }
1809
+ async validateUserCredentialsVtx(username, password) {
1810
+ const client = (0, client_1.createClient)({
1811
+ url: this.backendUrl + '/graphql',
1812
+ headers: this.headers,
1813
+ });
1814
+ const curatedEmail = username.trim().toLocaleLowerCase();
1815
+ let retValue = {};
1816
+ const fields = {
1817
+ _id: true,
1818
+ loginEmail: true,
1819
+ suspended: true,
1820
+ domains: {
1821
+ _id: true,
1822
+ name: true,
1823
+ description: true,
1824
+ tenant: {
1825
+ _id: true,
1826
+ name: true,
1827
+ tenant_uri: true,
1828
+ domain: {
1829
+ _id: true,
1830
+ name: true,
1831
+ description: true
1832
+ }
1833
+ }
1834
+ },
1835
+ loginMethods: true
1836
+ };
1837
+ try {
1838
+ const response = await client.query({
1839
+ validateUserCredentials: {
1840
+ __args: {
1841
+ username: curatedEmail,
1842
+ password: password
1843
+ },
1844
+ ...fields
1845
+ },
1846
+ });
1847
+ VTXBaseAPI.Logger.debug('validateUserCredentials Response:');
1848
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
1849
+ retValue = (0, response_builder_1.buildResponse)(response, 'validateUserCredentials', (r) => {
1850
+ const isResponseOk = true && response?.validateUserCredentials?._id;
1851
+ return isResponseOk;
1852
+ });
1853
+ }
1854
+ catch (err1) {
1855
+ VTXBaseAPI.Logger.error('validateUserCredentials err1:');
1856
+ VTXBaseAPI.Logger.error(err1);
1857
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1858
+ }
1859
+ return retValue;
1860
+ }
1861
+ async findAthleteForUser(loginEmail) {
1862
+ const client = (0, client_1.createClient)({
1863
+ url: this.backendUrl + "/graphql",
1864
+ headers: this.headers,
1865
+ });
1866
+ let retValue = {};
1867
+ const fields = {
1868
+ _id: true,
1869
+ firstName: true,
1870
+ lastName: true,
1871
+ screenName: true,
1872
+ dob: true,
1873
+ lgbt: true,
1874
+ competitionGender: true,
1875
+ country: {
1876
+ _id: true,
1877
+ name: true
1878
+ },
1879
+ location: {
1880
+ userProvidedLatitude: true,
1881
+ userProvidedLongitude: true,
1882
+ cityNameGeocode: true,
1883
+ stateNameGeocode: true,
1884
+ countryIso2CodeGeocode: true,
1885
+ timeZoneGeocode: true,
1886
+ latitudeGeocode: true,
1887
+ longitudeGeocode: true,
1888
+ city: {
1889
+ _id: true,
1890
+ name: true,
1891
+ localizedName: true,
1892
+ state: {
1893
+ _id: true,
1894
+ name: true,
1895
+ country: {
1896
+ _id: true,
1897
+ name: true
1898
+ }
1899
+ },
1900
+ latitude: true,
1901
+ longitude: true,
1902
+ timezone: true,
1903
+ }
1904
+ },
1905
+ trainer: true,
1906
+ trainerUrl: true,
1907
+ aboutMe: true,
1908
+ followStats: {
1909
+ followers: true,
1910
+ followed: true,
1911
+ raves: true,
1912
+ favorites: true
1913
+ },
1914
+ mainSport: {
1915
+ _id: true,
1916
+ name: true
1917
+ },
1918
+ mainSportLevel: {
1919
+ _id: true,
1920
+ label: true,
1921
+ index: true
1922
+ },
1923
+ scores: {
1924
+ vtxScore: true,
1925
+ socialScore: true,
1926
+ trainingScore: true,
1927
+ competitionScore: true
1928
+ },
1929
+ rankings: {
1930
+ worldRanking: {
1931
+ scope: true,
1932
+ scopeId: true,
1933
+ scopeName: true,
1934
+ position: true,
1935
+ total: true
1936
+ },
1937
+ countryRanking: {
1938
+ scope: true,
1939
+ scopeId: true,
1940
+ scopeName: true,
1941
+ position: true,
1942
+ total: true
1943
+ },
1944
+ stateRanking: {
1945
+ scope: true,
1946
+ scopeId: true,
1947
+ scopeName: true,
1948
+ position: true,
1949
+ total: true
1950
+ },
1951
+ cityRanking: {
1952
+ scope: true,
1953
+ scopeId: true,
1954
+ scopeName: true,
1955
+ position: true,
1956
+ total: true
1957
+ },
1958
+ },
1959
+ allSports: {
1960
+ _id: true,
1961
+ name: true
1962
+ },
1963
+ teams: {
1964
+ _id: true,
1965
+ name: true,
1966
+ description: true,
1967
+ approved: true,
1968
+ logo: {
1969
+ _id: true,
1970
+ name: true,
1971
+ contentType: true,
1972
+ size: true,
1973
+ useType: true,
1974
+ url: true,
1975
+ key: true
1976
+ },
1977
+ banner: {
1978
+ _id: true,
1979
+ name: true,
1980
+ contentType: true,
1981
+ size: true,
1982
+ useType: true,
1983
+ url: true,
1984
+ key: true
1985
+ }
1986
+ },
1987
+ sponsorBrands: {
1988
+ _id: true,
1989
+ name: true,
1990
+ slogan: true,
1991
+ website: true,
1992
+ description: true,
1993
+ approved: true,
1994
+ published: true,
1995
+ logo: {
1996
+ _id: true,
1997
+ name: true,
1998
+ contentType: true,
1999
+ size: true,
2000
+ useType: true,
2001
+ url: true,
2002
+ key: true
2003
+ },
2004
+ stats: {
2005
+ campaigns: true,
2006
+ sponsorships: true,
2007
+ sports: true,
2008
+ athletes: true
2009
+ },
2010
+ operatorIds: true,
2011
+ },
2012
+ competitions: {
2013
+ _id: true,
2014
+ event: {
2015
+ _id: true,
2016
+ name: true,
2017
+ eventWebSite: true,
2018
+ startDate: true,
2019
+ endDate: true,
2020
+ verified: true,
2021
+ banner: {
2022
+ _id: true,
2023
+ name: true,
2024
+ contentType: true,
2025
+ size: true,
2026
+ useType: true,
2027
+ url: true,
2028
+ key: true
2029
+ }
2030
+ },
2031
+ participationDate: true,
2032
+ result: {
2033
+ _id: true,
2034
+ resultType: true,
2035
+ position: true,
2036
+ score: true,
2037
+ finishTimeMS: true,
2038
+ resultWebLink: true
2039
+ }
2040
+ },
2041
+ totalUpcomingCompetitions: true,
2042
+ totalPastCompetitions: true,
2043
+ profilePicture: {
2044
+ _id: true,
2045
+ name: true,
2046
+ contentType: true,
2047
+ size: true,
2048
+ useType: true,
2049
+ url: true,
2050
+ key: true
2051
+ },
2052
+ cardPicture: {
2053
+ _id: true,
2054
+ name: true,
2055
+ contentType: true,
2056
+ size: true,
2057
+ useType: true,
2058
+ url: true,
2059
+ key: true
2060
+ }
2061
+ };
2062
+ try {
2063
+ let response = null;
2064
+ response = await client.query({
2065
+ findAthleteForUser: {
2066
+ __args: {
2067
+ loginEmail: loginEmail
2068
+ },
2069
+ ...fields
2070
+ }
2071
+ });
2072
+ VTXBaseAPI.Logger.debug('findAthleteForUser Response:');
2073
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
2074
+ retValue = (0, response_builder_1.buildResponse)(response, 'findAthleteForUser', (r) => {
2075
+ const isResponseOk = true && response?.findAthleteForUser?._id;
2076
+ return isResponseOk;
2077
+ });
2078
+ }
2079
+ catch (err1) {
2080
+ VTXBaseAPI.Logger.error('findAthleteForUser err1:');
2081
+ VTXBaseAPI.Logger.error(err1);
2082
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
2083
+ }
2084
+ return retValue;
2085
+ }
2086
+ async getBrands() {
2087
+ const client = (0, client_1.createClient)({
2088
+ url: this.backendUrl + "/graphql",
2089
+ headers: this.headers,
2090
+ });
2091
+ const fields = {
2092
+ _id: true,
2093
+ name: true,
2094
+ slogan: true,
2095
+ website: true,
2096
+ description: true,
2097
+ approved: true,
2098
+ published: true,
2099
+ logo: {
2100
+ _id: true,
2101
+ name: true,
2102
+ contentType: true,
2103
+ size: true,
2104
+ useType: true,
2105
+ url: true,
2106
+ key: true
2107
+ },
2108
+ banner: {
2109
+ _id: true,
2110
+ name: true,
2111
+ contentType: true,
2112
+ size: true,
2113
+ useType: true,
2114
+ url: true,
2115
+ key: true
2116
+ },
2117
+ stats: {
2118
+ campaigns: true,
2119
+ sponsorships: true,
2120
+ sports: true,
2121
+ athletes: true
2122
+ },
2123
+ operatorIds: true
2124
+ };
2125
+ let retValue;
2126
+ try {
2127
+ const response = await client.query({
2128
+ brands: {
2129
+ __args: {},
2130
+ ...fields
2131
+ }
2132
+ });
2133
+ VTXBaseAPI.Logger.debug('brands Response:');
2134
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
2135
+ retValue = (0, response_builder_1.buildResponse)(response, 'brands', (r) => {
2136
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
2137
+ const isResponseOk = true && Array.isArray(response?.brands);
2138
+ return isResponseOk;
2139
+ });
2140
+ }
2141
+ catch (err1) {
2142
+ VTXBaseAPI.Logger.error('brands err1:');
2143
+ VTXBaseAPI.Logger.error(err1);
2144
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
2145
+ }
2146
+ return retValue;
2147
+ }
2148
+ async getAthletes() {
2149
+ const client = (0, client_1.createClient)({
2150
+ url: this.backendUrl + "/graphql",
2151
+ headers: this.headers,
2152
+ });
2153
+ const fields = {
2154
+ _id: true,
2155
+ firstName: true,
2156
+ lastName: true,
2157
+ screenName: true,
2158
+ dob: true,
2159
+ lgbt: true,
2160
+ competitionGender: true,
2161
+ country: {
2162
+ _id: true,
2163
+ name: true
2164
+ },
2165
+ location: {
2166
+ userProvidedLatitude: true,
2167
+ userProvidedLongitude: true,
2168
+ cityNameGeocode: true,
2169
+ stateNameGeocode: true,
2170
+ countryIso2CodeGeocode: true,
2171
+ timeZoneGeocode: true,
2172
+ latitudeGeocode: true,
2173
+ longitudeGeocode: true,
2174
+ city: {
2175
+ _id: true,
2176
+ name: true,
2177
+ localizedName: true,
2178
+ state: {
2179
+ _id: true,
2180
+ name: true,
2181
+ country: {
2182
+ _id: true,
2183
+ name: true
2184
+ }
2185
+ },
2186
+ latitude: true,
2187
+ longitude: true,
2188
+ timezone: true,
2189
+ }
2190
+ },
2191
+ trainer: true,
2192
+ trainerUrl: true,
2193
+ aboutMe: true,
2194
+ followStats: {
2195
+ followers: true,
2196
+ followed: true,
2197
+ raves: true,
2198
+ favorites: true
2199
+ },
2200
+ mainSport: {
2201
+ _id: true,
2202
+ name: true
2203
+ },
2204
+ mainSportLevel: {
2205
+ _id: true,
2206
+ label: true,
2207
+ index: true
2208
+ },
2209
+ scores: {
2210
+ vtxScore: true,
2211
+ socialScore: true,
2212
+ trainingScore: true,
2213
+ competitionScore: true
2214
+ },
2215
+ rankings: {
2216
+ worldRanking: {
2217
+ scope: true,
2218
+ scopeId: true,
2219
+ scopeName: true,
2220
+ position: true,
2221
+ total: true
2222
+ },
2223
+ countryRanking: {
2224
+ scope: true,
2225
+ scopeId: true,
2226
+ scopeName: true,
2227
+ position: true,
2228
+ total: true
2229
+ },
2230
+ stateRanking: {
2231
+ scope: true,
2232
+ scopeId: true,
2233
+ scopeName: true,
2234
+ position: true,
2235
+ total: true
2236
+ },
2237
+ cityRanking: {
2238
+ scope: true,
2239
+ scopeId: true,
2240
+ scopeName: true,
2241
+ position: true,
2242
+ total: true
2243
+ },
2244
+ },
2245
+ allSports: {
2246
+ _id: true,
2247
+ name: true
2248
+ },
2249
+ teams: {
2250
+ _id: true,
2251
+ name: true,
2252
+ description: true,
2253
+ approved: true,
2254
+ logo: {
2255
+ _id: true,
2256
+ name: true,
2257
+ contentType: true,
2258
+ size: true,
2259
+ useType: true,
2260
+ url: true,
2261
+ key: true
2262
+ },
2263
+ banner: {
2264
+ _id: true,
2265
+ name: true,
2266
+ contentType: true,
2267
+ size: true,
2268
+ useType: true,
2269
+ url: true,
2270
+ key: true
2271
+ }
2272
+ },
2273
+ sponsorBrands: {
2274
+ _id: true,
2275
+ name: true,
2276
+ slogan: true,
2277
+ website: true,
2278
+ description: true,
2279
+ approved: true,
2280
+ published: true,
2281
+ logo: {
2282
+ _id: true,
2283
+ name: true,
2284
+ contentType: true,
2285
+ size: true,
2286
+ useType: true,
2287
+ url: true,
2288
+ key: true
2289
+ },
2290
+ stats: {
2291
+ campaigns: true,
2292
+ sponsorships: true,
2293
+ sports: true,
2294
+ athletes: true
2295
+ },
2296
+ operatorIds: true,
2297
+ },
2298
+ competitions: {
2299
+ _id: true,
2300
+ event: {
2301
+ _id: true,
2302
+ name: true,
2303
+ eventWebSite: true,
2304
+ startDate: true,
2305
+ endDate: true,
2306
+ verified: true,
2307
+ banner: {
2308
+ _id: true,
2309
+ name: true,
2310
+ contentType: true,
2311
+ size: true,
2312
+ useType: true,
2313
+ url: true,
2314
+ key: true
2315
+ }
2316
+ },
2317
+ participationDate: true,
2318
+ result: {
2319
+ _id: true,
2320
+ resultType: true,
2321
+ position: true,
2322
+ score: true,
2323
+ finishTimeMS: true,
2324
+ resultWebLink: true
2325
+ }
2326
+ },
2327
+ totalUpcomingCompetitions: true,
2328
+ totalPastCompetitions: true,
2329
+ profilePicture: {
2330
+ _id: true,
2331
+ name: true,
2332
+ contentType: true,
2333
+ size: true,
2334
+ useType: true,
2335
+ url: true,
2336
+ key: true
2337
+ },
2338
+ cardPicture: {
2339
+ _id: true,
2340
+ name: true,
2341
+ contentType: true,
2342
+ size: true,
2343
+ useType: true,
2344
+ url: true,
2345
+ key: true
2346
+ }
2347
+ };
2348
+ let retValue;
2349
+ try {
2350
+ const response = await client.query({
2351
+ getAthletes: {
2352
+ __args: {},
2353
+ ...fields
2354
+ }
2355
+ });
2356
+ VTXBaseAPI.Logger.debug('getAthletes Response:');
2357
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
2358
+ retValue = (0, response_builder_1.buildResponse)(response, 'getAthletes', (r) => {
2359
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
2360
+ const isResponseOk = true && Array.isArray(response?.getAthletes);
2361
+ return isResponseOk;
2362
+ });
2363
+ }
2364
+ catch (err1) {
2365
+ VTXBaseAPI.Logger.error('getAthletes err1:');
2366
+ VTXBaseAPI.Logger.error(err1);
2367
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
2368
+ }
2369
+ return retValue;
2370
+ }
2371
+ async searchAthletes(searchString) {
2372
+ const client = (0, client_1.createClient)({
2373
+ url: this.backendUrl + "/graphql",
2374
+ headers: this.headers,
2375
+ });
2376
+ const fields = {
2377
+ _id: true,
2378
+ firstName: true,
2379
+ lastName: true,
2380
+ screenName: true,
2381
+ dob: true,
2382
+ lgbt: true,
2383
+ competitionGender: true,
2384
+ country: {
2385
+ _id: true,
2386
+ name: true
2387
+ },
2388
+ location: {
2389
+ userProvidedLatitude: true,
2390
+ userProvidedLongitude: true,
2391
+ cityNameGeocode: true,
2392
+ stateNameGeocode: true,
2393
+ countryIso2CodeGeocode: true,
2394
+ timeZoneGeocode: true,
2395
+ latitudeGeocode: true,
2396
+ longitudeGeocode: true,
2397
+ city: {
2398
+ _id: true,
2399
+ name: true,
2400
+ localizedName: true,
2401
+ state: {
2402
+ _id: true,
2403
+ name: true,
2404
+ country: {
2405
+ _id: true,
2406
+ name: true
2407
+ }
2408
+ },
2409
+ latitude: true,
2410
+ longitude: true,
2411
+ timezone: true,
2412
+ }
2413
+ },
2414
+ trainer: true,
2415
+ trainerUrl: true,
2416
+ aboutMe: true,
2417
+ followStats: {
2418
+ followers: true,
2419
+ followed: true,
2420
+ raves: true,
2421
+ favorites: true
2422
+ },
2423
+ mainSport: {
2424
+ _id: true,
2425
+ name: true
2426
+ },
2427
+ mainSportLevel: {
2428
+ _id: true,
2429
+ label: true,
2430
+ index: true
2431
+ },
2432
+ scores: {
2433
+ vtxScore: true,
2434
+ socialScore: true,
2435
+ trainingScore: true,
2436
+ competitionScore: true
2437
+ },
2438
+ rankings: {
2439
+ worldRanking: {
2440
+ scope: true,
2441
+ scopeId: true,
2442
+ scopeName: true,
2443
+ position: true,
2444
+ total: true
2445
+ },
2446
+ countryRanking: {
2447
+ scope: true,
2448
+ scopeId: true,
2449
+ scopeName: true,
2450
+ position: true,
2451
+ total: true
2452
+ },
2453
+ stateRanking: {
2454
+ scope: true,
2455
+ scopeId: true,
2456
+ scopeName: true,
2457
+ position: true,
2458
+ total: true
2459
+ },
2460
+ cityRanking: {
2461
+ scope: true,
2462
+ scopeId: true,
2463
+ scopeName: true,
2464
+ position: true,
2465
+ total: true
2466
+ },
2467
+ },
2468
+ allSports: {
2469
+ _id: true,
2470
+ name: true
2471
+ },
2472
+ teams: {
2473
+ _id: true,
2474
+ name: true,
2475
+ description: true,
2476
+ approved: true,
2477
+ logo: {
2478
+ _id: true,
2479
+ name: true,
2480
+ contentType: true,
2481
+ size: true,
2482
+ useType: true,
2483
+ url: true,
2484
+ key: true
2485
+ },
2486
+ banner: {
2487
+ _id: true,
2488
+ name: true,
2489
+ contentType: true,
2490
+ size: true,
2491
+ useType: true,
2492
+ url: true,
2493
+ key: true
2494
+ }
2495
+ },
2496
+ sponsorBrands: {
2497
+ _id: true,
2498
+ name: true,
2499
+ slogan: true,
2500
+ website: true,
2501
+ description: true,
2502
+ approved: true,
2503
+ published: true,
2504
+ logo: {
2505
+ _id: true,
2506
+ name: true,
2507
+ contentType: true,
2508
+ size: true,
2509
+ useType: true,
2510
+ url: true,
2511
+ key: true
2512
+ },
2513
+ stats: {
2514
+ campaigns: true,
2515
+ sponsorships: true,
2516
+ sports: true,
2517
+ athletes: true
2518
+ },
2519
+ operatorIds: true,
2520
+ },
2521
+ competitions: {
2522
+ _id: true,
2523
+ event: {
2524
+ _id: true,
2525
+ name: true,
2526
+ eventWebSite: true,
2527
+ startDate: true,
2528
+ endDate: true,
2529
+ verified: true,
2530
+ banner: {
2531
+ _id: true,
2532
+ name: true,
2533
+ contentType: true,
2534
+ size: true,
2535
+ useType: true,
2536
+ url: true,
2537
+ key: true
2538
+ }
2539
+ },
2540
+ participationDate: true,
2541
+ result: {
2542
+ _id: true,
2543
+ resultType: true,
2544
+ position: true,
2545
+ score: true,
2546
+ finishTimeMS: true,
2547
+ resultWebLink: true
2548
+ }
2549
+ },
2550
+ totalUpcomingCompetitions: true,
2551
+ totalPastCompetitions: true,
2552
+ profilePicture: {
2553
+ _id: true,
2554
+ name: true,
2555
+ contentType: true,
2556
+ size: true,
2557
+ useType: true,
2558
+ url: true,
2559
+ key: true
2560
+ },
2561
+ cardPicture: {
2562
+ _id: true,
2563
+ name: true,
2564
+ contentType: true,
2565
+ size: true,
2566
+ useType: true,
2567
+ url: true,
2568
+ key: true
2569
+ }
2570
+ };
2571
+ let retValue;
2572
+ try {
2573
+ const response = await client.query({
2574
+ searchAthletes: {
2575
+ __args: {
2576
+ searchString: searchString
2577
+ },
2578
+ ...fields
2579
+ }
2580
+ });
2581
+ VTXBaseAPI.Logger.debug('searchAthletes Response:');
2582
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
2583
+ retValue = (0, response_builder_1.buildResponse)(response, 'searchAthletes', (r) => {
2584
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
2585
+ const isResponseOk = true && Array.isArray(response?.searchAthletes);
2586
+ return isResponseOk;
2587
+ });
2588
+ }
2589
+ catch (err1) {
2590
+ VTXBaseAPI.Logger.error('searchAthletes err1:');
2591
+ VTXBaseAPI.Logger.error(err1);
2592
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
2593
+ }
2594
+ return retValue;
2595
+ }
2596
+ async getRecommendedAthletes(loginEmail) {
2597
+ const client = (0, client_1.createClient)({
2598
+ url: this.backendUrl + "/graphql",
2599
+ headers: this.headers,
2600
+ });
2601
+ const fields = {
2602
+ _id: true,
2603
+ firstName: true,
2604
+ lastName: true,
2605
+ screenName: true,
2606
+ dob: true,
2607
+ lgbt: true,
2608
+ competitionGender: true,
2609
+ country: {
2610
+ _id: true,
2611
+ name: true
2612
+ },
2613
+ location: {
2614
+ userProvidedLatitude: true,
2615
+ userProvidedLongitude: true,
2616
+ cityNameGeocode: true,
2617
+ stateNameGeocode: true,
2618
+ countryIso2CodeGeocode: true,
2619
+ timeZoneGeocode: true,
2620
+ latitudeGeocode: true,
2621
+ longitudeGeocode: true,
2622
+ city: {
2623
+ _id: true,
2624
+ name: true,
2625
+ localizedName: true,
2626
+ state: {
2627
+ _id: true,
2628
+ name: true,
2629
+ country: {
2630
+ _id: true,
2631
+ name: true
2632
+ }
2633
+ },
2634
+ latitude: true,
2635
+ longitude: true,
2636
+ timezone: true,
2637
+ }
2638
+ },
2639
+ trainer: true,
2640
+ trainerUrl: true,
2641
+ aboutMe: true,
2642
+ followStats: {
2643
+ followers: true,
2644
+ followed: true,
2645
+ raves: true,
2646
+ favorites: true
2647
+ },
2648
+ mainSport: {
2649
+ _id: true,
2650
+ name: true
2651
+ },
2652
+ mainSportLevel: {
2653
+ _id: true,
2654
+ label: true,
2655
+ index: true
2656
+ },
2657
+ scores: {
2658
+ vtxScore: true,
2659
+ socialScore: true,
2660
+ trainingScore: true,
2661
+ competitionScore: true
2662
+ },
2663
+ rankings: {
2664
+ worldRanking: {
2665
+ scope: true,
2666
+ scopeId: true,
2667
+ scopeName: true,
2668
+ position: true,
2669
+ total: true
2670
+ },
2671
+ countryRanking: {
2672
+ scope: true,
2673
+ scopeId: true,
2674
+ scopeName: true,
2675
+ position: true,
2676
+ total: true
2677
+ },
2678
+ stateRanking: {
2679
+ scope: true,
2680
+ scopeId: true,
2681
+ scopeName: true,
2682
+ position: true,
2683
+ total: true
2684
+ },
2685
+ cityRanking: {
2686
+ scope: true,
2687
+ scopeId: true,
2688
+ scopeName: true,
2689
+ position: true,
2690
+ total: true
2691
+ },
2692
+ },
2693
+ allSports: {
2694
+ _id: true,
2695
+ name: true
2696
+ },
2697
+ teams: {
2698
+ _id: true,
2699
+ name: true,
2700
+ description: true,
2701
+ approved: true,
2702
+ logo: {
2703
+ _id: true,
2704
+ name: true,
2705
+ contentType: true,
2706
+ size: true,
2707
+ useType: true,
2708
+ url: true,
2709
+ key: true
2710
+ },
2711
+ banner: {
2712
+ _id: true,
2713
+ name: true,
2714
+ contentType: true,
2715
+ size: true,
2716
+ useType: true,
2717
+ url: true,
2718
+ key: true
2719
+ }
2720
+ },
2721
+ sponsorBrands: {
2722
+ _id: true,
2723
+ name: true,
2724
+ slogan: true,
2725
+ website: true,
2726
+ description: true,
2727
+ approved: true,
2728
+ published: true,
2729
+ logo: {
2730
+ _id: true,
2731
+ name: true,
2732
+ contentType: true,
2733
+ size: true,
2734
+ useType: true,
2735
+ url: true,
2736
+ key: true
2737
+ },
2738
+ stats: {
2739
+ campaigns: true,
2740
+ sponsorships: true,
2741
+ sports: true,
2742
+ athletes: true
2743
+ },
2744
+ operatorIds: true,
2745
+ },
2746
+ competitions: {
2747
+ _id: true,
2748
+ event: {
2749
+ _id: true,
2750
+ name: true,
2751
+ eventWebSite: true,
2752
+ startDate: true,
2753
+ endDate: true,
2754
+ verified: true,
2755
+ banner: {
2756
+ _id: true,
2757
+ name: true,
2758
+ contentType: true,
2759
+ size: true,
2760
+ useType: true,
2761
+ url: true,
2762
+ key: true
2763
+ }
2764
+ },
2765
+ participationDate: true,
2766
+ result: {
2767
+ _id: true,
2768
+ resultType: true,
2769
+ position: true,
2770
+ score: true,
2771
+ finishTimeMS: true,
2772
+ resultWebLink: true
2773
+ }
2774
+ },
2775
+ totalUpcomingCompetitions: true,
2776
+ totalPastCompetitions: true,
2777
+ profilePicture: {
2778
+ _id: true,
2779
+ name: true,
2780
+ contentType: true,
2781
+ size: true,
2782
+ useType: true,
2783
+ url: true,
2784
+ key: true
2785
+ },
2786
+ cardPicture: {
2787
+ _id: true,
2788
+ name: true,
2789
+ contentType: true,
2790
+ size: true,
2791
+ useType: true,
2792
+ url: true,
2793
+ key: true
2794
+ }
2795
+ };
2796
+ let retValue;
2797
+ try {
2798
+ const response = await client.query({
2799
+ getRecommendedAthletes: {
2800
+ __args: {
2801
+ loginEmail: loginEmail
2802
+ },
2803
+ ...fields
2804
+ }
2805
+ });
2806
+ VTXBaseAPI.Logger.debug('getRecommendedAthletes Response:');
2807
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
2808
+ retValue = (0, response_builder_1.buildResponse)(response, 'getRecommendedAthletes', (r) => {
2809
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
2810
+ const isResponseOk = true && Array.isArray(response?.getRecommendedAthletes);
2811
+ return isResponseOk;
2812
+ });
2813
+ }
2814
+ catch (err1) {
2815
+ VTXBaseAPI.Logger.error('getRecommendedAthletes err1:');
2816
+ VTXBaseAPI.Logger.error(err1);
2817
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
2818
+ }
2819
+ return retValue;
2820
+ }
2821
+ async getSponsorAthletesForTenant() {
2822
+ const client = (0, client_1.createClient)({
2823
+ url: this.backendUrl + "/graphql",
2824
+ headers: this.headers,
2825
+ });
2826
+ const fields = {
2827
+ _id: true,
2828
+ firstName: true,
2829
+ lastName: true,
2830
+ screenName: true,
2831
+ dob: true,
2832
+ lgbt: true,
2833
+ competitionGender: true,
2834
+ country: {
2835
+ _id: true,
2836
+ name: true
2837
+ },
2838
+ location: {
2839
+ userProvidedLatitude: true,
2840
+ userProvidedLongitude: true,
2841
+ cityNameGeocode: true,
2842
+ stateNameGeocode: true,
2843
+ countryIso2CodeGeocode: true,
2844
+ timeZoneGeocode: true,
2845
+ latitudeGeocode: true,
2846
+ longitudeGeocode: true,
2847
+ city: {
2848
+ _id: true,
2849
+ name: true,
2850
+ localizedName: true,
2851
+ state: {
2852
+ _id: true,
2853
+ name: true,
2854
+ country: {
2855
+ _id: true,
2856
+ name: true
2857
+ }
2858
+ },
2859
+ latitude: true,
2860
+ longitude: true,
2861
+ timezone: true,
2862
+ }
2863
+ },
2864
+ trainer: true,
2865
+ trainerUrl: true,
2866
+ aboutMe: true,
2867
+ followStats: {
2868
+ followers: true,
2869
+ followed: true,
2870
+ raves: true,
2871
+ favorites: true
2872
+ },
2873
+ mainSport: {
2874
+ _id: true,
2875
+ name: true
2876
+ },
2877
+ mainSportLevel: {
2878
+ _id: true,
2879
+ label: true,
2880
+ index: true
2881
+ },
2882
+ scores: {
2883
+ vtxScore: true,
2884
+ socialScore: true,
2885
+ trainingScore: true,
2886
+ competitionScore: true
2887
+ },
2888
+ rankings: {
2889
+ worldRanking: {
2890
+ scope: true,
2891
+ scopeId: true,
2892
+ scopeName: true,
2893
+ position: true,
2894
+ total: true
2895
+ },
2896
+ countryRanking: {
2897
+ scope: true,
2898
+ scopeId: true,
2899
+ scopeName: true,
2900
+ position: true,
2901
+ total: true
2902
+ },
2903
+ stateRanking: {
2904
+ scope: true,
2905
+ scopeId: true,
2906
+ scopeName: true,
2907
+ position: true,
2908
+ total: true
2909
+ },
2910
+ cityRanking: {
2911
+ scope: true,
2912
+ scopeId: true,
2913
+ scopeName: true,
2914
+ position: true,
2915
+ total: true
2916
+ },
2917
+ },
2918
+ allSports: {
2919
+ _id: true,
2920
+ name: true
2921
+ },
2922
+ teams: {
2923
+ _id: true,
2924
+ name: true,
2925
+ description: true,
2926
+ approved: true,
2927
+ logo: {
2928
+ _id: true,
2929
+ name: true,
2930
+ contentType: true,
2931
+ size: true,
2932
+ useType: true,
2933
+ url: true,
2934
+ key: true
2935
+ },
2936
+ banner: {
2937
+ _id: true,
2938
+ name: true,
2939
+ contentType: true,
2940
+ size: true,
2941
+ useType: true,
2942
+ url: true,
2943
+ key: true
2944
+ }
2945
+ },
2946
+ sponsorBrands: {
2947
+ _id: true,
2948
+ name: true,
2949
+ slogan: true,
2950
+ website: true,
2951
+ description: true,
2952
+ approved: true,
2953
+ published: true,
2954
+ logo: {
2955
+ _id: true,
2956
+ name: true,
2957
+ contentType: true,
2958
+ size: true,
2959
+ useType: true,
2960
+ url: true,
2961
+ key: true
2962
+ },
2963
+ stats: {
2964
+ campaigns: true,
2965
+ sponsorships: true,
2966
+ sports: true,
2967
+ athletes: true
2968
+ },
2969
+ operatorIds: true,
2970
+ },
2971
+ competitions: {
2972
+ _id: true,
2973
+ event: {
2974
+ _id: true,
2975
+ name: true,
2976
+ eventWebSite: true,
2977
+ startDate: true,
2978
+ endDate: true,
2979
+ verified: true,
2980
+ banner: {
2981
+ _id: true,
2982
+ name: true,
2983
+ contentType: true,
2984
+ size: true,
2985
+ useType: true,
2986
+ url: true,
2987
+ key: true
2988
+ }
2989
+ },
2990
+ participationDate: true,
2991
+ result: {
2992
+ _id: true,
2993
+ resultType: true,
2994
+ position: true,
2995
+ score: true,
2996
+ finishTimeMS: true,
2997
+ resultWebLink: true
2998
+ }
2999
+ },
3000
+ totalUpcomingCompetitions: true,
3001
+ totalPastCompetitions: true,
3002
+ profilePicture: {
3003
+ _id: true,
3004
+ name: true,
3005
+ contentType: true,
3006
+ size: true,
3007
+ useType: true,
3008
+ url: true,
3009
+ key: true
3010
+ },
3011
+ cardPicture: {
3012
+ _id: true,
3013
+ name: true,
3014
+ contentType: true,
3015
+ size: true,
3016
+ useType: true,
3017
+ url: true,
3018
+ key: true
3019
+ }
3020
+ };
3021
+ let retValue;
3022
+ try {
3023
+ const response = await client.query({
3024
+ getSponsorAthletesForTenant: {
3025
+ __args: {},
3026
+ ...fields
3027
+ }
3028
+ });
3029
+ VTXBaseAPI.Logger.debug('getSponsorAthletesForTenant Response:');
3030
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
3031
+ retValue = (0, response_builder_1.buildResponse)(response, 'getSponsorAthletesForTenant', (r) => {
3032
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
3033
+ const isResponseOk = true && Array.isArray(response?.getSponsorAthletesForTenant);
3034
+ return isResponseOk;
3035
+ });
3036
+ }
3037
+ catch (err1) {
3038
+ VTXBaseAPI.Logger.error('getSponsorAthletesForTenant err1:');
3039
+ VTXBaseAPI.Logger.error(err1);
3040
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
3041
+ }
3042
+ return retValue;
3043
+ }
3044
+ async getUserImagesFromEmail(loginEmail) {
3045
+ const client = (0, client_1.createClient)({
3046
+ url: this.backendUrl + "/graphql",
3047
+ headers: this.headers,
3048
+ });
3049
+ const fields = {
3050
+ profilePictureUrl: true,
3051
+ cardPictureUrl: true,
3052
+ bannerPictureUrl: true
3053
+ };
3054
+ let retValue;
3055
+ try {
3056
+ const response = await client.query({
3057
+ getUserImagesFromEmail: {
3058
+ __args: {
3059
+ loginEmail: loginEmail
3060
+ },
3061
+ ...fields
3062
+ }
3063
+ });
3064
+ VTXBaseAPI.Logger.debug('getUserImagesFromEmail Response:');
3065
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
3066
+ retValue = (0, response_builder_1.buildResponse)(response, 'getUserImagesFromEmail', (r) => {
3067
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
3068
+ const isResponseOk = true && response?.getUserImagesFromEmail;
3069
+ return isResponseOk;
3070
+ });
3071
+ }
3072
+ catch (err1) {
3073
+ VTXBaseAPI.Logger.error('getUserImagesFromEmail err1:');
3074
+ VTXBaseAPI.Logger.error(err1);
3075
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
3076
+ }
3077
+ return retValue;
3078
+ }
3079
+ async editAboutMe(newValue) {
3080
+ console.log('HEADERS:');
3081
+ console.log(JSON.stringify(this.headers, null, 2));
3082
+ const client = (0, client_1.createClient)({
3083
+ url: this.backendUrl + '/graphql',
3084
+ headers: this.headers,
3085
+ });
3086
+ let retValue = {};
3087
+ const fields = {
3088
+ field: true,
3089
+ oldValue: true,
3090
+ newValue: true,
3091
+ changed: true
3092
+ };
3093
+ const dto = {
3094
+ field: 'aboutMe',
3095
+ newValue: newValue
3096
+ };
3097
+ try {
3098
+ const response = await client.mutation({
3099
+ editProfileValue: {
3100
+ __args: {
3101
+ input: dto
3102
+ },
3103
+ ...fields
3104
+ },
3105
+ });
3106
+ VTXBaseAPI.Logger.debug('editProfileValue Response:');
3107
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
3108
+ retValue = (0, response_builder_1.buildResponse)(response, 'editProfileValue', (r) => {
3109
+ const isResponseOk = true && response?.editProfileValue?.field;
3110
+ return isResponseOk;
3111
+ });
3112
+ }
3113
+ catch (err1) {
3114
+ VTXBaseAPI.Logger.error('editProfileValue err1:');
3115
+ VTXBaseAPI.Logger.error(err1);
3116
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
3117
+ }
3118
+ return retValue;
3119
+ }
3120
+ async editProfileValue(newValue, field) {
3121
+ const client = (0, client_1.createClient)({
3122
+ url: this.backendUrl + '/graphql',
3123
+ headers: this.headers,
3124
+ });
3125
+ let retValue = {};
3126
+ const fields = {
3127
+ field: true,
3128
+ oldValue: true,
3129
+ newValue: true,
3130
+ changed: true
3131
+ };
3132
+ const dto = {
3133
+ field: field,
3134
+ newValue: newValue
3135
+ };
3136
+ try {
3137
+ const response = await client.mutation({
3138
+ editProfileValue: {
3139
+ __args: {
3140
+ input: dto
3141
+ },
3142
+ ...fields
3143
+ },
3144
+ });
3145
+ VTXBaseAPI.Logger.debug('editProfileValue Response:');
3146
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
3147
+ retValue = (0, response_builder_1.buildResponse)(response, 'editProfileValue', (r) => {
3148
+ const isResponseOk = true && response?.editProfileValue?.field;
3149
+ return isResponseOk;
3150
+ });
3151
+ }
3152
+ catch (err1) {
3153
+ VTXBaseAPI.Logger.error('editProfileValue err1:');
3154
+ VTXBaseAPI.Logger.error(err1);
3155
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
3156
+ }
3157
+ return retValue;
3158
+ }
3159
+ async addAthleteCompetition(dto) {
3160
+ console.log('HEADERS:');
3161
+ console.log(JSON.stringify(this.headers, null, 2));
3162
+ const client = (0, client_1.createClient)({
3163
+ url: this.backendUrl + '/graphql',
3164
+ headers: this.headers,
3165
+ });
3166
+ let retValue = {};
3167
+ const fields = {
3168
+ _id: true,
3169
+ event: {
3170
+ _id: true,
3171
+ name: true,
3172
+ eventWebSite: true,
3173
+ startDate: true,
3174
+ endDate: true,
3175
+ verified: true,
3176
+ banner: {
3177
+ _id: true,
3178
+ name: true,
3179
+ contentType: true,
3180
+ size: true,
3181
+ useType: true,
3182
+ url: true,
3183
+ key: true
3184
+ },
3185
+ },
3186
+ participationDate: true,
3187
+ competitionNumber: true,
3188
+ result: {
3189
+ resultType: true,
3190
+ position: true,
3191
+ score: true,
3192
+ finishTimeMS: true,
3193
+ resultWebLink: true
3194
+ },
3195
+ fundRaisingCampaignId: true
3196
+ };
3197
+ try {
3198
+ const response = await client.mutation({
3199
+ addAthleteCompetition: {
3200
+ __args: {
3201
+ input: dto
3202
+ },
3203
+ ...fields
3204
+ },
3205
+ });
3206
+ VTXBaseAPI.Logger.debug('addAthleteCompetition Response:');
3207
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
3208
+ retValue = (0, response_builder_1.buildResponse)(response, 'addAthleteCompetition', (r) => {
3209
+ const isResponseOk = true && response?.addAthleteCompetition?._id;
3210
+ return isResponseOk;
3211
+ });
3212
+ }
3213
+ catch (err1) {
3214
+ VTXBaseAPI.Logger.error('addAthleteCompetition err1:');
3215
+ VTXBaseAPI.Logger.error(err1);
3216
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
3217
+ }
3218
+ return retValue;
3219
+ }
3220
+ async getSportsEvents(dto) {
3221
+ const client = (0, client_1.createClient)({
3222
+ url: this.backendUrl + "/graphql",
3223
+ headers: this.headers,
3224
+ });
3225
+ const fields = {
3226
+ _id: true,
3227
+ name: true,
3228
+ eventWebSite: true,
3229
+ startDate: true,
3230
+ endDate: true,
3231
+ verified: true,
3232
+ banner: {
3233
+ _id: true,
3234
+ name: true,
3235
+ contentType: true,
3236
+ size: true,
3237
+ useType: true,
3238
+ url: true,
3239
+ key: true
3240
+ }
3241
+ };
3242
+ let retValue;
3243
+ try {
3244
+ const response = await client.query({
3245
+ getSportsEvents: {
3246
+ __args: {
3247
+ input: dto
3248
+ },
3249
+ ...fields
3250
+ }
3251
+ });
3252
+ VTXBaseAPI.Logger.debug('getSportsEvents Response:');
3253
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
3254
+ retValue = (0, response_builder_1.buildResponse)(response, 'getSportsEvents', (r) => {
3255
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
3256
+ const isResponseOk = true && Array.isArray(response?.getSportsEvents);
3257
+ return isResponseOk;
3258
+ });
3259
+ }
3260
+ catch (err1) {
3261
+ VTXBaseAPI.Logger.error('getSportsEvents err1:');
3262
+ VTXBaseAPI.Logger.error(err1);
3263
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
3264
+ }
3265
+ return retValue;
3266
+ }
3267
+ async createSportsEvent(dto) {
3268
+ console.log('HEADERS:');
3269
+ console.log(JSON.stringify(this.headers, null, 2));
3270
+ const client = (0, client_1.createClient)({
3271
+ url: this.backendUrl + '/graphql',
3272
+ headers: this.headers,
3273
+ });
3274
+ let retValue = {};
3275
+ const fields = {
3276
+ _id: true,
3277
+ name: true,
3278
+ eventWebSite: true,
3279
+ startDate: true,
3280
+ endDate: true,
3281
+ verified: true,
3282
+ banner: {
3283
+ _id: true,
3284
+ name: true,
3285
+ contentType: true,
3286
+ size: true,
3287
+ useType: true,
3288
+ url: true,
3289
+ key: true
3290
+ },
3291
+ };
3292
+ try {
3293
+ const response = await client.mutation({
3294
+ createSportsEvent: {
3295
+ __args: {
3296
+ input: dto
3297
+ },
3298
+ ...fields
3299
+ },
3300
+ });
3301
+ VTXBaseAPI.Logger.debug('createSportsEvent Response:');
3302
+ VTXBaseAPI.Logger.debug(JSON.stringify(response, null, 2));
3303
+ retValue = (0, response_builder_1.buildResponse)(response, 'createSportsEvent', (r) => {
3304
+ const isResponseOk = true && response?.createSportsEvent?._id;
3305
+ return isResponseOk;
3306
+ });
3307
+ }
3308
+ catch (err1) {
3309
+ VTXBaseAPI.Logger.error('createSportsEvent err1:');
3310
+ VTXBaseAPI.Logger.error(err1);
3311
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
243
3312
  }
244
3313
  return retValue;
245
3314
  }
246
3315
  }
247
3316
  exports.VTXBaseAPI = VTXBaseAPI;
3317
+ VTXBaseAPI.Logger = {
3318
+ debug: (str) => {
3319
+ },
3320
+ log: (str) => {
3321
+ },
3322
+ warn: (str) => {
3323
+ },
3324
+ error: (str) => {
3325
+ console.error(str);
3326
+ },
3327
+ };
248
3328
  //# sourceMappingURL=vtx-base-api.js.map