diff --git a/.github/dependabot.yml b/.github/dependabot.yml index e750e1a..ef8fec1 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -10,4 +10,4 @@ updates: - package-ecosystem: "npm" directory: "/" schedule: - interval: "weekly" + interval: "daily" diff --git a/.husky/pre-commit b/.husky/pre-commit deleted file mode 100755 index 3867a0f..0000000 --- a/.husky/pre-commit +++ /dev/null @@ -1 +0,0 @@ -npm run lint diff --git a/.husky/pre-push b/.husky/pre-push deleted file mode 100755 index e37998f..0000000 --- a/.husky/pre-push +++ /dev/null @@ -1 +0,0 @@ -npm run test diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e68205..7ae7c08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## [2.0.15](https://github.com/smsapi/smsapi-javascript-client/compare/v2.0.14...v2.0.15) - 2025-05-13 + +### Added + +- Possibility to set specific service url. + +```js +const smsapi = new SMSAPI('oAuthToken', 'https://ssl.smsapi.com/api'); +``` + ## [2.0.14](https://github.com/smsapi/smsapi-javascript-client/compare/v2.0.13...v2.0.14) - 2024-10-02 ### Changed diff --git a/package-lock.json b/package-lock.json index 7eb9343..b312347 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "smsapi", - "version": "2.0.14", + "version": "2.0.15", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "smsapi", - "version": "2.0.14", + "version": "2.0.15", "license": "Apache-2.0", "dependencies": { "axios": "^1.6.1", @@ -29,7 +29,6 @@ "eslint-plugin-prettier": "^5.0.1", "eslint-plugin-promise": "^6.1.1", "eslint-plugin-standard": "^5.0.0", - "husky": "^9.0.7", "jest": "^29.7.0", "lodash": "^4.17.21", "nock": "^13.3.8", @@ -6622,21 +6621,6 @@ "node": ">=10.17.0" } }, - "node_modules/husky": { - "version": "9.0.11", - "resolved": "https://registry.npmjs.org/husky/-/husky-9.0.11.tgz", - "integrity": "sha512-AB6lFlbwwyIqMdHYhwPe+kjOC3Oc5P3nThEoW/AaO2BX3vJDjWPFxYLxokUZOo6RNX20He3AaT8sESs9NJcmEw==", - "dev": true, - "bin": { - "husky": "bin.mjs" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/typicode" - } - }, "node_modules/ignore": { "version": "5.2.4", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", @@ -8244,9 +8228,9 @@ "license": "MIT" }, "node_modules/nock": { - "version": "13.5.4", - "resolved": "https://registry.npmjs.org/nock/-/nock-13.5.4.tgz", - "integrity": "sha512-yAyTfdeNJGGBFxWdzSKCBYxs5FxLbCg5X5Q4ets974hcQzG1+qCxvIyOo4j2Ry6MUlhWVMX4OoYDefAIIwupjw==", + "version": "13.5.6", + "resolved": "https://registry.npmjs.org/nock/-/nock-13.5.6.tgz", + "integrity": "sha512-o2zOYiCpzRqSzPj0Zt/dQ/DqZeYoaQ7TUonc/xUPjCGl9WeHpNbxgVvOquXYAaJzI0M9BXV3HTzG0p8IUAbBTQ==", "dev": true, "dependencies": { "debug": "^4.1.0", diff --git a/package.json b/package.json index 47c2eff..ed734c1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "smsapi", "description": "Official client for sending SMS and account management on SMSAPI", - "version": "2.0.14", + "version": "2.0.15", "license": "Apache-2.0", "author": "SMSAPI ", "repository": "github:smsapi/smsapi-javascript-client", @@ -15,7 +15,6 @@ "lint": "eslint .", "test": "jest", "test:watch": "jest --watchAll --verbose", - "prepare": "husky", "prepublishOnly": "npm run lint && npm run test" }, "dependencies": { @@ -39,7 +38,6 @@ "eslint-plugin-prettier": "^5.0.1", "eslint-plugin-promise": "^6.1.1", "eslint-plugin-standard": "^5.0.0", - "husky": "^9.0.7", "jest": "^29.7.0", "lodash": "^4.17.21", "nock": "^13.3.8", diff --git a/src/smsapi/index.spec.ts b/src/smsapi/index.spec.ts index 0204e82..4e47e5d 100644 --- a/src/smsapi/index.spec.ts +++ b/src/smsapi/index.spec.ts @@ -29,4 +29,26 @@ describe('SMSAPI', () => { expect(nock.pendingMocks()).toEqual([]); expect(nock.isDone()).toEqual(true); }); + + it(`SMSAPI should call service provided by user`, async () => { + // given + const url = 'https://ssl.smsapi.com/api'; + + nock(url, { + reqheaders: { + authorization: `Bearer ${token}`, + }, + }) + .get('/profile') + .reply(200); + + const smsapi = new SMSAPI(token, url); + + // when + await smsapi.profile.get(); + + // then + expect(nock.pendingMocks()).toEqual([]); + expect(nock.isDone()).toEqual(true); + }); }); diff --git a/src/smsapi/index.ts b/src/smsapi/index.ts index ba6a0ef..2332884 100644 --- a/src/smsapi/index.ts +++ b/src/smsapi/index.ts @@ -19,6 +19,7 @@ import { extractDataFromResponse } from './httpClient/extractDataFromResponse'; export class SMSAPI { private accessToken: string; + private serviceUrl: string; private httpClient: AxiosInstance; @@ -32,8 +33,9 @@ export class SMSAPI { public templates: Templates; public vms: Vms; - constructor(accessToken: string) { + constructor(accessToken: string, serviceUrl?: string) { this.accessToken = accessToken; + this.serviceUrl = serviceUrl ?? API_URL; this.httpClient = this.setHttpClient(); @@ -55,7 +57,7 @@ export class SMSAPI { private setHttpClient(): AxiosInstance { const httpClient = axios.create({ adapter: 'http', - baseURL: API_URL, + baseURL: this.serviceUrl, headers: { Accept: 'application/json', Authorization: `Bearer ${this.accessToken}`,