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.
- package/.manifest.json +24 -13
- package/README.md +11 -2
- package/dist/http/hooks/custom-hook.d.ts +0 -1
- package/dist/http/hooks/custom-hook.d.ts.map +1 -1
- package/dist/http/hooks/custom-hook.js +0 -52
- package/dist/http/hooks/custom-hook.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -1
- package/dist/index.js.map +1 -1
- package/dist/services/base-service.d.ts +1 -1
- package/dist/services/base-service.d.ts.map +1 -1
- package/dist/services/base-service.js +2 -2
- package/dist/services/base-service.js.map +1 -1
- package/dist/services/destinations/destinations.d.ts +1 -2
- package/dist/services/destinations/destinations.d.ts.map +1 -1
- package/dist/services/destinations/destinations.js +3 -3
- package/dist/services/destinations/destinations.js.map +1 -1
- package/dist/services/destinations/index.d.ts +2 -1
- package/dist/services/destinations/index.d.ts.map +1 -1
- package/dist/services/destinations/index.js +4 -1
- package/dist/services/destinations/index.js.map +1 -1
- package/dist/services/destinations/models/index.d.ts +2 -2
- package/dist/services/destinations/models/index.d.ts.map +1 -1
- package/dist/services/destinations/models/index.js +0 -16
- package/dist/services/destinations/models/index.js.map +1 -1
- package/dist/services/e-sim/e-sim.d.ts +1 -2
- package/dist/services/e-sim/e-sim.d.ts.map +1 -1
- package/dist/services/e-sim/e-sim.js +9 -9
- package/dist/services/e-sim/e-sim.js.map +1 -1
- package/dist/services/e-sim/index.d.ts +2 -1
- package/dist/services/e-sim/index.d.ts.map +1 -1
- package/dist/services/e-sim/index.js +4 -1
- package/dist/services/e-sim/index.js.map +1 -1
- package/dist/services/e-sim/models/index.d.ts +9 -9
- package/dist/services/e-sim/models/index.d.ts.map +1 -1
- package/dist/services/e-sim/models/index.js +0 -23
- package/dist/services/e-sim/models/index.js.map +1 -1
- package/dist/services/packages/index.d.ts +2 -1
- package/dist/services/packages/index.d.ts.map +1 -1
- package/dist/services/packages/index.js +4 -1
- package/dist/services/packages/index.js.map +1 -1
- package/dist/services/packages/models/index.d.ts +2 -2
- package/dist/services/packages/models/index.d.ts.map +1 -1
- package/dist/services/packages/models/index.js +0 -16
- package/dist/services/packages/models/index.js.map +1 -1
- package/dist/services/packages/packages.d.ts +1 -2
- package/dist/services/packages/packages.d.ts.map +1 -1
- package/dist/services/packages/packages.js +3 -3
- package/dist/services/packages/packages.js.map +1 -1
- package/dist/services/purchases/index.d.ts +2 -1
- package/dist/services/purchases/index.d.ts.map +1 -1
- package/dist/services/purchases/index.js +4 -1
- package/dist/services/purchases/index.js.map +1 -1
- package/dist/services/purchases/models/index.d.ts +15 -15
- package/dist/services/purchases/models/index.d.ts.map +1 -1
- package/dist/services/purchases/models/index.js +0 -29
- package/dist/services/purchases/models/index.js.map +1 -1
- package/dist/services/purchases/purchases.d.ts +1 -2
- package/dist/services/purchases/purchases.d.ts.map +1 -1
- package/dist/services/purchases/purchases.js +11 -11
- package/dist/services/purchases/purchases.js.map +1 -1
- package/documentation/services/PurchasesService.md +6 -3
- package/documentation/snippets/destinations-get.md +14 -0
- package/documentation/snippets/esim-get.md +16 -0
- package/documentation/snippets/esim-{iccid}-device-get.md +14 -0
- package/documentation/snippets/esim-{iccid}-history-get.md +14 -0
- package/documentation/snippets/esim-{iccid}-mac-get.md +14 -0
- package/documentation/snippets/packages-get.md +14 -0
- package/documentation/snippets/purchases-edit-post.md +23 -0
- package/documentation/snippets/purchases-get.md +14 -0
- package/documentation/snippets/purchases-post.md +27 -0
- package/documentation/snippets/purchases-topup-post.md +26 -0
- package/documentation/snippets/purchases-{purchaseId}-consumption-get.md +14 -0
- package/examples/package.json +1 -1
- package/package.json +1 -1
- package/src/http/hooks/custom-hook.ts +0 -68
- package/src/index.ts +5 -0
- package/src/services/base-service.ts +1 -1
- package/src/services/destinations/destinations.ts +1 -2
- package/src/services/destinations/index.ts +2 -1
- package/src/services/destinations/models/index.ts +2 -2
- package/src/services/e-sim/e-sim.ts +1 -2
- package/src/services/e-sim/index.ts +2 -1
- package/src/services/e-sim/models/index.ts +9 -9
- package/src/services/packages/index.ts +2 -1
- package/src/services/packages/models/index.ts +2 -2
- package/src/services/packages/packages.ts +1 -2
- package/src/services/purchases/index.ts +2 -1
- package/src/services/purchases/models/index.ts +15 -15
- package/src/services/purchases/purchases.ts +1 -2
- package/dist/http/index.d.ts +0 -5
- package/dist/http/index.d.ts.map +0 -1
- package/dist/http/index.js +0 -21
- package/dist/http/index.js.map +0 -1
- 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,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
|
1
|
+
export { DestinationsService } from './destinations';
|
2
|
+
export * from './models';
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export
|
2
|
-
export
|
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
|
1
|
+
export { ESimService } from './e-sim';
|
2
|
+
export * from './models';
|
@@ -1,9 +1,9 @@
|
|
1
|
-
export
|
2
|
-
export
|
3
|
-
export
|
4
|
-
export
|
5
|
-
export
|
6
|
-
export
|
7
|
-
export
|
8
|
-
export
|
9
|
-
export
|
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
|
1
|
+
export { PackagesService } from './packages';
|
2
|
+
export * from './models';
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export
|
2
|
-
export
|
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
|
1
|
+
export { PurchasesService } from './purchases';
|
2
|
+
export * from './models';
|
@@ -1,15 +1,15 @@
|
|
1
|
-
export
|
2
|
-
export
|
3
|
-
export
|
4
|
-
export
|
5
|
-
export
|
6
|
-
export
|
7
|
-
export
|
8
|
-
export
|
9
|
-
export
|
10
|
-
export
|
11
|
-
export
|
12
|
-
export
|
13
|
-
export
|
14
|
-
export
|
15
|
-
export
|
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';
|
package/dist/http/index.d.ts
DELETED
package/dist/http/index.d.ts.map
DELETED
@@ -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"}
|
package/dist/http/index.js
DELETED
@@ -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
|
package/dist/http/index.js.map
DELETED
@@ -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