celitech-sdk 1.1.84 → 1.1.85
Sign up to get free protection for your applications and to get access to all the features.
- package/.manifest.json +12 -12
- package/README.md +2 -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/services/destinations/index.d.ts +1 -0
- package/dist/services/destinations/index.d.ts.map +1 -1
- package/dist/services/destinations/index.js +15 -0
- package/dist/services/destinations/index.js.map +1 -1
- package/dist/services/e-sim/index.d.ts +1 -0
- package/dist/services/e-sim/index.d.ts.map +1 -1
- package/dist/services/e-sim/index.js +15 -0
- package/dist/services/e-sim/index.js.map +1 -1
- package/dist/services/packages/index.d.ts +1 -0
- package/dist/services/packages/index.d.ts.map +1 -1
- package/dist/services/packages/index.js +15 -0
- package/dist/services/packages/index.js.map +1 -1
- package/dist/services/purchases/index.d.ts +1 -0
- package/dist/services/purchases/index.d.ts.map +1 -1
- package/dist/services/purchases/index.js +15 -0
- package/dist/services/purchases/index.js.map +1 -1
- package/documentation/services/PurchasesService.md +6 -3
- package/documentation/snippets/purchases-edit-post.md +2 -1
- package/documentation/snippets/purchases-post.md +2 -1
- package/documentation/snippets/purchases-topup-post.md +2 -1
- package/examples/package.json +1 -1
- package/package.json +1 -1
- package/src/http/hooks/custom-hook.ts +0 -68
- package/src/services/destinations/index.ts +1 -0
- package/src/services/e-sim/index.ts +1 -0
- package/src/services/packages/index.ts +1 -0
- package/src/services/purchases/index.ts +1 -0
package/.manifest.json
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
{
|
2
|
-
"liblabVersion": "2.1.
|
3
|
-
"date": "2024-08-
|
2
|
+
"liblabVersion": "2.1.25",
|
3
|
+
"date": "2024-08-07T12:57:36.404Z",
|
4
4
|
"config": {
|
5
|
-
"apiId":
|
5
|
+
"apiId": 1005,
|
6
6
|
"sdkName": "Celitech",
|
7
|
-
"sdkVersion": "1.1.
|
7
|
+
"sdkVersion": "1.1.85",
|
8
8
|
"liblabVersion": "2",
|
9
9
|
"deliveryMethods": ["zip"],
|
10
10
|
"languages": ["typescript"],
|
11
|
-
"apiVersion": "1.1.
|
11
|
+
"apiVersion": "1.1.85",
|
12
12
|
"specFilePath": "swagger.yaml",
|
13
13
|
"docs": ["api", "snippets"],
|
14
14
|
"languageOptions": {
|
@@ -27,7 +27,7 @@
|
|
27
27
|
"pypiPackageName": "celitech-sdk",
|
28
28
|
"githubRepoName": "CelitechSDKPython",
|
29
29
|
"liblabVersion": "2",
|
30
|
-
"sdkVersion": "1.1.
|
30
|
+
"sdkVersion": "1.1.85"
|
31
31
|
},
|
32
32
|
"php": {
|
33
33
|
"packageName": "celitech-sdk/sdk",
|
@@ -43,7 +43,7 @@
|
|
43
43
|
],
|
44
44
|
"githubRepoName": "CelitechSDKPHP",
|
45
45
|
"liblabVersion": "2",
|
46
|
-
"sdkVersion": "1.1.
|
46
|
+
"sdkVersion": "1.1.85"
|
47
47
|
},
|
48
48
|
"typescript": {
|
49
49
|
"bundle": false,
|
@@ -62,7 +62,7 @@
|
|
62
62
|
],
|
63
63
|
"githubRepoName": "CelitechSDKTypeScript",
|
64
64
|
"liblabVersion": "2",
|
65
|
-
"sdkVersion": "1.1.
|
65
|
+
"sdkVersion": "1.1.85"
|
66
66
|
}
|
67
67
|
},
|
68
68
|
"publishing": {
|
@@ -102,16 +102,16 @@
|
|
102
102
|
},
|
103
103
|
"multiTenant": true,
|
104
104
|
"hooksLocation": {
|
105
|
-
"bucketKey": "
|
105
|
+
"bucketKey": "6573/hooks.zip",
|
106
106
|
"bucketName": "prod-liblab-api-stack-hooks"
|
107
107
|
},
|
108
|
-
"specUrl": "https://prod-liblab-api-stack-specs.s3.us-east-1.amazonaws.com/
|
108
|
+
"specUrl": "https://prod-liblab-api-stack-specs.s3.us-east-1.amazonaws.com/1005/open-api-spec.yaml?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA5P3QKKDKGVNIJ2H7%2F20240807%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240807T125731Z&X-Amz-Expires=43200&X-Amz-Signature=c7bbb5388e84c9ea3a476c648d7dbfdcbb60e1868482ba20c2604ff2d67e2c9a&X-Amz-SignedHeaders=host&x-id=GetObject",
|
109
109
|
"includeWatermark": false,
|
110
110
|
"language": "typescript",
|
111
111
|
"deliveryMethod": "zip",
|
112
112
|
"hooks": {
|
113
|
-
"enabled":
|
114
|
-
"sourceDir": "
|
113
|
+
"enabled": false,
|
114
|
+
"sourceDir": ""
|
115
115
|
},
|
116
116
|
"bundle": false,
|
117
117
|
"exportClassDefault": false,
|
package/README.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
# Celitech TypeScript SDK 1.1.
|
1
|
+
# Celitech TypeScript SDK 1.1.85
|
2
2
|
|
3
3
|
Welcome to the Celitech SDK documentation. This guide will help you get started with integrating and using the Celitech SDK in your project.
|
4
4
|
|
5
5
|
## Versions
|
6
6
|
|
7
7
|
- API version: `1.1.0`
|
8
|
-
- SDK version: `1.1.
|
8
|
+
- SDK version: `1.1.85`
|
9
9
|
|
10
10
|
## About the API
|
11
11
|
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import { Hook } from './hook';
|
2
2
|
import { HttpRequest, HttpResponse, HttpError } from './hook';
|
3
3
|
export declare class CustomHook implements Hook {
|
4
|
-
getToken(clientId: string, clientSecret: string): Promise<any>;
|
5
4
|
beforeRequest(request: HttpRequest, params: Map<string, string>): Promise<HttpRequest>;
|
6
5
|
afterResponse(request: HttpRequest, response: HttpResponse<any>, params: Map<string, string>): Promise<HttpResponse<any>>;
|
7
6
|
onError(request: HttpRequest, response: HttpResponse<any>, params: Map<string, string>): Promise<HttpError>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"custom-hook.d.ts","sourceRoot":"","sources":["../../../src/http/hooks/custom-hook.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;
|
1
|
+
{"version":3,"file":"custom-hook.d.ts","sourceRoot":"","sources":["../../../src/http/hooks/custom-hook.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAE9D,qBAAa,UAAW,YAAW,IAAI;IACxB,aAAa,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC;IAItF,aAAa,CACxB,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,YAAY,CAAC,GAAG,CAAC,EAC3B,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAC1B,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IAIhB,OAAO,CAClB,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,YAAY,CAAC,GAAG,CAAC,EAC3B,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAC1B,OAAO,CAAC,SAAS,CAAC;CAGtB"}
|
@@ -10,61 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
10
10
|
};
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
12
|
exports.CustomHook = void 0;
|
13
|
-
let CURRENT_TOKEN = '';
|
14
|
-
let CURRENT_EXPIRY = -1;
|
15
13
|
class CustomHook {
|
16
|
-
getToken(clientId, clientSecret) {
|
17
|
-
return __awaiter(this, void 0, void 0, function* () {
|
18
|
-
const tokenUrl = 'https://auth.celitech.net/oauth2/token';
|
19
|
-
const headers = {
|
20
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
21
|
-
};
|
22
|
-
const body = {
|
23
|
-
client_id: clientId,
|
24
|
-
client_secret: clientSecret,
|
25
|
-
grant_type: 'client_credentials',
|
26
|
-
};
|
27
|
-
const response = yield fetch(tokenUrl, {
|
28
|
-
method: 'POST',
|
29
|
-
headers: headers,
|
30
|
-
body: new URLSearchParams(body),
|
31
|
-
});
|
32
|
-
return response.json();
|
33
|
-
});
|
34
|
-
}
|
35
14
|
beforeRequest(request, params) {
|
36
15
|
return __awaiter(this, void 0, void 0, function* () {
|
37
|
-
console.log('request', request);
|
38
|
-
console.log('params', params);
|
39
|
-
const clientId = params.get('clientId') || '';
|
40
|
-
const clientSecret = params.get('clientSecret') || '';
|
41
|
-
console.log('clientId', clientId);
|
42
|
-
console.log('clientSecret', clientSecret);
|
43
|
-
if (!clientId || !clientSecret) {
|
44
|
-
throw new Error('Missing clientId and/or clientSecret constructor parameters');
|
45
|
-
}
|
46
|
-
if (!CURRENT_TOKEN || CURRENT_EXPIRY < Date.now()) {
|
47
|
-
// Fetch a fresh Oauth token
|
48
|
-
// Retrieve the new access token and expiry, and set them to the global variables
|
49
|
-
const tokenResponse = yield this.getToken(clientId, clientSecret);
|
50
|
-
console.log('tokenResponse', tokenResponse);
|
51
|
-
if (tokenResponse.error) {
|
52
|
-
throw new Error(tokenResponse.error);
|
53
|
-
}
|
54
|
-
const { expires_in, access_token } = tokenResponse;
|
55
|
-
if (!expires_in || !access_token) {
|
56
|
-
throw new Error('There is an issue with getting the oauth token');
|
57
|
-
}
|
58
|
-
CURRENT_EXPIRY = Date.now() + expires_in * 1000;
|
59
|
-
CURRENT_TOKEN = access_token;
|
60
|
-
}
|
61
|
-
// Set the Bearer token in the request header
|
62
|
-
const authorization = `Bearer ${CURRENT_TOKEN}`;
|
63
|
-
console.log('authorization', authorization);
|
64
|
-
if (!request.headers) {
|
65
|
-
request.headers = new Map();
|
66
|
-
}
|
67
|
-
request.headers.set('Authorization', authorization);
|
68
16
|
return request;
|
69
17
|
});
|
70
18
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"custom-hook.js","sourceRoot":"","sources":["../../../src/http/hooks/custom-hook.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA,
|
1
|
+
{"version":3,"file":"custom-hook.js","sourceRoot":"","sources":["../../../src/http/hooks/custom-hook.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA,MAAa,UAAU;IACR,aAAa,CAAC,OAAoB,EAAE,MAA2B;;YAC1E,OAAO,OAAO,CAAC;QACjB,CAAC;KAAA;IAEY,aAAa,CACxB,OAAoB,EACpB,QAA2B,EAC3B,MAA2B;;YAE3B,OAAO,QAAQ,CAAC;QAClB,CAAC;KAAA;IAEY,OAAO,CAClB,OAAoB,EACpB,QAA2B,EAC3B,MAA2B;;YAE3B,OAAO,IAAI,eAAe,CAAC,wBAAwB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC1E,CAAC;KAAA;CACF;AApBD,gCAoBC;AAED,MAAM,eAAe;IACnB,YACS,KAAa,EACb,QAAsB;QADtB,UAAK,GAAL,KAAK,CAAQ;QACb,aAAQ,GAAR,QAAQ,CAAc;IAC5B,CAAC;CACL"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/destinations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/destinations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,cAAc,UAAU,CAAC"}
|
@@ -1,6 +1,21 @@
|
|
1
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
|
+
};
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
17
|
exports.DestinationsService = void 0;
|
4
18
|
var destinations_1 = require("./destinations");
|
5
19
|
Object.defineProperty(exports, "DestinationsService", { enumerable: true, get: function () { return destinations_1.DestinationsService; } });
|
20
|
+
__exportStar(require("./models"), exports);
|
6
21
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/destinations/index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/destinations/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+CAAqD;AAA5C,mHAAA,mBAAmB,OAAA;AAC5B,2CAAyB"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/e-sim/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/e-sim/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,cAAc,UAAU,CAAC"}
|
@@ -1,6 +1,21 @@
|
|
1
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
|
+
};
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
17
|
exports.ESimService = void 0;
|
4
18
|
var e_sim_1 = require("./e-sim");
|
5
19
|
Object.defineProperty(exports, "ESimService", { enumerable: true, get: function () { return e_sim_1.ESimService; } });
|
20
|
+
__exportStar(require("./models"), exports);
|
6
21
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/e-sim/index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/e-sim/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iCAAsC;AAA7B,oGAAA,WAAW,OAAA;AACpB,2CAAyB"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/packages/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/packages/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,cAAc,UAAU,CAAC"}
|
@@ -1,6 +1,21 @@
|
|
1
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
|
+
};
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
17
|
exports.PackagesService = void 0;
|
4
18
|
var packages_1 = require("./packages");
|
5
19
|
Object.defineProperty(exports, "PackagesService", { enumerable: true, get: function () { return packages_1.PackagesService; } });
|
20
|
+
__exportStar(require("./models"), exports);
|
6
21
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/packages/index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/packages/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uCAA6C;AAApC,2GAAA,eAAe,OAAA;AACxB,2CAAyB"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/purchases/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/purchases/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,cAAc,UAAU,CAAC"}
|
@@ -1,6 +1,21 @@
|
|
1
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
|
+
};
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
17
|
exports.PurchasesService = void 0;
|
4
18
|
var purchases_1 = require("./purchases");
|
5
19
|
Object.defineProperty(exports, "PurchasesService", { enumerable: true, get: function () { return purchases_1.PurchasesService; } });
|
20
|
+
__exportStar(require("./models"), exports);
|
6
21
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/purchases/index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/purchases/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,yCAA+C;AAAtC,6GAAA,gBAAgB,OAAA;AACzB,2CAAyB"}
|
@@ -71,7 +71,8 @@ This endpoint is used to purchase a new eSIM by providing the package details.
|
|
71
71
|
**Example Usage Code Snippet**
|
72
72
|
|
73
73
|
```typescript
|
74
|
-
import { Celitech
|
74
|
+
import { Celitech } from 'celitech-sdk';
|
75
|
+
import { CreatePurchaseRequest } from 'celitech-sdk/services/src/services/purchases/models';
|
75
76
|
|
76
77
|
(async () => {
|
77
78
|
const celitech = new Celitech({
|
@@ -117,7 +118,8 @@ This endpoint is used to top-up an eSIM with the previously associated destinati
|
|
117
118
|
**Example Usage Code Snippet**
|
118
119
|
|
119
120
|
```typescript
|
120
|
-
import { Celitech
|
121
|
+
import { Celitech } from 'celitech-sdk';
|
122
|
+
import { TopUpEsimRequest } from 'celitech-sdk/services/src/services/purchases/models';
|
121
123
|
|
122
124
|
(async () => {
|
123
125
|
const celitech = new Celitech({
|
@@ -162,7 +164,8 @@ This endpoint allows you to modify the dates of an existing package with a futur
|
|
162
164
|
**Example Usage Code Snippet**
|
163
165
|
|
164
166
|
```typescript
|
165
|
-
import { Celitech
|
167
|
+
import { Celitech } from 'celitech-sdk';
|
168
|
+
import { EditPurchaseRequest } from 'celitech-sdk/services/src/services/purchases/models';
|
166
169
|
|
167
170
|
(async () => {
|
168
171
|
const celitech = new Celitech({
|
@@ -1,5 +1,6 @@
|
|
1
1
|
```typescript
|
2
|
-
import { Celitech
|
2
|
+
import { Celitech } from 'celitech-sdk';
|
3
|
+
import { CreatePurchaseRequest } from 'celitech-sdk/services/src/services/purchases/models';
|
3
4
|
|
4
5
|
(async () => {
|
5
6
|
const celitech = new Celitech({
|
package/examples/package.json
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "celitech-sdk",
|
3
|
-
"version": "1.1.
|
3
|
+
"version": "1.1.85",
|
4
4
|
"description": "Welcome to the CELITECH API documentation! Useful links: [Homepage](https://www.celitech.com) | [Support email](mailto:support@celitech.com) | [Blog](https://www.celitech.com/blog/) ",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
@@ -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
|
|