From c6d7d21b4c3f6934006f66dcd5814dfe8d0979a3 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Thu, 10 Feb 2022 11:24:43 +0900 Subject: [PATCH 1/2] Update api.websms.js --- lib/api.websms.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/api.websms.js b/lib/api.websms.js index a165434..728160a 100644 --- a/lib/api.websms.js +++ b/lib/api.websms.js @@ -1,3 +1,4 @@ +var RAND = require("lib/rand"); var HTTP = require("lib/http"); var WebSMSObject = function() { @@ -6,6 +7,7 @@ var WebSMSObject = function() { this.country = "any"; this.operator = "any"; this.product = ""; + this.profiles = []; this.setHost = function(host) { this.host = host; @@ -31,9 +33,25 @@ var WebSMSObject = function() { this.product = product; return this; }; + + this.addProfile = function(product, country, operator) { + this.profiles.push({ + "product": product, + "country": country, + "operator": operator + }); + return this; + }; this.buy = function() { try { + if (this.profiles.length > 0) { + var pf = RAND.one(this.profiles); + this.setProduct(pf.product); + this.setOperator(pf.operator); + this.setCountry(pf.country); + } + var response = HTTP.create() .setBearerAuth(this.token) .setUseCache(false) From 0eb192440620e7e662af5c05f2848311e953c23d Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Thu, 10 Feb 2022 11:32:28 +0900 Subject: [PATCH 2/2] Update api.websms.js --- lib/api.websms.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/api.websms.js b/lib/api.websms.js index 728160a..6c5ab72 100644 --- a/lib/api.websms.js +++ b/lib/api.websms.js @@ -7,7 +7,7 @@ var WebSMSObject = function() { this.country = "any"; this.operator = "any"; this.product = ""; - this.profiles = []; + this.profiles = []; this.setHost = function(host) { this.host = host; @@ -33,24 +33,24 @@ var WebSMSObject = function() { this.product = product; return this; }; - - this.addProfile = function(product, country, operator) { - this.profiles.push({ - "product": product, - "country": country, - "operator": operator - }); - return this; - }; + + this.addProfile = function(product, country, operator) { + this.profiles.push({ + "product": product, + "country": country, + "operator": operator + }); + return this; + }; this.buy = function() { try { - if (this.profiles.length > 0) { - var pf = RAND.one(this.profiles); - this.setProduct(pf.product); - this.setOperator(pf.operator); - this.setCountry(pf.country); - } + if (this.profiles.length > 0) { + var pf = RAND.one(this.profiles); + this.setProduct(pf.product); + this.setOperator(pf.operator); + this.setCountry(pf.country); + } var response = HTTP.create() .setBearerAuth(this.token)