@vertikalx/vtx-backend-client 1.0.0-dev.43 → 1.0.0-dev.44

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.
@@ -6,6 +6,7 @@ const client_1 = require("../client");
6
6
  const api_call_headers_1 = require("./api-call-headers");
7
7
  const response_builder_1 = require("./response-builder");
8
8
  const domains_1 = require("./domains");
9
+ const vtx_core_common_1 = require("@vertikalx/vtx-core-common");
9
10
  class VTXBaseAPI {
10
11
  constructor(headers, backendUrl) {
11
12
  this.headers = headers ?? api_call_headers_1.DEFAULT_HEADERS;
@@ -74,52 +75,21 @@ class VTXBaseAPI {
74
75
  }
75
76
  },
76
77
  });
78
+ console.log('findUserByEmail Response:');
77
79
  console.log(JSON.stringify(response, null, 2));
78
- if (response?.findUserByEmail?._id) {
79
- try {
80
- retValue.data = response.findUserByEmail;
81
- }
82
- catch (casterr) {
83
- console.log('Error trying to cast to User');
84
- retValue.errors = ['Error: Obtained incorrect data from Backend'];
85
- }
86
- }
87
- else if (response?.errors) {
88
- if (Array.isArray(response.errors)) {
89
- retValue.errors = response.errors;
90
- }
91
- else {
92
- retValue.errors = [response.errors];
93
- }
94
- }
95
- else if (response?.error) {
96
- if (Array.isArray(response.error)) {
97
- retValue.errors = response.error;
98
- }
99
- else {
100
- retValue.errors = [response.error];
101
- }
102
- }
103
- else {
104
- retValue.errors = ['Error: Obtained incorrect data from Backend'];
105
- }
80
+ retValue = (0, response_builder_1.buildResponse)(response, 'findUserByEmail', (r) => {
81
+ const isResponseOk = true && response?.findUserByEmail?._id;
82
+ return isResponseOk;
83
+ });
106
84
  }
107
85
  catch (err1) {
108
- try {
109
- console.log('ERROR trying to call server');
110
- console.log(JSON.stringify(err1, null, 2));
111
- }
112
- catch (ex) { }
113
- if (Array.isArray(err1)) {
114
- retValue.errors = err1;
115
- }
116
- else {
117
- retValue.errors = [err1];
118
- }
86
+ console.log('findUserByEmail err1:');
87
+ console.log(err1);
88
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
119
89
  }
120
90
  return retValue;
121
91
  }
122
- async loginUserFromEmail(loginEmail) {
92
+ async loginUserFromEmail(loginEmail, loginMethod = "") {
123
93
  const client = (0, client_1.createClient)({
124
94
  url: this.backendUrl + '/graphql',
125
95
  headers: this.headers,
@@ -131,50 +101,23 @@ class VTXBaseAPI {
131
101
  loginUserFromEmail: {
132
102
  __args: {
133
103
  email: curatedEmail,
104
+ loginMethod: loginMethod
134
105
  },
135
106
  actualToken: true,
136
107
  refreshToken: true,
137
108
  },
138
109
  });
110
+ console.log('loginUserFromEmail Response:');
139
111
  console.log(JSON.stringify(response, null, 2));
140
- if (response?.loginUserFromEmail?.actualToken) {
141
- try {
142
- retValue.data =
143
- response.loginUserFromEmail;
144
- }
145
- catch (casterr) {
146
- console.log('Error trying to cast to UserToken:');
147
- retValue.errors = ['Error: Obtained incorrect data from Backend'];
148
- }
149
- }
150
- else if (response?.errors) {
151
- if (Array.isArray(response.errors)) {
152
- retValue.errors = response.errors;
153
- }
154
- else {
155
- retValue.errors = [response.errors];
156
- }
157
- }
158
- else if (response?.error) {
159
- if (Array.isArray(response.error)) {
160
- retValue.errors = response.error;
161
- }
162
- else {
163
- retValue.errors = [response.error];
164
- }
165
- }
166
- else {
167
- retValue.errors = ['Error: Obtained incorrect data from Backend'];
168
- }
112
+ retValue = (0, response_builder_1.buildResponse)(response, 'loginUserFromEmail', (r) => {
113
+ const isResponseOk = true && response?.loginUserFromEmail?.actualToken;
114
+ return isResponseOk;
115
+ });
169
116
  }
170
117
  catch (err1) {
171
- console.log(JSON.stringify(err1, null, 2));
172
- if (Array.isArray(err1)) {
173
- retValue.errors = err1;
174
- }
175
- else {
176
- retValue.errors = [err1];
177
- }
118
+ console.log('loginUserFromEmail err1:');
119
+ console.log(err1);
120
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
178
121
  }
179
122
  return retValue;
180
123
  }
@@ -203,53 +146,17 @@ class VTXBaseAPI {
203
146
  }
204
147
  }
205
148
  });
149
+ console.log('createUserAndLogin Response:');
206
150
  console.log(JSON.stringify(response, null, 2));
207
- if (response?.createUserAndLogin?._id) {
208
- try {
209
- retValue.data = response.createUserAndLogin;
210
- }
211
- catch (casterr) {
212
- console.log('Error trying to cast to UserToken:');
213
- retValue.errors = ['Error: Obtained incorrect data from Backend'];
214
- }
215
- }
216
- else if (response?.errors) {
217
- if (Array.isArray(response.errors)) {
218
- retValue.errors = response.errors;
219
- }
220
- else {
221
- retValue.errors = [response.errors];
222
- }
223
- }
224
- else if (response?.error) {
225
- if (Array.isArray(response.error)) {
226
- retValue.errors = response.error;
227
- }
228
- else {
229
- retValue.errors = [response.error];
230
- }
231
- }
232
- else if (response?.data?._id) {
233
- try {
234
- retValue.data = response?.data;
235
- }
236
- catch (casterr) {
237
- console.log('Error trying to cast to UserWithToken:');
238
- retValue.errors = ['Error: Obtained incorrect data from Backend'];
239
- }
240
- }
241
- else {
242
- retValue.errors = ['Error: Obtained incorrect data from Backend'];
243
- }
151
+ retValue = (0, response_builder_1.buildResponse)(response, 'createUserAndLogin', (r) => {
152
+ const isResponseOk = true && response?.createUserAndLogin?._id;
153
+ return isResponseOk;
154
+ });
244
155
  }
245
156
  catch (err1) {
246
- console.log(JSON.stringify(err1, null, 2));
247
- if (Array.isArray(err1)) {
248
- retValue.errors = err1;
249
- }
250
- else {
251
- retValue.errors = [err1];
252
- }
157
+ console.log('createUserAndLogin err1:');
158
+ console.log(err1);
159
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
253
160
  }
254
161
  return retValue;
255
162
  }
@@ -259,67 +166,221 @@ class VTXBaseAPI {
259
166
  headers: this.headers,
260
167
  });
261
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
+ followStats: {
210
+ followers: true,
211
+ followed: true,
212
+ raves: true,
213
+ favorites: true
214
+ },
215
+ mainSport: {
216
+ _id: true,
217
+ name: true
218
+ },
219
+ mainSportLevel: {
220
+ _id: true,
221
+ label: true,
222
+ index: true
223
+ },
224
+ scores: {
225
+ vtxScore: true,
226
+ socialScore: true,
227
+ trainingScore: true,
228
+ competitionScore: true
229
+ },
230
+ rankings: {
231
+ worldRanking: {
232
+ scope: true,
233
+ scopeId: true,
234
+ scopeName: true,
235
+ position: true,
236
+ total: true
237
+ },
238
+ countryRanking: {
239
+ scope: true,
240
+ scopeId: true,
241
+ scopeName: true,
242
+ position: true,
243
+ total: true
244
+ },
245
+ stateRanking: {
246
+ scope: true,
247
+ scopeId: true,
248
+ scopeName: true,
249
+ position: true,
250
+ total: true
251
+ },
252
+ cityRanking: {
253
+ scope: true,
254
+ scopeId: true,
255
+ scopeName: true,
256
+ position: true,
257
+ total: true
258
+ },
259
+ },
260
+ allSports: {
261
+ _id: true,
262
+ name: true
263
+ },
264
+ teams: {
265
+ _id: true,
266
+ name: true,
267
+ description: true,
268
+ approved: true,
269
+ logo: {
270
+ _id: true,
271
+ name: true,
272
+ contentType: true,
273
+ size: true,
274
+ useType: true,
275
+ url: true,
276
+ key: true
277
+ },
278
+ banner: {
279
+ _id: true,
280
+ name: true,
281
+ contentType: true,
282
+ size: true,
283
+ useType: true,
284
+ url: true,
285
+ key: true
286
+ }
287
+ },
288
+ sponsorBrands: {
289
+ _id: true,
290
+ name: true,
291
+ slogan: true,
292
+ website: true,
293
+ description: true,
294
+ approved: true,
295
+ published: true,
296
+ logo: {
297
+ _id: true,
298
+ name: true,
299
+ contentType: true,
300
+ size: true,
301
+ useType: true,
302
+ url: true,
303
+ key: true
304
+ },
305
+ stats: {
306
+ campaigns: true,
307
+ sponsorships: true,
308
+ sports: true,
309
+ athletes: true
310
+ },
311
+ operatorIds: true,
312
+ },
313
+ competitions: {
314
+ _id: true,
315
+ event: {
316
+ _id: true,
317
+ name: true,
318
+ eventWebSite: true,
319
+ startDate: true,
320
+ endDate: true,
321
+ verified: true,
322
+ banner: {
323
+ _id: true,
324
+ name: true,
325
+ contentType: true,
326
+ size: true,
327
+ useType: true,
328
+ url: true,
329
+ key: true
330
+ }
331
+ },
332
+ eventName: true,
333
+ date: true,
334
+ result: {
335
+ _id: true,
336
+ type: true,
337
+ position: true,
338
+ score: true,
339
+ timems: true,
340
+ resultWebLink: true
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
362
+ }
363
+ };
262
364
  try {
263
365
  const response = await client.mutation({
264
366
  registerAthlete: {
265
367
  __args: {
266
368
  input: payload
267
369
  },
268
- _id: true,
269
- firstName: true,
270
- lastName: true,
271
- screenName: true,
272
- countryId: true,
273
- countryName: true
370
+ ...fields
274
371
  }
275
372
  });
373
+ console.log('registerAthlete Response:');
276
374
  console.log(JSON.stringify(response, null, 2));
277
- if (response?.registerAthlete?._id) {
278
- try {
279
- retValue.data = response?.registerAthlete;
280
- }
281
- catch (casterr) {
282
- console.log('Error trying to cast to Athlete:');
283
- retValue.errors = ['Error: Obtained incorrect data from Backend'];
284
- }
285
- }
286
- else if (response?.errors) {
287
- if (Array.isArray(response.errors)) {
288
- retValue.errors = response.errors;
289
- }
290
- else {
291
- retValue.errors = [response.errors];
292
- }
293
- }
294
- else if (response?.error) {
295
- if (Array.isArray(response.error)) {
296
- retValue.errors = response.error;
297
- }
298
- else {
299
- retValue.errors = [response.error];
300
- }
301
- }
302
- else if (response?.data?._id) {
303
- try {
304
- retValue.data = response?.data;
305
- }
306
- catch (casterr) {
307
- console.log('Error trying to cast to Athlete:');
308
- retValue.errors = ['Error: Obtained incorrect data from Backend'];
309
- }
310
- }
311
- else {
312
- retValue.errors = ['Error: Obtained incorrect data from Backend'];
313
- }
375
+ retValue = (0, response_builder_1.buildResponse)(response, 'registerAthlete', (r) => {
376
+ const isResponseOk = true && response?.registerAthlete?._id;
377
+ return isResponseOk;
378
+ });
314
379
  }
315
380
  catch (err1) {
316
- console.log(JSON.stringify(err1, null, 2));
317
- if (Array.isArray(err1)) {
318
- retValue.errors = err1;
319
- }
320
- else {
321
- retValue.errors = [err1];
322
- }
381
+ console.log('registerAthlete err1:');
382
+ console.log(err1);
383
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
323
384
  }
324
385
  return retValue;
325
386
  }
@@ -399,49 +460,17 @@ class VTXBaseAPI {
399
460
  }
400
461
  });
401
462
  }
402
- if (response?.getBrandByName?._id) {
403
- try {
404
- retValue.data = response?.getBrandByName;
405
- }
406
- catch (casterr) {
407
- retValue.errors = ['Error: Obtained incorrect data from Backend'];
408
- }
409
- }
410
- else if (response?.errors) {
411
- if (Array.isArray(response.errors)) {
412
- retValue.errors = response.errors;
413
- }
414
- else {
415
- retValue.errors = [response.errors];
416
- }
417
- }
418
- else if (response?.error) {
419
- if (Array.isArray(response.error)) {
420
- retValue.errors = response.error;
421
- }
422
- else {
423
- retValue.errors = [response.error];
424
- }
425
- }
426
- else if (response?.data?._id) {
427
- try {
428
- retValue.data = response?.data;
429
- }
430
- catch (casterr) {
431
- retValue.errors = ['Error: Obtained incorrect data from Backend'];
432
- }
433
- }
434
- else {
435
- retValue.errors = ['Error: Obtained incorrect data from Backend'];
436
- }
463
+ console.log('getBrandByName Response:');
464
+ console.log(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
+ });
437
469
  }
438
470
  catch (err1) {
439
- if (Array.isArray(err1)) {
440
- retValue.errors = err1;
441
- }
442
- else {
443
- retValue.errors = [err1];
444
- }
471
+ console.log('getBrandByName err1:');
472
+ console.log(err1);
473
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
445
474
  }
446
475
  return retValue;
447
476
  }
@@ -461,54 +490,17 @@ class VTXBaseAPI {
461
490
  ...fields
462
491
  }
463
492
  });
464
- console.log('Create Brand Response:');
493
+ console.log('createBrand Response:');
465
494
  console.log(JSON.stringify(response, null, 2));
466
- if (response?.createBrand?._id) {
467
- try {
468
- retValue.data = response?.createBrand;
469
- }
470
- catch (casterr) {
471
- console.log('Error trying to cast to Brand:');
472
- retValue.errors = ['Error: Obtained incorrect data from Backend'];
473
- }
474
- }
475
- else if (response?.errors) {
476
- if (Array.isArray(response.errors)) {
477
- retValue.errors = response.errors;
478
- }
479
- else {
480
- retValue.errors = [response.errors];
481
- }
482
- }
483
- else if (response?.error) {
484
- if (Array.isArray(response.error)) {
485
- retValue.errors = response.error;
486
- }
487
- else {
488
- retValue.errors = [response.error];
489
- }
490
- }
491
- else if (response?.data?._id) {
492
- try {
493
- retValue.data = response?.data;
494
- }
495
- catch (casterr) {
496
- console.log('Error trying to cast to Brand:');
497
- retValue.errors = ['Error: Obtained incorrect data from Backend'];
498
- }
499
- }
500
- else {
501
- retValue.errors = ['Error: Obtained incorrect data from Backend'];
502
- }
495
+ retValue = (0, response_builder_1.buildResponse)(response, 'createBrand', (r) => {
496
+ const isResponseOk = true && response?.createBrand?._id;
497
+ return isResponseOk;
498
+ });
503
499
  }
504
500
  catch (err1) {
505
- console.log(JSON.stringify(err1, null, 2));
506
- if (Array.isArray(err1)) {
507
- retValue.errors = err1;
508
- }
509
- else {
510
- retValue.errors = [err1];
511
- }
501
+ console.log('createBrand err1:');
502
+ console.log(err1);
503
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
512
504
  }
513
505
  return retValue;
514
506
  }
@@ -528,54 +520,17 @@ class VTXBaseAPI {
528
520
  ...fields
529
521
  }
530
522
  });
531
- console.log('Create Sponsorship Response:');
523
+ console.log('createSponsorship Response:');
532
524
  console.log(JSON.stringify(response, null, 2));
533
- if (response?.createSponsorship?._id) {
534
- try {
535
- retValue.data = response?.createSponsorship;
536
- }
537
- catch (casterr) {
538
- console.log('Error trying to cast to Sponsorship:');
539
- retValue.errors = ['Error: Obtained incorrect data from Backend'];
540
- }
541
- }
542
- else if (response?.errors) {
543
- if (Array.isArray(response.errors)) {
544
- retValue.errors = response.errors;
545
- }
546
- else {
547
- retValue.errors = [response.errors];
548
- }
549
- }
550
- else if (response?.error) {
551
- if (Array.isArray(response.error)) {
552
- retValue.errors = response.error;
553
- }
554
- else {
555
- retValue.errors = [response.error];
556
- }
557
- }
558
- else if (response?.data?._id) {
559
- try {
560
- retValue.data = response?.data;
561
- }
562
- catch (casterr) {
563
- console.log('Error trying to cast to Sponsorship:');
564
- retValue.errors = ['Error: Obtained incorrect data from Backend'];
565
- }
566
- }
567
- else {
568
- retValue.errors = ['Error: Obtained incorrect data from Backend'];
569
- }
525
+ retValue = (0, response_builder_1.buildResponse)(response, 'createSponsorship', (r) => {
526
+ const isResponseOk = true && response?.createSponsorship?._id;
527
+ return isResponseOk;
528
+ });
570
529
  }
571
530
  catch (err1) {
572
- console.log(JSON.stringify(err1, null, 2));
573
- if (Array.isArray(err1)) {
574
- retValue.errors = err1;
575
- }
576
- else {
577
- retValue.errors = [err1];
578
- }
531
+ console.log('createSponsorship err1:');
532
+ console.log(err1);
533
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
579
534
  }
580
535
  return retValue;
581
536
  }
@@ -606,27 +561,15 @@ class VTXBaseAPI {
606
561
  });
607
562
  console.log('getUploadUrl Response:');
608
563
  console.log(JSON.stringify(response, null, 2));
609
- if (response?.getUploadUrl?.key) {
610
- try {
611
- retValue.data = response?.getUploadUrl;
612
- }
613
- catch (casterr) {
614
- console.log('Error trying to cast to AWSS3UploadUrl:');
615
- retValue.errors = ['Error: Obtained incorrect data from Backend'];
616
- }
617
- }
618
- else {
619
- retValue.errors = ["Unable to generate correct upload URL"];
620
- }
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
+ });
621
568
  }
622
569
  catch (err1) {
623
- console.log(JSON.stringify(err1, null, 2));
624
- if (Array.isArray(err1)) {
625
- retValue.errors = err1;
626
- }
627
- else {
628
- retValue.errors = [err1];
629
- }
570
+ console.log('createSponsorship err1:');
571
+ console.log(err1);
572
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
630
573
  }
631
574
  return retValue;
632
575
  }
@@ -825,7 +768,42 @@ class VTXBaseAPI {
825
768
  _id: true,
826
769
  title: true,
827
770
  description: true,
828
- terms: 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
+ },
829
807
  banner: {
830
808
  _id: true,
831
809
  name: true,
@@ -835,6 +813,18 @@ class VTXBaseAPI {
835
813
  url: true,
836
814
  key: true
837
815
  },
816
+ criteria: {
817
+ _id: true,
818
+ label: true
819
+ },
820
+ deadline: true,
821
+ startDate: true,
822
+ duration: {
823
+ length: true,
824
+ unit: true
825
+ },
826
+ terms: true,
827
+ isPrivate: true,
838
828
  stats: {
839
829
  totalApplications: true,
840
830
  newApplications: true,
@@ -845,11 +835,7 @@ class VTXBaseAPI {
845
835
  remainingSponsorships: true
846
836
  },
847
837
  approved: true,
848
- published: true,
849
- criteria: {
850
- _id: true,
851
- label: true
852
- }
838
+ published: true
853
839
  };
854
840
  let retValue;
855
841
  try {
@@ -877,7 +863,11 @@ class VTXBaseAPI {
877
863
  async getTenantSponsorshipsFromUri(tenantUri, token) {
878
864
  if ((!tenantUri) || (tenantUri.trim() === "")) {
879
865
  return {
880
- errors: ["INVALID Tenant URI: " + tenantUri]
866
+ error: {
867
+ httpStatus: 400,
868
+ code: vtx_core_common_1.VTX_ERRORS.INVALID_TENANT_URI.code,
869
+ message: vtx_core_common_1.VTX_ERRORS.INVALID_TENANT_URI.description
870
+ }
881
871
  };
882
872
  }
883
873
  const credential = token.domains.find(c => {
@@ -890,13 +880,21 @@ class VTXBaseAPI {
890
880
  });
891
881
  if (!credential) {
892
882
  return {
893
- errors: ["Tenant in domain SPONSOR not found in domains with URI " + tenantUri]
883
+ error: {
884
+ httpStatus: 400,
885
+ code: vtx_core_common_1.VTX_ERRORS.INVALID_TENANT_URI_FOR_SPONSOR.code,
886
+ message: "Tenant in domain SPONSOR not found in domains with URI " + tenantUri
887
+ }
894
888
  };
895
889
  }
896
890
  const tenantId = credential.tenant?._id ?? null;
897
891
  if ((!tenantId) || (tenantId == "ALL")) {
898
892
  return {
899
- errors: ["INVALID Tenant ID: " + tenantId]
893
+ error: {
894
+ httpStatus: 400,
895
+ code: vtx_core_common_1.VTX_ERRORS.INVALID_TENANT_ID.code,
896
+ message: vtx_core_common_1.VTX_ERRORS.INVALID_TENANT_ID.description
897
+ }
900
898
  };
901
899
  }
902
900
  return this.getTenantSponsorships(tenantId);
@@ -959,6 +957,1388 @@ class VTXBaseAPI {
959
957
  }
960
958
  return retValue;
961
959
  }
960
+ async sendAthleteInvitations(input) {
961
+ const client = (0, client_1.createClient)({
962
+ url: this.backendUrl + "/graphql",
963
+ headers: this.headers,
964
+ });
965
+ const fields = {
966
+ _id: true,
967
+ name: true,
968
+ email: true,
969
+ dateSent: true,
970
+ sponsor: {
971
+ _id: true,
972
+ name: true,
973
+ tenant: {
974
+ _id: true,
975
+ name: true,
976
+ tenant_uri: true
977
+ }
978
+ },
979
+ magicLink: {
980
+ _id: true,
981
+ code: true,
982
+ type: true,
983
+ url: true,
984
+ expires: true,
985
+ data: true,
986
+ isExpired: true
987
+ },
988
+ brand: {
989
+ _id: true,
990
+ name: true,
991
+ logo: {
992
+ _id: true,
993
+ name: true,
994
+ contentType: true,
995
+ url: true,
996
+ useType: true
997
+ },
998
+ website: true
999
+ },
1000
+ status: true
1001
+ };
1002
+ let retValue;
1003
+ try {
1004
+ const response = await client.mutation({
1005
+ sendAthleteInvitations: {
1006
+ __args: {
1007
+ input: input
1008
+ },
1009
+ ...fields
1010
+ }
1011
+ });
1012
+ console.log('sendAthleteInvitations Response:');
1013
+ console.log(JSON.stringify(response, null, 2));
1014
+ retValue = (0, response_builder_1.buildResponse)(response, 'sendAthleteInvitations', (r) => {
1015
+ const isResponseOk = true && Array.isArray(response?.sendAthleteInvitations);
1016
+ return isResponseOk;
1017
+ });
1018
+ }
1019
+ catch (err1) {
1020
+ console.log('sendAthleteInvitations err1:');
1021
+ console.log(err1);
1022
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1023
+ }
1024
+ return retValue;
1025
+ }
1026
+ async registerAthleteUser(input) {
1027
+ const client = (0, client_1.createClient)({
1028
+ url: this.backendUrl + "/graphql",
1029
+ headers: this.headers,
1030
+ });
1031
+ const fields = {
1032
+ _id: true,
1033
+ loginEmail: true,
1034
+ suspended: true,
1035
+ domains: {
1036
+ _id: true,
1037
+ name: true,
1038
+ description: true,
1039
+ tenant: {
1040
+ _id: true,
1041
+ name: true,
1042
+ tenant_uri: true,
1043
+ domain: {
1044
+ _id: true,
1045
+ name: true,
1046
+ description: true
1047
+ }
1048
+ }
1049
+ }
1050
+ };
1051
+ let retValue;
1052
+ try {
1053
+ const response = await client.mutation({
1054
+ registerAthleteUser: {
1055
+ __args: {
1056
+ input: input
1057
+ },
1058
+ ...fields
1059
+ }
1060
+ });
1061
+ console.log('registerAthleteUser Response:');
1062
+ console.log(JSON.stringify(response, null, 2));
1063
+ retValue = (0, response_builder_1.buildResponse)(response, 'registerAthleteUser', (r) => {
1064
+ const isResponseOk = true && response?.registerAthleteUser._id;
1065
+ return isResponseOk;
1066
+ });
1067
+ }
1068
+ catch (err1) {
1069
+ console.log('registerAthleteUser err1:');
1070
+ console.log(err1);
1071
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1072
+ }
1073
+ return retValue;
1074
+ }
1075
+ async preRegisterAthleteUser(input) {
1076
+ const client = (0, client_1.createClient)({
1077
+ url: this.backendUrl + "/graphql",
1078
+ headers: this.headers,
1079
+ });
1080
+ const fields = {
1081
+ _id: true,
1082
+ type: true,
1083
+ recipient: true,
1084
+ expires: true,
1085
+ isExpired: true,
1086
+ createdDate: true
1087
+ };
1088
+ let retValue;
1089
+ try {
1090
+ const response = await client.mutation({
1091
+ preRegisterAthleteUser: {
1092
+ __args: {
1093
+ input: input
1094
+ },
1095
+ ...fields
1096
+ }
1097
+ });
1098
+ console.log('preRegisterAthleteUser Response:');
1099
+ console.log(JSON.stringify(response, null, 2));
1100
+ retValue = (0, response_builder_1.buildResponse)(response, 'preRegisterAthleteUser', (r) => {
1101
+ const isResponseOk = true && response?.preRegisterAthleteUser._id;
1102
+ return isResponseOk;
1103
+ });
1104
+ }
1105
+ catch (err1) {
1106
+ console.log('preRegisterAthleteUser err1:');
1107
+ console.log(err1);
1108
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1109
+ }
1110
+ return retValue;
1111
+ }
1112
+ async confirmAthleteUserRegistrationAndLogin(input) {
1113
+ const client = (0, client_1.createClient)({
1114
+ url: this.backendUrl + "/graphql",
1115
+ headers: this.headers,
1116
+ });
1117
+ const fields = {
1118
+ _id: true,
1119
+ loginEmail: true,
1120
+ suspended: true,
1121
+ domains: {
1122
+ _id: true,
1123
+ name: true,
1124
+ description: true,
1125
+ tenant: {
1126
+ _id: true,
1127
+ name: true,
1128
+ tenant_uri: true,
1129
+ domain: {
1130
+ _id: true,
1131
+ name: true,
1132
+ description: true
1133
+ }
1134
+ }
1135
+ },
1136
+ token: {
1137
+ actualToken: true,
1138
+ refreshToken: true
1139
+ }
1140
+ };
1141
+ let retValue;
1142
+ try {
1143
+ const response = await client.mutation({
1144
+ confirmAthleteUserRegistrationAndLogin: {
1145
+ __args: {
1146
+ input: input
1147
+ },
1148
+ ...fields
1149
+ }
1150
+ });
1151
+ console.log('confirmAthleteUserRegistrationAndLogin Response:');
1152
+ console.log(JSON.stringify(response, null, 2));
1153
+ retValue = (0, response_builder_1.buildResponse)(response, 'confirmAthleteUserRegistrationAndLogin', (r) => {
1154
+ const isResponseOk = true && response?.confirmAthleteUserRegistrationAndLogin._id;
1155
+ return isResponseOk;
1156
+ });
1157
+ }
1158
+ catch (err1) {
1159
+ console.log('confirmAthleteUserRegistrationAndLogin err1:');
1160
+ console.log(err1);
1161
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1162
+ }
1163
+ return retValue;
1164
+ }
1165
+ async confirmAthleteUserRegistration(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
+ loginEmail: true,
1173
+ suspended: true,
1174
+ domains: {
1175
+ _id: true,
1176
+ name: true,
1177
+ description: true,
1178
+ tenant: {
1179
+ _id: true,
1180
+ name: true,
1181
+ tenant_uri: true,
1182
+ domain: {
1183
+ _id: true,
1184
+ name: true,
1185
+ description: true
1186
+ }
1187
+ }
1188
+ }
1189
+ };
1190
+ let retValue;
1191
+ try {
1192
+ const response = await client.mutation({
1193
+ confirmAthleteUserRegistration: {
1194
+ __args: {
1195
+ input: input
1196
+ },
1197
+ ...fields
1198
+ }
1199
+ });
1200
+ console.log('confirmAthleteUserRegistration Response:');
1201
+ console.log(JSON.stringify(response, null, 2));
1202
+ retValue = (0, response_builder_1.buildResponse)(response, 'confirmAthleteUserRegistration', (r) => {
1203
+ const isResponseOk = true && response?.confirmAthleteUserRegistration._id;
1204
+ return isResponseOk;
1205
+ });
1206
+ }
1207
+ catch (err1) {
1208
+ console.log('confirmAthleteUserRegistration err1:');
1209
+ console.log(err1);
1210
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1211
+ }
1212
+ return retValue;
1213
+ }
1214
+ async findSponsorAthleteInvitation(dto) {
1215
+ const client = (0, client_1.createClient)({
1216
+ url: this.backendUrl + "/graphql",
1217
+ headers: this.headers,
1218
+ });
1219
+ const fields = {
1220
+ _id: true,
1221
+ name: true,
1222
+ email: true,
1223
+ dateSent: true,
1224
+ sponsor: {
1225
+ _id: true,
1226
+ name: true,
1227
+ description: true,
1228
+ approved: true
1229
+ },
1230
+ magicLink: {
1231
+ _id: true,
1232
+ code: true,
1233
+ type: true,
1234
+ url: true,
1235
+ expires: true,
1236
+ isExpired: true
1237
+ },
1238
+ brand: {
1239
+ _id: true,
1240
+ name: true,
1241
+ slogan: true,
1242
+ website: true,
1243
+ description: true,
1244
+ approved: true,
1245
+ published: true,
1246
+ logo: {
1247
+ _id: true,
1248
+ name: true,
1249
+ contentType: true,
1250
+ size: true,
1251
+ useType: true,
1252
+ url: true,
1253
+ key: true
1254
+ },
1255
+ banner: {
1256
+ _id: true,
1257
+ name: true,
1258
+ contentType: true,
1259
+ size: true,
1260
+ useType: true,
1261
+ url: true,
1262
+ key: true
1263
+ }
1264
+ },
1265
+ status: true
1266
+ };
1267
+ let retValue;
1268
+ try {
1269
+ const response = await client.query({
1270
+ findSponsorAthleteInvitation: {
1271
+ __args: {
1272
+ input: dto
1273
+ },
1274
+ ...fields
1275
+ }
1276
+ });
1277
+ console.log('findSponsorAthleteInvitation Response:');
1278
+ console.log(JSON.stringify(response, null, 2));
1279
+ retValue = (0, response_builder_1.buildResponse)(response, 'findSponsorAthleteInvitation', (r) => {
1280
+ console.log(JSON.stringify(response, null, 2));
1281
+ const isResponseOk = true && response?.findSponsorAthleteInvitation?._id;
1282
+ return isResponseOk;
1283
+ });
1284
+ }
1285
+ catch (err1) {
1286
+ console.log('findSponsorAthleteInvitation err1:');
1287
+ console.log(err1);
1288
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1289
+ }
1290
+ return retValue;
1291
+ }
1292
+ async findVtxUser(dto) {
1293
+ const client = (0, client_1.createClient)({
1294
+ url: this.backendUrl + "/graphql",
1295
+ headers: this.headers,
1296
+ });
1297
+ const fields = {
1298
+ _id: true,
1299
+ loginEmail: true,
1300
+ suspended: true,
1301
+ domains: {
1302
+ _id: true,
1303
+ name: true,
1304
+ description: true,
1305
+ tenant: {
1306
+ _id: true,
1307
+ name: true,
1308
+ tenant_uri: true,
1309
+ domain: {
1310
+ _id: true,
1311
+ name: true,
1312
+ description: true
1313
+ }
1314
+ }
1315
+ }
1316
+ };
1317
+ let retValue;
1318
+ try {
1319
+ const response = await client.query({
1320
+ findVtxUser: {
1321
+ __args: {
1322
+ input: dto
1323
+ },
1324
+ ...fields
1325
+ }
1326
+ });
1327
+ console.log('findVtxUser Response:');
1328
+ console.log(JSON.stringify(response, null, 2));
1329
+ retValue = (0, response_builder_1.buildResponse)(response, 'findVtxUser', (r) => {
1330
+ console.log(JSON.stringify(response, null, 2));
1331
+ const isResponseOk = true && response?.findVtxUser?._id;
1332
+ return isResponseOk;
1333
+ });
1334
+ }
1335
+ catch (err1) {
1336
+ console.log('findVtxUser err1:');
1337
+ console.log(err1);
1338
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1339
+ }
1340
+ return retValue;
1341
+ }
1342
+ async findCitiesStartingWith(pattern) {
1343
+ const client = (0, client_1.createClient)({
1344
+ url: this.backendUrl + "/graphql",
1345
+ headers: this.headers,
1346
+ });
1347
+ const fields = {
1348
+ _id: true,
1349
+ name: true,
1350
+ localizedName: true,
1351
+ state: {
1352
+ _id: true,
1353
+ name: true,
1354
+ country: {
1355
+ _id: true,
1356
+ name: true
1357
+ }
1358
+ },
1359
+ latitude: true,
1360
+ longitude: true,
1361
+ timezone: true
1362
+ };
1363
+ let retValue;
1364
+ try {
1365
+ const response = await client.query({
1366
+ findCitiesStartingWith: {
1367
+ __args: {
1368
+ text: pattern
1369
+ },
1370
+ ...fields
1371
+ }
1372
+ });
1373
+ console.log('findCitiesStartingWith Response:');
1374
+ console.log(JSON.stringify(response, null, 2));
1375
+ retValue = (0, response_builder_1.buildResponse)(response, 'findCitiesStartingWith', (r) => {
1376
+ console.log(JSON.stringify(response, null, 2));
1377
+ const isResponseOk = true && Array.isArray(response?.findCitiesStartingWith);
1378
+ return isResponseOk;
1379
+ });
1380
+ }
1381
+ catch (err1) {
1382
+ console.log('findCitiesStartingWith err1:');
1383
+ console.log(err1);
1384
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1385
+ }
1386
+ return retValue;
1387
+ }
1388
+ async findCityById(cityId) {
1389
+ const client = (0, client_1.createClient)({
1390
+ url: this.backendUrl + "/graphql",
1391
+ headers: this.headers,
1392
+ });
1393
+ const fields = {
1394
+ _id: true,
1395
+ name: true,
1396
+ localizedName: true,
1397
+ state: {
1398
+ _id: true,
1399
+ name: true,
1400
+ country: {
1401
+ _id: true,
1402
+ name: true
1403
+ }
1404
+ },
1405
+ latitude: true,
1406
+ longitude: true,
1407
+ timezone: true
1408
+ };
1409
+ let retValue;
1410
+ try {
1411
+ const response = await client.query({
1412
+ findCityById: {
1413
+ __args: {
1414
+ cityId: cityId
1415
+ },
1416
+ ...fields
1417
+ }
1418
+ });
1419
+ console.log('findCityById Response:');
1420
+ console.log(JSON.stringify(response, null, 2));
1421
+ retValue = (0, response_builder_1.buildResponse)(response, 'findCityById', (r) => {
1422
+ console.log(JSON.stringify(response, null, 2));
1423
+ const isResponseOk = true && response?.findCityById?._id;
1424
+ return isResponseOk;
1425
+ });
1426
+ }
1427
+ catch (err1) {
1428
+ console.log('findCityById err1:');
1429
+ console.log(err1);
1430
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1431
+ }
1432
+ return retValue;
1433
+ }
1434
+ async getSportLevels() {
1435
+ const client = (0, client_1.createClient)({
1436
+ url: this.backendUrl + "/graphql",
1437
+ headers: this.headers,
1438
+ });
1439
+ const fields = {
1440
+ _id: true,
1441
+ label: true,
1442
+ index: true
1443
+ };
1444
+ let retValue;
1445
+ try {
1446
+ const response = await client.query({
1447
+ getSportLevels: {
1448
+ __args: {},
1449
+ ...fields
1450
+ }
1451
+ });
1452
+ console.log('getSportLevels Response:');
1453
+ console.log(JSON.stringify(response, null, 2));
1454
+ retValue = (0, response_builder_1.buildResponse)(response, 'getSportLevels', (r) => {
1455
+ console.log(JSON.stringify(response, null, 2));
1456
+ const isResponseOk = true && Array.isArray(response?.getSportLevels);
1457
+ return isResponseOk;
1458
+ });
1459
+ }
1460
+ catch (err1) {
1461
+ console.log('getSportLevels err1:');
1462
+ console.log(err1);
1463
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1464
+ }
1465
+ return retValue;
1466
+ }
1467
+ async getSports() {
1468
+ const client = (0, client_1.createClient)({
1469
+ url: this.backendUrl + "/graphql",
1470
+ headers: this.headers,
1471
+ });
1472
+ const fields = {
1473
+ _id: true,
1474
+ name: true
1475
+ };
1476
+ let retValue;
1477
+ try {
1478
+ const response = await client.query({
1479
+ getSports: {
1480
+ __args: {},
1481
+ ...fields
1482
+ }
1483
+ });
1484
+ console.log('getSports Response:');
1485
+ console.log(JSON.stringify(response, null, 2));
1486
+ retValue = (0, response_builder_1.buildResponse)(response, 'getSports', (r) => {
1487
+ console.log(JSON.stringify(response, null, 2));
1488
+ const isResponseOk = true && Array.isArray(response?.getSports);
1489
+ return isResponseOk;
1490
+ });
1491
+ }
1492
+ catch (err1) {
1493
+ console.log('getSports err1:');
1494
+ console.log(err1);
1495
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1496
+ }
1497
+ return retValue;
1498
+ }
1499
+ async loginUserFromCredentialsVtx(username, password) {
1500
+ const client = (0, client_1.createClient)({
1501
+ url: this.backendUrl + '/graphql',
1502
+ headers: this.headers,
1503
+ });
1504
+ const curatedEmail = username.trim().toLocaleLowerCase();
1505
+ let retValue = {};
1506
+ const fields = {
1507
+ _id: true,
1508
+ loginEmail: true,
1509
+ suspended: true,
1510
+ domains: {
1511
+ _id: true,
1512
+ name: true,
1513
+ description: true,
1514
+ tenant: {
1515
+ _id: true,
1516
+ name: true,
1517
+ tenant_uri: true,
1518
+ domain: {
1519
+ _id: true,
1520
+ name: true,
1521
+ description: true
1522
+ }
1523
+ }
1524
+ },
1525
+ loginMethods: true,
1526
+ token: {
1527
+ actualToken: true,
1528
+ refreshToken: true
1529
+ }
1530
+ };
1531
+ try {
1532
+ const response = await client.mutation({
1533
+ loginUserFromCredentialsVtx: {
1534
+ __args: {
1535
+ username: curatedEmail,
1536
+ password: password
1537
+ },
1538
+ ...fields
1539
+ },
1540
+ });
1541
+ console.log('loginUserFromCredentialsVtx Response:');
1542
+ console.log(JSON.stringify(response, null, 2));
1543
+ retValue = (0, response_builder_1.buildResponse)(response, 'loginUserFromCredentialsVtx', (r) => {
1544
+ const isResponseOk = true && response?.loginUserFromCredentialsVtx?.actualToken;
1545
+ return isResponseOk;
1546
+ });
1547
+ }
1548
+ catch (err1) {
1549
+ console.log('loginUserFromCredentialsVtx err1:');
1550
+ console.log(err1);
1551
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1552
+ }
1553
+ return retValue;
1554
+ }
1555
+ async validateUserCredentialsVtx(username, password) {
1556
+ const client = (0, client_1.createClient)({
1557
+ url: this.backendUrl + '/graphql',
1558
+ headers: this.headers,
1559
+ });
1560
+ const curatedEmail = username.trim().toLocaleLowerCase();
1561
+ let retValue = {};
1562
+ const fields = {
1563
+ _id: true,
1564
+ loginEmail: true,
1565
+ suspended: true,
1566
+ domains: {
1567
+ _id: true,
1568
+ name: true,
1569
+ description: true,
1570
+ tenant: {
1571
+ _id: true,
1572
+ name: true,
1573
+ tenant_uri: true,
1574
+ domain: {
1575
+ _id: true,
1576
+ name: true,
1577
+ description: true
1578
+ }
1579
+ }
1580
+ },
1581
+ loginMethods: true
1582
+ };
1583
+ try {
1584
+ const response = await client.query({
1585
+ validateUserCredentials: {
1586
+ __args: {
1587
+ username: curatedEmail,
1588
+ password: password
1589
+ },
1590
+ ...fields
1591
+ },
1592
+ });
1593
+ console.log('validateUserCredentials Response:');
1594
+ console.log(JSON.stringify(response, null, 2));
1595
+ retValue = (0, response_builder_1.buildResponse)(response, 'validateUserCredentials', (r) => {
1596
+ const isResponseOk = true && response?.validateUserCredentials?._id;
1597
+ return isResponseOk;
1598
+ });
1599
+ }
1600
+ catch (err1) {
1601
+ console.log('validateUserCredentials err1:');
1602
+ console.log(err1);
1603
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1604
+ }
1605
+ return retValue;
1606
+ }
1607
+ async findAthleteForUser(loginEmail) {
1608
+ const client = (0, client_1.createClient)({
1609
+ url: this.backendUrl + "/graphql",
1610
+ headers: this.headers,
1611
+ });
1612
+ let retValue = {};
1613
+ const fields = {
1614
+ _id: true,
1615
+ firstName: true,
1616
+ lastName: true,
1617
+ screenName: true,
1618
+ dob: true,
1619
+ lgbt: true,
1620
+ competitionGender: true,
1621
+ country: {
1622
+ _id: true,
1623
+ name: true
1624
+ },
1625
+ location: {
1626
+ userProvidedLatitude: true,
1627
+ userProvidedLongitude: true,
1628
+ cityNameGeocode: true,
1629
+ stateNameGeocode: true,
1630
+ countryIso2CodeGeocode: true,
1631
+ timeZoneGeocode: true,
1632
+ latitudeGeocode: true,
1633
+ longitudeGeocode: true,
1634
+ city: {
1635
+ _id: true,
1636
+ name: true,
1637
+ localizedName: true,
1638
+ state: {
1639
+ _id: true,
1640
+ name: true,
1641
+ country: {
1642
+ _id: true,
1643
+ name: true
1644
+ }
1645
+ },
1646
+ latitude: true,
1647
+ longitude: true,
1648
+ timezone: true,
1649
+ }
1650
+ },
1651
+ trainer: true,
1652
+ trainerUrl: true,
1653
+ followStats: {
1654
+ followers: true,
1655
+ followed: true,
1656
+ raves: true,
1657
+ favorites: true
1658
+ },
1659
+ mainSport: {
1660
+ _id: true,
1661
+ name: true
1662
+ },
1663
+ mainSportLevel: {
1664
+ _id: true,
1665
+ label: true,
1666
+ index: true
1667
+ },
1668
+ scores: {
1669
+ vtxScore: true,
1670
+ socialScore: true,
1671
+ trainingScore: true,
1672
+ competitionScore: true
1673
+ },
1674
+ rankings: {
1675
+ worldRanking: {
1676
+ scope: true,
1677
+ scopeId: true,
1678
+ scopeName: true,
1679
+ position: true,
1680
+ total: true
1681
+ },
1682
+ countryRanking: {
1683
+ scope: true,
1684
+ scopeId: true,
1685
+ scopeName: true,
1686
+ position: true,
1687
+ total: true
1688
+ },
1689
+ stateRanking: {
1690
+ scope: true,
1691
+ scopeId: true,
1692
+ scopeName: true,
1693
+ position: true,
1694
+ total: true
1695
+ },
1696
+ cityRanking: {
1697
+ scope: true,
1698
+ scopeId: true,
1699
+ scopeName: true,
1700
+ position: true,
1701
+ total: true
1702
+ },
1703
+ },
1704
+ allSports: {
1705
+ _id: true,
1706
+ name: true
1707
+ },
1708
+ teams: {
1709
+ _id: true,
1710
+ name: true,
1711
+ description: true,
1712
+ approved: true,
1713
+ logo: {
1714
+ _id: true,
1715
+ name: true,
1716
+ contentType: true,
1717
+ size: true,
1718
+ useType: true,
1719
+ url: true,
1720
+ key: true
1721
+ },
1722
+ banner: {
1723
+ _id: true,
1724
+ name: true,
1725
+ contentType: true,
1726
+ size: true,
1727
+ useType: true,
1728
+ url: true,
1729
+ key: true
1730
+ }
1731
+ },
1732
+ sponsorBrands: {
1733
+ _id: true,
1734
+ name: true,
1735
+ slogan: true,
1736
+ website: true,
1737
+ description: true,
1738
+ approved: true,
1739
+ published: true,
1740
+ logo: {
1741
+ _id: true,
1742
+ name: true,
1743
+ contentType: true,
1744
+ size: true,
1745
+ useType: true,
1746
+ url: true,
1747
+ key: true
1748
+ },
1749
+ stats: {
1750
+ campaigns: true,
1751
+ sponsorships: true,
1752
+ sports: true,
1753
+ athletes: true
1754
+ },
1755
+ operatorIds: true,
1756
+ },
1757
+ competitions: {
1758
+ _id: true,
1759
+ event: {
1760
+ _id: true,
1761
+ name: true,
1762
+ eventWebSite: true,
1763
+ startDate: true,
1764
+ endDate: true,
1765
+ verified: true,
1766
+ banner: {
1767
+ _id: true,
1768
+ name: true,
1769
+ contentType: true,
1770
+ size: true,
1771
+ useType: true,
1772
+ url: true,
1773
+ key: true
1774
+ }
1775
+ },
1776
+ eventName: true,
1777
+ date: true,
1778
+ result: {
1779
+ _id: true,
1780
+ type: true,
1781
+ position: true,
1782
+ score: true,
1783
+ timems: true,
1784
+ resultWebLink: true
1785
+ }
1786
+ },
1787
+ totalUpcomingCompetitions: true,
1788
+ totalPastCompetitions: true,
1789
+ profilePicture: {
1790
+ _id: true,
1791
+ name: true,
1792
+ contentType: true,
1793
+ size: true,
1794
+ useType: true,
1795
+ url: true,
1796
+ key: true
1797
+ },
1798
+ cardPicture: {
1799
+ _id: true,
1800
+ name: true,
1801
+ contentType: true,
1802
+ size: true,
1803
+ useType: true,
1804
+ url: true,
1805
+ key: true
1806
+ }
1807
+ };
1808
+ try {
1809
+ let response = null;
1810
+ response = await client.query({
1811
+ findAthleteForUser: {
1812
+ __args: {
1813
+ loginEmail: loginEmail
1814
+ },
1815
+ ...fields
1816
+ }
1817
+ });
1818
+ console.log('findAthleteForUser Response:');
1819
+ console.log(JSON.stringify(response, null, 2));
1820
+ retValue = (0, response_builder_1.buildResponse)(response, 'findAthleteForUser', (r) => {
1821
+ const isResponseOk = true && response?.findAthleteForUser?._id;
1822
+ return isResponseOk;
1823
+ });
1824
+ }
1825
+ catch (err1) {
1826
+ console.log('findAthleteForUser err1:');
1827
+ console.log(err1);
1828
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1829
+ }
1830
+ return retValue;
1831
+ }
1832
+ async getBrands() {
1833
+ const client = (0, client_1.createClient)({
1834
+ url: this.backendUrl + "/graphql",
1835
+ headers: this.headers,
1836
+ });
1837
+ const fields = {
1838
+ _id: true,
1839
+ name: true,
1840
+ slogan: true,
1841
+ website: true,
1842
+ description: true,
1843
+ approved: true,
1844
+ published: true,
1845
+ logo: {
1846
+ _id: true,
1847
+ name: true,
1848
+ contentType: true,
1849
+ size: true,
1850
+ useType: true,
1851
+ url: true,
1852
+ key: true
1853
+ },
1854
+ banner: {
1855
+ _id: true,
1856
+ name: true,
1857
+ contentType: true,
1858
+ size: true,
1859
+ useType: true,
1860
+ url: true,
1861
+ key: true
1862
+ },
1863
+ stats: {
1864
+ campaigns: true,
1865
+ sponsorships: true,
1866
+ sports: true,
1867
+ athletes: true
1868
+ },
1869
+ operatorIds: true
1870
+ };
1871
+ let retValue;
1872
+ try {
1873
+ const response = await client.query({
1874
+ brands: {
1875
+ __args: {},
1876
+ ...fields
1877
+ }
1878
+ });
1879
+ console.log('brands Response:');
1880
+ console.log(JSON.stringify(response, null, 2));
1881
+ retValue = (0, response_builder_1.buildResponse)(response, 'brands', (r) => {
1882
+ console.log(JSON.stringify(response, null, 2));
1883
+ const isResponseOk = true && Array.isArray(response?.brands);
1884
+ return isResponseOk;
1885
+ });
1886
+ }
1887
+ catch (err1) {
1888
+ console.log('brands err1:');
1889
+ console.log(err1);
1890
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
1891
+ }
1892
+ return retValue;
1893
+ }
1894
+ async getAthletes() {
1895
+ const client = (0, client_1.createClient)({
1896
+ url: this.backendUrl + "/graphql",
1897
+ headers: this.headers,
1898
+ });
1899
+ const fields = {
1900
+ _id: true,
1901
+ firstName: true,
1902
+ lastName: true,
1903
+ screenName: true,
1904
+ dob: true,
1905
+ lgbt: true,
1906
+ competitionGender: true,
1907
+ country: {
1908
+ _id: true,
1909
+ name: true
1910
+ },
1911
+ location: {
1912
+ userProvidedLatitude: true,
1913
+ userProvidedLongitude: true,
1914
+ cityNameGeocode: true,
1915
+ stateNameGeocode: true,
1916
+ countryIso2CodeGeocode: true,
1917
+ timeZoneGeocode: true,
1918
+ latitudeGeocode: true,
1919
+ longitudeGeocode: true,
1920
+ city: {
1921
+ _id: true,
1922
+ name: true,
1923
+ localizedName: true,
1924
+ state: {
1925
+ _id: true,
1926
+ name: true,
1927
+ country: {
1928
+ _id: true,
1929
+ name: true
1930
+ }
1931
+ },
1932
+ latitude: true,
1933
+ longitude: true,
1934
+ timezone: true,
1935
+ }
1936
+ },
1937
+ trainer: true,
1938
+ trainerUrl: true,
1939
+ followStats: {
1940
+ followers: true,
1941
+ followed: true,
1942
+ raves: true,
1943
+ favorites: true
1944
+ },
1945
+ mainSport: {
1946
+ _id: true,
1947
+ name: true
1948
+ },
1949
+ mainSportLevel: {
1950
+ _id: true,
1951
+ label: true,
1952
+ index: true
1953
+ },
1954
+ scores: {
1955
+ vtxScore: true,
1956
+ socialScore: true,
1957
+ trainingScore: true,
1958
+ competitionScore: true
1959
+ },
1960
+ rankings: {
1961
+ worldRanking: {
1962
+ scope: true,
1963
+ scopeId: true,
1964
+ scopeName: true,
1965
+ position: true,
1966
+ total: true
1967
+ },
1968
+ countryRanking: {
1969
+ scope: true,
1970
+ scopeId: true,
1971
+ scopeName: true,
1972
+ position: true,
1973
+ total: true
1974
+ },
1975
+ stateRanking: {
1976
+ scope: true,
1977
+ scopeId: true,
1978
+ scopeName: true,
1979
+ position: true,
1980
+ total: true
1981
+ },
1982
+ cityRanking: {
1983
+ scope: true,
1984
+ scopeId: true,
1985
+ scopeName: true,
1986
+ position: true,
1987
+ total: true
1988
+ },
1989
+ },
1990
+ allSports: {
1991
+ _id: true,
1992
+ name: true
1993
+ },
1994
+ teams: {
1995
+ _id: true,
1996
+ name: true,
1997
+ description: true,
1998
+ approved: true,
1999
+ logo: {
2000
+ _id: true,
2001
+ name: true,
2002
+ contentType: true,
2003
+ size: true,
2004
+ useType: true,
2005
+ url: true,
2006
+ key: true
2007
+ },
2008
+ banner: {
2009
+ _id: true,
2010
+ name: true,
2011
+ contentType: true,
2012
+ size: true,
2013
+ useType: true,
2014
+ url: true,
2015
+ key: true
2016
+ }
2017
+ },
2018
+ sponsorBrands: {
2019
+ _id: true,
2020
+ name: true,
2021
+ slogan: true,
2022
+ website: true,
2023
+ description: true,
2024
+ approved: true,
2025
+ published: true,
2026
+ logo: {
2027
+ _id: true,
2028
+ name: true,
2029
+ contentType: true,
2030
+ size: true,
2031
+ useType: true,
2032
+ url: true,
2033
+ key: true
2034
+ },
2035
+ stats: {
2036
+ campaigns: true,
2037
+ sponsorships: true,
2038
+ sports: true,
2039
+ athletes: true
2040
+ },
2041
+ operatorIds: true,
2042
+ },
2043
+ competitions: {
2044
+ _id: true,
2045
+ event: {
2046
+ _id: true,
2047
+ name: true,
2048
+ eventWebSite: true,
2049
+ startDate: true,
2050
+ endDate: true,
2051
+ verified: true,
2052
+ banner: {
2053
+ _id: true,
2054
+ name: true,
2055
+ contentType: true,
2056
+ size: true,
2057
+ useType: true,
2058
+ url: true,
2059
+ key: true
2060
+ }
2061
+ },
2062
+ eventName: true,
2063
+ date: true,
2064
+ result: {
2065
+ _id: true,
2066
+ type: true,
2067
+ position: true,
2068
+ score: true,
2069
+ timems: true,
2070
+ resultWebLink: true
2071
+ }
2072
+ },
2073
+ totalUpcomingCompetitions: true,
2074
+ totalPastCompetitions: true,
2075
+ profilePicture: {
2076
+ _id: true,
2077
+ name: true,
2078
+ contentType: true,
2079
+ size: true,
2080
+ useType: true,
2081
+ url: true,
2082
+ key: true
2083
+ },
2084
+ cardPicture: {
2085
+ _id: true,
2086
+ name: true,
2087
+ contentType: true,
2088
+ size: true,
2089
+ useType: true,
2090
+ url: true,
2091
+ key: true
2092
+ }
2093
+ };
2094
+ let retValue;
2095
+ try {
2096
+ const response = await client.query({
2097
+ getAthletes: {
2098
+ __args: {},
2099
+ ...fields
2100
+ }
2101
+ });
2102
+ console.log('getAthletes Response:');
2103
+ console.log(JSON.stringify(response, null, 2));
2104
+ retValue = (0, response_builder_1.buildResponse)(response, 'getAthletes', (r) => {
2105
+ console.log(JSON.stringify(response, null, 2));
2106
+ const isResponseOk = true && Array.isArray(response?.getAthletes);
2107
+ return isResponseOk;
2108
+ });
2109
+ }
2110
+ catch (err1) {
2111
+ console.log('getAthletes err1:');
2112
+ console.log(err1);
2113
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
2114
+ }
2115
+ return retValue;
2116
+ }
2117
+ async getRecommendedAthletes(loginEmail) {
2118
+ const client = (0, client_1.createClient)({
2119
+ url: this.backendUrl + "/graphql",
2120
+ headers: this.headers,
2121
+ });
2122
+ const fields = {
2123
+ _id: true,
2124
+ firstName: true,
2125
+ lastName: true,
2126
+ screenName: true,
2127
+ dob: true,
2128
+ lgbt: true,
2129
+ competitionGender: true,
2130
+ country: {
2131
+ _id: true,
2132
+ name: true
2133
+ },
2134
+ location: {
2135
+ userProvidedLatitude: true,
2136
+ userProvidedLongitude: true,
2137
+ cityNameGeocode: true,
2138
+ stateNameGeocode: true,
2139
+ countryIso2CodeGeocode: true,
2140
+ timeZoneGeocode: true,
2141
+ latitudeGeocode: true,
2142
+ longitudeGeocode: true,
2143
+ city: {
2144
+ _id: true,
2145
+ name: true,
2146
+ localizedName: true,
2147
+ state: {
2148
+ _id: true,
2149
+ name: true,
2150
+ country: {
2151
+ _id: true,
2152
+ name: true
2153
+ }
2154
+ },
2155
+ latitude: true,
2156
+ longitude: true,
2157
+ timezone: true,
2158
+ }
2159
+ },
2160
+ trainer: true,
2161
+ trainerUrl: true,
2162
+ followStats: {
2163
+ followers: true,
2164
+ followed: true,
2165
+ raves: true,
2166
+ favorites: true
2167
+ },
2168
+ mainSport: {
2169
+ _id: true,
2170
+ name: true
2171
+ },
2172
+ mainSportLevel: {
2173
+ _id: true,
2174
+ label: true,
2175
+ index: true
2176
+ },
2177
+ scores: {
2178
+ vtxScore: true,
2179
+ socialScore: true,
2180
+ trainingScore: true,
2181
+ competitionScore: true
2182
+ },
2183
+ rankings: {
2184
+ worldRanking: {
2185
+ scope: true,
2186
+ scopeId: true,
2187
+ scopeName: true,
2188
+ position: true,
2189
+ total: true
2190
+ },
2191
+ countryRanking: {
2192
+ scope: true,
2193
+ scopeId: true,
2194
+ scopeName: true,
2195
+ position: true,
2196
+ total: true
2197
+ },
2198
+ stateRanking: {
2199
+ scope: true,
2200
+ scopeId: true,
2201
+ scopeName: true,
2202
+ position: true,
2203
+ total: true
2204
+ },
2205
+ cityRanking: {
2206
+ scope: true,
2207
+ scopeId: true,
2208
+ scopeName: true,
2209
+ position: true,
2210
+ total: true
2211
+ },
2212
+ },
2213
+ allSports: {
2214
+ _id: true,
2215
+ name: true
2216
+ },
2217
+ teams: {
2218
+ _id: true,
2219
+ name: true,
2220
+ description: true,
2221
+ approved: true,
2222
+ logo: {
2223
+ _id: true,
2224
+ name: true,
2225
+ contentType: true,
2226
+ size: true,
2227
+ useType: true,
2228
+ url: true,
2229
+ key: true
2230
+ },
2231
+ banner: {
2232
+ _id: true,
2233
+ name: true,
2234
+ contentType: true,
2235
+ size: true,
2236
+ useType: true,
2237
+ url: true,
2238
+ key: true
2239
+ }
2240
+ },
2241
+ sponsorBrands: {
2242
+ _id: true,
2243
+ name: true,
2244
+ slogan: true,
2245
+ website: true,
2246
+ description: true,
2247
+ approved: true,
2248
+ published: true,
2249
+ logo: {
2250
+ _id: true,
2251
+ name: true,
2252
+ contentType: true,
2253
+ size: true,
2254
+ useType: true,
2255
+ url: true,
2256
+ key: true
2257
+ },
2258
+ stats: {
2259
+ campaigns: true,
2260
+ sponsorships: true,
2261
+ sports: true,
2262
+ athletes: true
2263
+ },
2264
+ operatorIds: true,
2265
+ },
2266
+ competitions: {
2267
+ _id: true,
2268
+ event: {
2269
+ _id: true,
2270
+ name: true,
2271
+ eventWebSite: true,
2272
+ startDate: true,
2273
+ endDate: true,
2274
+ verified: true,
2275
+ banner: {
2276
+ _id: true,
2277
+ name: true,
2278
+ contentType: true,
2279
+ size: true,
2280
+ useType: true,
2281
+ url: true,
2282
+ key: true
2283
+ }
2284
+ },
2285
+ eventName: true,
2286
+ date: true,
2287
+ result: {
2288
+ _id: true,
2289
+ type: true,
2290
+ position: true,
2291
+ score: true,
2292
+ timems: true,
2293
+ resultWebLink: true
2294
+ }
2295
+ },
2296
+ totalUpcomingCompetitions: true,
2297
+ totalPastCompetitions: true,
2298
+ profilePicture: {
2299
+ _id: true,
2300
+ name: true,
2301
+ contentType: true,
2302
+ size: true,
2303
+ useType: true,
2304
+ url: true,
2305
+ key: true
2306
+ },
2307
+ cardPicture: {
2308
+ _id: true,
2309
+ name: true,
2310
+ contentType: true,
2311
+ size: true,
2312
+ useType: true,
2313
+ url: true,
2314
+ key: true
2315
+ }
2316
+ };
2317
+ let retValue;
2318
+ try {
2319
+ const response = await client.query({
2320
+ getRecommendedAthletes: {
2321
+ __args: {
2322
+ loginEmail: loginEmail
2323
+ },
2324
+ ...fields
2325
+ }
2326
+ });
2327
+ console.log('getRecommendedAthletes Response:');
2328
+ console.log(JSON.stringify(response, null, 2));
2329
+ retValue = (0, response_builder_1.buildResponse)(response, 'getRecommendedAthletes', (r) => {
2330
+ console.log(JSON.stringify(response, null, 2));
2331
+ const isResponseOk = true && Array.isArray(response?.getRecommendedAthletes);
2332
+ return isResponseOk;
2333
+ });
2334
+ }
2335
+ catch (err1) {
2336
+ console.log('getRecommendedAthletes err1:');
2337
+ console.log(err1);
2338
+ retValue = (0, response_builder_1.buildErrorResponse)(err1);
2339
+ }
2340
+ return retValue;
2341
+ }
962
2342
  }
963
2343
  exports.VTXBaseAPI = VTXBaseAPI;
964
2344
  //# sourceMappingURL=vtx-base-api.js.map