This commit is contained in:
Namhyeon Go 2022-02-10 12:09:56 +09:00
commit 67d365026a

View File

@ -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)