hoiio 1.0.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.
@@ -0,0 +1,49 @@
1
+ #Copyright (C) 2012 Hoiio Pte Ltd (http://www.hoiio.com)
2
+ #
3
+ #Permission is hereby granted, free of charge, to any person
4
+ #obtaining a copy of this software and associated documentation
5
+ #files (the "Software"), to deal in the Software without
6
+ #restriction, including without limitation the rights to use,
7
+ # copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ #copies of the Software, and to permit persons to whom the
9
+ #Software is furnished to do so, subject to the following
10
+ #conditions:
11
+ #
12
+ #The above copyright notice and this permission notice shall be
13
+ #included in all copies or substantial portions of the Software.
14
+ #
15
+ #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ #EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ #OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ #NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ #HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ #WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ #FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ #OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
25
+ require 'hoiio-ruby'
26
+ require 'fakeweb'
27
+ require 'json'
28
+
29
+ FakeWeb.allow_net_connect = false
30
+
31
+ APP_ID='test'
32
+ ACCESS_TOKEN='test'
33
+ TEST_PHONE='+6511233123'
34
+ SUCCESS = "success_ok"
35
+ CLIENT = Hoiio::Client.new APP_ID, ACCESS_TOKEN
36
+
37
+
38
+ def check_status(response)
39
+ response['status'].should == SUCCESS
40
+ end
41
+
42
+ def check_txn_ref(response)
43
+ response['txn_ref'].should_not be_nil
44
+ end
45
+
46
+ def construct_fakeweb_uri(path)
47
+ @base_uri = "https://secure.hoiio.com/open"
48
+ @base_uri << path
49
+ end
@@ -0,0 +1,50 @@
1
+ #Copyright (C) 2012 Hoiio Pte Ltd (http://www.hoiio.com)
2
+ #
3
+ #Permission is hereby granted, free of charge, to any person
4
+ #obtaining a copy of this software and associated documentation
5
+ #files (the "Software"), to deal in the Software without
6
+ #restriction, including without limitation the rights to use,
7
+ # copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ #copies of the Software, and to permit persons to whom the
9
+ #Software is furnished to do so, subject to the following
10
+ #conditions:
11
+ #
12
+ #The above copyright notice and this permission notice shall be
13
+ #included in all copies or substantial portions of the Software.
14
+ #
15
+ #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ #EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ #OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ #NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ #HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ #WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ #FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ #OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ require 'spec_helper'
25
+
26
+ USER_GET_BALANCE_RESPONSE = {:status => SUCCESS, :balance => "10.03", :currency => "SGD"}
27
+ USER_GET_INFO_RESPONSE = {:status => SUCCESS, :uid => "AA-1", :name => "Steve", :country => "SG"}
28
+
29
+ FakeWeb.register_uri :post, construct_fakeweb_uri("/user/get_balance"), :body => USER_GET_BALANCE_RESPONSE.to_json
30
+ FakeWeb.register_uri :post, construct_fakeweb_uri("/user/get_info"), :body => USER_GET_INFO_RESPONSE.to_json
31
+
32
+
33
+ describe Hoiio::User do
34
+
35
+ it 'should retrieve user balance' do
36
+ response = CLIENT.user.get_balance
37
+ check_status response
38
+ response["currency"].should == "SGD"
39
+ response["balance"].should == "10.03"
40
+ end
41
+
42
+ it 'should retrieve user basic info' do
43
+ response = CLIENT.user.get_info
44
+ check_status response
45
+ response["uid"].should == "AA-1"
46
+ response["name"].should == "Steve"
47
+ response["country"].should == "SG"
48
+ end
49
+
50
+ end
@@ -0,0 +1,80 @@
1
+ #Copyright (C) 2012 Hoiio Pte Ltd (http://www.hoiio.com)
2
+ #
3
+ #Permission is hereby granted, free of charge, to any person
4
+ #obtaining a copy of this software and associated documentation
5
+ #files (the "Software"), to deal in the Software without
6
+ #restriction, including without limitation the rights to use,
7
+ # copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ #copies of the Software, and to permit persons to whom the
9
+ #Software is furnished to do so, subject to the following
10
+ #conditions:
11
+ #
12
+ #The above copyright notice and this permission notice shall be
13
+ #included in all copies or substantial portions of the Software.
14
+ #
15
+ #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ #EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ #OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ #NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ #HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ #WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ #FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ #OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ require 'spec_helper'
25
+
26
+ VOICE_CALL_RESPONSE = {:status => SUCCESS, :txn_ref => "test-1"}
27
+ VOICE_CONFERENCE_RESPONSE = {:status => SUCCESS, :txn_ref => "test-1"}
28
+ VOICE_HANGUP_RESPONSE = {:status => SUCCESS}
29
+ VOICE_GET_HISTORY_RESPONSE = {:status => SUCCESS, :entries_count => "1"}
30
+ VOICE_GET_RATE_RESPONSE = {:status => SUCCESS, :rate => "0.03", :currency => "SGD"}
31
+ VOICE_QUERY_STATUS_RESPONSE = {:status => SUCCESS, :call_status_dest1 => "answered", :currency => "SGD"}
32
+
33
+ FakeWeb.register_uri :post, construct_fakeweb_uri("/voice/call"), :body => VOICE_CALL_RESPONSE.to_json
34
+ FakeWeb.register_uri :post, construct_fakeweb_uri("/voice/conference"), :body => VOICE_CONFERENCE_RESPONSE.to_json
35
+ FakeWeb.register_uri :post, construct_fakeweb_uri("/voice/hangup"), :body => VOICE_HANGUP_RESPONSE.to_json
36
+ FakeWeb.register_uri :post, construct_fakeweb_uri("/voice/get_history"), :body => VOICE_GET_HISTORY_RESPONSE.to_json
37
+ FakeWeb.register_uri :post, construct_fakeweb_uri("/voice/get_rate"), :body => VOICE_GET_RATE_RESPONSE.to_json
38
+ FakeWeb.register_uri :post, construct_fakeweb_uri("/voice/query_status"), :body => VOICE_QUERY_STATUS_RESPONSE.to_json
39
+
40
+
41
+ describe Hoiio::Voice do
42
+
43
+ it 'should make a call and return txn_ref' do
44
+ response = CLIENT.voice.call({:dest2 => TEST_PHONE})
45
+ check_status response
46
+ check_txn_ref response
47
+ end
48
+
49
+ it 'should set up conference call' do
50
+ response = CLIENT.voice.conference({:dest => TEST_PHONE})
51
+ check_status response
52
+ check_txn_ref response
53
+ end
54
+
55
+ it 'should hang up a call' do
56
+ response = CLIENT.voice.hangup({:txn_ref => "test"})
57
+ check_status response
58
+ end
59
+
60
+ it 'should return history' do
61
+ response = CLIENT.voice.get_history
62
+ check_status response
63
+ response['entries_count'].should == "1"
64
+ end
65
+
66
+ it 'should return call rate' do
67
+ response = CLIENT.voice.get_rate({:dest1 => "+1231231", :dest2 => "+23123132"})
68
+ check_status response
69
+ response["currency"].should == "SGD"
70
+ response["rate"].should == "0.03"
71
+ end
72
+
73
+ it 'should query call status' do
74
+ response = CLIENT.voice.query_status({:txn_ref => "test"})
75
+ check_status response
76
+ response["currency"].should == "SGD"
77
+ response["call_status_dest1"].should == "answered"
78
+ end
79
+
80
+ end
metadata ADDED
@@ -0,0 +1,167 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hoiio
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Steve Van
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: json
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>'
20
+ - !ruby/object:Gem::Version
21
+ version: 1.4.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>'
28
+ - !ruby/object:Gem::Version
29
+ version: 1.4.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: httparty
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>'
36
+ - !ruby/object:Gem::Version
37
+ version: 0.6.0
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>'
44
+ - !ruby/object:Gem::Version
45
+ version: 0.6.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 0.9.0
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.9.0
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 2.6.0
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 2.6.0
78
+ - !ruby/object:Gem::Dependency
79
+ name: fakeweb
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 1.3.0
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 1.3.0
94
+ description: This is an SDK for Hoiio API, a set of telephony API that integrate telephony
95
+ services - phone calls, conference, IVR (Interactive Voice Responses), Fax and SMS
96
+ - into your services and website easily.
97
+ email:
98
+ - stevevan@hoiio.com
99
+ executables: []
100
+ extensions: []
101
+ extra_rdoc_files:
102
+ - README.md
103
+ - LICENSE.txt
104
+ files:
105
+ - lib/hoiio-ruby.rb
106
+ - lib/hoiio-ruby/api/fax.rb
107
+ - lib/hoiio-ruby/api/ivr.rb
108
+ - lib/hoiio-ruby/api/ivr/end.rb
109
+ - lib/hoiio-ruby/api/ivr/middle.rb
110
+ - lib/hoiio-ruby/api/ivr/start.rb
111
+ - lib/hoiio-ruby/api/number.rb
112
+ - lib/hoiio-ruby/api/sms.rb
113
+ - lib/hoiio-ruby/api/user.rb
114
+ - lib/hoiio-ruby/api/voice.rb
115
+ - lib/hoiio-ruby/client.rb
116
+ - lib/hoiio-ruby/errors.rb
117
+ - lib/hoiio-ruby/request.rb
118
+ - lib/hoiio-ruby/util/request_util.rb
119
+ - lib/hoiio-ruby/util/response_util.rb
120
+ - lib/hoiio-ruby/version/version.rb
121
+ - README.md
122
+ - LICENSE.txt
123
+ - spec/fax_spec.rb
124
+ - spec/ivr_spec.rb
125
+ - spec/number_spec.rb
126
+ - spec/sms_spec.rb
127
+ - spec/spec_helper.rb
128
+ - spec/user_spec.rb
129
+ - spec/voice_spec.rb
130
+ homepage: https://github.com/icarusK/hoiio-ruby
131
+ licenses: []
132
+ post_install_message:
133
+ rdoc_options:
134
+ - --line-numbers
135
+ - --inline-source
136
+ - --title
137
+ - hoiio-ruby
138
+ - --main
139
+ - README.md
140
+ require_paths:
141
+ - lib
142
+ required_ruby_version: !ruby/object:Gem::Requirement
143
+ none: false
144
+ requirements:
145
+ - - ! '>='
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ required_rubygems_version: !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirements:
151
+ - - ! '>='
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ requirements: []
155
+ rubyforge_project:
156
+ rubygems_version: 1.8.24
157
+ signing_key:
158
+ specification_version: 3
159
+ summary: Hoiio SDK for Ruby
160
+ test_files:
161
+ - spec/fax_spec.rb
162
+ - spec/ivr_spec.rb
163
+ - spec/number_spec.rb
164
+ - spec/sms_spec.rb
165
+ - spec/spec_helper.rb
166
+ - spec/user_spec.rb
167
+ - spec/voice_spec.rb