@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.es.js CHANGED
@@ -114,10 +114,10 @@ const authenticateByCode = (code) => __awaiter(void 0, void 0, void 0, function*
114
114
  const result = yield fetch(`${getApiServer()}/oauth/token`, {
115
115
  method: 'POST',
116
116
  headers: {
117
- 'Content-Type': 'application/json'
117
+ 'Content-Type': 'application/x-www-form-urlencoded'
118
118
  },
119
- body: JSON.stringify({
120
- grant_type: 'code',
119
+ body: new URLSearchParams({
120
+ grant_type: 'authorization_code',
121
121
  code
122
122
  })
123
123
  });
@@ -125,7 +125,7 @@ const authenticateByCode = (code) => __awaiter(void 0, void 0, void 0, function*
125
125
  return false;
126
126
  }
127
127
  const response = yield result.json();
128
- TOKEN = response.token;
128
+ TOKEN = response.access_token;
129
129
  REFRESH_TOKEN = response.refresh_token;
130
130
  return true;
131
131
  });
@@ -143,7 +143,9 @@ const refreshToken = () => __awaiter(void 0, void 0, void 0, function* () {
143
143
  if (result.status !== 200) {
144
144
  throw new RefreshError("Unable to authenticate");
145
145
  }
146
- TOKEN = (yield result.json()).token;
146
+ const tokens = yield result.json();
147
+ TOKEN = tokens.access_token;
148
+ REFRESH_TOKEN = tokens.refresh_token;
147
149
  });
148
150
  const checkExpiry = (token) => {
149
151
  const now = new Date().getTime() / 1000;
@@ -169,6 +171,12 @@ const getToken = () => __awaiter(void 0, void 0, void 0, function* () {
169
171
  }
170
172
  return TOKEN;
171
173
  });
174
+ const getAuthHeaders = () => __awaiter(void 0, void 0, void 0, function* () {
175
+ const token = yield getToken();
176
+ return {
177
+ "Authorization": `Bearer ${token}`
178
+ };
179
+ });
172
180
  const getRefreshToken = () => __awaiter(void 0, void 0, void 0, function* () {
173
181
  return REFRESH_TOKEN;
174
182
  });
@@ -185,6 +193,7 @@ var index = /*#__PURE__*/Object.freeze({
185
193
  __proto__: null,
186
194
  authenticateByCode: authenticateByCode,
187
195
  getToken: getToken,
196
+ getAuthHeaders: getAuthHeaders,
188
197
  getRefreshToken: getRefreshToken,
189
198
  setAuthState: setAuthState,
190
199
  getTokenPayload: getTokenPayload
@@ -193,10 +202,7 @@ var index = /*#__PURE__*/Object.freeze({
193
202
  const getFriendships = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
194
203
  const response = yield fetch(`${getApiServer()}/user/${uuid}/friendships`, {
195
204
  method: 'GET',
196
- headers: {
197
- 'Content-Type': 'application/json',
198
- "X-Phoenix-Auth": yield getToken()
199
- },
205
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
200
206
  });
201
207
  if (response.status !== 200) {
202
208
  throw new ApiGetError("Unable to get the user's active friendships");
@@ -206,10 +212,7 @@ const getFriendships = (uuid) => __awaiter(void 0, void 0, void 0, function* ()
206
212
  const getFriendRequests = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
207
213
  const response = yield fetch(`${getApiServer()}/user/${uuid}/friend_requests`, {
208
214
  method: 'GET',
209
- headers: {
210
- 'Content-Type': 'application/json',
211
- "X-Phoenix-Auth": yield getToken()
212
- },
215
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
213
216
  });
214
217
  if (response.status !== 200) {
215
218
  throw new ApiGetError("Unable to get the user's active friend requests");
@@ -219,10 +222,7 @@ const getFriendRequests = (uuid) => __awaiter(void 0, void 0, void 0, function*
219
222
  const getOwnedTickets = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
220
223
  const response = yield fetch(`${getApiServer()}/user/${uuid}/owned_tickets`, {
221
224
  method: 'GET',
222
- headers: {
223
- 'Content-Type': 'application/json',
224
- "X-Phoenix-Auth": yield getToken()
225
- },
225
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
226
226
  });
227
227
  if (response.status !== 200) {
228
228
  throw new ApiGetError("Unable to get the user's tickets");
@@ -232,10 +232,7 @@ const getOwnedTickets = (uuid) => __awaiter(void 0, void 0, void 0, function* ()
232
232
  const getPurchasedTickets = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
233
233
  const response = yield fetch(`${getApiServer()}/user/${uuid}/purchased_tickets`, {
234
234
  method: 'GET',
235
- headers: {
236
- 'Content-Type': 'application/json',
237
- "X-Phoenix-Auth": yield getToken()
238
- },
235
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
239
236
  });
240
237
  if (response.status !== 200) {
241
238
  throw new ApiGetError("Unable to get the user's tickets");
@@ -245,10 +242,7 @@ const getPurchasedTickets = (uuid) => __awaiter(void 0, void 0, void 0, function
245
242
  const getTicketVouchers = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
246
243
  const response = yield fetch(`${getApiServer()}/user/${uuid}/ticket_vouchers`, {
247
244
  method: 'GET',
248
- headers: {
249
- 'Content-Type': 'application/json',
250
- "X-Phoenix-Auth": yield getToken()
251
- },
245
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
252
246
  });
253
247
  if (response.status !== 200) {
254
248
  throw new ApiGetError("Unable to get the user's ticket_vouchers");
@@ -258,10 +252,7 @@ const getTicketVouchers = (uuid) => __awaiter(void 0, void 0, void 0, function*
258
252
  const getTicketTransfers = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
259
253
  const response = yield fetch(`${getApiServer()}/user/${uuid}/ticket_transfers`, {
260
254
  method: 'GET',
261
- headers: {
262
- 'Content-Type': 'application/json',
263
- "X-Phoenix-Auth": yield getToken()
264
- },
255
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
265
256
  });
266
257
  if (response.status !== 200) {
267
258
  throw new ApiGetError("Unable to get ticket transfers");
@@ -271,10 +262,7 @@ const getTicketTransfers = (uuid) => __awaiter(void 0, void 0, void 0, function*
271
262
  const getSeatableTickets = (uuid, event_uuid) => __awaiter(void 0, void 0, void 0, function* () {
272
263
  const response = yield fetch(`${getApiServer()}/user/${uuid}/seatable_tickets${event_uuid ? "?event_uuid=" + event_uuid : ''}`, {
273
264
  method: 'GET',
274
- headers: {
275
- 'Content-Type': 'application/json',
276
- "X-Phoenix-Auth": yield getToken()
277
- },
265
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
278
266
  });
279
267
  if (response.status !== 200) {
280
268
  throw new ApiGetError("Unable to get seatable tickets");
@@ -284,10 +272,7 @@ const getSeatableTickets = (uuid, event_uuid) => __awaiter(void 0, void 0, void
284
272
  const getAuthenticatedUser = () => __awaiter(void 0, void 0, void 0, function* () {
285
273
  const result = yield fetch(`${getApiServer()}/user/current`, {
286
274
  method: 'GET',
287
- headers: {
288
- 'Content-Type': 'application/json',
289
- "X-Phoenix-Auth": yield getToken()
290
- }
275
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders()))
291
276
  });
292
277
  if (result.status !== 200) {
293
278
  throw new AuthError("Unable to get current user");
@@ -297,10 +282,7 @@ const getAuthenticatedUser = () => __awaiter(void 0, void 0, void 0, function* (
297
282
  const getUserMembershipStatus = (uuid, year) => __awaiter(void 0, void 0, void 0, function* () {
298
283
  const result = yield fetch(`${getApiServer()}/user/${uuid}/membership${year ? '?year=' + year : ""}`, {
299
284
  method: 'GET',
300
- headers: {
301
- 'Content-Type': 'application/json',
302
- "X-Phoenix-Auth": yield getToken()
303
- }
285
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders()))
304
286
  });
305
287
  if (result.status !== 200) {
306
288
  throw new AuthError("Unable to get membership status");
@@ -310,10 +292,7 @@ const getUserMembershipStatus = (uuid, year) => __awaiter(void 0, void 0, void 0
310
292
  const getUser = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
311
293
  const result = yield fetch(`${getApiServer()}/user/${uuid}`, {
312
294
  method: 'GET',
313
- headers: {
314
- 'Content-Type': 'application/json',
315
- "X-Phoenix-Auth": yield getToken()
316
- }
295
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders()))
317
296
  });
318
297
  if (result.status !== 200) {
319
298
  throw new AuthError("Unable to get user");
@@ -323,10 +302,7 @@ const getUser = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
323
302
  const getUserActivationState = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
324
303
  const result = yield fetch(`${getApiServer()}/user/${uuid}/activation`, {
325
304
  method: 'GET',
326
- headers: {
327
- 'Content-Type': 'application/json',
328
- "X-Phoenix-Auth": yield getToken()
329
- }
305
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders()))
330
306
  });
331
307
  if (result.status !== 200) {
332
308
  throw new AuthError("Unable to get authentication token");
@@ -336,10 +312,7 @@ const getUserActivationState = (uuid) => __awaiter(void 0, void 0, void 0, funct
336
312
  const activateUser = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
337
313
  const result = yield fetch(`${getApiServer()}/user/${uuid}/activation`, {
338
314
  method: 'PATCH',
339
- headers: {
340
- 'Content-Type': 'application/json',
341
- "X-Phoenix-Auth": yield getToken()
342
- }
315
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders()))
343
316
  });
344
317
  if (result.status !== 200) {
345
318
  throw new AuthError("Unable to get authentication token");
@@ -348,9 +321,7 @@ const activateUser = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
348
321
  const searchUsers = (query) => __awaiter(void 0, void 0, void 0, function* () {
349
322
  const result = yield fetch(`${getApiServer()}/user/search?query=${encodeURIComponent(query)}`, {
350
323
  method: 'GET',
351
- headers: {
352
- "X-Phoenix-Auth": yield getToken()
353
- }
324
+ headers: Object.assign({}, (yield getAuthHeaders()))
354
325
  });
355
326
  if (result.status !== 200) {
356
327
  throw new AuthError("Unable to search");
@@ -361,10 +332,7 @@ const searchUsers = (query) => __awaiter(void 0, void 0, void 0, function* () {
361
332
  const getUsers = () => __awaiter(void 0, void 0, void 0, function* () {
362
333
  const result = yield fetch(`${getApiServer()}/user`, {
363
334
  method: 'GET',
364
- headers: {
365
- 'Content-Type': 'application/json',
366
- "X-Phoenix-Auth": yield getToken()
367
- }
335
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders()))
368
336
  });
369
337
  if (result.status !== 200) {
370
338
  throw new AuthError("Unable to get users");
@@ -374,10 +342,7 @@ const getUsers = () => __awaiter(void 0, void 0, void 0, function* () {
374
342
  const createDiscordMappingOauthUrl = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
375
343
  const result = yield fetch(`${getApiServer()}/user/${uuid}/discord_mapping`, {
376
344
  method: 'POST',
377
- headers: {
378
- 'Content-Type': 'application/json',
379
- "X-Phoenix-Auth": yield getToken()
380
- }
345
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders()))
381
346
  });
382
347
  if (!result.ok) {
383
348
  try {
@@ -392,10 +357,7 @@ const createDiscordMappingOauthUrl = (uuid) => __awaiter(void 0, void 0, void 0,
392
357
  const revokeDiscordMapping = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
393
358
  const result = yield fetch(`${getApiServer()}/user/${uuid}/discord_mapping`, {
394
359
  method: 'DELETE',
395
- headers: {
396
- 'Content-Type': 'application/json',
397
- "X-Phoenix-Auth": yield getToken()
398
- }
360
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders()))
399
361
  });
400
362
  if (!result.ok) {
401
363
  throw new ApiGetError("Unable to revoke Discord mapping");
@@ -404,10 +366,7 @@ const revokeDiscordMapping = (uuid) => __awaiter(void 0, void 0, void 0, functio
404
366
  const getDiscordMapping = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
405
367
  const result = yield fetch(`${getApiServer()}/user/${uuid}/discord_mapping`, {
406
368
  method: 'GET',
407
- headers: {
408
- 'Content-Type': 'application/json',
409
- "X-Phoenix-Auth": yield getToken()
410
- }
369
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders()))
411
370
  });
412
371
  if (result.status === 404) {
413
372
  return null;
@@ -420,9 +379,7 @@ const getDiscordMapping = (uuid) => __awaiter(void 0, void 0, void 0, function*
420
379
  const getCrewCard = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
421
380
  const result = yield fetch(`${getApiServer()}/user/${uuid}/crew_card`, {
422
381
  method: "GET",
423
- headers: {
424
- "X-Phoenix-Auth": yield getToken()
425
- }
382
+ headers: Object.assign({}, (yield getAuthHeaders()))
426
383
  });
427
384
  return result;
428
385
  });
@@ -509,10 +466,7 @@ const getEventTicketTypes = (uuid) => __awaiter(void 0, void 0, void 0, function
509
466
  const addEventTicketType = (event_uuid, ticket_type_uuid) => __awaiter(void 0, void 0, void 0, function* () {
510
467
  const response = yield fetch(`${getApiServer()}/event/${event_uuid}/ticketType`, {
511
468
  method: 'PUT',
512
- headers: {
513
- 'Content-Type': 'application/json',
514
- "X-Phoenix-Auth": yield getToken(),
515
- },
469
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
516
470
  body: JSON.stringify({
517
471
  ticket_type_uuid
518
472
  })
@@ -525,9 +479,7 @@ const addEventTicketType = (event_uuid, ticket_type_uuid) => __awaiter(void 0, v
525
479
  const getEventMembersRequiringMembership = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
526
480
  const response = yield fetch(`${getApiServer()}/event/${uuid}/customers_requiring_memberships`, {
527
481
  method: 'GET',
528
- headers: {
529
- "X-Phoenix-Auth": yield getToken(),
530
- }
482
+ headers: Object.assign({}, (yield getAuthHeaders()))
531
483
  });
532
484
  if (response.status !== 200) {
533
485
  throw new ApiGetError("Unable to get customers requiring memberships");
@@ -537,9 +489,7 @@ const getEventMembersRequiringMembership = (uuid) => __awaiter(void 0, void 0, v
537
489
  const getEventNewMembers = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
538
490
  const response = yield fetch(`${getApiServer()}/event/${uuid}/new_memberships`, {
539
491
  method: 'GET',
540
- headers: {
541
- "X-Phoenix-Auth": yield getToken(),
542
- }
492
+ headers: Object.assign({}, (yield getAuthHeaders()))
543
493
  });
544
494
  if (response.status !== 200) {
545
495
  throw new ApiGetError("Unable to get new memberships");
@@ -549,9 +499,7 @@ const getEventNewMembers = (uuid) => __awaiter(void 0, void 0, void 0, function*
549
499
  const getEventTickets = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
550
500
  const response = yield fetch(`${getApiServer()}/event/${uuid}/ticket`, {
551
501
  method: 'GET',
552
- headers: {
553
- "X-Phoenix-Auth": yield getToken(),
554
- }
502
+ headers: Object.assign({}, (yield getAuthHeaders()))
555
503
  });
556
504
  if (response.status !== 200) {
557
505
  throw new ApiGetError("Unable to get the events tickets");
@@ -561,10 +509,7 @@ const getEventTickets = (uuid) => __awaiter(void 0, void 0, void 0, function* ()
561
509
  const getApplicationsByEvent = (event_uuid) => __awaiter(void 0, void 0, void 0, function* () {
562
510
  const response = yield fetch(`${getApiServer()}/event/${event_uuid}/applications`, {
563
511
  method: 'GET',
564
- headers: {
565
- 'Content-Type': 'application/json',
566
- "X-Phoenix-Auth": yield getToken(),
567
- },
512
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
568
513
  });
569
514
  if (response.status !== 200) {
570
515
  throw new ApiGetError('Unable to get applications');
@@ -581,10 +526,7 @@ var ApplicationState;
581
526
  const getAllApplications = () => __awaiter(void 0, void 0, void 0, function* () {
582
527
  const response = yield fetch(`${getApiServer()}/application`, {
583
528
  method: 'GET',
584
- headers: {
585
- 'Content-Type': 'application/json',
586
- "X-Phoenix-Auth": yield getToken(),
587
- },
529
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
588
530
  });
589
531
  if (response.status !== 200) {
590
532
  throw new ApiGetError('Unable to get applications');
@@ -597,10 +539,7 @@ const getApplication = (uuid) => __awaiter(void 0, void 0, void 0, function* ()
597
539
  }
598
540
  const response = yield fetch(`${getApiServer()}/application/${uuid}`, {
599
541
  method: 'GET',
600
- headers: {
601
- 'Content-Type': 'application/json',
602
- "X-Phoenix-Auth": yield getToken(),
603
- },
542
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
604
543
  });
605
544
  if (response.status !== 200) {
606
545
  throw new ApiGetError('Unable to get applications');
@@ -617,7 +556,7 @@ export const getAllApplicationsByEvent = async (event: Event): Promise<Array<Bas
617
556
  method: 'GET',
618
557
  headers: {
619
558
  'Content-Type': 'application/json',
620
- "X-Phoenix-Auth": await Oauth.getToken(),
559
+ ...(await Oauth.getAuthHeaders()),
621
560
  },
622
561
  });
623
562
 
@@ -631,10 +570,7 @@ export const getAllApplicationsByEvent = async (event: Event): Promise<Array<Bas
631
570
  const getUserApplications = () => __awaiter(void 0, void 0, void 0, function* () {
632
571
  const response = yield fetch(`${getApiServer()}/application/my`, {
633
572
  method: 'GET',
634
- headers: {
635
- 'Content-Type': 'application/json',
636
- "X-Phoenix-Auth": yield getToken(),
637
- },
573
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
638
574
  });
639
575
  if (response.status !== 200) {
640
576
  throw new ApiGetError('Unable to get applications');
@@ -644,10 +580,7 @@ const getUserApplications = () => __awaiter(void 0, void 0, void 0, function* ()
644
580
  const createApplication = (crews, contents) => __awaiter(void 0, void 0, void 0, function* () {
645
581
  const response = yield fetch(`${getApiServer()}/application`, {
646
582
  method: 'PUT',
647
- headers: {
648
- 'Content-Type': 'application/json',
649
- "X-Phoenix-Auth": yield getToken(),
650
- },
583
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
651
584
  body: JSON.stringify({
652
585
  crews,
653
586
  contents,
@@ -677,10 +610,7 @@ const answerApplication = (uuid, crew_uuid, answer, state) => __awaiter(void 0,
677
610
  }
678
611
  const response = yield fetch(`${getApiServer()}/application/${uuid}`, {
679
612
  method: 'PATCH',
680
- headers: {
681
- 'Content-Type': 'application/json',
682
- "X-Phoenix-Auth": yield getToken(),
683
- },
613
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
684
614
  body: JSON.stringify({
685
615
  answer,
686
616
  crew_uuid,
@@ -697,10 +627,7 @@ const hideApplication = (uuid) => __awaiter(void 0, void 0, void 0, function* ()
697
627
  }
698
628
  const response = yield fetch(`${getApiServer()}/application/${uuid}/hide`, {
699
629
  method: 'PATCH',
700
- headers: {
701
- 'Content-Type': 'application/json',
702
- "X-Phoenix-Auth": yield getToken(),
703
- }
630
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders()))
704
631
  });
705
632
  if (!response.ok) {
706
633
  let error = "";
@@ -727,10 +654,7 @@ var index$2 = /*#__PURE__*/Object.freeze({
727
654
  const getCrews = () => __awaiter(void 0, void 0, void 0, function* () {
728
655
  const response = yield fetch(`${getApiServer()}/crew/`, {
729
656
  method: 'GET',
730
- headers: {
731
- 'Content-Type': 'application/json',
732
- "X-Phoenix-Auth": yield getToken(),
733
- },
657
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
734
658
  });
735
659
  if (response.status !== 200) {
736
660
  throw new ApiGetError('Unable to get crews');
@@ -740,10 +664,7 @@ const getCrews = () => __awaiter(void 0, void 0, void 0, function* () {
740
664
  const getCrew = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
741
665
  const response = yield fetch(`${getApiServer()}/crew/${uuid}`, {
742
666
  method: 'GET',
743
- headers: {
744
- 'Content-Type': 'application/json',
745
- "X-Phoenix-Auth": yield getToken(),
746
- },
667
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
747
668
  });
748
669
  if (response.status !== 200) {
749
670
  throw new ApiGetError(`Unable to get crew: ${uuid}`);
@@ -767,9 +688,7 @@ const createAvatar = (file, x, y, w, h, uuid) => __awaiter(void 0, void 0, void
767
688
  data.set("h", h.toString());
768
689
  const result = yield fetch(`${getApiServer()}/user/${uuid}/avatar`, {
769
690
  method: 'POST',
770
- headers: {
771
- "X-Phoenix-Auth": yield getToken()
772
- },
691
+ headers: Object.assign({}, (yield getAuthHeaders())),
773
692
  body: data,
774
693
  });
775
694
  if (result.status !== 200) {
@@ -779,9 +698,7 @@ const createAvatar = (file, x, y, w, h, uuid) => __awaiter(void 0, void 0, void
779
698
  const deleteAvatar = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
780
699
  const result = yield fetch(`${getApiServer()}/avatar/${uuid}`, {
781
700
  method: 'DELETE',
782
- headers: {
783
- "X-Phoenix-Auth": yield getToken()
784
- }
701
+ headers: Object.assign({}, (yield getAuthHeaders()))
785
702
  });
786
703
  if (result.status !== 200) {
787
704
  throw new ApiPostError("Failed to delete avatar");
@@ -790,10 +707,7 @@ const deleteAvatar = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
790
707
  const getAvatar = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
791
708
  const result = yield fetch(`${getApiServer()}/avatar/${uuid}`, {
792
709
  method: 'GET',
793
- headers: {
794
- 'Content-Type': 'application/json',
795
- "X-Phoenix-Auth": yield getToken()
796
- }
710
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders()))
797
711
  });
798
712
  if (result.status !== 200) {
799
713
  throw new ApiGetError("Unable to get avatar");
@@ -803,10 +717,7 @@ const getAvatar = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
803
717
  const getAvatars = () => __awaiter(void 0, void 0, void 0, function* () {
804
718
  const result = yield fetch(`${getApiServer()}/avatar`, {
805
719
  method: 'GET',
806
- headers: {
807
- 'Content-Type': 'application/json',
808
- "X-Phoenix-Auth": yield getToken()
809
- }
720
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders()))
810
721
  });
811
722
  if (result.status !== 200) {
812
723
  throw new ApiGetError("Unable to get avatars");
@@ -816,10 +727,7 @@ const getAvatars = () => __awaiter(void 0, void 0, void 0, function* () {
816
727
  const getPendingAvatars = () => __awaiter(void 0, void 0, void 0, function* () {
817
728
  const result = yield fetch(`${getApiServer()}/avatar/pending`, {
818
729
  method: 'GET',
819
- headers: {
820
- 'Content-Type': 'application/json',
821
- "X-Phoenix-Auth": yield getToken()
822
- }
730
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders()))
823
731
  });
824
732
  if (result.status !== 200) {
825
733
  throw new ApiGetError("Unable to get pending avatars");
@@ -829,10 +737,7 @@ const getPendingAvatars = () => __awaiter(void 0, void 0, void 0, function* () {
829
737
  const setApproved = (uuid, state) => __awaiter(void 0, void 0, void 0, function* () {
830
738
  const result = yield fetch(`${getApiServer()}/avatar/${uuid}`, {
831
739
  method: 'PATCH',
832
- headers: {
833
- 'Content-Type': 'application/json',
834
- "X-Phoenix-Auth": yield getToken()
835
- },
740
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
836
741
  body: JSON.stringify({
837
742
  new_state: state ? "accepted" : "rejected"
838
743
  })
@@ -880,9 +785,7 @@ const getTosPayment = () => __awaiter(void 0, void 0, void 0, function* () {
880
785
  const getPosition = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
881
786
  const response = yield fetch(`${getApiServer()}/position/${uuid}`, {
882
787
  method: 'GET',
883
- headers: {
884
- "X-Phoenix-Auth": yield getToken(),
885
- },
788
+ headers: Object.assign({}, (yield getAuthHeaders())),
886
789
  });
887
790
  if (!response.ok) {
888
791
  throw new ApiGetError('Unable to get position');
@@ -892,9 +795,7 @@ const getPosition = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
892
795
  const getPositions = () => __awaiter(void 0, void 0, void 0, function* () {
893
796
  const response = yield fetch(`${getApiServer()}/position/`, {
894
797
  method: 'GET',
895
- headers: {
896
- "X-Phoenix-Auth": yield getToken(),
897
- },
798
+ headers: Object.assign({}, (yield getAuthHeaders())),
898
799
  });
899
800
  if (!response.ok) {
900
801
  throw new ApiGetError('Unable to get positions');
@@ -904,9 +805,7 @@ const getPositions = () => __awaiter(void 0, void 0, void 0, function* () {
904
805
  const createPosition = (name, description, crew_uuid, team_uuid) => __awaiter(void 0, void 0, void 0, function* () {
905
806
  const response = yield fetch(`${getApiServer()}/position/`, {
906
807
  method: 'POST',
907
- headers: {
908
- "X-Phoenix-Auth": yield getToken(),
909
- },
808
+ headers: Object.assign({}, (yield getAuthHeaders())),
910
809
  body: JSON.stringify({
911
810
  name,
912
811
  description,
@@ -937,9 +836,7 @@ var index$5 = /*#__PURE__*/Object.freeze({
937
836
  const deletePositionMapping = (position_mapping_uuid) => __awaiter(void 0, void 0, void 0, function* () {
938
837
  const response = yield fetch(`${getApiServer()}/position_mapping/${position_mapping_uuid}`, {
939
838
  method: 'DELETE',
940
- headers: {
941
- "X-Phoenix-Auth": yield getToken(),
942
- }
839
+ headers: Object.assign({}, (yield getAuthHeaders()))
943
840
  });
944
841
  if (!response.ok) {
945
842
  let error = "";
@@ -956,9 +853,7 @@ const deletePositionMapping = (position_mapping_uuid) => __awaiter(void 0, void
956
853
  const createPositionMapping = (user_uuid, position_uuid) => __awaiter(void 0, void 0, void 0, function* () {
957
854
  const response = yield fetch(`${getApiServer()}/position_mapping/`, {
958
855
  method: 'POST',
959
- headers: {
960
- "X-Phoenix-Auth": yield getToken(),
961
- },
856
+ headers: Object.assign({}, (yield getAuthHeaders())),
962
857
  body: JSON.stringify({
963
858
  user_uuid,
964
859
  position_uuid
@@ -986,10 +881,7 @@ var index$6 = /*#__PURE__*/Object.freeze({
986
881
  const createSeatmap = (name, description) => __awaiter(void 0, void 0, void 0, function* () {
987
882
  const response = yield fetch(`${getApiServer()}/seatmap`, {
988
883
  method: 'PUT',
989
- headers: {
990
- 'Content-Type': 'application/json',
991
- "X-Phoenix-Auth": yield getToken(),
992
- },
884
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
993
885
  body: JSON.stringify({
994
886
  name,
995
887
  description
@@ -1003,9 +895,7 @@ const createSeatmap = (name, description) => __awaiter(void 0, void 0, void 0, f
1003
895
  const getSeatmap = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
1004
896
  const response = yield fetch(`${getApiServer()}/seatmap/${uuid}`, {
1005
897
  method: 'GET',
1006
- headers: {
1007
- "X-Phoenix-Auth": yield getToken(),
1008
- },
898
+ headers: Object.assign({}, (yield getAuthHeaders())),
1009
899
  });
1010
900
  if (!response.ok) {
1011
901
  throw new ApiGetError('Unable to get seatmap');
@@ -1015,9 +905,7 @@ const getSeatmap = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
1015
905
  const getSeatmapAvailability = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
1016
906
  const response = yield fetch(`${getApiServer()}/seatmap/${uuid}/availability`, {
1017
907
  method: 'GET',
1018
- headers: {
1019
- "X-Phoenix-Auth": yield getToken(),
1020
- },
908
+ headers: Object.assign({}, (yield getAuthHeaders())),
1021
909
  });
1022
910
  if (!response.ok) {
1023
911
  throw new ApiGetError('Unable to get seatmap availability');
@@ -1027,9 +915,7 @@ const getSeatmapAvailability = (uuid) => __awaiter(void 0, void 0, void 0, funct
1027
915
  const getSeatmaps = () => __awaiter(void 0, void 0, void 0, function* () {
1028
916
  const response = yield fetch(`${getApiServer()}/seatmap/`, {
1029
917
  method: 'GET',
1030
- headers: {
1031
- "X-Phoenix-Auth": yield getToken(),
1032
- },
918
+ headers: Object.assign({}, (yield getAuthHeaders())),
1033
919
  });
1034
920
  if (!response.ok) {
1035
921
  throw new ApiGetError('Unable to get seatmaps');
@@ -1039,10 +925,7 @@ const getSeatmaps = () => __awaiter(void 0, void 0, void 0, function* () {
1039
925
  const addRow = (seatmapUuid, rowNumber, x, y, horizontal, entrance, ticketType) => __awaiter(void 0, void 0, void 0, function* () {
1040
926
  const response = yield fetch(`${getApiServer()}/seatmap/${seatmapUuid}/row`, {
1041
927
  method: 'PUT',
1042
- headers: {
1043
- 'Content-Type': 'application/json',
1044
- "X-Phoenix-Auth": yield getToken(),
1045
- },
928
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
1046
929
  body: JSON.stringify({
1047
930
  row_number: rowNumber,
1048
931
  x,
@@ -1060,9 +943,7 @@ const addRow = (seatmapUuid, rowNumber, x, y, horizontal, entrance, ticketType)
1060
943
  const uploadBackground = (uuid, body) => __awaiter(void 0, void 0, void 0, function* () {
1061
944
  const response = yield fetch(`${getApiServer()}/seatmap/${uuid}/background`, {
1062
945
  method: 'PUT',
1063
- headers: {
1064
- "X-Phoenix-Auth": yield getToken(),
1065
- },
946
+ headers: Object.assign({}, (yield getAuthHeaders())),
1066
947
  body
1067
948
  });
1068
949
  if (!response.ok) {
@@ -1084,9 +965,7 @@ var index$7 = /*#__PURE__*/Object.freeze({
1084
965
  const getEntrances = () => __awaiter(void 0, void 0, void 0, function* () {
1085
966
  const response = yield fetch(`${getApiServer()}/entrance/`, {
1086
967
  method: 'GET',
1087
- headers: {
1088
- "X-Phoenix-Auth": yield getToken(),
1089
- },
968
+ headers: Object.assign({}, (yield getAuthHeaders())),
1090
969
  });
1091
970
  if (!response.ok) {
1092
971
  throw new ApiGetError('Unable to get entrances');
@@ -1102,9 +981,7 @@ var index$8 = /*#__PURE__*/Object.freeze({
1102
981
  const getTicketTypes = () => __awaiter(void 0, void 0, void 0, function* () {
1103
982
  const response = yield fetch(`${getApiServer()}/ticketType/`, {
1104
983
  method: 'GET',
1105
- headers: {
1106
- "X-Phoenix-Auth": yield getToken(),
1107
- },
984
+ headers: Object.assign({}, (yield getAuthHeaders())),
1108
985
  });
1109
986
  if (!response.ok) {
1110
987
  throw new ApiGetError('Unable to get ticket types');
@@ -1120,10 +997,7 @@ var index$9 = /*#__PURE__*/Object.freeze({
1120
997
  const createTicketVoucher = (recipient_user_uuid, ticket_type_uuid, last_use_event_uuid) => __awaiter(void 0, void 0, void 0, function* () {
1121
998
  const response = yield fetch(`${getApiServer()}/ticket_voucher`, {
1122
999
  method: 'POST',
1123
- headers: {
1124
- "Content-Type": "application/json",
1125
- "X-Phoenix-Auth": yield getToken(),
1126
- },
1000
+ headers: Object.assign({ "Content-Type": "application/json" }, (yield getAuthHeaders())),
1127
1001
  body: JSON.stringify({
1128
1002
  recipient_user_uuid,
1129
1003
  ticket_type_uuid,
@@ -1145,10 +1019,7 @@ const createTicketVoucher = (recipient_user_uuid, ticket_type_uuid, last_use_eve
1145
1019
  const burnTicketVoucher = (ticket_voucher_uuid) => __awaiter(void 0, void 0, void 0, function* () {
1146
1020
  const response = yield fetch(`${getApiServer()}/ticket_voucher/${ticket_voucher_uuid}/burn`, {
1147
1021
  method: 'POST',
1148
- headers: {
1149
- "Content-Type": "application/json",
1150
- "X-Phoenix-Auth": yield getToken(),
1151
- }
1022
+ headers: Object.assign({ "Content-Type": "application/json" }, (yield getAuthHeaders()))
1152
1023
  });
1153
1024
  if (!response.ok) {
1154
1025
  let error = "";
@@ -1165,10 +1036,7 @@ const burnTicketVoucher = (ticket_voucher_uuid) => __awaiter(void 0, void 0, voi
1165
1036
  const getAllTicketVouchers = () => __awaiter(void 0, void 0, void 0, function* () {
1166
1037
  const response = yield fetch(`${getApiServer()}/ticket_voucher`, {
1167
1038
  method: 'GET',
1168
- headers: {
1169
- 'Content-Type': 'application/json',
1170
- "X-Phoenix-Auth": yield getToken()
1171
- },
1039
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
1172
1040
  });
1173
1041
  if (response.status !== 200) {
1174
1042
  throw new ApiGetError("Unable to get all ticket vouchers");
@@ -1186,10 +1054,7 @@ var index$a = /*#__PURE__*/Object.freeze({
1186
1054
  const getTicket = (ticket_id) => __awaiter(void 0, void 0, void 0, function* () {
1187
1055
  const response = yield fetch(`${getApiServer()}/ticket/${ticket_id}`, {
1188
1056
  method: 'GET',
1189
- headers: {
1190
- "Content-Type": "application/json",
1191
- "X-Phoenix-Auth": yield getToken(),
1192
- }
1057
+ headers: Object.assign({ "Content-Type": "application/json" }, (yield getAuthHeaders()))
1193
1058
  });
1194
1059
  if (!response.ok) {
1195
1060
  let error = "";
@@ -1206,10 +1071,7 @@ const getTicket = (ticket_id) => __awaiter(void 0, void 0, void 0, function* ()
1206
1071
  const transferTicket = (ticket_id, userEmail) => __awaiter(void 0, void 0, void 0, function* () {
1207
1072
  const response = yield fetch(`${getApiServer()}/ticket/${ticket_id}/transfer`, {
1208
1073
  method: 'POST',
1209
- headers: {
1210
- "Content-Type": "application/json",
1211
- "X-Phoenix-Auth": yield getToken(),
1212
- },
1074
+ headers: Object.assign({ "Content-Type": "application/json" }, (yield getAuthHeaders())),
1213
1075
  body: JSON.stringify({
1214
1076
  user_email: userEmail
1215
1077
  })
@@ -1228,10 +1090,7 @@ const transferTicket = (ticket_id, userEmail) => __awaiter(void 0, void 0, void
1228
1090
  const revertTransfer = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
1229
1091
  const response = yield fetch(`${getApiServer()}/ticket_transfer/${uuid}/revert`, {
1230
1092
  method: 'POST',
1231
- headers: {
1232
- "Content-Type": "application/json",
1233
- "X-Phoenix-Auth": yield getToken(),
1234
- }
1093
+ headers: Object.assign({ "Content-Type": "application/json" }, (yield getAuthHeaders()))
1235
1094
  });
1236
1095
  if (!response.ok) {
1237
1096
  let error = "";
@@ -1247,10 +1106,7 @@ const revertTransfer = (uuid) => __awaiter(void 0, void 0, void 0, function* ()
1247
1106
  const checkInTicket = (ticket_id) => __awaiter(void 0, void 0, void 0, function* () {
1248
1107
  const response = yield fetch(`${getApiServer()}/ticket/${ticket_id}/check_in`, {
1249
1108
  method: 'POST',
1250
- headers: {
1251
- "Content-Type": "application/json",
1252
- "X-Phoenix-Auth": yield getToken(),
1253
- }
1109
+ headers: Object.assign({ "Content-Type": "application/json" }, (yield getAuthHeaders()))
1254
1110
  });
1255
1111
  if (!response.ok) {
1256
1112
  let error = "";
@@ -1266,10 +1122,7 @@ const checkInTicket = (ticket_id) => __awaiter(void 0, void 0, void 0, function*
1266
1122
  const setTicketSeater = (ticket_id, userEmail) => __awaiter(void 0, void 0, void 0, function* () {
1267
1123
  const response = yield fetch(`${getApiServer()}/ticket/${ticket_id}/seater`, {
1268
1124
  method: 'PUT',
1269
- headers: {
1270
- "Content-Type": "application/json",
1271
- "X-Phoenix-Auth": yield getToken(),
1272
- },
1125
+ headers: Object.assign({ "Content-Type": "application/json" }, (yield getAuthHeaders())),
1273
1126
  body: JSON.stringify({
1274
1127
  user_email: userEmail
1275
1128
  })
@@ -1288,10 +1141,7 @@ const setTicketSeater = (ticket_id, userEmail) => __awaiter(void 0, void 0, void
1288
1141
  const seatTicket = (ticket_id, seatUuid) => __awaiter(void 0, void 0, void 0, function* () {
1289
1142
  const response = yield fetch(`${getApiServer()}/ticket/${ticket_id}/seat`, {
1290
1143
  method: 'PUT',
1291
- headers: {
1292
- "Content-Type": "application/json",
1293
- "X-Phoenix-Auth": yield getToken(),
1294
- },
1144
+ headers: Object.assign({ "Content-Type": "application/json" }, (yield getAuthHeaders())),
1295
1145
  body: JSON.stringify({
1296
1146
  seat_uuid: seatUuid
1297
1147
  })
@@ -1310,10 +1160,7 @@ const seatTicket = (ticket_id, seatUuid) => __awaiter(void 0, void 0, void 0, fu
1310
1160
  const createTicket = (recipient, ticketType) => __awaiter(void 0, void 0, void 0, function* () {
1311
1161
  const response = yield fetch(`${getApiServer()}/ticket`, {
1312
1162
  method: 'POST',
1313
- headers: {
1314
- "Content-Type": "application/json",
1315
- "X-Phoenix-Auth": yield getToken(),
1316
- },
1163
+ headers: Object.assign({ "Content-Type": "application/json" }, (yield getAuthHeaders())),
1317
1164
  body: JSON.stringify({
1318
1165
  recipient,
1319
1166
  ticket_type: ticketType
@@ -1339,10 +1186,7 @@ var index$b = /*#__PURE__*/Object.freeze({
1339
1186
  const updateRow = (uuid, options) => __awaiter(void 0, void 0, void 0, function* () {
1340
1187
  const response = yield fetch(`${getApiServer()}/row/${uuid}`, {
1341
1188
  method: 'PATCH',
1342
- headers: {
1343
- 'Content-Type': 'application/json',
1344
- "X-Phoenix-Auth": yield getToken(),
1345
- },
1189
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
1346
1190
  body: JSON.stringify(options)
1347
1191
  });
1348
1192
  if (!response.ok) {
@@ -1353,9 +1197,7 @@ const updateRow = (uuid, options) => __awaiter(void 0, void 0, void 0, function*
1353
1197
  const addSeat = (rowUuid) => __awaiter(void 0, void 0, void 0, function* () {
1354
1198
  const response = yield fetch(`${getApiServer()}/row/${rowUuid}/seat`, {
1355
1199
  method: 'PUT',
1356
- headers: {
1357
- "X-Phoenix-Auth": yield getToken(),
1358
- },
1200
+ headers: Object.assign({}, (yield getAuthHeaders())),
1359
1201
  });
1360
1202
  if (!response.ok) {
1361
1203
  throw new ApiGetError('Unable to add seat');
@@ -1372,10 +1214,7 @@ var index$c = /*#__PURE__*/Object.freeze({
1372
1214
  const getTicketSaleData = (include_free) => __awaiter(void 0, void 0, void 0, function* () {
1373
1215
  const response = yield fetch(`${getApiServer()}/statistics/ticket_sales${include_free ? "?include_free" : ""}`, {
1374
1216
  method: 'GET',
1375
- headers: {
1376
- "Content-Type": "application/json",
1377
- "X-Phoenix-Auth": yield getToken(),
1378
- }
1217
+ headers: Object.assign({ "Content-Type": "application/json" }, (yield getAuthHeaders()))
1379
1218
  });
1380
1219
  if (!response.ok) {
1381
1220
  let error = "";
@@ -1403,9 +1242,7 @@ var index$d = /*#__PURE__*/Object.freeze({
1403
1242
  const getActiveStoreSessions = () => __awaiter(void 0, void 0, void 0, function* () {
1404
1243
  const response = yield fetch(`${getApiServer()}/store_session/active`, {
1405
1244
  method: 'GET',
1406
- headers: {
1407
- "X-Phoenix-Auth": yield getToken(),
1408
- },
1245
+ headers: Object.assign({}, (yield getAuthHeaders())),
1409
1246
  });
1410
1247
  if (!response.ok) {
1411
1248
  throw new ApiGetError('Unable to get active store sessions');
@@ -1415,10 +1252,7 @@ const getActiveStoreSessions = () => __awaiter(void 0, void 0, void 0, function*
1415
1252
  const createStoreSession = (data) => __awaiter(void 0, void 0, void 0, function* () {
1416
1253
  const response = yield fetch(`${getApiServer()}/store_session`, {
1417
1254
  method: 'PUT',
1418
- headers: {
1419
- 'Content-Type': 'application/json',
1420
- "X-Phoenix-Auth": yield getToken(),
1421
- },
1255
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
1422
1256
  body: JSON.stringify(data)
1423
1257
  });
1424
1258
  if (response.status !== 200) {
@@ -1430,10 +1264,7 @@ const createStoreSession = (data) => __awaiter(void 0, void 0, void 0, function*
1430
1264
  const createPayment = (store_session, provider) => __awaiter(void 0, void 0, void 0, function* () {
1431
1265
  const response = yield fetch(`${getApiServer()}/payment`, {
1432
1266
  method: 'POST',
1433
- headers: {
1434
- 'Content-Type': 'application/json',
1435
- "X-Phoenix-Auth": yield getToken(),
1436
- },
1267
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
1437
1268
  body: JSON.stringify({
1438
1269
  store_session,
1439
1270
  provider,
@@ -1451,10 +1282,7 @@ const initiatePayment = (paymentUuid, fallbackUrl) => __awaiter(void 0, void 0,
1451
1282
  }
1452
1283
  const response = yield fetch(`${getApiServer()}/payment/${paymentUuid}/initiate`, {
1453
1284
  method: 'POST',
1454
- headers: {
1455
- 'Content-Type': 'application/json',
1456
- "X-Phoenix-Auth": yield getToken(),
1457
- },
1285
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
1458
1286
  body: JSON.stringify(body)
1459
1287
  });
1460
1288
  if (response.status !== 200) {
@@ -1473,10 +1301,7 @@ const initiateVisaPayment = (paymentUuid) => __awaiter(void 0, void 0, void 0, f
1473
1301
  const poll = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
1474
1302
  const response = yield fetch(`${getApiServer()}/payment/${uuid}`, {
1475
1303
  method: 'GET',
1476
- headers: {
1477
- 'Content-Type': 'application/json',
1478
- 'X-Phoenix-Auth': yield getToken(),
1479
- },
1304
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
1480
1305
  });
1481
1306
  if (response.status !== 200) {
1482
1307
  throw new ApiGetError("Unable to get payment data");
@@ -1491,7 +1316,7 @@ const getAgenda = () => __awaiter(void 0, void 0, void 0, function* () {
1491
1316
  'Content-Type': 'application/json',
1492
1317
  },
1493
1318
  });
1494
- if (response.status !== 200) {
1319
+ if (!response.ok) {
1495
1320
  throw new ApiGetError('Unable to get agenda');
1496
1321
  }
1497
1322
  return (yield response.json());
@@ -1503,36 +1328,89 @@ const getAgendaElement = (uuid) => __awaiter(void 0, void 0, void 0, function* (
1503
1328
  'Content-Type': 'application/json',
1504
1329
  },
1505
1330
  });
1506
- if (response.status !== 200) {
1507
- throw new ApiGetError('Unable to get agenda element');
1331
+ if (!response.ok) {
1332
+ throw new ApiGetError('Unable to get agenda element.');
1508
1333
  }
1509
1334
  return (yield response.json());
1510
1335
  });
1511
- const createAgendaEntry = (title, description, event_uuid, time) => __awaiter(void 0, void 0, void 0, function* () {
1336
+ const createAgendaEntry = (event_uuid, title, description, location, time, pinned) => __awaiter(void 0, void 0, void 0, function* () {
1512
1337
  const response = yield fetch(`${getApiServer()}/agenda`, {
1513
1338
  method: 'PUT',
1514
- headers: {
1515
- 'Content-Type': 'application/json',
1516
- 'X-Phoenix-Auth': yield getToken(),
1517
- },
1339
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
1518
1340
  body: JSON.stringify({
1341
+ event_uuid,
1519
1342
  title,
1520
1343
  description,
1344
+ location,
1345
+ time,
1346
+ pinned
1347
+ })
1348
+ });
1349
+ if (!response.ok) {
1350
+ let error = "";
1351
+ try {
1352
+ error = (yield response.json())['error'];
1353
+ }
1354
+ catch (e) {
1355
+ throw new ApiPutError('Unable to create a new agenda entry.');
1356
+ }
1357
+ throw new ApiPutError(error);
1358
+ }
1359
+ else {
1360
+ return yield response.json();
1361
+ }
1362
+ });
1363
+ 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* () {
1364
+ const response = yield fetch(`${getApiServer()}/agenda/${uuid}`, {
1365
+ method: 'PATCH',
1366
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
1367
+ body: JSON.stringify({
1368
+ uuid,
1521
1369
  event_uuid,
1522
- time
1370
+ title,
1371
+ description,
1372
+ time,
1373
+ location,
1374
+ deviating_time_unknown,
1375
+ deviating_location,
1376
+ deviating_information,
1377
+ pinned,
1378
+ cancelled,
1379
+ deviating_time
1523
1380
  })
1524
1381
  });
1525
- return response.status === 200;
1382
+ if (!response.ok) {
1383
+ let error = "";
1384
+ try {
1385
+ error = (yield response.json())['error'];
1386
+ }
1387
+ catch (e) {
1388
+ throw new ApiPutError('Unable to modify requested agenda entry.');
1389
+ }
1390
+ throw new ApiPutError(error);
1391
+ }
1392
+ else {
1393
+ return yield response.json();
1394
+ }
1526
1395
  });
1527
1396
  const deleteAgendaEntry = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
1528
1397
  const response = yield fetch(`${getApiServer()}/agenda/${uuid}`, {
1529
1398
  method: 'DELETE',
1530
- headers: {
1531
- 'Content-Type': 'application/json',
1532
- 'X-Phoenix-Auth': yield getToken()
1533
- }
1399
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders()))
1534
1400
  });
1535
- return response.status === 200;
1401
+ if (!response.ok) {
1402
+ let error = "";
1403
+ try {
1404
+ error = (yield response.json())['error'];
1405
+ }
1406
+ catch (e) {
1407
+ throw new ApiDeleteError('Unable to delete requested agenda entry.');
1408
+ }
1409
+ throw new ApiDeleteError(error);
1410
+ }
1411
+ else {
1412
+ return yield response.json();
1413
+ }
1536
1414
  });
1537
1415
 
1538
1416
  var index$e = /*#__PURE__*/Object.freeze({
@@ -1540,16 +1418,14 @@ var index$e = /*#__PURE__*/Object.freeze({
1540
1418
  getAgenda: getAgenda,
1541
1419
  getAgendaElement: getAgendaElement,
1542
1420
  createAgendaEntry: createAgendaEntry,
1421
+ modifyAgendaEntry: modifyAgendaEntry,
1543
1422
  deleteAgendaEntry: deleteAgendaEntry
1544
1423
  });
1545
1424
 
1546
1425
  const emailDryrun = (recipient_category, subject, body, argument) => __awaiter(void 0, void 0, void 0, function* () {
1547
1426
  const response = yield fetch(`${getApiServer()}/email/dryrun`, {
1548
1427
  method: 'POST',
1549
- headers: {
1550
- "Content-Type": "application/json",
1551
- "X-Phoenix-Auth": yield getToken(),
1552
- },
1428
+ headers: Object.assign({ "Content-Type": "application/json" }, (yield getAuthHeaders())),
1553
1429
  body: JSON.stringify({
1554
1430
  recipient_category,
1555
1431
  subject,
@@ -1572,10 +1448,7 @@ const emailDryrun = (recipient_category, subject, body, argument) => __awaiter(v
1572
1448
  const sendEmails = (recipient_category, subject, body, argument) => __awaiter(void 0, void 0, void 0, function* () {
1573
1449
  const response = yield fetch(`${getApiServer()}/email/send`, {
1574
1450
  method: 'POST',
1575
- headers: {
1576
- "Content-Type": "application/json",
1577
- "X-Phoenix-Auth": yield getToken(),
1578
- },
1451
+ headers: Object.assign({ "Content-Type": "application/json" }, (yield getAuthHeaders())),
1579
1452
  body: JSON.stringify({
1580
1453
  recipient_category,
1581
1454
  subject,
@@ -1605,10 +1478,7 @@ var index$f = /*#__PURE__*/Object.freeze({
1605
1478
  const createFriendRequest = (user_email) => __awaiter(void 0, void 0, void 0, function* () {
1606
1479
  const response = yield fetch(`${getApiServer()}/friend_request`, {
1607
1480
  method: 'POST',
1608
- headers: {
1609
- "Content-Type": "application/json",
1610
- "X-Phoenix-Auth": yield getToken(),
1611
- },
1481
+ headers: Object.assign({ "Content-Type": "application/json" }, (yield getAuthHeaders())),
1612
1482
  body: JSON.stringify({
1613
1483
  user_email: user_email
1614
1484
  })
@@ -1628,10 +1498,7 @@ const createFriendRequest = (user_email) => __awaiter(void 0, void 0, void 0, fu
1628
1498
  const viewFriendRequest = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
1629
1499
  const response = yield fetch(`${getApiServer()}/friend_request/${uuid}`, {
1630
1500
  method: 'GET',
1631
- headers: {
1632
- 'Content-Type': 'application/json',
1633
- "X-Phoenix-Auth": yield getToken()
1634
- },
1501
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (yield getAuthHeaders())),
1635
1502
  });
1636
1503
  if (response.status !== 200) {
1637
1504
  throw new ApiGetError("Unable to get the friend request");
@@ -1641,10 +1508,7 @@ const viewFriendRequest = (uuid) => __awaiter(void 0, void 0, void 0, function*
1641
1508
  const revokeFriendRequest = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
1642
1509
  const response = yield fetch(`${getApiServer()}/friend_request/${uuid}`, {
1643
1510
  method: 'DELETE',
1644
- headers: {
1645
- "Content-Type": "application/json",
1646
- "X-Phoenix-Auth": yield getToken(),
1647
- }
1511
+ headers: Object.assign({ "Content-Type": "application/json" }, (yield getAuthHeaders()))
1648
1512
  });
1649
1513
  if (!response.ok) {
1650
1514
  let error = "";
@@ -1661,10 +1525,7 @@ const revokeFriendRequest = (uuid) => __awaiter(void 0, void 0, void 0, function
1661
1525
  const acceptFriendRequest = (uuid) => __awaiter(void 0, void 0, void 0, function* () {
1662
1526
  const response = yield fetch(`${getApiServer()}/friend_request/${uuid}/accept`, {
1663
1527
  method: 'POST',
1664
- headers: {
1665
- "Content-Type": "application/json",
1666
- "X-Phoenix-Auth": yield getToken(),
1667
- }
1528
+ headers: Object.assign({ "Content-Type": "application/json" }, (yield getAuthHeaders()))
1668
1529
  });
1669
1530
  if (!response.ok) {
1670
1531
  let error = "";