@phoenixlan/phoenix.js 2.33.0 → 2.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.js CHANGED
@@ -118,10 +118,10 @@ const authenticateByCode = (code) => __awaiter(void 0, void 0, void 0, function*
118
118
  const result = yield fetch(`${getApiServer()}/oauth/token`, {
119
119
  method: 'POST',
120
120
  headers: {
121
- 'Content-Type': 'application/json'
121
+ 'Content-Type': 'application/x-www-form-urlencoded'
122
122
  },
123
- body: JSON.stringify({
124
- grant_type: 'code',
123
+ body: new URLSearchParams({
124
+ grant_type: 'authorization_code',
125
125
  code
126
126
  })
127
127
  });
@@ -129,7 +129,7 @@ const authenticateByCode = (code) => __awaiter(void 0, void 0, void 0, function*
129
129
  return false;
130
130
  }
131
131
  const response = yield result.json();
132
- TOKEN = response.token;
132
+ TOKEN = response.access_token;
133
133
  REFRESH_TOKEN = response.refresh_token;
134
134
  return true;
135
135
  });
@@ -147,7 +147,9 @@ const refreshToken = () => __awaiter(void 0, void 0, void 0, function* () {
147
147
  if (result.status !== 200) {
148
148
  throw new RefreshError("Unable to authenticate");
149
149
  }
150
- TOKEN = (yield result.json()).token;
150
+ const tokens = yield result.json();
151
+ TOKEN = tokens.access_token;
152
+ REFRESH_TOKEN = tokens.refresh_token;
151
153
  });
152
154
  const checkExpiry = (token) => {
153
155
  const now = new Date().getTime() / 1000;
@@ -173,6 +175,12 @@ const getToken = () => __awaiter(void 0, void 0, void 0, function* () {
173
175
  }
174
176
  return TOKEN;
175
177
  });
178
+ const getAuthHeaders = () => __awaiter(void 0, void 0, void 0, function* () {
179
+ const token = yield getToken();
180
+ return {
181
+ "Authorization": `Bearer ${token}`
182
+ };
183
+ });
176
184
  const getRefreshToken = () => __awaiter(void 0, void 0, void 0, function* () {
177
185
  return REFRESH_TOKEN;
178
186
  });
@@ -189,6 +197,7 @@ var index = /*#__PURE__*/Object.freeze({
189
197
  __proto__: null,
190
198
  authenticateByCode: authenticateByCode,
191
199
  getToken: getToken,
200
+ getAuthHeaders: getAuthHeaders,
192
201
  getRefreshToken: getRefreshToken,
193
202
  setAuthState: setAuthState,
194
203
  getTokenPayload: getTokenPayload
@@ -197,10 +206,7 @@ var index = /*#__PURE__*/Object.freeze({
197
206
  const getFriendships = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
198
207
  const response = yield fetch(`${getApiServer()}/user/${uuid}/friendships`, {
199
208
  method: 'GET',
200
- headers: {
201
- 'Content-Type': 'application/json',
202
- "X-Phoenix-Auth": yield getToken()
203
- },
209
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
204
210
  });
205
211
  if (response.status !== 200) {
206
212
  throw new ApiGetError("Unable to get the user's active friendships");
@@ -210,10 +216,7 @@ const getFriendships = (uuid) => __awaiter(void 0, void 0, void 0, function* ()
210
216
  const getFriendRequests = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
211
217
  const response = yield fetch(`${getApiServer()}/user/${uuid}/friend_requests`, {
212
218
  method: 'GET',
213
- headers: {
214
- 'Content-Type': 'application/json',
215
- "X-Phoenix-Auth": yield getToken()
216
- },
219
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
217
220
  });
218
221
  if (response.status !== 200) {
219
222
  throw new ApiGetError("Unable to get the user's active friend requests");
@@ -223,10 +226,7 @@ const getFriendRequests = (uuid) => __awaiter(void 0, void 0, void 0, function*
223
226
  const getOwnedTickets = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
224
227
  const response = yield fetch(`${getApiServer()}/user/${uuid}/owned_tickets`, {
225
228
  method: 'GET',
226
- headers: {
227
- 'Content-Type': 'application/json',
228
- "X-Phoenix-Auth": yield getToken()
229
- },
229
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
230
230
  });
231
231
  if (response.status !== 200) {
232
232
  throw new ApiGetError("Unable to get the user's tickets");
@@ -236,10 +236,7 @@ const getOwnedTickets = (uuid) => __awaiter(void 0, void 0, void 0, function* ()
236
236
  const getPurchasedTickets = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
237
237
  const response = yield fetch(`${getApiServer()}/user/${uuid}/purchased_tickets`, {
238
238
  method: 'GET',
239
- headers: {
240
- 'Content-Type': 'application/json',
241
- "X-Phoenix-Auth": yield getToken()
242
- },
239
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
243
240
  });
244
241
  if (response.status !== 200) {
245
242
  throw new ApiGetError("Unable to get the user's tickets");
@@ -249,10 +246,7 @@ const getPurchasedTickets = (uuid) => __awaiter(void 0, void 0, void 0, function
249
246
  const getTicketVouchers = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
250
247
  const response = yield fetch(`${getApiServer()}/user/${uuid}/ticket_vouchers`, {
251
248
  method: 'GET',
252
- headers: {
253
- 'Content-Type': 'application/json',
254
- "X-Phoenix-Auth": yield getToken()
255
- },
249
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
256
250
  });
257
251
  if (response.status !== 200) {
258
252
  throw new ApiGetError("Unable to get the user's ticket_vouchers");
@@ -262,10 +256,7 @@ const getTicketVouchers = (uuid) => __awaiter(void 0, void 0, void 0, function*
262
256
  const getTicketTransfers = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
263
257
  const response = yield fetch(`${getApiServer()}/user/${uuid}/ticket_transfers`, {
264
258
  method: 'GET',
265
- headers: {
266
- 'Content-Type': 'application/json',
267
- "X-Phoenix-Auth": yield getToken()
268
- },
259
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
269
260
  });
270
261
  if (response.status !== 200) {
271
262
  throw new ApiGetError("Unable to get ticket transfers");
@@ -275,10 +266,7 @@ const getTicketTransfers = (uuid) => __awaiter(void 0, void 0, void 0, function*
275
266
  const getSeatableTickets = (uuid, event_uuid) => __awaiter(void 0, void 0, void 0, function* () {
276
267
  const response = yield fetch(`${getApiServer()}/user/${uuid}/seatable_tickets${event_uuid ? "?event_uuid=" + event_uuid : ''}`, {
277
268
  method: 'GET',
278
- headers: {
279
- 'Content-Type': 'application/json',
280
- "X-Phoenix-Auth": yield getToken()
281
- },
269
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
282
270
  });
283
271
  if (response.status !== 200) {
284
272
  throw new ApiGetError("Unable to get seatable tickets");
@@ -288,10 +276,7 @@ const getSeatableTickets = (uuid, event_uuid) => __awaiter(void 0, void 0, void
288
276
  const getAuthenticatedUser = () => __awaiter(void 0, void 0, void 0, function* () {
289
277
  const result = yield fetch(`${getApiServer()}/user/current`, {
290
278
  method: 'GET',
291
- headers: {
292
- 'Content-Type': 'application/json',
293
- "X-Phoenix-Auth": yield getToken()
294
- }
279
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders()))
295
280
  });
296
281
  if (result.status !== 200) {
297
282
  throw new AuthError("Unable to get current user");
@@ -301,10 +286,7 @@ const getAuthenticatedUser = () => __awaiter(void 0, void 0, void 0, function* (
301
286
  const getUserMembershipStatus = (uuid, year) => __awaiter(void 0, void 0, void 0, function* () {
302
287
  const result = yield fetch(`${getApiServer()}/user/${uuid}/membership${year ? '?year=' + year : ""}`, {
303
288
  method: 'GET',
304
- headers: {
305
- 'Content-Type': 'application/json',
306
- "X-Phoenix-Auth": yield getToken()
307
- }
289
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders()))
308
290
  });
309
291
  if (result.status !== 200) {
310
292
  throw new AuthError("Unable to get membership status");
@@ -314,10 +296,7 @@ const getUserMembershipStatus = (uuid, year) => __awaiter(void 0, void 0, void 0
314
296
  const getUser = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
315
297
  const result = yield fetch(`${getApiServer()}/user/${uuid}`, {
316
298
  method: 'GET',
317
- headers: {
318
- 'Content-Type': 'application/json',
319
- "X-Phoenix-Auth": yield getToken()
320
- }
299
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders()))
321
300
  });
322
301
  if (result.status !== 200) {
323
302
  throw new AuthError("Unable to get user");
@@ -327,10 +306,7 @@ const getUser = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
327
306
  const getUserActivationState = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
328
307
  const result = yield fetch(`${getApiServer()}/user/${uuid}/activation`, {
329
308
  method: 'GET',
330
- headers: {
331
- 'Content-Type': 'application/json',
332
- "X-Phoenix-Auth": yield getToken()
333
- }
309
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders()))
334
310
  });
335
311
  if (result.status !== 200) {
336
312
  throw new AuthError("Unable to get authentication token");
@@ -340,10 +316,7 @@ const getUserActivationState = (uuid) => __awaiter(void 0, void 0, void 0, funct
340
316
  const activateUser = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
341
317
  const result = yield fetch(`${getApiServer()}/user/${uuid}/activation`, {
342
318
  method: 'PATCH',
343
- headers: {
344
- 'Content-Type': 'application/json',
345
- "X-Phoenix-Auth": yield getToken()
346
- }
319
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders()))
347
320
  });
348
321
  if (result.status !== 200) {
349
322
  throw new AuthError("Unable to get authentication token");
@@ -352,9 +325,7 @@ const activateUser = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
352
325
  const searchUsers = (query) => __awaiter(void 0, void 0, void 0, function* () {
353
326
  const result = yield fetch(`${getApiServer()}/user/search?query=${encodeURIComponent(query)}`, {
354
327
  method: 'GET',
355
- headers: {
356
- "X-Phoenix-Auth": yield getToken()
357
- }
328
+ headers: Object.assign({}, (yield getAuthHeaders()))
358
329
  });
359
330
  if (result.status !== 200) {
360
331
  throw new AuthError("Unable to search");
@@ -365,10 +336,7 @@ const searchUsers = (query) => __awaiter(void 0, void 0, void 0, function* () {
365
336
  const getUsers = () => __awaiter(void 0, void 0, void 0, function* () {
366
337
  const result = yield fetch(`${getApiServer()}/user`, {
367
338
  method: 'GET',
368
- headers: {
369
- 'Content-Type': 'application/json',
370
- "X-Phoenix-Auth": yield getToken()
371
- }
339
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders()))
372
340
  });
373
341
  if (result.status !== 200) {
374
342
  throw new AuthError("Unable to get users");
@@ -378,10 +346,7 @@ const getUsers = () => __awaiter(void 0, void 0, void 0, function* () {
378
346
  const createDiscordMappingOauthUrl = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
379
347
  const result = yield fetch(`${getApiServer()}/user/${uuid}/discord_mapping`, {
380
348
  method: 'POST',
381
- headers: {
382
- 'Content-Type': 'application/json',
383
- "X-Phoenix-Auth": yield getToken()
384
- }
349
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders()))
385
350
  });
386
351
  if (!result.ok) {
387
352
  try {
@@ -396,10 +361,7 @@ const createDiscordMappingOauthUrl = (uuid) => __awaiter(void 0, void 0, void 0,
396
361
  const revokeDiscordMapping = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
397
362
  const result = yield fetch(`${getApiServer()}/user/${uuid}/discord_mapping`, {
398
363
  method: 'DELETE',
399
- headers: {
400
- 'Content-Type': 'application/json',
401
- "X-Phoenix-Auth": yield getToken()
402
- }
364
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders()))
403
365
  });
404
366
  if (!result.ok) {
405
367
  throw new ApiGetError("Unable to revoke Discord mapping");
@@ -408,10 +370,7 @@ const revokeDiscordMapping = (uuid) => __awaiter(void 0, void 0, void 0, functio
408
370
  const getDiscordMapping = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
409
371
  const result = yield fetch(`${getApiServer()}/user/${uuid}/discord_mapping`, {
410
372
  method: 'GET',
411
- headers: {
412
- 'Content-Type': 'application/json',
413
- "X-Phoenix-Auth": yield getToken()
414
- }
373
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders()))
415
374
  });
416
375
  if (result.status === 404) {
417
376
  return null;
@@ -424,9 +383,7 @@ const getDiscordMapping = (uuid) => __awaiter(void 0, void 0, void 0, function*
424
383
  const getCrewCard = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
425
384
  const result = yield fetch(`${getApiServer()}/user/${uuid}/crew_card`, {
426
385
  method: "GET",
427
- headers: {
428
- "X-Phoenix-Auth": yield getToken()
429
- }
386
+ headers: Object.assign({}, (yield getAuthHeaders()))
430
387
  });
431
388
  return result;
432
389
  });
@@ -513,10 +470,7 @@ const getEventTicketTypes = (uuid) => __awaiter(void 0, void 0, void 0, function
513
470
  const addEventTicketType = (event_uuid, ticket_type_uuid) => __awaiter(void 0, void 0, void 0, function* () {
514
471
  const response = yield fetch(`${getApiServer()}/event/${event_uuid}/ticketType`, {
515
472
  method: 'PUT',
516
- headers: {
517
- 'Content-Type': 'application/json',
518
- "X-Phoenix-Auth": yield getToken(),
519
- },
473
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
520
474
  body: JSON.stringify({
521
475
  ticket_type_uuid
522
476
  })
@@ -529,9 +483,7 @@ const addEventTicketType = (event_uuid, ticket_type_uuid) => __awaiter(void 0, v
529
483
  const getEventMembersRequiringMembership = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
530
484
  const response = yield fetch(`${getApiServer()}/event/${uuid}/customers_requiring_memberships`, {
531
485
  method: 'GET',
532
- headers: {
533
- "X-Phoenix-Auth": yield getToken(),
534
- }
486
+ headers: Object.assign({}, (yield getAuthHeaders()))
535
487
  });
536
488
  if (response.status !== 200) {
537
489
  throw new ApiGetError("Unable to get customers requiring memberships");
@@ -541,9 +493,7 @@ const getEventMembersRequiringMembership = (uuid) => __awaiter(void 0, void 0, v
541
493
  const getEventNewMembers = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
542
494
  const response = yield fetch(`${getApiServer()}/event/${uuid}/new_memberships`, {
543
495
  method: 'GET',
544
- headers: {
545
- "X-Phoenix-Auth": yield getToken(),
546
- }
496
+ headers: Object.assign({}, (yield getAuthHeaders()))
547
497
  });
548
498
  if (response.status !== 200) {
549
499
  throw new ApiGetError("Unable to get new memberships");
@@ -553,9 +503,7 @@ const getEventNewMembers = (uuid) => __awaiter(void 0, void 0, void 0, function*
553
503
  const getEventTickets = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
554
504
  const response = yield fetch(`${getApiServer()}/event/${uuid}/ticket`, {
555
505
  method: 'GET',
556
- headers: {
557
- "X-Phoenix-Auth": yield getToken(),
558
- }
506
+ headers: Object.assign({}, (yield getAuthHeaders()))
559
507
  });
560
508
  if (response.status !== 200) {
561
509
  throw new ApiGetError("Unable to get the events tickets");
@@ -565,10 +513,7 @@ const getEventTickets = (uuid) => __awaiter(void 0, void 0, void 0, function* ()
565
513
  const getApplicationsByEvent = (event_uuid) => __awaiter(void 0, void 0, void 0, function* () {
566
514
  const response = yield fetch(`${getApiServer()}/event/${event_uuid}/applications`, {
567
515
  method: 'GET',
568
- headers: {
569
- 'Content-Type': 'application/json',
570
- "X-Phoenix-Auth": yield getToken(),
571
- },
516
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
572
517
  });
573
518
  if (response.status !== 200) {
574
519
  throw new ApiGetError('Unable to get applications');
@@ -585,10 +530,7 @@ var ApplicationState;
585
530
  const getAllApplications = () => __awaiter(void 0, void 0, void 0, function* () {
586
531
  const response = yield fetch(`${getApiServer()}/application`, {
587
532
  method: 'GET',
588
- headers: {
589
- 'Content-Type': 'application/json',
590
- "X-Phoenix-Auth": yield getToken(),
591
- },
533
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
592
534
  });
593
535
  if (response.status !== 200) {
594
536
  throw new ApiGetError('Unable to get applications');
@@ -601,10 +543,7 @@ const getApplication = (uuid) => __awaiter(void 0, void 0, void 0, function* ()
601
543
  }
602
544
  const response = yield fetch(`${getApiServer()}/application/${uuid}`, {
603
545
  method: 'GET',
604
- headers: {
605
- 'Content-Type': 'application/json',
606
- "X-Phoenix-Auth": yield getToken(),
607
- },
546
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
608
547
  });
609
548
  if (response.status !== 200) {
610
549
  throw new ApiGetError('Unable to get applications');
@@ -621,7 +560,7 @@ export const getAllApplicationsByEvent = async (event: Event): Promise<Array<Bas
621
560
  method: 'GET',
622
561
  headers: {
623
562
  'Content-Type': 'application/json',
624
- "X-Phoenix-Auth": await Oauth.getToken(),
563
+ ...(await Oauth.getAuthHeaders()),
625
564
  },
626
565
  });
627
566
 
@@ -635,10 +574,7 @@ export const getAllApplicationsByEvent = async (event: Event): Promise<Array<Bas
635
574
  const getUserApplications = () => __awaiter(void 0, void 0, void 0, function* () {
636
575
  const response = yield fetch(`${getApiServer()}/application/my`, {
637
576
  method: 'GET',
638
- headers: {
639
- 'Content-Type': 'application/json',
640
- "X-Phoenix-Auth": yield getToken(),
641
- },
577
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
642
578
  });
643
579
  if (response.status !== 200) {
644
580
  throw new ApiGetError('Unable to get applications');
@@ -648,10 +584,7 @@ const getUserApplications = () => __awaiter(void 0, void 0, void 0, function* ()
648
584
  const createApplication = (crews, contents) => __awaiter(void 0, void 0, void 0, function* () {
649
585
  const response = yield fetch(`${getApiServer()}/application`, {
650
586
  method: 'PUT',
651
- headers: {
652
- 'Content-Type': 'application/json',
653
- "X-Phoenix-Auth": yield getToken(),
654
- },
587
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
655
588
  body: JSON.stringify({
656
589
  crews,
657
590
  contents,
@@ -681,10 +614,7 @@ const answerApplication = (uuid, crew_uuid, answer, state) => __awaiter(void 0,
681
614
  }
682
615
  const response = yield fetch(`${getApiServer()}/application/${uuid}`, {
683
616
  method: 'PATCH',
684
- headers: {
685
- 'Content-Type': 'application/json',
686
- "X-Phoenix-Auth": yield getToken(),
687
- },
617
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
688
618
  body: JSON.stringify({
689
619
  answer,
690
620
  crew_uuid,
@@ -701,10 +631,7 @@ const hideApplication = (uuid) => __awaiter(void 0, void 0, void 0, function* ()
701
631
  }
702
632
  const response = yield fetch(`${getApiServer()}/application/${uuid}/hide`, {
703
633
  method: 'PATCH',
704
- headers: {
705
- 'Content-Type': 'application/json',
706
- "X-Phoenix-Auth": yield getToken(),
707
- }
634
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders()))
708
635
  });
709
636
  if (!response.ok) {
710
637
  let error = "";
@@ -731,10 +658,7 @@ var index$2 = /*#__PURE__*/Object.freeze({
731
658
  const getCrews = () => __awaiter(void 0, void 0, void 0, function* () {
732
659
  const response = yield fetch(`${getApiServer()}/crew/`, {
733
660
  method: 'GET',
734
- headers: {
735
- 'Content-Type': 'application/json',
736
- "X-Phoenix-Auth": yield getToken(),
737
- },
661
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
738
662
  });
739
663
  if (response.status !== 200) {
740
664
  throw new ApiGetError('Unable to get crews');
@@ -744,10 +668,7 @@ const getCrews = () => __awaiter(void 0, void 0, void 0, function* () {
744
668
  const getCrew = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
745
669
  const response = yield fetch(`${getApiServer()}/crew/${uuid}`, {
746
670
  method: 'GET',
747
- headers: {
748
- 'Content-Type': 'application/json',
749
- "X-Phoenix-Auth": yield getToken(),
750
- },
671
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
751
672
  });
752
673
  if (response.status !== 200) {
753
674
  throw new ApiGetError(`Unable to get crew: ${uuid}`);
@@ -771,9 +692,7 @@ const createAvatar = (file, x, y, w, h, uuid) => __awaiter(void 0, void 0, void
771
692
  data.set("h", h.toString());
772
693
  const result = yield fetch(`${getApiServer()}/user/${uuid}/avatar`, {
773
694
  method: 'POST',
774
- headers: {
775
- "X-Phoenix-Auth": yield getToken()
776
- },
695
+ headers: Object.assign({}, (yield getAuthHeaders())),
777
696
  body: data,
778
697
  });
779
698
  if (result.status !== 200) {
@@ -783,9 +702,7 @@ const createAvatar = (file, x, y, w, h, uuid) => __awaiter(void 0, void 0, void
783
702
  const deleteAvatar = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
784
703
  const result = yield fetch(`${getApiServer()}/avatar/${uuid}`, {
785
704
  method: 'DELETE',
786
- headers: {
787
- "X-Phoenix-Auth": yield getToken()
788
- }
705
+ headers: Object.assign({}, (yield getAuthHeaders()))
789
706
  });
790
707
  if (result.status !== 200) {
791
708
  throw new ApiPostError("Failed to delete avatar");
@@ -794,10 +711,7 @@ const deleteAvatar = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
794
711
  const getAvatar = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
795
712
  const result = yield fetch(`${getApiServer()}/avatar/${uuid}`, {
796
713
  method: 'GET',
797
- headers: {
798
- 'Content-Type': 'application/json',
799
- "X-Phoenix-Auth": yield getToken()
800
- }
714
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders()))
801
715
  });
802
716
  if (result.status !== 200) {
803
717
  throw new ApiGetError("Unable to get avatar");
@@ -807,10 +721,7 @@ const getAvatar = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
807
721
  const getAvatars = () => __awaiter(void 0, void 0, void 0, function* () {
808
722
  const result = yield fetch(`${getApiServer()}/avatar`, {
809
723
  method: 'GET',
810
- headers: {
811
- 'Content-Type': 'application/json',
812
- "X-Phoenix-Auth": yield getToken()
813
- }
724
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders()))
814
725
  });
815
726
  if (result.status !== 200) {
816
727
  throw new ApiGetError("Unable to get avatars");
@@ -820,10 +731,7 @@ const getAvatars = () => __awaiter(void 0, void 0, void 0, function* () {
820
731
  const getPendingAvatars = () => __awaiter(void 0, void 0, void 0, function* () {
821
732
  const result = yield fetch(`${getApiServer()}/avatar/pending`, {
822
733
  method: 'GET',
823
- headers: {
824
- 'Content-Type': 'application/json',
825
- "X-Phoenix-Auth": yield getToken()
826
- }
734
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders()))
827
735
  });
828
736
  if (result.status !== 200) {
829
737
  throw new ApiGetError("Unable to get pending avatars");
@@ -833,10 +741,7 @@ const getPendingAvatars = () => __awaiter(void 0, void 0, void 0, function* () {
833
741
  const setApproved = (uuid, state) => __awaiter(void 0, void 0, void 0, function* () {
834
742
  const result = yield fetch(`${getApiServer()}/avatar/${uuid}`, {
835
743
  method: 'PATCH',
836
- headers: {
837
- 'Content-Type': 'application/json',
838
- "X-Phoenix-Auth": yield getToken()
839
- },
744
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
840
745
  body: JSON.stringify({
841
746
  new_state: state ? "accepted" : "rejected"
842
747
  })
@@ -884,9 +789,7 @@ const getTosPayment = () => __awaiter(void 0, void 0, void 0, function* () {
884
789
  const getPosition = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
885
790
  const response = yield fetch(`${getApiServer()}/position/${uuid}`, {
886
791
  method: 'GET',
887
- headers: {
888
- "X-Phoenix-Auth": yield getToken(),
889
- },
792
+ headers: Object.assign({}, (yield getAuthHeaders())),
890
793
  });
891
794
  if (!response.ok) {
892
795
  throw new ApiGetError('Unable to get position');
@@ -896,9 +799,7 @@ const getPosition = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
896
799
  const getPositions = () => __awaiter(void 0, void 0, void 0, function* () {
897
800
  const response = yield fetch(`${getApiServer()}/position/`, {
898
801
  method: 'GET',
899
- headers: {
900
- "X-Phoenix-Auth": yield getToken(),
901
- },
802
+ headers: Object.assign({}, (yield getAuthHeaders())),
902
803
  });
903
804
  if (!response.ok) {
904
805
  throw new ApiGetError('Unable to get positions');
@@ -908,9 +809,7 @@ const getPositions = () => __awaiter(void 0, void 0, void 0, function* () {
908
809
  const createPosition = (name, description, crew_uuid, team_uuid) => __awaiter(void 0, void 0, void 0, function* () {
909
810
  const response = yield fetch(`${getApiServer()}/position/`, {
910
811
  method: 'POST',
911
- headers: {
912
- "X-Phoenix-Auth": yield getToken(),
913
- },
812
+ headers: Object.assign({}, (yield getAuthHeaders())),
914
813
  body: JSON.stringify({
915
814
  name,
916
815
  description,
@@ -941,9 +840,7 @@ var index$5 = /*#__PURE__*/Object.freeze({
941
840
  const deletePositionMapping = (position_mapping_uuid) => __awaiter(void 0, void 0, void 0, function* () {
942
841
  const response = yield fetch(`${getApiServer()}/position_mapping/${position_mapping_uuid}`, {
943
842
  method: 'DELETE',
944
- headers: {
945
- "X-Phoenix-Auth": yield getToken(),
946
- }
843
+ headers: Object.assign({}, (yield getAuthHeaders()))
947
844
  });
948
845
  if (!response.ok) {
949
846
  let error = "";
@@ -960,9 +857,7 @@ const deletePositionMapping = (position_mapping_uuid) => __awaiter(void 0, void
960
857
  const createPositionMapping = (user_uuid, position_uuid) => __awaiter(void 0, void 0, void 0, function* () {
961
858
  const response = yield fetch(`${getApiServer()}/position_mapping/`, {
962
859
  method: 'POST',
963
- headers: {
964
- "X-Phoenix-Auth": yield getToken(),
965
- },
860
+ headers: Object.assign({}, (yield getAuthHeaders())),
966
861
  body: JSON.stringify({
967
862
  user_uuid,
968
863
  position_uuid
@@ -990,10 +885,7 @@ var index$6 = /*#__PURE__*/Object.freeze({
990
885
  const createSeatmap = (name, description) => __awaiter(void 0, void 0, void 0, function* () {
991
886
  const response = yield fetch(`${getApiServer()}/seatmap`, {
992
887
  method: 'PUT',
993
- headers: {
994
- 'Content-Type': 'application/json',
995
- "X-Phoenix-Auth": yield getToken(),
996
- },
888
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
997
889
  body: JSON.stringify({
998
890
  name,
999
891
  description
@@ -1007,9 +899,7 @@ const createSeatmap = (name, description) => __awaiter(void 0, void 0, void 0, f
1007
899
  const getSeatmap = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
1008
900
  const response = yield fetch(`${getApiServer()}/seatmap/${uuid}`, {
1009
901
  method: 'GET',
1010
- headers: {
1011
- "X-Phoenix-Auth": yield getToken(),
1012
- },
902
+ headers: Object.assign({}, (yield getAuthHeaders())),
1013
903
  });
1014
904
  if (!response.ok) {
1015
905
  throw new ApiGetError('Unable to get seatmap');
@@ -1019,9 +909,7 @@ const getSeatmap = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
1019
909
  const getSeatmapAvailability = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
1020
910
  const response = yield fetch(`${getApiServer()}/seatmap/${uuid}/availability`, {
1021
911
  method: 'GET',
1022
- headers: {
1023
- "X-Phoenix-Auth": yield getToken(),
1024
- },
912
+ headers: Object.assign({}, (yield getAuthHeaders())),
1025
913
  });
1026
914
  if (!response.ok) {
1027
915
  throw new ApiGetError('Unable to get seatmap availability');
@@ -1031,9 +919,7 @@ const getSeatmapAvailability = (uuid) => __awaiter(void 0, void 0, void 0, funct
1031
919
  const getSeatmaps = () => __awaiter(void 0, void 0, void 0, function* () {
1032
920
  const response = yield fetch(`${getApiServer()}/seatmap/`, {
1033
921
  method: 'GET',
1034
- headers: {
1035
- "X-Phoenix-Auth": yield getToken(),
1036
- },
922
+ headers: Object.assign({}, (yield getAuthHeaders())),
1037
923
  });
1038
924
  if (!response.ok) {
1039
925
  throw new ApiGetError('Unable to get seatmaps');
@@ -1043,10 +929,7 @@ const getSeatmaps = () => __awaiter(void 0, void 0, void 0, function* () {
1043
929
  const addRow = (seatmapUuid, rowNumber, x, y, horizontal, entrance, ticketType) => __awaiter(void 0, void 0, void 0, function* () {
1044
930
  const response = yield fetch(`${getApiServer()}/seatmap/${seatmapUuid}/row`, {
1045
931
  method: 'PUT',
1046
- headers: {
1047
- 'Content-Type': 'application/json',
1048
- "X-Phoenix-Auth": yield getToken(),
1049
- },
932
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
1050
933
  body: JSON.stringify({
1051
934
  row_number: rowNumber,
1052
935
  x,
@@ -1064,9 +947,7 @@ const addRow = (seatmapUuid, rowNumber, x, y, horizontal, entrance, ticketType)
1064
947
  const uploadBackground = (uuid, body) => __awaiter(void 0, void 0, void 0, function* () {
1065
948
  const response = yield fetch(`${getApiServer()}/seatmap/${uuid}/background`, {
1066
949
  method: 'PUT',
1067
- headers: {
1068
- "X-Phoenix-Auth": yield getToken(),
1069
- },
950
+ headers: Object.assign({}, (yield getAuthHeaders())),
1070
951
  body
1071
952
  });
1072
953
  if (!response.ok) {
@@ -1088,9 +969,7 @@ var index$7 = /*#__PURE__*/Object.freeze({
1088
969
  const getEntrances = () => __awaiter(void 0, void 0, void 0, function* () {
1089
970
  const response = yield fetch(`${getApiServer()}/entrance/`, {
1090
971
  method: 'GET',
1091
- headers: {
1092
- "X-Phoenix-Auth": yield getToken(),
1093
- },
972
+ headers: Object.assign({}, (yield getAuthHeaders())),
1094
973
  });
1095
974
  if (!response.ok) {
1096
975
  throw new ApiGetError('Unable to get entrances');
@@ -1106,9 +985,7 @@ var index$8 = /*#__PURE__*/Object.freeze({
1106
985
  const getTicketTypes = () => __awaiter(void 0, void 0, void 0, function* () {
1107
986
  const response = yield fetch(`${getApiServer()}/ticketType/`, {
1108
987
  method: 'GET',
1109
- headers: {
1110
- "X-Phoenix-Auth": yield getToken(),
1111
- },
988
+ headers: Object.assign({}, (yield getAuthHeaders())),
1112
989
  });
1113
990
  if (!response.ok) {
1114
991
  throw new ApiGetError('Unable to get ticket types');
@@ -1124,10 +1001,7 @@ var index$9 = /*#__PURE__*/Object.freeze({
1124
1001
  const createTicketVoucher = (recipient_user_uuid, ticket_type_uuid, last_use_event_uuid) => __awaiter(void 0, void 0, void 0, function* () {
1125
1002
  const response = yield fetch(`${getApiServer()}/ticket_voucher`, {
1126
1003
  method: 'POST',
1127
- headers: {
1128
- "Content-Type": "application/json",
1129
- "X-Phoenix-Auth": yield getToken(),
1130
- },
1004
+ headers: Object.assign({ "Content-Type": "application/json" }, (yield getAuthHeaders())),
1131
1005
  body: JSON.stringify({
1132
1006
  recipient_user_uuid,
1133
1007
  ticket_type_uuid,
@@ -1149,10 +1023,7 @@ const createTicketVoucher = (recipient_user_uuid, ticket_type_uuid, last_use_eve
1149
1023
  const burnTicketVoucher = (ticket_voucher_uuid) => __awaiter(void 0, void 0, void 0, function* () {
1150
1024
  const response = yield fetch(`${getApiServer()}/ticket_voucher/${ticket_voucher_uuid}/burn`, {
1151
1025
  method: 'POST',
1152
- headers: {
1153
- "Content-Type": "application/json",
1154
- "X-Phoenix-Auth": yield getToken(),
1155
- }
1026
+ headers: Object.assign({ "Content-Type": "application/json" }, (yield getAuthHeaders()))
1156
1027
  });
1157
1028
  if (!response.ok) {
1158
1029
  let error = "";
@@ -1169,10 +1040,7 @@ const burnTicketVoucher = (ticket_voucher_uuid) => __awaiter(void 0, void 0, voi
1169
1040
  const getAllTicketVouchers = () => __awaiter(void 0, void 0, void 0, function* () {
1170
1041
  const response = yield fetch(`${getApiServer()}/ticket_voucher`, {
1171
1042
  method: 'GET',
1172
- headers: {
1173
- 'Content-Type': 'application/json',
1174
- "X-Phoenix-Auth": yield getToken()
1175
- },
1043
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
1176
1044
  });
1177
1045
  if (response.status !== 200) {
1178
1046
  throw new ApiGetError("Unable to get all ticket vouchers");
@@ -1190,10 +1058,7 @@ var index$a = /*#__PURE__*/Object.freeze({
1190
1058
  const getTicket = (ticket_id) => __awaiter(void 0, void 0, void 0, function* () {
1191
1059
  const response = yield fetch(`${getApiServer()}/ticket/${ticket_id}`, {
1192
1060
  method: 'GET',
1193
- headers: {
1194
- "Content-Type": "application/json",
1195
- "X-Phoenix-Auth": yield getToken(),
1196
- }
1061
+ headers: Object.assign({ "Content-Type": "application/json" }, (yield getAuthHeaders()))
1197
1062
  });
1198
1063
  if (!response.ok) {
1199
1064
  let error = "";
@@ -1210,10 +1075,7 @@ const getTicket = (ticket_id) => __awaiter(void 0, void 0, void 0, function* ()
1210
1075
  const transferTicket = (ticket_id, userEmail) => __awaiter(void 0, void 0, void 0, function* () {
1211
1076
  const response = yield fetch(`${getApiServer()}/ticket/${ticket_id}/transfer`, {
1212
1077
  method: 'POST',
1213
- headers: {
1214
- "Content-Type": "application/json",
1215
- "X-Phoenix-Auth": yield getToken(),
1216
- },
1078
+ headers: Object.assign({ "Content-Type": "application/json" }, (yield getAuthHeaders())),
1217
1079
  body: JSON.stringify({
1218
1080
  user_email: userEmail
1219
1081
  })
@@ -1232,10 +1094,7 @@ const transferTicket = (ticket_id, userEmail) => __awaiter(void 0, void 0, void
1232
1094
  const revertTransfer = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
1233
1095
  const response = yield fetch(`${getApiServer()}/ticket_transfer/${uuid}/revert`, {
1234
1096
  method: 'POST',
1235
- headers: {
1236
- "Content-Type": "application/json",
1237
- "X-Phoenix-Auth": yield getToken(),
1238
- }
1097
+ headers: Object.assign({ "Content-Type": "application/json" }, (yield getAuthHeaders()))
1239
1098
  });
1240
1099
  if (!response.ok) {
1241
1100
  let error = "";
@@ -1251,10 +1110,7 @@ const revertTransfer = (uuid) => __awaiter(void 0, void 0, void 0, function* ()
1251
1110
  const checkInTicket = (ticket_id) => __awaiter(void 0, void 0, void 0, function* () {
1252
1111
  const response = yield fetch(`${getApiServer()}/ticket/${ticket_id}/check_in`, {
1253
1112
  method: 'POST',
1254
- headers: {
1255
- "Content-Type": "application/json",
1256
- "X-Phoenix-Auth": yield getToken(),
1257
- }
1113
+ headers: Object.assign({ "Content-Type": "application/json" }, (yield getAuthHeaders()))
1258
1114
  });
1259
1115
  if (!response.ok) {
1260
1116
  let error = "";
@@ -1270,10 +1126,7 @@ const checkInTicket = (ticket_id) => __awaiter(void 0, void 0, void 0, function*
1270
1126
  const setTicketSeater = (ticket_id, userEmail) => __awaiter(void 0, void 0, void 0, function* () {
1271
1127
  const response = yield fetch(`${getApiServer()}/ticket/${ticket_id}/seater`, {
1272
1128
  method: 'PUT',
1273
- headers: {
1274
- "Content-Type": "application/json",
1275
- "X-Phoenix-Auth": yield getToken(),
1276
- },
1129
+ headers: Object.assign({ "Content-Type": "application/json" }, (yield getAuthHeaders())),
1277
1130
  body: JSON.stringify({
1278
1131
  user_email: userEmail
1279
1132
  })
@@ -1292,10 +1145,7 @@ const setTicketSeater = (ticket_id, userEmail) => __awaiter(void 0, void 0, void
1292
1145
  const seatTicket = (ticket_id, seatUuid) => __awaiter(void 0, void 0, void 0, function* () {
1293
1146
  const response = yield fetch(`${getApiServer()}/ticket/${ticket_id}/seat`, {
1294
1147
  method: 'PUT',
1295
- headers: {
1296
- "Content-Type": "application/json",
1297
- "X-Phoenix-Auth": yield getToken(),
1298
- },
1148
+ headers: Object.assign({ "Content-Type": "application/json" }, (yield getAuthHeaders())),
1299
1149
  body: JSON.stringify({
1300
1150
  seat_uuid: seatUuid
1301
1151
  })
@@ -1314,10 +1164,7 @@ const seatTicket = (ticket_id, seatUuid) => __awaiter(void 0, void 0, void 0, fu
1314
1164
  const createTicket = (recipient, ticketType) => __awaiter(void 0, void 0, void 0, function* () {
1315
1165
  const response = yield fetch(`${getApiServer()}/ticket`, {
1316
1166
  method: 'POST',
1317
- headers: {
1318
- "Content-Type": "application/json",
1319
- "X-Phoenix-Auth": yield getToken(),
1320
- },
1167
+ headers: Object.assign({ "Content-Type": "application/json" }, (yield getAuthHeaders())),
1321
1168
  body: JSON.stringify({
1322
1169
  recipient,
1323
1170
  ticket_type: ticketType
@@ -1343,10 +1190,7 @@ var index$b = /*#__PURE__*/Object.freeze({
1343
1190
  const updateRow = (uuid, options) => __awaiter(void 0, void 0, void 0, function* () {
1344
1191
  const response = yield fetch(`${getApiServer()}/row/${uuid}`, {
1345
1192
  method: 'PATCH',
1346
- headers: {
1347
- 'Content-Type': 'application/json',
1348
- "X-Phoenix-Auth": yield getToken(),
1349
- },
1193
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
1350
1194
  body: JSON.stringify(options)
1351
1195
  });
1352
1196
  if (!response.ok) {
@@ -1357,9 +1201,7 @@ const updateRow = (uuid, options) => __awaiter(void 0, void 0, void 0, function*
1357
1201
  const addSeat = (rowUuid) => __awaiter(void 0, void 0, void 0, function* () {
1358
1202
  const response = yield fetch(`${getApiServer()}/row/${rowUuid}/seat`, {
1359
1203
  method: 'PUT',
1360
- headers: {
1361
- "X-Phoenix-Auth": yield getToken(),
1362
- },
1204
+ headers: Object.assign({}, (yield getAuthHeaders())),
1363
1205
  });
1364
1206
  if (!response.ok) {
1365
1207
  throw new ApiGetError('Unable to add seat');
@@ -1376,10 +1218,7 @@ var index$c = /*#__PURE__*/Object.freeze({
1376
1218
  const getTicketSaleData = (include_free) => __awaiter(void 0, void 0, void 0, function* () {
1377
1219
  const response = yield fetch(`${getApiServer()}/statistics/ticket_sales${include_free ? "?include_free" : ""}`, {
1378
1220
  method: 'GET',
1379
- headers: {
1380
- "Content-Type": "application/json",
1381
- "X-Phoenix-Auth": yield getToken(),
1382
- }
1221
+ headers: Object.assign({ "Content-Type": "application/json" }, (yield getAuthHeaders()))
1383
1222
  });
1384
1223
  if (!response.ok) {
1385
1224
  let error = "";
@@ -1407,9 +1246,7 @@ var index$d = /*#__PURE__*/Object.freeze({
1407
1246
  const getActiveStoreSessions = () => __awaiter(void 0, void 0, void 0, function* () {
1408
1247
  const response = yield fetch(`${getApiServer()}/store_session/active`, {
1409
1248
  method: 'GET',
1410
- headers: {
1411
- "X-Phoenix-Auth": yield getToken(),
1412
- },
1249
+ headers: Object.assign({}, (yield getAuthHeaders())),
1413
1250
  });
1414
1251
  if (!response.ok) {
1415
1252
  throw new ApiGetError('Unable to get active store sessions');
@@ -1419,10 +1256,7 @@ const getActiveStoreSessions = () => __awaiter(void 0, void 0, void 0, function*
1419
1256
  const createStoreSession = (data) => __awaiter(void 0, void 0, void 0, function* () {
1420
1257
  const response = yield fetch(`${getApiServer()}/store_session`, {
1421
1258
  method: 'PUT',
1422
- headers: {
1423
- 'Content-Type': 'application/json',
1424
- "X-Phoenix-Auth": yield getToken(),
1425
- },
1259
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
1426
1260
  body: JSON.stringify(data)
1427
1261
  });
1428
1262
  if (response.status !== 200) {
@@ -1434,10 +1268,7 @@ const createStoreSession = (data) => __awaiter(void 0, void 0, void 0, function*
1434
1268
  const createPayment = (store_session, provider) => __awaiter(void 0, void 0, void 0, function* () {
1435
1269
  const response = yield fetch(`${getApiServer()}/payment`, {
1436
1270
  method: 'POST',
1437
- headers: {
1438
- 'Content-Type': 'application/json',
1439
- "X-Phoenix-Auth": yield getToken(),
1440
- },
1271
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
1441
1272
  body: JSON.stringify({
1442
1273
  store_session,
1443
1274
  provider,
@@ -1455,10 +1286,7 @@ const initiatePayment = (paymentUuid, fallbackUrl) => __awaiter(void 0, void 0,
1455
1286
  }
1456
1287
  const response = yield fetch(`${getApiServer()}/payment/${paymentUuid}/initiate`, {
1457
1288
  method: 'POST',
1458
- headers: {
1459
- 'Content-Type': 'application/json',
1460
- "X-Phoenix-Auth": yield getToken(),
1461
- },
1289
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
1462
1290
  body: JSON.stringify(body)
1463
1291
  });
1464
1292
  if (response.status !== 200) {
@@ -1477,10 +1305,7 @@ const initiateVisaPayment = (paymentUuid) => __awaiter(void 0, void 0, void 0, f
1477
1305
  const poll = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
1478
1306
  const response = yield fetch(`${getApiServer()}/payment/${uuid}`, {
1479
1307
  method: 'GET',
1480
- headers: {
1481
- 'Content-Type': 'application/json',
1482
- 'X-Phoenix-Auth': yield getToken(),
1483
- },
1308
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
1484
1309
  });
1485
1310
  if (response.status !== 200) {
1486
1311
  throw new ApiGetError("Unable to get payment data");
@@ -1495,7 +1320,7 @@ const getAgenda = () => __awaiter(void 0, void 0, void 0, function* () {
1495
1320
  'Content-Type': 'application/json',
1496
1321
  },
1497
1322
  });
1498
- if (response.status !== 200) {
1323
+ if (!response.ok) {
1499
1324
  throw new ApiGetError('Unable to get agenda');
1500
1325
  }
1501
1326
  return (yield response.json());
@@ -1507,36 +1332,89 @@ const getAgendaElement = (uuid) => __awaiter(void 0, void 0, void 0, function* (
1507
1332
  'Content-Type': 'application/json',
1508
1333
  },
1509
1334
  });
1510
- if (response.status !== 200) {
1511
- throw new ApiGetError('Unable to get agenda element');
1335
+ if (!response.ok) {
1336
+ throw new ApiGetError('Unable to get agenda element.');
1512
1337
  }
1513
1338
  return (yield response.json());
1514
1339
  });
1515
- const createAgendaEntry = (title, description, event_uuid, time) => __awaiter(void 0, void 0, void 0, function* () {
1340
+ const createAgendaEntry = (event_uuid, title, description, location, time, pinned) => __awaiter(void 0, void 0, void 0, function* () {
1516
1341
  const response = yield fetch(`${getApiServer()}/agenda`, {
1517
1342
  method: 'PUT',
1518
- headers: {
1519
- 'Content-Type': 'application/json',
1520
- 'X-Phoenix-Auth': yield getToken(),
1521
- },
1343
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
1522
1344
  body: JSON.stringify({
1345
+ event_uuid,
1523
1346
  title,
1524
1347
  description,
1348
+ location,
1349
+ time,
1350
+ pinned
1351
+ })
1352
+ });
1353
+ if (!response.ok) {
1354
+ let error = "";
1355
+ try {
1356
+ error = (yield response.json())['error'];
1357
+ }
1358
+ catch (e) {
1359
+ throw new ApiPutError('Unable to create a new agenda entry.');
1360
+ }
1361
+ throw new ApiPutError(error);
1362
+ }
1363
+ else {
1364
+ return yield response.json();
1365
+ }
1366
+ });
1367
+ const modifyAgendaEntry = (uuid, event_uuid, title, description, time, location, deviating_time_unknown, deviating_location, deviating_information, pinned, cancelled, deviating_time) => __awaiter(void 0, void 0, void 0, function* () {
1368
+ const response = yield fetch(`${getApiServer()}/agenda/${uuid}`, {
1369
+ method: 'PATCH',
1370
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
1371
+ body: JSON.stringify({
1372
+ uuid,
1525
1373
  event_uuid,
1526
- time
1374
+ title,
1375
+ description,
1376
+ time,
1377
+ location,
1378
+ deviating_time_unknown,
1379
+ deviating_location,
1380
+ deviating_information,
1381
+ pinned,
1382
+ cancelled,
1383
+ deviating_time
1527
1384
  })
1528
1385
  });
1529
- return response.status === 200;
1386
+ if (!response.ok) {
1387
+ let error = "";
1388
+ try {
1389
+ error = (yield response.json())['error'];
1390
+ }
1391
+ catch (e) {
1392
+ throw new ApiPutError('Unable to modify requested agenda entry.');
1393
+ }
1394
+ throw new ApiPutError(error);
1395
+ }
1396
+ else {
1397
+ return yield response.json();
1398
+ }
1530
1399
  });
1531
1400
  const deleteAgendaEntry = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
1532
1401
  const response = yield fetch(`${getApiServer()}/agenda/${uuid}`, {
1533
1402
  method: 'DELETE',
1534
- headers: {
1535
- 'Content-Type': 'application/json',
1536
- 'X-Phoenix-Auth': yield getToken()
1537
- }
1403
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders()))
1538
1404
  });
1539
- return response.status === 200;
1405
+ if (!response.ok) {
1406
+ let error = "";
1407
+ try {
1408
+ error = (yield response.json())['error'];
1409
+ }
1410
+ catch (e) {
1411
+ throw new ApiDeleteError('Unable to delete requested agenda entry.');
1412
+ }
1413
+ throw new ApiDeleteError(error);
1414
+ }
1415
+ else {
1416
+ return yield response.json();
1417
+ }
1540
1418
  });
1541
1419
 
1542
1420
  var index$e = /*#__PURE__*/Object.freeze({
@@ -1544,16 +1422,14 @@ var index$e = /*#__PURE__*/Object.freeze({
1544
1422
  getAgenda: getAgenda,
1545
1423
  getAgendaElement: getAgendaElement,
1546
1424
  createAgendaEntry: createAgendaEntry,
1425
+ modifyAgendaEntry: modifyAgendaEntry,
1547
1426
  deleteAgendaEntry: deleteAgendaEntry
1548
1427
  });
1549
1428
 
1550
1429
  const emailDryrun = (recipient_category, subject, body, argument) => __awaiter(void 0, void 0, void 0, function* () {
1551
1430
  const response = yield fetch(`${getApiServer()}/email/dryrun`, {
1552
1431
  method: 'POST',
1553
- headers: {
1554
- "Content-Type": "application/json",
1555
- "X-Phoenix-Auth": yield getToken(),
1556
- },
1432
+ headers: Object.assign({ "Content-Type": "application/json" }, (yield getAuthHeaders())),
1557
1433
  body: JSON.stringify({
1558
1434
  recipient_category,
1559
1435
  subject,
@@ -1576,10 +1452,7 @@ const emailDryrun = (recipient_category, subject, body, argument) => __awaiter(v
1576
1452
  const sendEmails = (recipient_category, subject, body, argument) => __awaiter(void 0, void 0, void 0, function* () {
1577
1453
  const response = yield fetch(`${getApiServer()}/email/send`, {
1578
1454
  method: 'POST',
1579
- headers: {
1580
- "Content-Type": "application/json",
1581
- "X-Phoenix-Auth": yield getToken(),
1582
- },
1455
+ headers: Object.assign({ "Content-Type": "application/json" }, (yield getAuthHeaders())),
1583
1456
  body: JSON.stringify({
1584
1457
  recipient_category,
1585
1458
  subject,
@@ -1609,10 +1482,7 @@ var index$f = /*#__PURE__*/Object.freeze({
1609
1482
  const createFriendRequest = (user_email) => __awaiter(void 0, void 0, void 0, function* () {
1610
1483
  const response = yield fetch(`${getApiServer()}/friend_request`, {
1611
1484
  method: 'POST',
1612
- headers: {
1613
- "Content-Type": "application/json",
1614
- "X-Phoenix-Auth": yield getToken(),
1615
- },
1485
+ headers: Object.assign({ "Content-Type": "application/json" }, (yield getAuthHeaders())),
1616
1486
  body: JSON.stringify({
1617
1487
  user_email: user_email
1618
1488
  })
@@ -1632,10 +1502,7 @@ const createFriendRequest = (user_email) => __awaiter(void 0, void 0, void 0, fu
1632
1502
  const viewFriendRequest = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
1633
1503
  const response = yield fetch(`${getApiServer()}/friend_request/${uuid}`, {
1634
1504
  method: 'GET',
1635
- headers: {
1636
- 'Content-Type': 'application/json',
1637
- "X-Phoenix-Auth": yield getToken()
1638
- },
1505
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
1639
1506
  });
1640
1507
  if (response.status !== 200) {
1641
1508
  throw new ApiGetError("Unable to get the friend request");
@@ -1645,10 +1512,7 @@ const viewFriendRequest = (uuid) => __awaiter(void 0, void 0, void 0, function*
1645
1512
  const revokeFriendRequest = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
1646
1513
  const response = yield fetch(`${getApiServer()}/friend_request/${uuid}`, {
1647
1514
  method: 'DELETE',
1648
- headers: {
1649
- "Content-Type": "application/json",
1650
- "X-Phoenix-Auth": yield getToken(),
1651
- }
1515
+ headers: Object.assign({ "Content-Type": "application/json" }, (yield getAuthHeaders()))
1652
1516
  });
1653
1517
  if (!response.ok) {
1654
1518
  let error = "";
@@ -1665,10 +1529,7 @@ const revokeFriendRequest = (uuid) => __awaiter(void 0, void 0, void 0, function
1665
1529
  const acceptFriendRequest = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
1666
1530
  const response = yield fetch(`${getApiServer()}/friend_request/${uuid}/accept`, {
1667
1531
  method: 'POST',
1668
- headers: {
1669
- "Content-Type": "application/json",
1670
- "X-Phoenix-Auth": yield getToken(),
1671
- }
1532
+ headers: Object.assign({ "Content-Type": "application/json" }, (yield getAuthHeaders()))
1672
1533
  });
1673
1534
  if (!response.ok) {
1674
1535
  let error = "";