xoxzo-cloudruby 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +29 -1
- data/lib/xoxzo/cloudruby.rb +51 -32
- data/xoxzo-cloudruby.gemspec +1 -1
- metadata +16 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cea386f4bede872b81a09952b122c1c6508546f
|
4
|
+
data.tar.gz: cf75e74653ae4ded88d73fca7412aaeef7b816fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2188d1ded294cc709cf1a9546a3583dfd31d3b374a57dc3237400452c61eed648616f854a408c91901a2615eaba592fb2c00d0509d184acc1bc5499e447dffb0
|
7
|
+
data.tar.gz: d76142785560a6e074ca2d4712072352393e08e4d60c8a874d8c7b0a2273320a7d480f4db618b6f0836a3e9f3a0d48b547250eb6a2323c68ecfb4c39940db640
|
data/README.md
CHANGED
@@ -83,9 +83,37 @@ Or install it yourself as:
|
|
83
83
|
|
84
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
85
|
|
86
|
-
|
87
86
|
## Sample Code 3
|
88
87
|
|
88
|
+
### TTS Playback
|
89
|
+
|
90
|
+
sid = ENV['XOXZO_API_SID']
|
91
|
+
token = ENV['XOXZO_API_AUTH_TOKEN']
|
92
|
+
xc = XoxzoClient.new(sid,token)
|
93
|
+
res = xc.call_tts_playback(caller:"810812345678",recipient: "+818012345678",tts_message:"Hello",tts_lang:"en")
|
94
|
+
if res.errors != nil
|
95
|
+
pp res
|
96
|
+
exit -1
|
97
|
+
end
|
98
|
+
|
99
|
+
callid = res.messages[0]['callid']
|
100
|
+
pp xc.get_simple_playback_status(callid: callid)
|
101
|
+
|
102
|
+
#### Explanation
|
103
|
+
|
104
|
+
+ You can call `call_tts_playback()` method to playback TTS message. You need to provide four parameters.
|
105
|
+
|
106
|
+
- caller: this number will be displayed on the recipient device.
|
107
|
+
- tts_message: TTS text message you want to playback.
|
108
|
+
- tts_lang: language code of TTS call.
|
109
|
+
- recipient: phone number of the sms recipient. This must start with Japanese country code "+81" and follow the E.164 format.
|
110
|
+
|
111
|
+
+ 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.
|
112
|
+
|
113
|
+
+ 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.
|
114
|
+
|
115
|
+
## Sample Code 4
|
116
|
+
|
89
117
|
### DIN (Dial in numbers)
|
90
118
|
|
91
119
|
### Get list of available DINs.
|
data/lib/xoxzo/cloudruby.rb
CHANGED
@@ -7,13 +7,13 @@ module Xoxzo
|
|
7
7
|
module Cloudruby
|
8
8
|
|
9
9
|
# Return object class for Xoxzo Cloud API
|
10
|
-
class
|
10
|
+
class XoxzoResponse
|
11
11
|
def initialize(errors: nil, message: Hash.new, messages: [])
|
12
12
|
# error status, nil if no errors
|
13
13
|
@errors = errors
|
14
|
-
# return
|
14
|
+
# return information in hash
|
15
15
|
@message = message
|
16
|
-
#
|
16
|
+
# return information in array
|
17
17
|
@messages = messages
|
18
18
|
end
|
19
19
|
attr_accessor :errors,:message,:messages
|
@@ -24,7 +24,7 @@ module Xoxzo
|
|
24
24
|
# initialize xoxzo api client
|
25
25
|
# sid :: your api sid of Xoxzo account
|
26
26
|
# token :: your api token of Xoxzo account
|
27
|
-
#
|
27
|
+
# return :: XoxzoResponse
|
28
28
|
def initialize(sid,token)
|
29
29
|
@auth = {:username => sid, :password => token}
|
30
30
|
api_host = "https://api.xoxzo.com"
|
@@ -37,7 +37,7 @@ module Xoxzo
|
|
37
37
|
# messages :: sms text message
|
38
38
|
# recipient :: sms recipient phone numner eg. "+818012345678", remove first 0 in front of area number
|
39
39
|
# sender :: sem sender phone number. This value may not be displayed as is for some operators.
|
40
|
-
#
|
40
|
+
# return :: XoxzoResponse
|
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,
|
@@ -45,30 +45,30 @@ module Xoxzo
|
|
45
45
|
#:debug_output => $stdout,
|
46
46
|
:headers => { 'Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json'})
|
47
47
|
if res.code == 201
|
48
|
-
xr =
|
48
|
+
xr = XoxzoResponse.new(messages: json_safe_parse(res.body))
|
49
49
|
else
|
50
|
-
xr =
|
50
|
+
xr = XoxzoResponse.new(errors: res.code,message: json_safe_parse(res.body))
|
51
51
|
end
|
52
52
|
return xr
|
53
53
|
end
|
54
54
|
|
55
55
|
# get sms delivery status method
|
56
56
|
# msgid :: message id of in the return value of the send_sms method.
|
57
|
-
#
|
57
|
+
# return :: XoxzoResponse
|
58
58
|
def get_sms_delivery_status(msgid:)
|
59
59
|
url = @xoxzo_api_sms_url + msgid
|
60
60
|
res = HTTParty.get(url, :basic_auth => @auth)
|
61
61
|
if res.code == 200
|
62
|
-
xr =
|
62
|
+
xr = XoxzoResponse.new(message: json_safe_parse(res.body))
|
63
63
|
else
|
64
|
-
xr =
|
64
|
+
xr = XoxzoResponse.new(errors: res.code,message: json_safe_parse(res.body))
|
65
65
|
end
|
66
66
|
return xr
|
67
67
|
end
|
68
68
|
|
69
69
|
# get setn sms list method
|
70
70
|
# send_data :: query string. eg. "=2016-05-18"
|
71
|
-
#
|
71
|
+
# return :: XoxzoResponse
|
72
72
|
def get_sent_sms_list(sent_date: nil)
|
73
73
|
if sent_date == nil
|
74
74
|
url = @xoxzo_api_sms_url
|
@@ -77,41 +77,60 @@ module Xoxzo
|
|
77
77
|
end
|
78
78
|
res = HTTParty.get(url, :basic_auth => @auth)
|
79
79
|
if res.code == 200
|
80
|
-
xr =
|
80
|
+
xr = XoxzoResponse.new(messages: json_safe_parse(res.body))
|
81
81
|
else
|
82
|
-
xr =
|
82
|
+
xr = XoxzoResponse.new(errors: res.code, message: json_safe_parse(res.body))
|
83
83
|
end
|
84
84
|
return xr
|
85
85
|
end
|
86
86
|
|
87
|
-
# call simple
|
87
|
+
# call simple playback method
|
88
88
|
# caller :: caller phone number displayed on the recipient hand set
|
89
|
-
# recipient :: sms recipient phone
|
89
|
+
# recipient :: sms recipient phone number eg. "+818012345678", remove first 0 in front of area number
|
90
90
|
# recording_url :: URL of the mp3 file to playback. eg. "http://example.com/example.mp3"
|
91
|
-
#
|
91
|
+
# return :: XoxzoResponse
|
92
92
|
def call_simple_playback(caller:, recipient:, recording_url:)
|
93
93
|
body = {"caller" => caller , "recipient" => recipient , "recording_url" => recording_url}
|
94
94
|
res = HTTParty.post(@xoxzo_api_voice_simple_url, :basic_auth => @auth,
|
95
95
|
:body => body,
|
96
96
|
:headers => { 'Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json'})
|
97
97
|
if res.code == 201
|
98
|
-
xr =
|
98
|
+
xr = XoxzoResponse.new(messages: json_safe_parse(res.body))
|
99
|
+
else
|
100
|
+
xr = XoxzoResponse.new(errors: res.code,message: json_safe_parse(res.body))
|
101
|
+
end
|
102
|
+
return xr
|
103
|
+
end
|
104
|
+
|
105
|
+
# call TTS playback method
|
106
|
+
# caller :: caller phone number displayed on the recipient hand set
|
107
|
+
# recipient :: sms recipient phone number eg. "+818012345678", remove first 0 in front of area number
|
108
|
+
# tts_message :: TTS text message you want to playback. eg. "Hello"
|
109
|
+
# tts_lang :: language code of TTS call. eg. "en"
|
110
|
+
# return :: XoxzoResponse
|
111
|
+
def call_tts_playback(caller:, recipient:, tts_message:, tts_lang:)
|
112
|
+
body = {"caller" => caller , "recipient" => recipient , "tts_message" => tts_message , "tts_lang" => tts_lang}
|
113
|
+
res = HTTParty.post(@xoxzo_api_voice_simple_url, :basic_auth => @auth,
|
114
|
+
:body => body,
|
115
|
+
:headers => { 'Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json'})
|
116
|
+
if res.code == 201
|
117
|
+
xr = XoxzoResponse.new(messages: json_safe_parse(res.body))
|
99
118
|
else
|
100
|
-
xr =
|
119
|
+
xr = XoxzoResponse.new(errors: res.code,message: json_safe_parse(res.body))
|
101
120
|
end
|
102
121
|
return xr
|
103
122
|
end
|
104
123
|
|
105
|
-
# get simple
|
124
|
+
# get simple playback status method
|
106
125
|
# callid :: call id in the return value of the call_simple_playback method
|
107
|
-
#
|
126
|
+
# return :: XoxzoResponse
|
108
127
|
def get_simple_playback_status(callid:)
|
109
128
|
url = @xoxzo_api_voice_simple_url + callid
|
110
129
|
res = HTTParty.get(url, :basic_auth => @auth)
|
111
130
|
if res.code == 200
|
112
|
-
xr =
|
131
|
+
xr = XoxzoResponse.new(message: json_safe_parse(res.body))
|
113
132
|
else
|
114
|
-
xr =
|
133
|
+
xr = XoxzoResponse.new(errors: res.code,message: json_safe_parse(res.body))
|
115
134
|
end
|
116
135
|
return xr
|
117
136
|
end
|
@@ -124,9 +143,9 @@ module Xoxzo
|
|
124
143
|
end
|
125
144
|
res = HTTParty.get(url, :basic_auth => @auth)
|
126
145
|
if res.code == 200
|
127
|
-
xr =
|
146
|
+
xr = XoxzoResponse.new(message: json_safe_parse(res.body))
|
128
147
|
else
|
129
|
-
xr =
|
148
|
+
xr = XoxzoResponse.new(errors: res.code,message: json_safe_parse(res.body))
|
130
149
|
end
|
131
150
|
return xr
|
132
151
|
end
|
@@ -138,9 +157,9 @@ module Xoxzo
|
|
138
157
|
:body => body,
|
139
158
|
:headers => { 'Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json'})
|
140
159
|
if res.code == 201
|
141
|
-
xr =
|
160
|
+
xr = XoxzoResponse.new(messages: json_safe_parse(res.body))
|
142
161
|
else
|
143
|
-
xr =
|
162
|
+
xr = XoxzoResponse.new(errors: res.code,message: json_safe_parse(res.body))
|
144
163
|
end
|
145
164
|
return xr
|
146
165
|
end
|
@@ -149,9 +168,9 @@ module Xoxzo
|
|
149
168
|
url = @xoxzo_api_dins_url + 'subscriptions/' + din_uid + '/'
|
150
169
|
res = HTTParty.delete(url, :basic_auth => @auth)
|
151
170
|
if res.code == 200
|
152
|
-
xr =
|
171
|
+
xr = XoxzoResponse.new(messages: json_safe_parse(res.body))
|
153
172
|
else
|
154
|
-
xr =
|
173
|
+
xr = XoxzoResponse.new(errors: res.code,message: json_safe_parse(res.body))
|
155
174
|
end
|
156
175
|
return xr
|
157
176
|
end
|
@@ -160,9 +179,9 @@ module Xoxzo
|
|
160
179
|
url = @xoxzo_api_dins_url + 'subscriptions/'
|
161
180
|
res = HTTParty.get(url, :basic_auth => @auth)
|
162
181
|
if res.code == 200
|
163
|
-
xr =
|
182
|
+
xr = XoxzoResponse.new(messages: json_safe_parse(res.body))
|
164
183
|
else
|
165
|
-
xr =
|
184
|
+
xr = XoxzoResponse.new(errors: res.code,message: json_safe_parse(res.body))
|
166
185
|
end
|
167
186
|
return xr
|
168
187
|
end
|
@@ -174,9 +193,9 @@ module Xoxzo
|
|
174
193
|
:body => body,
|
175
194
|
:headers => { 'Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json'})
|
176
195
|
if res.code == 200
|
177
|
-
xr =
|
196
|
+
xr = XoxzoResponse.new(messages: json_safe_parse(res.body))
|
178
197
|
else
|
179
|
-
xr =
|
198
|
+
xr = XoxzoResponse.new(errors: res.code,message: json_safe_parse(res.body))
|
180
199
|
end
|
181
200
|
return xr
|
182
201
|
end
|
data/xoxzo-cloudruby.gemspec
CHANGED
@@ -5,7 +5,7 @@ require 'xoxzo/cloudruby/version'
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "xoxzo-cloudruby"
|
8
|
-
spec.version =
|
8
|
+
spec.version = "0.4.0"
|
9
9
|
spec.authors = ["Akira Nonaka"]
|
10
10
|
spec.email = ["akira@xoxzo.com"]
|
11
11
|
spec.licenses = ['MIT']
|
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xoxzo-cloudruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.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:
|
11
|
+
date: 2017-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.13.7
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.13.7
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.11'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.11'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '10.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '10.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '3.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.0'
|
69
69
|
description: Xoxzo telephony API library in Ruby. Pleae look http://docs.xoxzo.com/en/
|
@@ -74,9 +74,9 @@ executables: []
|
|
74
74
|
extensions: []
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
|
-
-
|
78
|
-
-
|
79
|
-
-
|
77
|
+
- .gitignore
|
78
|
+
- .rspec
|
79
|
+
- .travis.yml
|
80
80
|
- Gemfile
|
81
81
|
- LICENSE
|
82
82
|
- Makefile
|
@@ -98,19 +98,18 @@ require_paths:
|
|
98
98
|
- lib
|
99
99
|
required_ruby_version: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - '>='
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
105
|
requirements:
|
106
|
-
- -
|
106
|
+
- - '>='
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: '0'
|
109
109
|
requirements: []
|
110
110
|
rubyforge_project:
|
111
|
-
rubygems_version: 2.
|
111
|
+
rubygems_version: 2.6.10
|
112
112
|
signing_key:
|
113
113
|
specification_version: 4
|
114
114
|
summary: Xoxzo telephony API library
|
115
115
|
test_files: []
|
116
|
-
has_rdoc:
|