skebby 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6f807a00dcb5af7ff43aa47fc9c88645e05a1716
4
+ data.tar.gz: e2790316384cceed44ba50c8ba3de1255673daab
5
+ SHA512:
6
+ metadata.gz: 5b646ae265f4786bcdbc7ae0dc00f0f5ff7916b612f23a74011bf56f417bd68181756827f5057e7a9c6c5725b2150b695926f90a98df58caf7af4c0b92bb26eb
7
+ data.tar.gz: 2ac514db022b1a973b60f8f5a5e6ee5298cf9ff259188af55a7091f06c2490eb359437db53ad6b750b1c18fc788146aefe517a2578f7f0bd5283b95bb22c0423
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format Fuubar
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
4
+ - 2.0.0
5
+ - 1.9.3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in skebby.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 InterConn
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,74 @@
1
+ # Skebby ![Build Status](https://travis-ci.org/interconn-wisp/skebby.png?branch=master)](https://travis-ci.org/interconn-wisp/skebby) [![Dependency Status](https://gemnasium.com/interconn-wisp/skebby.png)](https://gemnasium.com/interconn-wisp/skebby) [![Code Climate](https://codeclimate.com/github/interconn-wisp/skebby.png)](https://codeclimate.com/github/interconn-wisp/skebby)
2
+
3
+ This is a Ruby gem providing a wrapper around [Skebby](http://www.skebby.it/) RESTful API.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'skebby'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install skebby
18
+
19
+ ## Usage
20
+
21
+ ### Initialize the client
22
+
23
+ To initialize the API client you only need to provide your credentials:
24
+
25
+ ```ruby
26
+ skebby = Skebby::Client.new(username: 'john.doe', password: 'foobar')
27
+ ```
28
+
29
+ ### Check the remaining credit
30
+
31
+ ```ruby
32
+ skebby.get_credit # { credit_left: 1.61972, classic_sms: 25, basic_sms: 35 }
33
+ ```
34
+
35
+ ### Send an SMS (SMS Classic)
36
+
37
+ ```ruby
38
+ skebby.send_sms_classic(
39
+ recipients: ['393459187391', '393786104981'],
40
+ text: 'Hello, world!'
41
+ ) # { remaining_sms: 5 }
42
+ ```
43
+
44
+ (Note: You can provide other parameters. For more info, check [Skebby's docs](http://www.skebby.it/business/index/send-docs/)).
45
+
46
+ ### Send an SMS (SMS Basic)
47
+
48
+ ```ruby
49
+ skebby.send_sms_basic(
50
+ recipients: ['393459187391', '393786104981'],
51
+ text: 'Hello, world!'
52
+ ) # { remaining_sms: 5 }
53
+ ```
54
+
55
+ (Note: You can provide other parameters. For more info, check [Skebby's docs](http://www.skebby.it/business/index/send-docs/)).
56
+
57
+ ### Send an SMS and request a read-receipt (SMS Classic Plus)
58
+
59
+ ```ruby
60
+ skebby.send_sms_classic_report(
61
+ recipients: ['393459187391', '393786104981'],
62
+ text: 'Hello, world!'
63
+ ) # { remaining_sms: 5, dispatch_id: 1392562134 }
64
+ ```
65
+
66
+ (Note: You can provide other parameters. For more info, check [Skebby's docs](http://www.skebby.it/business/index/send-docs/)).
67
+
68
+ ## Contributing
69
+
70
+ 1. [Fork it](http://github.com/interconn/skebby/fork)
71
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
72
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
73
+ 4. Push to the branch (`git push origin my-new-feature`)
74
+ 5. Create a new Pull Request
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,5 @@
1
+ require 'skebby/version'
2
+ require 'skebby/client'
3
+
4
+ module Skebby
5
+ end
@@ -0,0 +1,88 @@
1
+ require 'httparty'
2
+ require 'json'
3
+ require 'date'
4
+
5
+ module Skebby
6
+ class Client
7
+ include HTTParty
8
+
9
+ BASE_URI = 'https://gateway.skebby.it/api/send/smseasy/advanced'
10
+ REQUIRED_OPTIONS = [:username, :password]
11
+
12
+ base_uri BASE_URI
13
+
14
+ attr_reader :options
15
+
16
+ def initialize(options = {})
17
+ @options = options
18
+ end
19
+
20
+ def get_credit(request_options = {})
21
+ response = get('get_credit')
22
+
23
+ {
24
+ credit_left: response['credit_left'].to_f,
25
+ classic_sms: response['classic_sms'].to_i,
26
+ basic_sms: response['basic_sms'].to_i
27
+ }
28
+ end
29
+
30
+ %w(classic classic_report basic).each do |sms_type|
31
+ define_method("send_sms_#{sms_type}") do |request_options = {}|
32
+ perform_sms_request(sms_type, request_options)
33
+ end
34
+ end
35
+
36
+ protected
37
+
38
+ def perform_sms_request(sms_type, request_options = {})
39
+ type = "send_sms_#{sms_type}"
40
+ type = "test_#{type}" if options[:test_mode]
41
+
42
+ request_options[:recipients] = JSON.generate(request_options[:recipients])
43
+
44
+ if request_options[:delivery_start]
45
+ unless request_options[:delivery_start].is_a?(Date)
46
+ request_options[:delivery_start] = Date.parse(request_options[:delivery_start])
47
+ end
48
+
49
+ request_options[:delivery_start] = request_options[:delivery_start].rfc2822
50
+ end
51
+
52
+ response = post(type, request_options)
53
+
54
+ parsed_response = { remaining_sms: response['remaining_sms'].to_i }
55
+ parsed_response[:dispatch_id] = response['id'].to_i if response['id']
56
+
57
+ parsed_response
58
+ end
59
+
60
+ def get(type, request_options = {})
61
+ perform('get', type, request_options)
62
+ end
63
+
64
+ def post(type, request_options)
65
+ perform('post', type, request_options)
66
+ end
67
+
68
+ def perform(method, type, request_options = {})
69
+ request_options = request_options.merge({
70
+ method: type,
71
+ username: options[:username],
72
+ password: options[:password]
73
+ })
74
+
75
+ response = self.class.send(method, '/rest.php', query: request_options)
76
+
77
+ if response['SkebbyApi_Public_Send_SmsEasy_Advanced']
78
+ response = response['SkebbyApi_Public_Send_SmsEasy_Advanced'][type]
79
+ else
80
+ response = response[type]
81
+ end
82
+
83
+ raise "#{type} request failed! (#{response['response']['message']})" if response['status'] == 'failed'
84
+
85
+ response.delete('status') and response
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,3 @@
1
+ module Skebby
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'skebby/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "skebby"
8
+ spec.version = Skebby::VERSION
9
+ spec.authors = ["Alessandro Desantis"]
10
+ spec.email = ["desa.alessandro@gmail.com"]
11
+ spec.summary = %q{A Ruby client for the Skebby SMS API.}
12
+ spec.description = %q{A Ruby client for the Skebby SMS API.}
13
+ spec.homepage = "https://github.com/interconn/skebby"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "httparty", "~> 0.13"
22
+
23
+ spec.add_development_dependency "webmock", '~> 1.17'
24
+ spec.add_development_dependency "vcr", '~> 2.8'
25
+ spec.add_development_dependency "bundler", '~> 1.5'
26
+ spec.add_development_dependency "rake", '~> 10.1'
27
+ spec.add_development_dependency "rspec", '~> 2.14'
28
+ spec.add_development_dependency "fuubar", '~> 1.3'
29
+ end
@@ -0,0 +1,454 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://gateway.skebby.it/api/send/smseasy/advanced/rest.php?method=get_credit&password=password&username=john.doe
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Date:
16
+ - Sun, 16 Feb 2014 14:15:25 GMT
17
+ Server:
18
+ - Apache
19
+ Vary:
20
+ - Accept-Encoding
21
+ Content-Length:
22
+ - '289'
23
+ Content-Type:
24
+ - text/xml
25
+ body:
26
+ encoding: UTF-8
27
+ string: |
28
+ <?xml version="1.0" encoding="UTF-8"?>
29
+ <SkebbyApi_Public_Send_SmsEasy_Advanced generator="zend" version="1.0"><get_credit><credit_left>1.61972</credit_left><classic_sms>25</classic_sms><basic_sms>35</basic_sms><status>success</status></get_credit></SkebbyApi_Public_Send_SmsEasy_Advanced>
30
+ http_version:
31
+ recorded_at: Sun, 16 Feb 2014 14:15:25 GMT
32
+ - request:
33
+ method: get
34
+ uri: https://gateway.skebby.it/api/send/smseasy/advanced/rest.php?method=get_credit&password=&username=
35
+ body:
36
+ encoding: US-ASCII
37
+ string: ''
38
+ headers: {}
39
+ response:
40
+ status:
41
+ code: 400
42
+ message: Bad Request
43
+ headers:
44
+ Date:
45
+ - Sun, 16 Feb 2014 14:32:05 GMT
46
+ Server:
47
+ - Apache
48
+ Vary:
49
+ - Accept-Encoding
50
+ Content-Length:
51
+ - '287'
52
+ Connection:
53
+ - close
54
+ Content-Type:
55
+ - text/xml
56
+ body:
57
+ encoding: UTF-8
58
+ string: |
59
+ <?xml version="1.0" encoding="UTF-8"?>
60
+ <SkebbyApi_Public_Send_SmsEasy_Advanced generator="zend" version="1.0"><get_credit><response><code>12</code><message>Set all the mandatory parameters</message></response><status>failed</status></get_credit></SkebbyApi_Public_Send_SmsEasy_Advanced>
61
+ http_version:
62
+ recorded_at: Sun, 16 Feb 2014 14:32:05 GMT
63
+ - request:
64
+ method: post
65
+ uri: https://gateway.skebby.it/api/send/smseasy/advanced/rest.php?method=test_send_sms_classic&password=password&username=john.doe
66
+ body:
67
+ encoding: UTF-8
68
+ string: ''
69
+ headers: {}
70
+ response:
71
+ status:
72
+ code: 400
73
+ message: Bad Request
74
+ headers:
75
+ Date:
76
+ - Sun, 16 Feb 2014 14:37:44 GMT
77
+ Server:
78
+ - Apache
79
+ Vary:
80
+ - Accept-Encoding
81
+ Content-Length:
82
+ - '346'
83
+ Connection:
84
+ - close
85
+ Content-Type:
86
+ - text/xml
87
+ body:
88
+ encoding: UTF-8
89
+ string: |
90
+ <?xml version="1.0" encoding="UTF-8"?>
91
+ <SkebbyApi_Public_Send_SmsEasy_Advanced generator="zend" version="1.0"><test_send_sms_classic><response><message>Invalid Method Call to test_send_sms_classic. Missing argument(s): recipients, text.</message></response><status>failed</status></test_send_sms_classic></SkebbyApi_Public_Send_SmsEasy_Advanced>
92
+ http_version:
93
+ recorded_at: Sun, 16 Feb 2014 14:37:44 GMT
94
+ - request:
95
+ method: post
96
+ uri: https://gateway.skebby.it/api/send/smseasy/advanced/rest.php?method=test_send_sms_classic&password=password&recipients%5B0%5D=393459187391&text=Hello,%20world!&username=john.doe
97
+ body:
98
+ encoding: UTF-8
99
+ string: ''
100
+ headers: {}
101
+ response:
102
+ status:
103
+ code: 400
104
+ message: Bad Request
105
+ headers:
106
+ Date:
107
+ - Sun, 16 Feb 2014 14:39:27 GMT
108
+ Server:
109
+ - Apache
110
+ Vary:
111
+ - Accept-Encoding
112
+ Content-Length:
113
+ - '309'
114
+ Connection:
115
+ - close
116
+ Content-Type:
117
+ - text/xml
118
+ body:
119
+ encoding: UTF-8
120
+ string: |
121
+ <?xml version="1.0" encoding="UTF-8"?>
122
+ <SkebbyApi_Public_Send_SmsEasy_Advanced generator="zend" version="1.0"><test_send_sms_classic><response><code>12</code><message>Set all the mandatory parameters</message></response><status>failed</status></test_send_sms_classic></SkebbyApi_Public_Send_SmsEasy_Advanced>
123
+ http_version:
124
+ recorded_at: Sun, 16 Feb 2014 14:39:27 GMT
125
+ - request:
126
+ method: post
127
+ uri: https://gateway.skebby.it/api/send/smseasy/advanced/rest.php?method=test_send_sms_classic&password=password&recipients=%5B%22393459187391%22%5D&text=Hello,%20world!&username=john.doe
128
+ body:
129
+ encoding: UTF-8
130
+ string: ''
131
+ headers: {}
132
+ response:
133
+ status:
134
+ code: 200
135
+ message: OK
136
+ headers:
137
+ Date:
138
+ - Sun, 16 Feb 2014 14:41:41 GMT
139
+ Server:
140
+ - Apache
141
+ Vary:
142
+ - Accept-Encoding
143
+ Content-Length:
144
+ - '255'
145
+ Content-Type:
146
+ - text/xml
147
+ body:
148
+ encoding: UTF-8
149
+ string: |
150
+ <?xml version="1.0" encoding="UTF-8"?>
151
+ <SkebbyApi_Public_Send_SmsEasy_Advanced generator="zend" version="1.0"><test_send_sms_classic><remaining_sms>5</remaining_sms><status>success</status></test_send_sms_classic></SkebbyApi_Public_Send_SmsEasy_Advanced>
152
+ http_version:
153
+ recorded_at: Sun, 16 Feb 2014 14:41:41 GMT
154
+ - request:
155
+ method: post
156
+ uri: https://gateway.skebby.it/api/send/smseasy/advanced/rest.php?method=test_send_sms_basic&password=password&recipients=%5B%22393459187391%22%5D&text=Hello,%20world!&username=john.doe
157
+ body:
158
+ encoding: UTF-8
159
+ string: ''
160
+ headers: {}
161
+ response:
162
+ status:
163
+ code: 200
164
+ message: OK
165
+ headers:
166
+ Date:
167
+ - Sun, 16 Feb 2014 14:45:04 GMT
168
+ Server:
169
+ - Apache
170
+ Vary:
171
+ - Accept-Encoding
172
+ Content-Length:
173
+ - '251'
174
+ Content-Type:
175
+ - text/xml
176
+ body:
177
+ encoding: UTF-8
178
+ string: |
179
+ <?xml version="1.0" encoding="UTF-8"?>
180
+ <SkebbyApi_Public_Send_SmsEasy_Advanced generator="zend" version="1.0"><test_send_sms_basic><remaining_sms>5</remaining_sms><status>success</status></test_send_sms_basic></SkebbyApi_Public_Send_SmsEasy_Advanced>
181
+ http_version:
182
+ recorded_at: Sun, 16 Feb 2014 14:45:04 GMT
183
+ - request:
184
+ method: post
185
+ uri: https://gateway.skebby.it/api/send/smseasy/advanced/rest.php?method=test_send_sms_classic_report&password=password&recipients=%5B%22393459187391%22%5D&text=Hello,%20world!&username=john.doe
186
+ body:
187
+ encoding: UTF-8
188
+ string: ''
189
+ headers: {}
190
+ response:
191
+ status:
192
+ code: 200
193
+ message: OK
194
+ headers:
195
+ Date:
196
+ - Sun, 16 Feb 2014 14:48:25 GMT
197
+ Server:
198
+ - Apache
199
+ Vary:
200
+ - Accept-Encoding
201
+ Content-Length:
202
+ - '288'
203
+ Content-Type:
204
+ - text/xml
205
+ body:
206
+ encoding: UTF-8
207
+ string: |
208
+ <?xml version="1.0" encoding="UTF-8"?>
209
+ <SkebbyApi_Public_Send_SmsEasy_Advanced generator="zend" version="1.0"><test_send_sms_classic_report><remaining_sms>5</remaining_sms><id>1392562105</id><status>success</status></test_send_sms_classic_report></SkebbyApi_Public_Send_SmsEasy_Advanced>
210
+ http_version:
211
+ recorded_at: Sun, 16 Feb 2014 14:48:25 GMT
212
+ - request:
213
+ method: post
214
+ uri: https://gateway.skebby.it/api/send/smseasy/advanced/rest.php?method=test_send_sms_classic&password=password&recipients=%5B%22393459187391%22,%22393786104981%22%5D&text=Hello,%20world!&username=john.doe
215
+ body:
216
+ encoding: UTF-8
217
+ string: ''
218
+ headers: {}
219
+ response:
220
+ status:
221
+ code: 200
222
+ message: OK
223
+ headers:
224
+ Date:
225
+ - Sun, 16 Feb 2014 14:48:53 GMT
226
+ Server:
227
+ - Apache
228
+ Vary:
229
+ - Accept-Encoding
230
+ Content-Length:
231
+ - '255'
232
+ Content-Type:
233
+ - text/xml
234
+ body:
235
+ encoding: UTF-8
236
+ string: |
237
+ <?xml version="1.0" encoding="UTF-8"?>
238
+ <SkebbyApi_Public_Send_SmsEasy_Advanced generator="zend" version="1.0"><test_send_sms_classic><remaining_sms>5</remaining_sms><status>success</status></test_send_sms_classic></SkebbyApi_Public_Send_SmsEasy_Advanced>
239
+ http_version:
240
+ recorded_at: Sun, 16 Feb 2014 14:48:53 GMT
241
+ - request:
242
+ method: post
243
+ uri: https://gateway.skebby.it/api/send/smseasy/advanced/rest.php?method=test_send_sms_classic_report&password=password&recipients=%5B%22393459187391%22,%22393786104981%22%5D&text=Hello,%20world!&username=john.doe
244
+ body:
245
+ encoding: UTF-8
246
+ string: ''
247
+ headers: {}
248
+ response:
249
+ status:
250
+ code: 200
251
+ message: OK
252
+ headers:
253
+ Date:
254
+ - Sun, 16 Feb 2014 14:48:54 GMT
255
+ Server:
256
+ - Apache
257
+ Vary:
258
+ - Accept-Encoding
259
+ Content-Length:
260
+ - '288'
261
+ Content-Type:
262
+ - text/xml
263
+ body:
264
+ encoding: UTF-8
265
+ string: |
266
+ <?xml version="1.0" encoding="UTF-8"?>
267
+ <SkebbyApi_Public_Send_SmsEasy_Advanced generator="zend" version="1.0"><test_send_sms_classic_report><remaining_sms>5</remaining_sms><id>1392562134</id><status>success</status></test_send_sms_classic_report></SkebbyApi_Public_Send_SmsEasy_Advanced>
268
+ http_version:
269
+ recorded_at: Sun, 16 Feb 2014 14:48:54 GMT
270
+ - request:
271
+ method: post
272
+ uri: https://gateway.skebby.it/api/send/smseasy/advanced/rest.php?method=test_send_sms_basic&password=password&recipients=%5B%22393459187391%22,%22393786104981%22%5D&text=Hello,%20world!&username=john.doe
273
+ body:
274
+ encoding: UTF-8
275
+ string: ''
276
+ headers: {}
277
+ response:
278
+ status:
279
+ code: 200
280
+ message: OK
281
+ headers:
282
+ Date:
283
+ - Sun, 16 Feb 2014 14:48:54 GMT
284
+ Server:
285
+ - Apache
286
+ Vary:
287
+ - Accept-Encoding
288
+ Content-Length:
289
+ - '251'
290
+ Content-Type:
291
+ - text/xml
292
+ body:
293
+ encoding: UTF-8
294
+ string: |
295
+ <?xml version="1.0" encoding="UTF-8"?>
296
+ <SkebbyApi_Public_Send_SmsEasy_Advanced generator="zend" version="1.0"><test_send_sms_basic><remaining_sms>5</remaining_sms><status>success</status></test_send_sms_basic></SkebbyApi_Public_Send_SmsEasy_Advanced>
297
+ http_version:
298
+ recorded_at: Sun, 16 Feb 2014 14:48:54 GMT
299
+ - request:
300
+ method: post
301
+ uri: https://gateway.skebby.it/api/send/smseasy/advanced/rest.php?method=sens_sms&password=password&recipients=%5B%22393459187391%22,%22393786104981%22%5D&text=Hello,%20world!&username=john.doe
302
+ body:
303
+ encoding: UTF-8
304
+ string: ''
305
+ headers: {}
306
+ response:
307
+ status:
308
+ code: 400
309
+ message: Bad Request
310
+ headers:
311
+ Date:
312
+ - Sun, 16 Feb 2014 15:03:33 GMT
313
+ Server:
314
+ - Apache
315
+ Vary:
316
+ - Accept-Encoding
317
+ Content-Length:
318
+ - '181'
319
+ Connection:
320
+ - close
321
+ Content-Type:
322
+ - text/xml
323
+ body:
324
+ encoding: UTF-8
325
+ string: |
326
+ <?xml version="1.0" encoding="UTF-8"?>
327
+ <sens_sms generator="zend" version="1.0"><response><message>Unknown Method 'sens_sms'.</message></response><status>failed</status></sens_sms>
328
+ http_version:
329
+ recorded_at: Sun, 16 Feb 2014 15:03:33 GMT
330
+ - request:
331
+ method: post
332
+ uri: https://gateway.skebby.it/api/send/smseasy/advanced/rest.php?method=send_sms&password=password&recipients=%5B%22393459187391%22,%22393786104981%22%5D&text=Hello,%20world!&username=john.doe
333
+ body:
334
+ encoding: UTF-8
335
+ string: ''
336
+ headers: {}
337
+ response:
338
+ status:
339
+ code: 400
340
+ message: Bad Request
341
+ headers:
342
+ Date:
343
+ - Sun, 16 Feb 2014 15:05:26 GMT
344
+ Server:
345
+ - Apache
346
+ Vary:
347
+ - Accept-Encoding
348
+ Content-Length:
349
+ - '181'
350
+ Connection:
351
+ - close
352
+ Content-Type:
353
+ - text/xml
354
+ body:
355
+ encoding: UTF-8
356
+ string: |
357
+ <?xml version="1.0" encoding="UTF-8"?>
358
+ <send_sms generator="zend" version="1.0"><response><message>Unknown Method 'send_sms'.</message></response><status>failed</status></send_sms>
359
+ http_version:
360
+ recorded_at: Sun, 16 Feb 2014 15:05:26 GMT
361
+ - request:
362
+ method: post
363
+ uri: https://gateway.skebby.it/api/send/smseasy/advanced/rest.php?method=test_send_sms_classic_report&password=password&recipients=%5B%22393459187391%22,%22393786104981%22%5D&username=john.doe
364
+ body:
365
+ encoding: UTF-8
366
+ string: ''
367
+ headers: {}
368
+ response:
369
+ status:
370
+ code: 400
371
+ message: Bad Request
372
+ headers:
373
+ Date:
374
+ - Sun, 16 Feb 2014 15:08:14 GMT
375
+ Server:
376
+ - Apache
377
+ Vary:
378
+ - Accept-Encoding
379
+ Content-Length:
380
+ - '355'
381
+ Connection:
382
+ - close
383
+ Content-Type:
384
+ - text/xml
385
+ body:
386
+ encoding: UTF-8
387
+ string: |
388
+ <?xml version="1.0" encoding="UTF-8"?>
389
+ <SkebbyApi_Public_Send_SmsEasy_Advanced generator="zend" version="1.0"><test_send_sms_classic_report><response><message>Invalid Method Call to test_send_sms_classic_report. Missing argument(s): text.</message></response><status>failed</status></test_send_sms_classic_report></SkebbyApi_Public_Send_SmsEasy_Advanced>
390
+ http_version:
391
+ recorded_at: Sun, 16 Feb 2014 15:08:14 GMT
392
+ - request:
393
+ method: post
394
+ uri: https://gateway.skebby.it/api/send/smseasy/advanced/rest.php?method=test_send_sms_basic&password=password&recipients=%5B%22393459187391%22,%22393786104981%22%5D&username=john.doe
395
+ body:
396
+ encoding: UTF-8
397
+ string: ''
398
+ headers: {}
399
+ response:
400
+ status:
401
+ code: 400
402
+ message: Bad Request
403
+ headers:
404
+ Date:
405
+ - Sun, 16 Feb 2014 15:08:15 GMT
406
+ Server:
407
+ - Apache
408
+ Vary:
409
+ - Accept-Encoding
410
+ Content-Length:
411
+ - '328'
412
+ Connection:
413
+ - close
414
+ Content-Type:
415
+ - text/xml
416
+ body:
417
+ encoding: UTF-8
418
+ string: |
419
+ <?xml version="1.0" encoding="UTF-8"?>
420
+ <SkebbyApi_Public_Send_SmsEasy_Advanced generator="zend" version="1.0"><test_send_sms_basic><response><message>Invalid Method Call to test_send_sms_basic. Missing argument(s): text.</message></response><status>failed</status></test_send_sms_basic></SkebbyApi_Public_Send_SmsEasy_Advanced>
421
+ http_version:
422
+ recorded_at: Sun, 16 Feb 2014 15:08:15 GMT
423
+ - request:
424
+ method: post
425
+ uri: https://gateway.skebby.it/api/send/smseasy/advanced/rest.php?method=test_send_sms_classic&password=password&recipients=%5B%22393459187391%22,%22393786104981%22%5D&username=john.doe
426
+ body:
427
+ encoding: UTF-8
428
+ string: ''
429
+ headers: {}
430
+ response:
431
+ status:
432
+ code: 400
433
+ message: Bad Request
434
+ headers:
435
+ Date:
436
+ - Sun, 16 Feb 2014 15:08:15 GMT
437
+ Server:
438
+ - Apache
439
+ Vary:
440
+ - Accept-Encoding
441
+ Content-Length:
442
+ - '334'
443
+ Connection:
444
+ - close
445
+ Content-Type:
446
+ - text/xml
447
+ body:
448
+ encoding: UTF-8
449
+ string: |
450
+ <?xml version="1.0" encoding="UTF-8"?>
451
+ <SkebbyApi_Public_Send_SmsEasy_Advanced generator="zend" version="1.0"><test_send_sms_classic><response><message>Invalid Method Call to test_send_sms_classic. Missing argument(s): text.</message></response><status>failed</status></test_send_sms_classic></SkebbyApi_Public_Send_SmsEasy_Advanced>
452
+ http_version:
453
+ recorded_at: Sun, 16 Feb 2014 15:08:15 GMT
454
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,72 @@
1
+ require 'spec_helper'
2
+
3
+ describe Skebby::Client do
4
+ subject do
5
+ Skebby::Client.new(
6
+ username: 'john.doe',
7
+ password: 'password',
8
+ test_mode: true
9
+ )
10
+ end
11
+
12
+ before { VCR.insert_cassette 'player', record: :new_episodes }
13
+ after { VCR.eject_cassette }
14
+
15
+ describe '#get_credit' do
16
+ let(:response) { subject.get_credit }
17
+
18
+ it 'returns the remaining credit' do
19
+ expect(response[:credit_left]).to eq(1.61972)
20
+ end
21
+
22
+ it 'returns the remaining classic SMS' do
23
+ expect(response[:classic_sms]).to eq(25)
24
+ end
25
+
26
+ it 'returns the remaining basic SMS' do
27
+ expect(response[:basic_sms]).to eq(35)
28
+ end
29
+ end
30
+
31
+ %w(classic basic classic_report).each do |sms_type|
32
+ meth = "send_sms_#{sms_type}"
33
+
34
+ describe "##{meth}" do
35
+ context 'with the needed parameters' do
36
+ let(:response) do
37
+ subject.send(meth, {
38
+ recipients: ['393459187391', '393786104981'],
39
+ text: 'Hello, world!'
40
+ })
41
+ end
42
+
43
+ it 'returns the remaining SMS' do
44
+ expect(response[:remaining_sms]).to eq(5)
45
+ end
46
+ end
47
+
48
+ context 'without parameters' do
49
+ let(:response) do
50
+ subject.send(meth)
51
+ end
52
+
53
+ it 'raises an error' do
54
+ expect { response }.to raise_error
55
+ end
56
+ end
57
+ end
58
+ end
59
+
60
+ describe '#send_sms_classic_report' do
61
+ let(:response) do
62
+ subject.send_sms_classic_report(
63
+ recipients: ['393459187391', '393786104981'],
64
+ text: 'Hello, world!'
65
+ )
66
+ end
67
+
68
+ it "returns the dispatch ID" do
69
+ expect(response[:dispatch_id]).to eq(1392562134)
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,27 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ require 'skebby'
8
+
9
+ require 'webmock/rspec'
10
+ require 'vcr'
11
+
12
+ RSpec.configure do |config|
13
+ config.treat_symbols_as_metadata_keys_with_true_values = true
14
+ config.run_all_when_everything_filtered = true
15
+ config.filter_run :focus
16
+
17
+ # Run specs in random order to surface order dependencies. If you find an
18
+ # order dependency and want to debug it, you can fix the order by providing
19
+ # the seed, which is printed after each run.
20
+ # --seed 1234
21
+ config.order = 'random'
22
+ end
23
+
24
+ VCR.configure do |c|
25
+ c.cassette_library_dir = 'spec/fixtures/dish_cassettes'
26
+ c.hook_into :webmock
27
+ end
metadata ADDED
@@ -0,0 +1,159 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: skebby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alessandro Desantis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.13'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: webmock
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.17'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.17'
41
+ - !ruby/object:Gem::Dependency
42
+ name: vcr
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.8'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.8'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.5'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.5'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.1'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.1'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.14'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.14'
97
+ - !ruby/object:Gem::Dependency
98
+ name: fuubar
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.3'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.3'
111
+ description: A Ruby client for the Skebby SMS API.
112
+ email:
113
+ - desa.alessandro@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - ".travis.yml"
121
+ - Gemfile
122
+ - LICENSE.txt
123
+ - README.md
124
+ - Rakefile
125
+ - lib/skebby.rb
126
+ - lib/skebby/client.rb
127
+ - lib/skebby/version.rb
128
+ - skebby.gemspec
129
+ - spec/fixtures/dish_cassettes/player.yml
130
+ - spec/skebby/client_spec.rb
131
+ - spec/spec_helper.rb
132
+ homepage: https://github.com/interconn/skebby
133
+ licenses:
134
+ - MIT
135
+ metadata: {}
136
+ post_install_message:
137
+ rdoc_options: []
138
+ require_paths:
139
+ - lib
140
+ required_ruby_version: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ required_rubygems_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ requirements: []
151
+ rubyforge_project:
152
+ rubygems_version: 2.2.1
153
+ signing_key:
154
+ specification_version: 4
155
+ summary: A Ruby client for the Skebby SMS API.
156
+ test_files:
157
+ - spec/fixtures/dish_cassettes/player.yml
158
+ - spec/skebby/client_spec.rb
159
+ - spec/spec_helper.rb