class Sksk_1 attr_accessor :sk_url, :sk_login, :sk_password def initialize(sk_url, sk_login, sk_password) @sk_url = sk_url @sk_login = sk_login @sk_password = sk_password @internal_func = InternalFunc.new end def sk_send_sms(msisdn, callback_url, text, alphaname) uri = URI(sk_url) #8 - client id https = Net::HTTP.new(uri.host, uri.port) https.use_ssl=true https.verify_mode = OpenSSL::SSL::VERIFY_NONE req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'}) req.basic_auth sk_login, sk_password request_message = { "phone_number": msisdn, "extra_id": "4232j4h89932kjhs", "callback_url": callback_url, #"start_time": "2019-08-16 09:59:10", "tag": "Dabrab_custom_api_1", "channels": [ "sms" ], "channel_options": { "sms": { "text": text, "alpha_name": alphaname, "ttl": 600 } } } p request_message req.body = request_message.to_json p req.body p req res = https.request(req) p res.body p res.code end def sk_send_viber(msisdn, callback_url, text) uri = URI(sk_url) #8 - client id https = Net::HTTP.new(uri.host, uri.port) https.use_ssl=true https.verify_mode = OpenSSL::SSL::VERIFY_NONE req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'}) req.basic_auth sk_login, sk_password request_message = { "phone_number": msisdn, "extra_id": "4232j4h89932kjhs", "callback_url": callback_url, #"start_time": "2019-08-16 09:59:10", "tag": "Dabrab_custom_api_1", "channels": [ "viber" ], "channel_options": { "viber": { "text": text, "ttl": 60, # "img": "http://olddogs.org/logo.png", # "caption": "Old Dogs need you!", # "action": "http://olddogs.org", }, } } p request_message req.body = request_message.to_json p req.body p req res = https.request(req) p res.body p res.code end def sk_send_viber_sms(msisdn, callback_url, sms_text, viber_txt, alphaname) uri = URI(sk_url) #8 - client id https = Net::HTTP.new(uri.host, uri.port) https.use_ssl=true https.verify_mode = OpenSSL::SSL::VERIFY_NONE req = Net::HTTP::Post.new(uri.path, initheader = {:"Content-Type" => 'application/json'}) req.basic_auth sk_login, sk_password request_message = { "phone_number": msisdn, "extra_id": "4232j4h89932kjhs", "callback_url": callback_url, #"start_time": "2019-08-16 09:59:10", "tag": "Dabrab_custom_api_1", "channels": [ "viber", "sms" ], "channel_options": { "sms": { "text": sms_text, "alpha_name": alphaname, "ttl": 600 }, "viber": { "text": viber_txt, "ttl": 60, # "img": "http://olddogs.org/logo.png", # "caption": "Old Dogs need you!", # "action": "http://olddogs.org", }, } } p request_message req.body = request_message.to_json p req.body p req res = https.request(req) p res.body p res.code end end