xoxzo-cloudruby 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20b8dbe6b4b4c792c3eb918b2283e60401b275f8
4
- data.tar.gz: 08fdea29480d7914e54148bb89ddf75e70ca966c
3
+ metadata.gz: 594c617a8a9834f06f819038c718dcfce60b9687
4
+ data.tar.gz: 72b022af8779a53992421034a46cdf4224dd75ad
5
5
  SHA512:
6
- metadata.gz: 20fc3388a54f6d939ed36e81063f8e12a3ca614165faf2328e701d6743e615a8e35248cacfa6f482e4c70db70e1e5283ae9b0233859b481568d9e099d57bfed1
7
- data.tar.gz: a2b3a224464805ceabc3ed8ffb96527e696a9d88db70b568b00853f6ead4fadd0adcbb7c7eb44dc5103de331fae3a24d8a53fba45f0b934a9b6da5725f92ad9c
6
+ metadata.gz: 3823e61df8fe22310db8e66362d89e7f6dbb9147182ee3d04a953846daea6361a5ae0005fd89950c6b23861351bfddfa179ea571c13a42af5466b1d036b930b2
7
+ data.tar.gz: 1686a9888e6b25498b3e20a46a3d4ad2c11f0c28b7556f5b405bebbf2cef3d0547d725ff1f593d5b3ed6a747848ac6049f4b51da98d73949cdb7d3056750e0d3
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in xoxzo-cloudruby.gemspec
4
4
  gemspec
5
+
6
+ add_runtime_dependency 'httparty', '~> 0.13', '>= 0.13.7'
data/Makefile CHANGED
@@ -1,2 +1,5 @@
1
1
  all:
2
- gem build xoxzo-cloudruby.gemspec
2
+ gem build xoxzo-cloudruby.gemspec
3
+
4
+ release:
5
+ bundle exec rake release
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Xoxzo::Cloudruby
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/xoxzo/cloudruby`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ xoxzo-cloudruby is the API wrapper for Xoxzo telephoney cloud API for Ruby.
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,9 +20,9 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- Sample Code 1
23
+ ## Sample Code 1
26
24
 
27
- Send SMS
25
+ ### Send SMS
28
26
 
29
27
  require 'pp'
30
28
  require 'xoxzo/cloudruby'
@@ -38,10 +36,28 @@ Send SMS
38
36
  pp res
39
37
  exit -1
40
38
  end
39
+
40
+ msgid = res.messages[0]['msgid']
41
+ res = xc.get_sms_delivery_status(msgid: msgid)
42
+ pp res
43
+
44
+ #### Explanation
45
+
46
+ + First, you need to create `XoxzoClient()` object. You must provide xoxzo sid and auth_token when initializing this object. You can get sid and auth_token after you sign up the xoxzo account and access the xoxzo dashboard.
47
+
48
+ + Then you can call `send_sms()` method. You need to provide three parameters.
41
49
 
42
- Sample Code 2
50
+ - message: sms text you want to send.
51
+ - recipient: phone number of the sms recipient. This must start with Japanese country code "+81" and follow the E.164 format.
52
+ - sender: this number will be displayed on the recipient device.
43
53
 
44
- Simple Playback
54
+ + This method will return `XoxzoResponse` object. If `XoxzoResponse.errors == nil`, `XoxzoResponse.messages[0]['msgid']` is the meesage id that you can pass to the `get_sms_delivery_status()` call.
55
+
56
+ + You can check the sms delivery status by `get_sms_delivery_status()` method. You will provide message-id of the sms you want to check.
57
+
58
+ ## Sample Code 2
59
+
60
+ ### Simple Playback
45
61
 
46
62
  sid = ENV['XOXZO_API_SID']
47
63
  token = ENV['XOXZO_API_AUTH_TOKEN']
@@ -55,13 +71,24 @@ Simple Playback
55
71
  callid = res.messages[0]['callid']
56
72
  pp xc.get_simple_playback_status(callid: callid)
57
73
 
58
- msgid = res.messages[0]['msgid']
59
- res = xc.get_sms_delivery_status(msgid: msgid)
60
- pp res
61
-
62
- Sample Code 3
74
+ #### Explanation
75
+
76
+ + You can call `call_simple_playback()` method to playback MP3 files. You need to provide three parameters.
63
77
 
64
- Get list of available DINs.
78
+ - caller: this number will be displayed on the recipient device.
79
+ - recording_url: MP3 file URL.
80
+ - recipient: phone number of the sms recipient. This must start with Japanese country code "+81" and follow the E.164 format.
81
+
82
+ + This method will return `XoxzoResponse` object. If `XoxzoResponse.errors == nil`, `XoxzoResponse.messages[0]['callid']` is the call id that you can pass to the `get_simple_playback_status()` call.
83
+
84
+ + You can check the call status by `get_simple_playback_status()` method. You will provide call-id of the phone call you want to check.
85
+
86
+
87
+ ## Sample Code 3
88
+
89
+ ### DIN (Dial in numbers)
90
+
91
+ ### Get list of available DINs.
65
92
 
66
93
  sid = ENV['XOXZO_API_SID']
67
94
  token = ENV['XOXZO_API_AUTH_TOKEN']
@@ -69,23 +96,44 @@ Get list of available DINs.
69
96
  res = xc.get_din_list()
70
97
  din_uid = res.message[0]['din_uid'] # get the din unique ID for the frist one for expample
71
98
 
72
- Subscribe a DIN.
99
+ #### Explanation
100
+
101
+ 1. In order to subscribe DIN, you must find available unsubscribed DINs using get_din_list() method.
102
+
103
+ ### Subscribe a DIN.
73
104
 
74
105
  res = xc.subscribe_din(din_uid: din_uid)
75
106
 
76
- Set the action url.
107
+ #### Explanation
108
+
109
+ 1. Then you subscribe a DIN via subscribe_din() method specifying din unique id.
110
+
111
+ ### Set the action url.
77
112
 
78
113
  dummy_action_url = 'http://example.com/dummy_action'
79
114
  res = xc.set_action_url(din_uid: din_uid, action_url: dummy_action_url)
80
115
 
81
- Get the list of subscriptions.
116
+ #### Explanation
117
+
118
+ 1. Once you subscribed the DIN, you can set action url to the DIN. This URL will be called in the event of the DIN gets called.
119
+ The URL will called by http GET method with the parameters, caller and recipient.
120
+
121
+ ### Get the list of subscriptions.
82
122
 
83
123
  res = xc.get_subscription_list()
124
+
125
+ #### Explanation
126
+
127
+ 1. In order to get the list of current subscription, you can call the method above.
84
128
 
85
- Unsubscribe the DIN.
129
+ ### Unsubscribe the DIN.
86
130
 
87
131
  res = xc.unsubscribe_din(din_uid: din_uid)
88
132
 
133
+ #### Explanation
134
+
135
+ 1. When you no longer use DIN, you can unsubscribe the DIN by specifying the din unique id.
136
+
89
137
  ## Development
90
138
 
91
139
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -41,8 +41,9 @@ module Xoxzo
41
41
  def send_sms(message:, recipient:, sender:)
42
42
  body = {"message" => message , "recipient" => recipient , "sender" => sender}
43
43
  res = HTTParty.post(@xoxzo_api_sms_url, :basic_auth => @auth,
44
- :body => body.to_json,
45
- :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json'})
44
+ :body => body,
45
+ #:debug_output => $stdout,
46
+ :headers => { 'Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json'})
46
47
  if res.code == 201
47
48
  xr = XoxzoRespose.new(messages: json_safe_parse(res.body))
48
49
  else
@@ -91,8 +92,8 @@ module Xoxzo
91
92
  def call_simple_playback(caller:, recipient:, recording_url:)
92
93
  body = {"caller" => caller , "recipient" => recipient , "recording_url" => recording_url}
93
94
  res = HTTParty.post(@xoxzo_api_voice_simple_url, :basic_auth => @auth,
94
- :body => body.to_json,
95
- :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json'})
95
+ :body => body,
96
+ :headers => { 'Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json'})
96
97
  if res.code == 201
97
98
  xr = XoxzoRespose.new(messages: json_safe_parse(res.body))
98
99
  else
@@ -134,8 +135,8 @@ module Xoxzo
134
135
  url = @xoxzo_api_dins_url + 'subscriptions/'
135
136
  body = {"din_uid" => din_uid }
136
137
  res = HTTParty.post(url, :basic_auth => @auth,
137
- :body => body.to_json,
138
- :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json'})
138
+ :body => body,
139
+ :headers => { 'Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json'})
139
140
  if res.code == 201
140
141
  xr = XoxzoRespose.new(messages: json_safe_parse(res.body))
141
142
  else
@@ -170,8 +171,8 @@ module Xoxzo
170
171
  url = @xoxzo_api_dins_url + 'subscriptions/' + din_uid + '/'
171
172
  body = {'action_url': action_url}
172
173
  res = HTTParty.post(url, :basic_auth => @auth,
173
- :body => body.to_json,
174
- :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json'})
174
+ :body => body,
175
+ :headers => { 'Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json'})
175
176
  if res.code == 200
176
177
  xr = XoxzoRespose.new(messages: json_safe_parse(res.body))
177
178
  else
@@ -1,5 +1,5 @@
1
1
  module Xoxzo
2
2
  module Cloudruby
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xoxzo-cloudruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akira Nonaka
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-20 00:00:00.000000000 Z
11
+ date: 2016-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -113,3 +113,4 @@ signing_key:
113
113
  specification_version: 4
114
114
  summary: Xoxzo telephony API library
115
115
  test_files: []
116
+ has_rdoc: