diff --git a/examples/freeTrialNumbers-create.ts b/examples/freeTrialNumbers-create.js similarity index 62% rename from examples/freeTrialNumbers-create.ts rename to examples/freeTrialNumbers-create.js index 7ce4f01..c955196 100644 --- a/examples/freeTrialNumbers-create.ts +++ b/examples/freeTrialNumbers-create.js @@ -1,27 +1,23 @@ -import { FreeTrialNumbers } from '../dist/index.js'; -import { TFreeTrialNumbers } from '../dist/messaging/types/FreeTrialNumberTypes.js'; - +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var index_js_1 = require("../dist/index.js"); // Auth using JSON file import // var AUTH_CONFIG = require('./credentials.json'); // const trialNumber = new TrialNumbers(AUTH_CONFIG); - // Auth via ENV VARS or SHARED CREDENTIALS -const freeTrialNumbers = new FreeTrialNumbers(); - +var freeTrialNumbers = new index_js_1.FreeTrialNumbers(); /** * FreeTrial Numbers - Create */ - -const params: TFreeTrialNumbers = { +var params = { freeTrialNumbers: [ "0412345678" ] }; - freeTrialNumbers.create(params) -.then(result => { + .then(function (result) { console.log('SUCCESS:freeTrialNumbers:create:', result); }) -.catch(error => { + .catch(function (error) { console.error('ERROR:freeTrialNumber:create:', error); }); diff --git a/examples/freeTrialNumbers-get-all.js b/examples/freeTrialNumbers-get-all.js new file mode 100644 index 0000000..6f9bf28 --- /dev/null +++ b/examples/freeTrialNumbers-get-all.js @@ -0,0 +1,14 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var index_js_1 = require("../dist/index.js"); +// Auth using JSON file import +// var AUTH_CONFIG = require('./credentials.json'); +// const trialNumber = new TrialNumbers(AUTH_CONFIG); +// Auth via ENV VARS or SHARED CREDENTIALS +var freeTrialNumbers = new index_js_1.FreeTrialNumbers(); +/** + * FreeTrial Numbers - Fetch all numbers associated to the account + */ +freeTrialNumbers.getAll() + .then(function (result) { return console.log('SUCCESS:freeTrialNumbers:getAll:', result); }) + .catch(function (error) { return console.error('ERROR:freeTrialNumber:getAll:', error); }); diff --git a/examples/freeTrialNumbers-get-all.ts b/examples/freeTrialNumbers-get-all.ts deleted file mode 100644 index bcbcbc8..0000000 --- a/examples/freeTrialNumbers-get-all.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { FreeTrialNumbers } from '../dist/index.js'; - -// Auth using JSON file import -// var AUTH_CONFIG = require('./credentials.json'); -// const trialNumber = new TrialNumbers(AUTH_CONFIG); - -// Auth via ENV VARS or SHARED CREDENTIALS -const freeTrialNumbers = new FreeTrialNumbers(); - -/** - * FreeTrial Numbers - Fetch all numbers associated to the account - */ -freeTrialNumbers.getAll() - .then(result => console.log('SUCCESS:freeTrialNumbers:getAll:', result)) - .catch(error => console.error('ERROR:freeTrialNumber:getAll:', error)); diff --git a/examples/healthcheck.ts b/examples/healthcheck.js similarity index 56% rename from examples/healthcheck.ts rename to examples/healthcheck.js index 30efba9..23f0424 100644 --- a/examples/healthcheck.ts +++ b/examples/healthcheck.js @@ -1,16 +1,15 @@ -import { HealthCheck } from '../dist/index.js' - +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var index_js_1 = require("../dist/index.js"); // Auth using JSON file import // var AUTH_CONFIG = require('./credentials.json'); // const healthCheck = new HealthCheck(AUTH_CONFIG); - // Auth via ENV VARS or SHARED CREDENTIALS -const healthCheck = new HealthCheck(); - +var healthCheck = new index_js_1.HealthCheck(); healthCheck.get() -.then(result => { + .then(function (result) { console.log('SUCCESS:healthCheck:', result); }) -.catch(error => { + .catch(function (error) { console.error('ERROR:healthCheck:', error); }); diff --git a/examples/messages-fetch-all.js b/examples/messages-fetch-all.js new file mode 100644 index 0000000..40fd1f6 --- /dev/null +++ b/examples/messages-fetch-all.js @@ -0,0 +1,14 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var dist_1 = require("../dist"); +// Auth using JSON file import +// var AUTH_CONFIG = require('./credentials.json'); +// const message = new Message(AUTH_CONFIG); +// Auth via ENV VARS or SHARED CREDENTIALS +var messages = new dist_1.Messages(); +/** + * Messages - Fetch all + */ +messages.getAll() + .then(function (result) { return console.log('SUCCESS:messages:getAll:', result); }) + .catch(function (error) { return console.error('ERROR:messages:getAll:', error); }); diff --git a/examples/messages-fetch-all.ts b/examples/messages-fetch-all.ts deleted file mode 100644 index 03e2eea..0000000 --- a/examples/messages-fetch-all.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Messages } from '../dist'; - -// Auth using JSON file import -// var AUTH_CONFIG = require('./credentials.json'); -// const message = new Message(AUTH_CONFIG); - -// Auth via ENV VARS or SHARED CREDENTIALS -const messages = new Messages(); - -/** - * Messages - Fetch all - */ - -messages.getAll() - .then(result => console.log('SUCCESS:messages:getAll:', result)) - .catch(error => console.error('ERROR:messages:getAll:', error)) diff --git a/examples/messages-send-fetch.js b/examples/messages-send-fetch.js new file mode 100644 index 0000000..37523af --- /dev/null +++ b/examples/messages-send-fetch.js @@ -0,0 +1,24 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var index_js_1 = require("../dist/index.js"); +// Auth using JSON file import +// var AUTH_CONFIG = require('./credentials.json'); +// const message = new Message(AUTH_CONFIG); +// Auth via ENV VARS or SHARED CREDENTIALS +var message = new index_js_1.Messages(); +message.send({ + to: '+61123456789', + from: 'private', + messageContent: 'Hello from Messaging SDK!' +}) + .then(function (result) { + console.log('SUCCESS:messages:send:sms:', result); + var messageId = Array.isArray(result.messageId) ? result.messageId[0] : result.messageId; + /** Get a Message */ + message.get(messageId) + .then(function (getMsgResult) { return console.log('SUCCESS:messages:get:', getMsgResult); }) + .catch(function (getMsgError) { return console.error('ERROR:messages:get:', getMsgError); }); +}) + .catch(function (error) { + console.error('ERROR:messages:send:sms:', error); +}); diff --git a/examples/messages-send-fetch.ts b/examples/messages-send-fetch.ts deleted file mode 100644 index 3d454a8..0000000 --- a/examples/messages-send-fetch.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { Messages } from '../dist/index.js' - -// Auth using JSON file import -// var AUTH_CONFIG = require('./credentials.json'); -// const message = new Message(AUTH_CONFIG); - -// Auth via ENV VARS or SHARED CREDENTIALS -const message = new Messages(); - -message.send({ - to: '+61123456789', - from: 'private', - messageContent: 'Hello from Messaging SDK!' -}) - .then(result => { - console.log('SUCCESS:messages:send:sms:', result); - const messageId = Array.isArray(result.messageId) ? result.messageId[0] : result.messageId; - - /** Get a Message */ - message.get(messageId) - .then(getMsgResult => console.log('SUCCESS:messages:get:', getMsgResult)) - .catch(getMsgError => console.error('ERROR:messages:get:', getMsgError)); - - }) - .catch(error => { - console.error('ERROR:messages:send:sms:', error); - }); diff --git a/examples/messages-send-mms.js b/examples/messages-send-mms.js new file mode 100644 index 0000000..a070b34 --- /dev/null +++ b/examples/messages-send-mms.js @@ -0,0 +1,28 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var index_js_1 = require("../dist/index.js"); +var MessageTypes_js_1 = require("../dist/messaging/types/MessageTypes.js"); +// Auth using JSON file import +// var AUTH_CONFIG = require('./credentials.json'); +// const message = new Message(AUTH_CONFIG); +// Auth via ENV VARS or SHARED CREDENTIALS +var messages = new index_js_1.Messages(); +var mobileNumber = process.env.MOBILE_NUMBER ? process.env.MOBILE_NUMBER : '+61123456789'; +/** + * Messages + */ +messages + .send({ + to: mobileNumber, + from: 'private', + messageContent: 'Hello from Messaging SDK!', + multimedia: [ + { + type: MessageTypes_js_1.TMultimediaContentType.IMAGE_GIF, + fileName: 'bus.gif', + payload: 'R0lGODlhPQBEAPeoAJosM//AwO/AwHVYZ/z595kzAP/s7P+goOXMv8+fhw/v739/f+8PD98fH/8mJl+fn/9ZWb8/PzWlwv///6wWGbImAPgTEMImIN9gUFCEm/gDALULDN8PAD6atYdCTX9gUNKlj8wZAKUsAOzZz+UMAOsJAP/Z2ccMDA8PD/95eX5NWvsJCOVNQPtfX/8zM8+QePLl38MGBr8JCP+zs9myn/8GBqwpAP/GxgwJCPny78lzYLgjAJ8vAP9fX/+MjMUcAN8zM/9wcM8ZGcATEL+QePdZWf/29uc/P9cmJu9MTDImIN+/r7+/vz8/P8VNQGNugV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KPAgCBZSQHQ1A2EWDfDEUVLyADj5AChSIQW6gu10bE/JG2VnCZGfo4R4d0sdQoBAHhPjhIB94v/wRoRKQWGRHgrhGSQJxCS+0pCZbEhAAOw==', + }, + ], +}) + .then(function (result) { return console.log('SUCCESS:message:send:mms', result); }) + .catch(function (error) { return console.error('ERROR:message:send:mms', error); }); diff --git a/examples/messages-send-mms.ts b/examples/messages-send-mms.ts deleted file mode 100644 index 55d2fde..0000000 --- a/examples/messages-send-mms.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { Messages } from '../dist/index.js' -import { TMultimediaContentType } from '../dist/messaging/types/MessageTypes.js'; - -// Auth using JSON file import -// var AUTH_CONFIG = require('./credentials.json'); -// const message = new Message(AUTH_CONFIG); - -// Auth via ENV VARS or SHARED CREDENTIALS -const messages = new Messages(); - -const mobileNumber = process.env.MOBILE_NUMBER ? process.env.MOBILE_NUMBER : '+61123456789'; - -/** - * Messages - */ - -messages - .send({ - to: mobileNumber, - from: 'private', - messageContent: 'Hello from Messaging SDK!', - multimedia: [ - { - type: TMultimediaContentType.IMAGE_GIF, - fileName: 'bus.gif', - payload: - 'R0lGODlhPQBEAPeoAJosM//AwO/AwHVYZ/z595kzAP/s7P+goOXMv8+fhw/v739/f+8PD98fH/8mJl+fn/9ZWb8/PzWlwv///6wWGbImAPgTEMImIN9gUFCEm/gDALULDN8PAD6atYdCTX9gUNKlj8wZAKUsAOzZz+UMAOsJAP/Z2ccMDA8PD/95eX5NWvsJCOVNQPtfX/8zM8+QePLl38MGBr8JCP+zs9myn/8GBqwpAP/GxgwJCPny78lzYLgjAJ8vAP9fX/+MjMUcAN8zM/9wcM8ZGcATEL+QePdZWf/29uc/P9cmJu9MTDImIN+/r7+/vz8/P8VNQGNugV8AAF9fX8swMNgTAFlDOICAgPNSUnNWSMQ5MBAQEJE3QPIGAM9AQMqGcG9vb6MhJsEdGM8vLx8fH98AANIWAMuQeL8fABkTEPPQ0OM5OSYdGFl5jo+Pj/+pqcsTE78wMF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IIYaFlcDhytd51sGAJbo3onOpajiihlO92KHGaUXGwWjUBChjSPiWJuOO/LYIm4v1tXfE6J4gCSJEZ7YgRYUNrkji9P55sF/ogxw5ZkSqIDaZBV6aSGYq/lGZplndkckZ98xoICbTcIJGQAZcNmdmUc210hs35nCyJ58fgmIKX5RQGOZowxaZwYA+JaoKQwswGijBV4C6SiTUmpphMspJx9unX4KaimjDv9aaXOEBteBqmuuxgEHoLX6Kqx+yXqqBANsgCtit4FWQAEkrNbpq7HSOmtwag5w57GrmlJBASEU18ADjUYb3ADTinIttsgSB1oJFfA63bduimuqKB1keqwUhoCSK374wbujvOSu4QG6UvxBRydcpKsav++Ca6G8A6Pr1x2kVMyHwsVxUALDq/krnrhPSOzXG1lUTIoffqGR7Goi2MAxbv6O2kEG56I7CSlRsEFKFVyovDJoIRTg7sugNRDGqCJzJgcKE0ywc0ELm6KBCCJo8DIPFeCWNGcyqNFE06ToAfV0HBRgxsvLThHn1oddQMrXj5DyAQgjEHSAJMWZwS3HPxT/QMbabI/iBCliMLEJKX2EEkomBAUCxRi42VDADxyTYDVogV+wSChqmKxEKCDAYFDFj4OmwbY7bDGdBhtrnTQYOigeChUmc1K3QTnAUfEgGFgAWt88hKA6aCRIXhxnQ1yg3BCayK44EWdkUQcBByEQChFXfCB776aQsG0BIlQgQgE8qO26X1h8cEUep8ngRBnOy74E9QgRgEAC8SvOfQkh7FDBDmS43PmGoIiKUUEGkMEC/PJHgxw0xH74yx/3XnaYRJgMB8obxQW6kL9QYEJ0FIFgByfIL7/IQAlvQwEpnAC7DtLNJCKUoO/w45c44GwCXiAFB/OXAATQryUxdN4LfFiwgjCNYg+kYMIEFkCKDs6PKAIJouyGWMS1FSKJOMRB/BoIxYJIUXFUxNwoIkEKPAgCBZSQHQ1A2EWDfDEUVLyADj5AChSIQW6gu10bE/JG2VnCZGfo4R4d0sdQoBAHhPjhIB94v/wRoRKQWGRHgrhGSQJxCS+0pCZbEhAAOw==', - }, - ], - }) - .then(result => console.log('SUCCESS:message:send:mms', result)) - .catch(error => console.error('ERROR:message:send:mms', error)); diff --git a/examples/reports-create-dailySummary.js b/examples/reports-create-dailySummary.js new file mode 100644 index 0000000..f6f4810 --- /dev/null +++ b/examples/reports-create-dailySummary.js @@ -0,0 +1,23 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var index_js_1 = require("../dist/index.js"); +// Auth using JSON file import +// var AUTH_CONFIG = require('./credentials.json'); +// const reports = new Reports(AUTH_CONFIG); +// Auth via ENV VARS or SHARED CREDENTIALS +var reports = new index_js_1.Reports(); +var startDate = new Date(); +var endDate = new Date(startDate); +endDate.setDate(startDate.getDate() - 10); +var startDateStr = "".concat(startDate.toLocaleDateString('fr-CA')); +var endDateStr = "".concat(endDate.toLocaleDateString('fr-CA')); +/** + * Reports - Create - Daily Summary Report + */ +var params = { + startDate: startDateStr, + endDate: endDateStr +}; +reports.createDailySummary(params) + .then(function (result) { return console.log('SUCCESS:reports:create-daily:', result); }) + .catch(function (error) { return console.error('ERROR:reports:create-daily:', error); }); diff --git a/examples/reports-create-dailySummary.ts b/examples/reports-create-dailySummary.ts deleted file mode 100644 index a549380..0000000 --- a/examples/reports-create-dailySummary.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { Reports } from '../dist/index.js'; -import { TCreateReport } from '../dist/messaging/types/ReportTypes.js'; - -// Auth using JSON file import -// var AUTH_CONFIG = require('./credentials.json'); -// const reports = new Reports(AUTH_CONFIG); - -// Auth via ENV VARS or SHARED CREDENTIALS -const reports = new Reports(); - -const startDate = new Date(); -const endDate = new Date(startDate); -endDate.setDate(startDate.getDate() - 10); - -const startDateStr = `${startDate.toLocaleDateString('fr-CA')}`; -const endDateStr = `${endDate.toLocaleDateString('fr-CA')}`; - -/** - * Reports - Create - Daily Summary Report - */ -const params : TCreateReport = { - startDate: startDateStr, - endDate: endDateStr -} -reports.createDailySummary(params) - .then(result => console.log('SUCCESS:reports:create-daily:', result)) - .catch(error => console.error('ERROR:reports:create-daily:', error)) \ No newline at end of file diff --git a/examples/reports-create.js b/examples/reports-create.js new file mode 100644 index 0000000..debf84f --- /dev/null +++ b/examples/reports-create.js @@ -0,0 +1,23 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var index_js_1 = require("../dist/index.js"); +// Auth using JSON file import +// var AUTH_CONFIG = require('./credentials.json'); +// const reports = new Reports(AUTH_CONFIG); +// Auth via ENV VARS or SHARED CREDENTIALS +var reports = new index_js_1.Reports(); +var startDate = new Date(); +var endDate = new Date(startDate); +endDate.setDate(startDate.getDate() - 10); +var startDateStr = "".concat(startDate.toLocaleDateString('fr-CA')); +var endDateStr = "".concat(endDate.toLocaleDateString('fr-CA')); +/** + * Reports - Create - Messages Report + */ +var params = { + startDate: startDateStr, + endDate: endDateStr +}; +reports.create(params) + .then(function (result) { return console.log('SUCCESS:reports:create:', result); }) + .catch(function (error) { return console.error('ERROR:reports:create:', error); }); diff --git a/examples/reports-create.ts b/examples/reports-create.ts deleted file mode 100644 index 5f465f5..0000000 --- a/examples/reports-create.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Reports } from '../dist/index.js'; -import { TCreateReport } from '../dist/messaging/types/ReportTypes.js'; - -// Auth using JSON file import -// var AUTH_CONFIG = require('./credentials.json'); -// const reports = new Reports(AUTH_CONFIG); - -// Auth via ENV VARS or SHARED CREDENTIALS -const reports = new Reports(); -const startDate = new Date(); -const endDate = new Date(startDate); -endDate.setDate(startDate.getDate() - 10); - -const startDateStr = `${startDate.toLocaleDateString('fr-CA')}`; -const endDateStr = `${endDate.toLocaleDateString('fr-CA')}`; - -/** - * Reports - Create - Messages Report - */ -const params : TCreateReport = { - startDate: startDateStr, - endDate: endDateStr -} -reports.create(params) - .then(result => console.log('SUCCESS:reports:create:', result)) - .catch(error => console.error('ERROR:reports:create:', error)) diff --git a/examples/reports-get-all.js b/examples/reports-get-all.js new file mode 100644 index 0000000..e5a6668 --- /dev/null +++ b/examples/reports-get-all.js @@ -0,0 +1,14 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var dist_1 = require("../dist"); +// Auth using JSON file import +// var AUTH_CONFIG = require('./credentials.json'); +// const reports = new Reports(AUTH_CONFIG); +// Auth via ENV VARS or SHARED CREDENTIALS +var reports = new dist_1.Reports(); +/** + * Reports - Fetch all reports + */ +reports.getAll() + .then(function (result) { return console.log('SUCCESS:reports:getAll:', result); }) + .catch(function (error) { return console.error('ERROR:reports:getAll:', error); }); diff --git a/examples/reports-get-all.ts b/examples/reports-get-all.ts deleted file mode 100644 index 2f21f93..0000000 --- a/examples/reports-get-all.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Reports } from '../dist'; - -// Auth using JSON file import -// var AUTH_CONFIG = require('./credentials.json'); -// const reports = new Reports(AUTH_CONFIG); - -// Auth via ENV VARS or SHARED CREDENTIALS -const reports = new Reports(); - -/** - * Reports - Fetch all reports - */ - -reports.getAll() - .then(result => console.log('SUCCESS:reports:getAll:', result)) - .catch(error => console.error('ERROR:reports:getAll:', error)) diff --git a/examples/virtualNumbers-crud.js b/examples/virtualNumbers-crud.js new file mode 100644 index 0000000..cd46f11 --- /dev/null +++ b/examples/virtualNumbers-crud.js @@ -0,0 +1,41 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var index_js_1 = require("../dist/index.js"); +// Auth using JSON file import +// var AUTH_CONFIG = require('./credentials.json'); +// const number = new Numbers(AUTH_CONFIG); +// Auth via ENV VARS or SHARED CREDENTIALS +var virtualNumbers = new index_js_1.VirtualNumbers(); +/** + * VirtualNumbers + * - Assign + * - Fetch VirtualNumber + * - Update VirtualNumber + * - Delete VirtualNumber + */ +virtualNumbers.assign() + .then(function (result) { + console.log('SUCCESS:number:create:', result); + var virtualNumber = result.virtualNumber; + /** Fetch VirtualNumber */ + virtualNumbers.get(virtualNumber) + .then(function (getVNResponse) { return console.log('SUCCESS:virtualNumber:get:', getVNResponse); }) + .catch(function (getVNError) { return console.error('ERROR:virtualNumbers:get:', getVNError); }); + /** Fetch all opt-out numbers */ + virtualNumbers.getOptouts(virtualNumber) + .then(function (getVNOptoutsResponse) { return console.log('SUCCESS:virtualNumber:get:optouts', getVNOptoutsResponse); }) + .catch(function (getVNOptoutsError) { return console.error('ERROR:virtualNumbers:get:optouts', getVNOptoutsError); }); + /** Update VirtualNumber */ + var updateParams = { + virtualNumber: virtualNumber, + updateData: { tags: ['V3'] }, + }; + virtualNumbers.update(updateParams) + .then(function (updateVNResponse) { return console.log('SUCCESS:virtualNumber:update:', updateVNResponse); }) + .catch(function (updateVNError) { return console.error('ERROR:virtualNumbers:update:', updateVNError); }); + /** Delete VirtualNumber */ + virtualNumbers.delete(virtualNumber) + .then(function (deleteVNResponse) { return console.log('SUCCESS:virtualNumber:delete:', deleteVNResponse); }) + .catch(function (deleteVNError) { return console.error('ERROR:virtualNumbers:delete:', deleteVNError); }); +}) + .catch(function (error) { return console.error('ERROR:number:create:', error); }); diff --git a/examples/virtualNumbers-crud.ts b/examples/virtualNumbers-crud.ts deleted file mode 100644 index fcf13dc..0000000 --- a/examples/virtualNumbers-crud.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { VirtualNumbers } from '../dist/index.js'; -import { TUpdateVirtualNumberRequest } from '../dist/messaging/types'; - -// Auth using JSON file import -// var AUTH_CONFIG = require('./credentials.json'); -// const number = new Numbers(AUTH_CONFIG); - -// Auth via ENV VARS or SHARED CREDENTIALS -const virtualNumbers = new VirtualNumbers(); - -/** - * VirtualNumbers - * - Assign - * - Fetch VirtualNumber - * - Update VirtualNumber - * - Delete VirtualNumber - */ - -virtualNumbers.assign() - .then(result => { - console.log('SUCCESS:number:create:', result); - const virtualNumber = result.virtualNumber; - - /** Fetch VirtualNumber */ - virtualNumbers.get(virtualNumber) - .then(getVNResponse => console.log('SUCCESS:virtualNumber:get:', getVNResponse)) - .catch(getVNError => console.error('ERROR:virtualNumbers:get:', getVNError)); - - /** Fetch all opt-out numbers */ - virtualNumbers.getOptouts(virtualNumber) - .then(getVNOptoutsResponse => console.log('SUCCESS:virtualNumber:get:optouts', getVNOptoutsResponse)) - .catch(getVNOptoutsError => console.error('ERROR:virtualNumbers:get:optouts', getVNOptoutsError)); - - /** Update VirtualNumber */ - const updateParams: TUpdateVirtualNumberRequest = { - virtualNumber, - updateData: { tags: ['V3'] }, - } - virtualNumbers.update(updateParams) - .then(updateVNResponse => console.log('SUCCESS:virtualNumber:update:', updateVNResponse)) - .catch(updateVNError => console.error('ERROR:virtualNumbers:update:', updateVNError)); - - /** Delete VirtualNumber */ - virtualNumbers.delete(virtualNumber) - .then(deleteVNResponse => console.log('SUCCESS:virtualNumber:delete:', deleteVNResponse)) - .catch(deleteVNError => console.error('ERROR:virtualNumbers:delete:', deleteVNError)); - }) - .catch(error => console.error('ERROR:number:create:', error)); diff --git a/examples/virtualNumbers-get-all.js b/examples/virtualNumbers-get-all.js new file mode 100644 index 0000000..9f9c207 --- /dev/null +++ b/examples/virtualNumbers-get-all.js @@ -0,0 +1,14 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var dist_1 = require("../dist"); +// Auth using JSON file import +// var AUTH_CONFIG = require('./credentials.json'); +// const number = new Numbers(AUTH_CONFIG); +// Auth via ENV VARS or SHARED CREDENTIALS +var virtualNumbers = new dist_1.VirtualNumbers(); +/** + * VirtualNumbers - Fetch all + */ +virtualNumbers.getAll() + .then(function (result) { return console.log('SUCCESS:virtualNumbers:getAll:', result); }) + .catch(function (error) { return console.error('ERROR:virtualNumbers:getAll:', error); }); diff --git a/examples/virtualNumbers-get-all.ts b/examples/virtualNumbers-get-all.ts deleted file mode 100644 index 3c02850..0000000 --- a/examples/virtualNumbers-get-all.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { VirtualNumbers } from '../dist'; - -// Auth using JSON file import -// var AUTH_CONFIG = require('./credentials.json'); -// const number = new Numbers(AUTH_CONFIG); - -// Auth via ENV VARS or SHARED CREDENTIALS -const virtualNumbers = new VirtualNumbers(); - -/** - * VirtualNumbers - Fetch all - */ - -virtualNumbers.getAll() - .then(result => console.log('SUCCESS:virtualNumbers:getAll:', result)) - .catch(error => console.error('ERROR:virtualNumbers:getAll:', error)) diff --git a/src/messaging/classes/HttpClient.ts b/src/messaging/classes/HttpClient.ts index e6b66ab..153dbe3 100644 --- a/src/messaging/classes/HttpClient.ts +++ b/src/messaging/classes/HttpClient.ts @@ -56,9 +56,6 @@ export abstract class HttpClient { private _handleRequest = async (config: InternalAxiosRequestConfig) => { config.headers = config.headers ?? {}; - // config.headers['User-Agent'] = Constants.USER_AGENT; - // config.headers['X-Telstra-Media-Type'] = - // Constants.X_TELSTRA_AGENT_MEDIA_TYPE; // set headers due to oauth api proxy differences if (config.url === '/v2/oauth/token') { @@ -67,6 +64,9 @@ export abstract class HttpClient { 'Content-Type' ] = `application/x-www-form-urlencoded`; } else { + config.headers['Telstra-api-version'] = `3.x`; + config.headers['Content-Language'] = `en-au`; + config.headers['Accept-Charset'] = `utf-8`; config.headers['Accept'] = `application/json`; config.headers['Content-Type'] = `application/json`; }