Class: Xoxzo::Cloudruby::XoxzoClient
- Inherits:
-
Object
- Object
- Xoxzo::Cloudruby::XoxzoClient
- Defined in:
- lib/xoxzo/cloudruby.rb
Overview
API obejet class Xoxzo service
Instance Method Summary collapse
-
#call_simple_playback(caller:, recipient:, recording_url:) ⇒ Object
- call simple palyback method caller
- caller phone number displayed on the recipient hand set recipient
-
sms recipient phone numner eg.
- #get_din_list(search_string: nil) ⇒ Object
-
#get_sent_sms_list(sent_date: nil) ⇒ Object
- get setn sms list method send_data
-
query string.
-
#get_simple_playback_status(callid:) ⇒ Object
- get simple plaback status method callid
- call id in the return value of the call_simple_playback method retrun
-
XoxzoRespose.
-
#get_sms_delivery_status(msgid:) ⇒ Object
- get sms delivery status method msgid
-
message id of in the return value of the send_sms method.
- #get_subscription_list ⇒ Object
-
#initialize(sid, token) ⇒ XoxzoClient
constructor
- initialize xoxzo api client sid
- your api sid of Xoxzo account token
- your api token of Xoxzo account retrun
-
XoxzoRespose.
-
#send_sms(message:, recipient:, sender:) ⇒ Object
- send sms method messages
- sms text message recipient
-
sms recipient phone numner eg.
- #set_action_url(din_uid:, action_url:) ⇒ Object
- #subscribe_din(din_uid:) ⇒ Object
- #unsubscribe_din(din_uid:) ⇒ Object
Constructor Details
#initialize(sid, token) ⇒ XoxzoClient
initialize xoxzo api client
- sid
-
your api sid of Xoxzo account
- token
-
your api token of Xoxzo account
- retrun
-
XoxzoRespose
28 29 30 31 32 33 34 |
# File 'lib/xoxzo/cloudruby.rb', line 28 def initialize(sid,token) @auth = {:username => sid, :password => token} api_host = "https://api.xoxzo.com" @xoxzo_api_sms_url = api_host + "/sms/messages/" @xoxzo_api_voice_simple_url = api_host + "/voice/simple/playback/" @xoxzo_api_dins_url = api_host + "/voice/dins/" end |
Instance Method Details
#call_simple_playback(caller:, recipient:, recording_url:) ⇒ Object
call simple palyback method
- caller
-
caller phone number displayed on the recipient hand set
- recipient
-
sms recipient phone numner eg. “+818012345678”, remove first 0 in front of area number
- recording_url
-
URL of the mp3 file to playback. eg. “example.com/example.mp3”
- retrun
-
XoxzoRespose
92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/xoxzo/cloudruby.rb', line 92 def call_simple_playback(caller:, recipient:, recording_url:) body = {"caller" => caller , "recipient" => recipient , "recording_url" => recording_url} res = HTTParty.post(@xoxzo_api_voice_simple_url, :basic_auth => @auth, :body => body, :headers => { 'Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json'}) if res.code == 201 xr = XoxzoRespose.new(messages: json_safe_parse(res.body)) else xr = XoxzoRespose.new(errors: res.code,message: json_safe_parse(res.body)) end return xr end |
#get_din_list(search_string: nil) ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/xoxzo/cloudruby.rb', line 119 def get_din_list(search_string: nil) if search_string == nil url = @xoxzo_api_dins_url else url = @xoxzo_api_dins_url + '?' + search_string end res = HTTParty.get(url, :basic_auth => @auth) if res.code == 200 xr = XoxzoRespose.new(message: json_safe_parse(res.body)) else xr = XoxzoRespose.new(errors: res.code,message: json_safe_parse(res.body)) end return xr end |
#get_sent_sms_list(sent_date: nil) ⇒ Object
get setn sms list method
- send_data
-
query string. eg. “=2016-05-18”
- retrun
-
XoxzoRespose
72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/xoxzo/cloudruby.rb', line 72 def get_sent_sms_list(sent_date: nil) if sent_date == nil url = @xoxzo_api_sms_url else url = @xoxzo_api_sms_url + "?sent_date" + sent_date end res = HTTParty.get(url, :basic_auth => @auth) if res.code == 200 xr = XoxzoRespose.new(messages: json_safe_parse(res.body)) else xr = XoxzoRespose.new(errors: res.code, message: json_safe_parse(res.body)) end return xr end |
#get_simple_playback_status(callid:) ⇒ Object
get simple plaback status method
- callid
-
call id in the return value of the call_simple_playback method
- retrun
-
XoxzoRespose
108 109 110 111 112 113 114 115 116 117 |
# File 'lib/xoxzo/cloudruby.rb', line 108 def get_simple_playback_status(callid:) url = @xoxzo_api_voice_simple_url + callid res = HTTParty.get(url, :basic_auth => @auth) if res.code == 200 xr = XoxzoRespose.new(message: json_safe_parse(res.body)) else xr = XoxzoRespose.new(errors: res.code,message: json_safe_parse(res.body)) end return xr end |
#get_sms_delivery_status(msgid:) ⇒ Object
get sms delivery status method
- msgid
-
message id of in the return value of the send_sms method.
- retrun
-
XoxzoRespose
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/xoxzo/cloudruby.rb', line 58 def get_sms_delivery_status(msgid:) url = @xoxzo_api_sms_url + msgid res = HTTParty.get(url, :basic_auth => @auth) if res.code == 200 xr = XoxzoRespose.new(message: json_safe_parse(res.body)) else xr = XoxzoRespose.new(errors: res.code,message: json_safe_parse(res.body)) end return xr end |
#get_subscription_list ⇒ Object
159 160 161 162 163 164 165 166 167 168 |
# File 'lib/xoxzo/cloudruby.rb', line 159 def get_subscription_list() url = @xoxzo_api_dins_url + 'subscriptions/' res = HTTParty.get(url, :basic_auth => @auth) if res.code == 200 xr = XoxzoRespose.new(messages: json_safe_parse(res.body)) else xr = XoxzoRespose.new(errors: res.code,message: json_safe_parse(res.body)) end return xr end |
#send_sms(message:, recipient:, sender:) ⇒ Object
send sms method
- messages
-
sms text message
- recipient
-
sms recipient phone numner eg. “+818012345678”, remove first 0 in front of area number
- sender
-
sem sender phone number. This value may not be displayed as is for some operators.
- retrun
-
XoxzoRespose
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/xoxzo/cloudruby.rb', line 41 def send_sms(message:, recipient:, sender:) body = {"message" => , "recipient" => recipient , "sender" => sender} res = HTTParty.post(@xoxzo_api_sms_url, :basic_auth => @auth, :body => body, #:debug_output => $stdout, :headers => { 'Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json'}) if res.code == 201 xr = XoxzoRespose.new(messages: json_safe_parse(res.body)) else xr = XoxzoRespose.new(errors: res.code,message: json_safe_parse(res.body)) end return xr end |
#set_action_url(din_uid:, action_url:) ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/xoxzo/cloudruby.rb', line 170 def set_action_url(din_uid:, action_url:) url = @xoxzo_api_dins_url + 'subscriptions/' + din_uid + '/' body = {'action_url': action_url} res = HTTParty.post(url, :basic_auth => @auth, :body => body, :headers => { 'Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json'}) if res.code == 200 xr = XoxzoRespose.new(messages: json_safe_parse(res.body)) else xr = XoxzoRespose.new(errors: res.code,message: json_safe_parse(res.body)) end return xr end |
#subscribe_din(din_uid:) ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/xoxzo/cloudruby.rb', line 134 def subscribe_din(din_uid:) url = @xoxzo_api_dins_url + 'subscriptions/' body = {"din_uid" => din_uid } res = HTTParty.post(url, :basic_auth => @auth, :body => body, :headers => { 'Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json'}) if res.code == 201 xr = XoxzoRespose.new(messages: json_safe_parse(res.body)) else xr = XoxzoRespose.new(errors: res.code,message: json_safe_parse(res.body)) end return xr end |
#unsubscribe_din(din_uid:) ⇒ Object
148 149 150 151 152 153 154 155 156 157 |
# File 'lib/xoxzo/cloudruby.rb', line 148 def unsubscribe_din(din_uid:) url = @xoxzo_api_dins_url + 'subscriptions/' + din_uid + '/' res = HTTParty.delete(url, :basic_auth => @auth) if res.code == 200 xr = XoxzoRespose.new(messages: json_safe_parse(res.body)) else xr = XoxzoRespose.new(errors: res.code,message: json_safe_parse(res.body)) end return xr end |