celitech-sdk 1.1.77 → 1.1.85

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. package/.manifest.json +24 -13
  2. package/README.md +11 -2
  3. package/dist/http/hooks/custom-hook.d.ts +0 -1
  4. package/dist/http/hooks/custom-hook.d.ts.map +1 -1
  5. package/dist/http/hooks/custom-hook.js +0 -52
  6. package/dist/http/hooks/custom-hook.js.map +1 -1
  7. package/dist/index.d.ts +4 -0
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +28 -1
  10. package/dist/index.js.map +1 -1
  11. package/dist/services/base-service.d.ts +1 -1
  12. package/dist/services/base-service.d.ts.map +1 -1
  13. package/dist/services/base-service.js +2 -2
  14. package/dist/services/base-service.js.map +1 -1
  15. package/dist/services/destinations/destinations.d.ts +1 -2
  16. package/dist/services/destinations/destinations.d.ts.map +1 -1
  17. package/dist/services/destinations/destinations.js +3 -3
  18. package/dist/services/destinations/destinations.js.map +1 -1
  19. package/dist/services/destinations/index.d.ts +2 -1
  20. package/dist/services/destinations/index.d.ts.map +1 -1
  21. package/dist/services/destinations/index.js +4 -1
  22. package/dist/services/destinations/index.js.map +1 -1
  23. package/dist/services/destinations/models/index.d.ts +2 -2
  24. package/dist/services/destinations/models/index.d.ts.map +1 -1
  25. package/dist/services/destinations/models/index.js +0 -16
  26. package/dist/services/destinations/models/index.js.map +1 -1
  27. package/dist/services/e-sim/e-sim.d.ts +1 -2
  28. package/dist/services/e-sim/e-sim.d.ts.map +1 -1
  29. package/dist/services/e-sim/e-sim.js +9 -9
  30. package/dist/services/e-sim/e-sim.js.map +1 -1
  31. package/dist/services/e-sim/index.d.ts +2 -1
  32. package/dist/services/e-sim/index.d.ts.map +1 -1
  33. package/dist/services/e-sim/index.js +4 -1
  34. package/dist/services/e-sim/index.js.map +1 -1
  35. package/dist/services/e-sim/models/index.d.ts +9 -9
  36. package/dist/services/e-sim/models/index.d.ts.map +1 -1
  37. package/dist/services/e-sim/models/index.js +0 -23
  38. package/dist/services/e-sim/models/index.js.map +1 -1
  39. package/dist/services/packages/index.d.ts +2 -1
  40. package/dist/services/packages/index.d.ts.map +1 -1
  41. package/dist/services/packages/index.js +4 -1
  42. package/dist/services/packages/index.js.map +1 -1
  43. package/dist/services/packages/models/index.d.ts +2 -2
  44. package/dist/services/packages/models/index.d.ts.map +1 -1
  45. package/dist/services/packages/models/index.js +0 -16
  46. package/dist/services/packages/models/index.js.map +1 -1
  47. package/dist/services/packages/packages.d.ts +1 -2
  48. package/dist/services/packages/packages.d.ts.map +1 -1
  49. package/dist/services/packages/packages.js +3 -3
  50. package/dist/services/packages/packages.js.map +1 -1
  51. package/dist/services/purchases/index.d.ts +2 -1
  52. package/dist/services/purchases/index.d.ts.map +1 -1
  53. package/dist/services/purchases/index.js +4 -1
  54. package/dist/services/purchases/index.js.map +1 -1
  55. package/dist/services/purchases/models/index.d.ts +15 -15
  56. package/dist/services/purchases/models/index.d.ts.map +1 -1
  57. package/dist/services/purchases/models/index.js +0 -29
  58. package/dist/services/purchases/models/index.js.map +1 -1
  59. package/dist/services/purchases/purchases.d.ts +1 -2
  60. package/dist/services/purchases/purchases.d.ts.map +1 -1
  61. package/dist/services/purchases/purchases.js +11 -11
  62. package/dist/services/purchases/purchases.js.map +1 -1
  63. package/documentation/services/PurchasesService.md +6 -3
  64. package/documentation/snippets/destinations-get.md +14 -0
  65. package/documentation/snippets/esim-get.md +16 -0
  66. package/documentation/snippets/esim-{iccid}-device-get.md +14 -0
  67. package/documentation/snippets/esim-{iccid}-history-get.md +14 -0
  68. package/documentation/snippets/esim-{iccid}-mac-get.md +14 -0
  69. package/documentation/snippets/packages-get.md +14 -0
  70. package/documentation/snippets/purchases-edit-post.md +23 -0
  71. package/documentation/snippets/purchases-get.md +14 -0
  72. package/documentation/snippets/purchases-post.md +27 -0
  73. package/documentation/snippets/purchases-topup-post.md +26 -0
  74. package/documentation/snippets/purchases-{purchaseId}-consumption-get.md +14 -0
  75. package/examples/package.json +1 -1
  76. package/package.json +1 -1
  77. package/src/http/hooks/custom-hook.ts +0 -68
  78. package/src/index.ts +5 -0
  79. package/src/services/base-service.ts +1 -1
  80. package/src/services/destinations/destinations.ts +1 -2
  81. package/src/services/destinations/index.ts +2 -1
  82. package/src/services/destinations/models/index.ts +2 -2
  83. package/src/services/e-sim/e-sim.ts +1 -2
  84. package/src/services/e-sim/index.ts +2 -1
  85. package/src/services/e-sim/models/index.ts +9 -9
  86. package/src/services/packages/index.ts +2 -1
  87. package/src/services/packages/models/index.ts +2 -2
  88. package/src/services/packages/packages.ts +1 -2
  89. package/src/services/purchases/index.ts +2 -1
  90. package/src/services/purchases/models/index.ts +15 -15
  91. package/src/services/purchases/purchases.ts +1 -2
  92. package/dist/http/index.d.ts +0 -5
  93. package/dist/http/index.d.ts.map +0 -1
  94. package/dist/http/index.js +0 -21
  95. package/dist/http/index.js.map +0 -1
  96. package/src/http/index.ts +0 -4
@@ -2,76 +2,8 @@ import { HttpMetadata } from '../types';
2
2
  import { Hook } from './hook';
3
3
  import { HttpRequest, HttpResponse, HttpError } from './hook';
4
4
 
5
- let CURRENT_TOKEN = '';
6
- let CURRENT_EXPIRY = -1;
7
-
8
5
  export class CustomHook implements Hook {
9
- async getToken(clientId: string, clientSecret: string): Promise<any> {
10
- const tokenUrl = 'https://auth.celitech.net/oauth2/token';
11
-
12
- const headers = {
13
- 'Content-Type': 'application/x-www-form-urlencoded',
14
- };
15
-
16
- const body = {
17
- client_id: clientId,
18
- client_secret: clientSecret,
19
- grant_type: 'client_credentials',
20
- };
21
-
22
- const response = await fetch(tokenUrl, {
23
- method: 'POST',
24
- headers: headers,
25
- body: new URLSearchParams(body),
26
- });
27
-
28
- return response.json();
29
- }
30
-
31
6
  public async beforeRequest(request: HttpRequest, params: Map<string, string>): Promise<HttpRequest> {
32
- console.log('request', request);
33
- console.log('params', params);
34
-
35
- const clientId = params.get('clientId') || '';
36
- const clientSecret = params.get('clientSecret') || '';
37
-
38
- console.log('clientId', clientId);
39
- console.log('clientSecret', clientSecret);
40
-
41
- if (!clientId || !clientSecret) {
42
- throw new Error('Missing clientId and/or clientSecret constructor parameters');
43
- }
44
-
45
- if (!CURRENT_TOKEN || CURRENT_EXPIRY < Date.now()) {
46
- // Fetch a fresh Oauth token
47
- // Retrieve the new access token and expiry, and set them to the global variables
48
- const tokenResponse = await this.getToken(clientId, clientSecret);
49
-
50
- console.log('tokenResponse', tokenResponse);
51
-
52
- if (tokenResponse.error) {
53
- throw new Error(tokenResponse.error);
54
- }
55
-
56
- const { expires_in, access_token } = tokenResponse;
57
-
58
- if (!expires_in || !access_token) {
59
- throw new Error('There is an issue with getting the oauth token');
60
- }
61
- CURRENT_EXPIRY = Date.now() + expires_in * 1000;
62
- CURRENT_TOKEN = access_token;
63
- }
64
-
65
- // Set the Bearer token in the request header
66
- const authorization = `Bearer ${CURRENT_TOKEN}`;
67
-
68
- console.log('authorization', authorization);
69
-
70
- if (!request.headers) {
71
- request.headers = new Map();
72
- }
73
- request.headers.set('Authorization', authorization);
74
-
75
7
  return request;
76
8
  }
77
9
 
package/src/index.ts CHANGED
@@ -5,6 +5,11 @@ import { PackagesService } from './services/packages';
5
5
  import { PurchasesService } from './services/purchases';
6
6
  import { ESimService } from './services/e-sim';
7
7
 
8
+ export * as Destinations from './services/destinations';
9
+ export * as Packages from './services/packages';
10
+ export * as Purchases from './services/purchases';
11
+ export * as ESim from './services/e-sim';
12
+
8
13
  export class Celitech {
9
14
  public readonly destinations: DestinationsService;
10
15
 
@@ -1,5 +1,5 @@
1
1
  import { Environment } from '../http/environment';
2
- import { HttpClient } from '../http';
2
+ import { HttpClient } from '../http/client';
3
3
  import { SdkConfig } from '../http/types';
4
4
 
5
5
  export class BaseService {
@@ -1,7 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { BaseService } from '../base-service';
3
- import { ContentType, HttpResponse } from '../../http';
4
- import { RequestConfig } from '../../http/types';
3
+ import { ContentType, HttpResponse, RequestConfig } from '../../http/types';
5
4
  import { RequestBuilder } from '../../http/transport/request-builder';
6
5
  import { ListDestinationsOkResponse, listDestinationsOkResponseResponse } from './models/list-destinations-ok-response';
7
6
 
@@ -1 +1,2 @@
1
- export * from './destinations';
1
+ export { DestinationsService } from './destinations';
2
+ export * from './models';
@@ -1,2 +1,2 @@
1
- export * from './list-destinations-ok-response';
2
- export * from './destinations';
1
+ export type { ListDestinationsOkResponse } from './list-destinations-ok-response';
2
+ export type { Destinations } from './destinations';
@@ -1,7 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { BaseService } from '../base-service';
3
- import { ContentType, HttpResponse } from '../../http';
4
- import { RequestConfig } from '../../http/types';
3
+ import { ContentType, HttpResponse, RequestConfig } from '../../http/types';
5
4
  import { RequestBuilder } from '../../http/transport/request-builder';
6
5
  import { GetEsimOkResponse, getEsimOkResponseResponse } from './models/get-esim-ok-response';
7
6
  import { GetEsimParams } from './request-params';
@@ -1 +1,2 @@
1
- export * from './e-sim';
1
+ export { ESimService } from './e-sim';
2
+ export * from './models';
@@ -1,9 +1,9 @@
1
- export * from './get-esim-ok-response';
2
- export * from './get-esim-device-ok-response';
3
- export * from './get-esim-history-ok-response';
4
- export * from './get-esim-mac-ok-response';
5
- export * from './get-esim-ok-response-esim';
6
- export * from './device';
7
- export * from './get-esim-history-ok-response-esim';
8
- export * from './history';
9
- export * from './get-esim-mac-ok-response-esim';
1
+ export type { GetEsimOkResponse } from './get-esim-ok-response';
2
+ export type { GetEsimDeviceOkResponse } from './get-esim-device-ok-response';
3
+ export type { GetEsimHistoryOkResponse } from './get-esim-history-ok-response';
4
+ export type { GetEsimMacOkResponse } from './get-esim-mac-ok-response';
5
+ export type { GetEsimOkResponseEsim } from './get-esim-ok-response-esim';
6
+ export type { Device } from './device';
7
+ export type { GetEsimHistoryOkResponseEsim } from './get-esim-history-ok-response-esim';
8
+ export type { History } from './history';
9
+ export type { GetEsimMacOkResponseEsim } from './get-esim-mac-ok-response-esim';
@@ -1 +1,2 @@
1
- export * from './packages';
1
+ export { PackagesService } from './packages';
2
+ export * from './models';
@@ -1,2 +1,2 @@
1
- export * from './list-packages-ok-response';
2
- export * from './packages';
1
+ export type { ListPackagesOkResponse } from './list-packages-ok-response';
2
+ export type { Packages } from './packages';
@@ -1,7 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { BaseService } from '../base-service';
3
- import { ContentType, HttpResponse } from '../../http';
4
- import { RequestConfig } from '../../http/types';
3
+ import { ContentType, HttpResponse, RequestConfig } from '../../http/types';
5
4
  import { RequestBuilder } from '../../http/transport/request-builder';
6
5
  import { ListPackagesOkResponse, listPackagesOkResponseResponse } from './models/list-packages-ok-response';
7
6
  import { ListPackagesParams } from './request-params';
@@ -1 +1,2 @@
1
- export * from './purchases';
1
+ export { PurchasesService } from './purchases';
2
+ export * from './models';
@@ -1,15 +1,15 @@
1
- export * from './list-purchases-ok-response';
2
- export * from './create-purchase-request';
3
- export * from './create-purchase-ok-response';
4
- export * from './top-up-esim-request';
5
- export * from './top-up-esim-ok-response';
6
- export * from './edit-purchase-request';
7
- export * from './edit-purchase-ok-response';
8
- export * from './get-purchase-consumption-ok-response';
9
- export * from './purchases';
10
- export * from './package_';
11
- export * from './purchases-esim';
12
- export * from './create-purchase-ok-response-purchase';
13
- export * from './create-purchase-ok-response-profile';
14
- export * from './top-up-esim-ok-response-purchase';
15
- export * from './top-up-esim-ok-response-profile';
1
+ export type { ListPurchasesOkResponse } from './list-purchases-ok-response';
2
+ export type { CreatePurchaseRequest } from './create-purchase-request';
3
+ export type { CreatePurchaseOkResponse } from './create-purchase-ok-response';
4
+ export type { TopUpEsimRequest } from './top-up-esim-request';
5
+ export type { TopUpEsimOkResponse } from './top-up-esim-ok-response';
6
+ export type { EditPurchaseRequest } from './edit-purchase-request';
7
+ export type { EditPurchaseOkResponse } from './edit-purchase-ok-response';
8
+ export type { GetPurchaseConsumptionOkResponse } from './get-purchase-consumption-ok-response';
9
+ export type { Purchases } from './purchases';
10
+ export type { Package_ } from './package_';
11
+ export type { PurchasesEsim } from './purchases-esim';
12
+ export type { CreatePurchaseOkResponsePurchase } from './create-purchase-ok-response-purchase';
13
+ export type { CreatePurchaseOkResponseProfile } from './create-purchase-ok-response-profile';
14
+ export type { TopUpEsimOkResponsePurchase } from './top-up-esim-ok-response-purchase';
15
+ export type { TopUpEsimOkResponseProfile } from './top-up-esim-ok-response-profile';
@@ -1,7 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { BaseService } from '../base-service';
3
- import { ContentType, HttpResponse } from '../../http';
4
- import { RequestConfig } from '../../http/types';
3
+ import { ContentType, HttpResponse, RequestConfig } from '../../http/types';
5
4
  import { RequestBuilder } from '../../http/transport/request-builder';
6
5
  import { ListPurchasesOkResponse, listPurchasesOkResponseResponse } from './models/list-purchases-ok-response';
7
6
  import { ListPurchasesParams } from './request-params';
@@ -1,5 +0,0 @@
1
- export * from './client';
2
- export * from './serializer';
3
- export * from './types';
4
- export * from './error';
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/http/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
@@ -1,21 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./client"), exports);
18
- __exportStar(require("./serializer"), exports);
19
- __exportStar(require("./types"), exports);
20
- __exportStar(require("./error"), exports);
21
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/http/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,+CAA6B;AAC7B,0CAAwB;AACxB,0CAAwB"}
package/src/http/index.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from './client';
2
- export * from './serializer';
3
- export * from './types';
4
- export * from './error';