sms-activate-sdk
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -7,4 +7,4 @@ import { Query } from '../../query/query.module'; | ||
query: Query; | ||
waitForCode(id: string | number, tries?: number): Promise<string>; | ||
waitForCode(id: string | number, tries?: number, space?: number): Promise<string>; | ||
} | ||
//# sourceMappingURL=code.d.ts.map |
@@ -27,3 +27,3 @@ "use strict"; | ||
class waitForCode { | ||
waitForCode(id, tries = 180) { | ||
waitForCode(id, tries = 180, space = 1000) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -37,3 +37,3 @@ return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { | ||
return reject(result.code); | ||
yield (0, helpers_1.sleep)(1000); | ||
yield (0, helpers_1.sleep)(space); | ||
} | ||
@@ -48,3 +48,3 @@ reject('EXPIRED'); | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", [Object, Object]), | ||
__metadata("design:paramtypes", [Object, Object, Object]), | ||
__metadata("design:returntype", Promise) | ||
@@ -51,0 +51,0 @@ ], waitForCode.prototype, "waitForCode", null); |
@@ -23,3 +23,3 @@ import { INumber } from '../../../ressources/responses'; | ||
data(): INumber; | ||
getCode(tries?: number): Promise<string>; | ||
getCode(tries?: number, space?: number): Promise<string>; | ||
ready(): Promise<import("../../../ressources/status").IStatusResponse>; | ||
@@ -26,0 +26,0 @@ failed(): Promise<import("../../../ressources/status").IStatusResponse>; |
@@ -50,6 +50,6 @@ "use strict"; | ||
} | ||
getCode(tries = 180) { | ||
getCode(tries = 180, space = 1000) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return (_a = this.utils) === null || _a === void 0 ? void 0 : _a.waitForCode(this.activationId, tries); | ||
return (_a = this.utils) === null || _a === void 0 ? void 0 : _a.waitForCode(this.activationId, tries, space); | ||
}); | ||
@@ -56,0 +56,0 @@ } |
@@ -1,2 +0,2 @@ | ||
export {}; | ||
import 'axios-debug-log'; | ||
//# sourceMappingURL=test.d.ts.map |
@@ -13,8 +13,11 @@ "use strict"; | ||
const index_1 = require("./index"); | ||
require("axios-debug-log"); | ||
function main() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const api = new index_1.SMSActivate(process.env.TOKEN); | ||
const result = yield api.getNumber({ service: 'tw', country: 0 }); | ||
const result = yield api.getNumber({ service: 'lf', country: 0 }); | ||
yield result.ready(); | ||
const code = yield result.getCode(); | ||
console.log(result); | ||
const code = yield result.getCode(180, 5000); | ||
console.log(code); | ||
}); | ||
@@ -21,0 +24,0 @@ } |
{ | ||
"name": "sms-activate-sdk", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "A full NodeJS API for sms-activate.org", | ||
"main": "dist/index.js", | ||
"devDependencies": { | ||
"@types/node": "^18.11.15", | ||
"@typescript-eslint/eslint-plugin": "^5.36.1", | ||
@@ -28,3 +29,3 @@ "@typescript-eslint/parser": "^5.36.1", | ||
"lint:fix": "eslint . --fix", | ||
"test":"tsc && node dist/test.js" | ||
"test": "tsc && node dist/test.js" | ||
}, | ||
@@ -31,0 +32,0 @@ "repository": { |
@@ -13,3 +13,3 @@ import { use } from 'typescript-mix'; | ||
@use(getStatus) | ||
async waitForCode(id: string | number, tries = 180): Promise<string> { | ||
async waitForCode(id: string | number, tries = 180,space = 1000): Promise<string> { | ||
return new Promise<string>(async (resolve, reject) => { | ||
@@ -22,3 +22,3 @@ while (tries--) { | ||
return reject(result.code); | ||
await sleep(1000); | ||
await sleep(space); | ||
} | ||
@@ -25,0 +25,0 @@ reject('EXPIRED'); |
@@ -51,4 +51,4 @@ import { autoInjectable } from 'tsyringe'; | ||
async getCode(tries = 180): Promise<string> { | ||
return this.utils?.waitForCode(this.activationId, tries); | ||
async getCode(tries = 180,space = 1000): Promise<string> { | ||
return this.utils?.waitForCode(this.activationId, tries, space); | ||
} | ||
@@ -55,0 +55,0 @@ |
import {SMSActivate} from './index' | ||
import 'axios-debug-log' | ||
async function main() { | ||
const api = new SMSActivate(process.env.TOKEN) | ||
const result = await api.getNumber({service:'tw',country:0}) | ||
const result = await api.getNumber({service:'lf',country:0}) | ||
await result.ready() | ||
const code = await result.getCode() | ||
console.log(result) | ||
const code = await result.getCode(180,5000) | ||
console.log(code) | ||
} | ||
main().catch(console.error) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
196913
211
3179
9