skapi-js 1.0.53-beta.8 → 1.0.53

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.
@@ -19,22 +19,27 @@ function map_ticket_obj(t) {
19
19
  'plch': 'placeholder',
20
20
  'hash': 'hash'
21
21
  };
22
+ let new_obj = {};
22
23
  for (let k in t) {
23
- if (mapper[k]) {
24
- t[mapper[k]] = t[k];
25
- if (k === 'tkid') {
26
- let tkid = t[k].split('#');
27
- if (tkid.length === 1) {
28
- continue;
29
- }
30
- t['ticket_id'] = tkid[1];
31
- t['consume_id'] = tkid[2];
32
- t['user_id'] = tkid[3];
33
- t['timestamp'] = base_decode(tkid[2].slice(-4));
34
- }
35
- delete t[k];
24
+ if (k === 'tkid') {
25
+ let tkid = t[k].split('#');
26
+ if (tkid.length === 1) {
27
+ new_obj['ticket_id'] = tkid[0];
28
+ continue;
29
+ }
30
+ new_obj['ticket_id'] = tkid[1];
31
+ new_obj['consume_id'] = tkid[2];
32
+ new_obj['user_id'] = tkid[3];
33
+ new_obj['timestamp'] = base_decode(tkid[2].slice(-4));
34
+ }
35
+ else if (mapper[k]) {
36
+ new_obj[mapper[k]] = t[k];
37
+ }
38
+ else {
39
+ new_obj[k] = t[k];
36
40
  }
37
41
  }
42
+ return new_obj;
38
43
  }
39
44
  export async function consumeTicket(params, placeholder) {
40
45
  if (!params.ticket_id) {
@@ -42,8 +47,7 @@ export async function consumeTicket(params, placeholder) {
42
47
  }
43
48
  await this.__connection;
44
49
  let resp = await request.bind(this)('ticket', Object.assign({ exec: 'consume' }, params, { placeholder }), { auth: true });
45
- map_ticket_obj(resp);
46
- return resp;
50
+ return map_ticket_obj(resp);
47
51
  }
48
52
  export async function releaseTicket(params) {
49
53
  if (!params.ticket_id) {
@@ -55,9 +59,7 @@ export async function releaseTicket(params) {
55
59
  export async function getTickets(params, fetchOptions) {
56
60
  await this.__connection;
57
61
  let tickets = await request.bind(this)('ticket', Object.assign({ exec: 'list' }, params || {}), { auth: true, fetchOptions });
58
- for (let t of tickets.list) {
59
- map_ticket_obj(t);
60
- }
62
+ tickets.list = tickets.list.map(map_ticket_obj);
61
63
  return tickets;
62
64
  }
63
65
  export async function getConsumedTickets(params, fetchOptions) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skapi-js",
3
- "version": "1.0.53-beta.8",
3
+ "version": "1.0.53",
4
4
  "description": "Skapi: Backend API Library for HTML frontend.",
5
5
  "main": "./dist/skapi.module.js",
6
6
  "types": "./js/Main.d.ts",