skuby 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b3a7223daf23c2b544211d00cf23ef18b4105817
4
+ data.tar.gz: fb4b363f23d4e9b3f8d7e0c0fc71082ff3594254
5
+ SHA512:
6
+ metadata.gz: f3d95b18eba653c4003c5aecc6ef129977028ddd6b0c1dbb9c209805442749cc70c0d6dc155749d90ddb995b903f033416e9b5befc346c0b9c1c3a0609189edf
7
+ data.tar.gz: e619a585c8b796bbe002c74aaaf4b947a9a79423202d493ee17fc06d24ab7aeccc722cfc90475f874df51293dbf420a23cea8e4edbafb5fb07958cdc46eb5627
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .ruby-version
7
+ .ruby-gemset
8
+ Gemfile.lock
9
+ InstalledFiles
10
+ _yardoc
11
+ coverage
12
+ doc/
13
+ lib/bundler/man
14
+ pkg
15
+ rdoc
16
+ spec/reports
17
+ test/tmp
18
+ test/version_tmp
19
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - "1.9.3"
5
+ - "2.0.0"
6
+
7
+ script: "bundle exec rspec spec"
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in skuby.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Fabrizio Monti
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.
data/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # Skuby
2
+
3
+ [![Build Status](https://travis-ci.org/welaika/skuby.png?branch=master)](https://travis-ci.org/welaika/skuby)
4
+ [![Coverage Status](https://coveralls.io/repos/welaika/skuby/badge.png)](https://coveralls.io/r/welaika/skuby)
5
+ [![Dependency Status](https://gemnasium.com/welaika/skuby.png)](https://gemnasium.com/welaika/skuby)
6
+
7
+ A Ruby interface for Skebby
8
+ Allows you to send SMS through Skebby SMS Gateway.
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ gem 'skuby'
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install skuby
23
+
24
+ ## Usage
25
+
26
+ ### Configuration
27
+
28
+ Skuby.setup do |config|
29
+ config.method = 'send_sms_classic' #default
30
+ config.username = 'username'
31
+ config.password = 'password'
32
+ config.sender_string = 'company' #optional
33
+ config.sender_number = '39329900000' #optional
34
+ end
35
+
36
+ Put these lines in `config/environments/production.rb` if you are using Skuby in Rails.
37
+
38
+ ### Send SMS
39
+
40
+ Use international phone numbers without +, e.g. (for Italy) `393290000000`
41
+
42
+ sms = Skuby::Gateway.send_sms('Lorem ipsum', '393290000000')
43
+ sms.success? #=> true
44
+
45
+ ### Credit
46
+
47
+ To retrieve your current balance in Euros:
48
+
49
+ Skuby::Credit.balance
50
+
51
+
52
+ ## Contributing
53
+
54
+ 1. Fork it
55
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
56
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
57
+ 4. Push to the branch (`git push origin my-new-feature`)
58
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ desc 'Default: run specs'
5
+ task default: :spec
6
+
7
+ RSpec::Core::RakeTask.new do |t|
8
+ t.pattern = "spec/**/*_spec.rb"
9
+ end
data/lib/skuby.rb ADDED
@@ -0,0 +1,21 @@
1
+ require 'httparty'
2
+ require 'cgi'
3
+ require 'active_support/core_ext/object'
4
+ require 'skuby/version'
5
+ require 'skuby/configuration'
6
+ require 'skuby/gateway'
7
+ require 'skuby/sms_response'
8
+ require 'skuby/report'
9
+ require 'skuby/credit'
10
+
11
+ module Skuby
12
+
13
+ def self.setup
14
+ yield self.config
15
+ end
16
+
17
+ def self.config
18
+ @config ||= Configuration.new
19
+ end
20
+
21
+ end
@@ -0,0 +1,28 @@
1
+ module Skuby
2
+ class Configuration
3
+
4
+ SEND_METHODS = [
5
+ 'send_sms_basic',
6
+ 'send_sms_classic',
7
+ 'send_sms_classic_report',
8
+ 'test_send_sms_basic',
9
+ 'test_send_sms_classic',
10
+ 'test_send_sms_classic_report'
11
+ ]
12
+
13
+ attr_accessor :username, :password, :method,
14
+ :sender_number, :sender_string, :charset
15
+
16
+ def initialize
17
+ @method = 'send_sms_classic'
18
+ end
19
+
20
+ def to_hash
21
+ instance_variables.inject({}) do |result, var|
22
+ result[var.to_s.delete("@")] = instance_variable_get(var)
23
+ result
24
+ end
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,17 @@
1
+ module Skuby
2
+ class Credit
3
+ include HTTParty
4
+ base_uri 'https://gateway.skebby.it/api/send/smseasy/advanced/http.php'
5
+
6
+ def self.balance
7
+ response = CGI.parse(post('', body: build_params))
8
+ response["credit_left"].first.to_f if response["status"].first == "success"
9
+ end
10
+
11
+ def self.build_params
12
+ Skuby.config.to_hash.merge({'method' => 'get_credit'})
13
+ end
14
+
15
+ end
16
+ end
17
+
@@ -0,0 +1,16 @@
1
+ module Skuby
2
+ class Gateway
3
+ include HTTParty
4
+ base_uri 'https://gateway.skebby.it/api/send/smseasy/advanced/http.php'
5
+
6
+ def self.send_sms(text = '', recipients = '')
7
+ params = build_params(text, recipients)
8
+ SmsResponse.new(self.post('', body: params))
9
+ end
10
+
11
+ def self.build_params(text, recipients)
12
+ Skuby.config.to_hash.merge({'text' => text, 'recipients[]' => recipients})
13
+ end
14
+ end
15
+ end
16
+
@@ -0,0 +1,72 @@
1
+ module Skuby
2
+ class Report
3
+
4
+ STATUS_MAPPING = {
5
+ 'DELIVERED' => 'Messaggio consegnato',
6
+ 'EXPIRED' => 'Messaggio scaduto (telefono spento/non raggiungibile)',
7
+ 'DELETED' => 'Errore rete operatore',
8
+ 'UNDELIVERABLE' => 'Messaggio non spedito (Vedi sotto variabile error_code)',
9
+ 'UNKNOWN' => 'Errore generico',
10
+ 'REJECTD' => 'Messaggio rifiutato dall\'operatore'
11
+ }
12
+
13
+ ERROR_CODES = {
14
+ 1 => 'Consegnato',
15
+ 401 => 'Messaggio scaduto (telefono spento/non raggiungibile)',
16
+ 201 => 'Malfunzionamento rete operatore',
17
+ 203 => 'Destinatario non raggiungibile (in roaming)',
18
+ 301 => 'Destinatario non valido (inesistente/in portabilita\' - non abilitato)',
19
+ 302 => 'Numero errato',
20
+ 303 => 'Servizio SMS non abilitato',
21
+ 304 => 'Testo riconosciuto come spam',
22
+ 501 => 'Telefono non supporta l\'SMS',
23
+ 502 => 'Telefono con memoria piena',
24
+ 901 => 'Mappatura errata del malfunzionamento',
25
+ 902 => 'Servizio temporaneamente non disponibile',
26
+ 903 => 'Nessun operatore disponibile',
27
+ 904 => 'Messaggio privo di testo',
28
+ 905 => 'Destinatario non valido',
29
+ 906 => 'Destinatari duplicati',
30
+ 907 => 'Compilazione messaggio non corretta',
31
+ 909 => 'User_reference non corretta',
32
+ 910 => 'Testo troppo lungo',
33
+ 101 => 'Malfunzionamento generico operatore',
34
+ 202 => 'Messaggio rifiutato dall\'operatore'
35
+ }
36
+
37
+ attr_reader :raw
38
+
39
+ def initialize(params)
40
+ @raw = params
41
+ end
42
+
43
+ def success?
44
+ status == "DELIVERED"
45
+ end
46
+
47
+ def failure?
48
+ !success?
49
+ end
50
+
51
+ def status
52
+ @raw["status"]
53
+ end
54
+
55
+ def error_code
56
+ @raw["error_code"].to_i
57
+ end
58
+
59
+ def error_message
60
+ "#{STATUS_MAPPING[status]} - #{ERROR_CODES[error_code]}"
61
+ end
62
+
63
+ def sms_id
64
+ @raw["skebby_message_id"]
65
+ end
66
+
67
+ def delivered_at
68
+ @raw["operator_date_time"]
69
+ end
70
+
71
+ end
72
+ end
@@ -0,0 +1,43 @@
1
+ module Skuby
2
+ class SmsResponse
3
+ attr_reader :raw
4
+
5
+ def initialize(query)
6
+ @raw = CGI.parse(query)
7
+ end
8
+
9
+ def success?
10
+ status == "success"
11
+ end
12
+
13
+ def failed?
14
+ !success?
15
+ end
16
+
17
+ def sms_id?
18
+ sms_id.present?
19
+ end
20
+
21
+ def status
22
+ @raw["status"].first
23
+ end
24
+
25
+ def remaining_sms
26
+ @raw["remaining_sms"].first.to_i
27
+ end
28
+
29
+ def sms_id
30
+ @raw["id"].first
31
+ end
32
+
33
+ def error_code
34
+ @raw["code"].first.to_i
35
+ end
36
+
37
+ def error_message
38
+ @raw["message"].first
39
+ end
40
+
41
+ end
42
+ end
43
+
@@ -0,0 +1,3 @@
1
+ module Skuby
2
+ VERSION = "0.0.2"
3
+ end
data/skuby.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'skuby/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "skuby"
8
+ spec.version = Skuby::VERSION
9
+ spec.authors = ["Fabrizio Monti", "Filippo Gangi Dino"]
10
+ spec.email = ["fabrizio.monti@welaika.com", "filippo.gangidino@welaika.com"]
11
+ spec.description = %q{A Ruby interface to Skebby}
12
+ spec.summary = %q{Allows you to send SMS through Skebby SMS Gateway}
13
+ spec.homepage = "https://github.com/welaika/skuby"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
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"
22
+ spec.add_runtime_dependency "activesupport"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.3"
25
+ spec.add_development_dependency "pry-plus"
26
+ spec.add_development_dependency "rake"
27
+ spec.add_development_dependency "rspec"
28
+ spec.add_development_dependency "mocha"
29
+ spec.add_development_dependency "webmock"
30
+ spec.add_development_dependency "vcr"
31
+ spec.add_development_dependency "coveralls"
32
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe Skuby::Credit do
4
+
5
+ before do
6
+ Skuby.setup do |config|
7
+ config.username = 'username'
8
+ config.password = 'password'
9
+ config.sender_string = 'company'
10
+ end
11
+ end
12
+
13
+ context "::balance" do
14
+ it "returns balance in euro" do
15
+ VCR.use_cassette('get_credit', match_requests_on: [:body]) do
16
+ request = Skuby::Credit.balance
17
+ expect(request).to eq(9.49)
18
+ end
19
+ end
20
+
21
+ context "with wrong credentials" do
22
+ before { Skuby.setup do |config| config.password = 'wrong_password' end }
23
+
24
+ it "returns nil if something's wrong" do
25
+ VCR.use_cassette('get_credit_wrong_credentials', match_requests_on: [:body]) do
26
+ expect(Skuby::Credit.balance).to be_nil
27
+ end
28
+ end
29
+
30
+ end
31
+ end
32
+ end
33
+
@@ -0,0 +1,30 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://gateway.skebby.it/api/send/smseasy/advanced/http.php
6
+ body:
7
+ encoding: UTF-8
8
+ string: method=get_credit&username=username&password=password&sender_string=company
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Date:
16
+ - Mon, 11 Nov 2013 11:02:23 GMT
17
+ Server:
18
+ - Apache
19
+ Vary:
20
+ - Accept-Encoding
21
+ Content-Length:
22
+ - '61'
23
+ Content-Type:
24
+ - text/html
25
+ body:
26
+ encoding: UTF-8
27
+ string: status=success&credit_left=9.49&classic_sms=148&basic_sms=206
28
+ http_version:
29
+ recorded_at: Mon, 11 Nov 2013 11:02:24 GMT
30
+ recorded_with: VCR 2.7.0
@@ -0,0 +1,30 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://gateway.skebby.it/api/send/smseasy/advanced/http.php
6
+ body:
7
+ encoding: UTF-8
8
+ string: method=get_credit&username=username&password=wrong_password&sender_string=company
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Date:
16
+ - Mon, 11 Nov 2013 11:03:19 GMT
17
+ Server:
18
+ - Apache
19
+ Vary:
20
+ - Accept-Encoding
21
+ Content-Length:
22
+ - '144'
23
+ Content-Type:
24
+ - text/html
25
+ body:
26
+ encoding: UTF-8
27
+ string: status=failed&code=21&message=Username+or+password+not+valid%2C+you+cannot+use+your+email+or+phone+number%2C+only+username+is+allowed+on+gateway
28
+ http_version:
29
+ recorded_at: Mon, 11 Nov 2013 11:03:19 GMT
30
+ recorded_with: VCR 2.7.0
@@ -0,0 +1,30 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://gateway.skebby.it/api/send/smseasy/advanced/http.php
6
+ body:
7
+ encoding: UTF-8
8
+ string: method=send_sms_basic&username=username&password=password&sender_string=company&text=Lorem%20ipsum&recipients[]=393290000000
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Date:
16
+ - Mon, 11 Nov 2013 10:52:45 GMT
17
+ Server:
18
+ - Apache
19
+ Vary:
20
+ - Accept-Encoding
21
+ Content-Length:
22
+ - '32'
23
+ Content-Type:
24
+ - text/html
25
+ body:
26
+ encoding: UTF-8
27
+ string: status=success&remaining_sms=207
28
+ http_version:
29
+ recorded_at: Mon, 11 Nov 2013 10:52:45 GMT
30
+ recorded_with: VCR 2.7.0
@@ -0,0 +1,30 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://gateway.skebby.it/api/send/smseasy/advanced/http.php
6
+ body:
7
+ encoding: UTF-8
8
+ string: method=send_sms_classic&username=username&password=password&sender_string=company&text=Lorem%20ipsum&recipients[]=393290000000
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Date:
16
+ - Mon, 11 Nov 2013 10:50:00 GMT
17
+ Server:
18
+ - Apache
19
+ Vary:
20
+ - Accept-Encoding
21
+ Content-Length:
22
+ - '32'
23
+ Content-Type:
24
+ - text/html
25
+ body:
26
+ encoding: UTF-8
27
+ string: status=success&remaining_sms=152
28
+ http_version:
29
+ recorded_at: Mon, 11 Nov 2013 10:50:00 GMT
30
+ recorded_with: VCR 2.7.0
@@ -0,0 +1,30 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://gateway.skebby.it/api/send/smseasy/advanced/http.php
6
+ body:
7
+ encoding: UTF-8
8
+ string: method=send_sms_classic_report&username=username&password=password&sender_string=company&text=Lorem%20ipsum&recipients[]=393290000000
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Date:
16
+ - Mon, 11 Nov 2013 10:51:14 GMT
17
+ Server:
18
+ - Apache
19
+ Vary:
20
+ - Accept-Encoding
21
+ Content-Length:
22
+ - '44'
23
+ Content-Type:
24
+ - text/html
25
+ body:
26
+ encoding: UTF-8
27
+ string: status=success&remaining_sms=150&id=64608933
28
+ http_version:
29
+ recorded_at: Mon, 11 Nov 2013 10:51:14 GMT
30
+ recorded_with: VCR 2.7.0
@@ -0,0 +1,30 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://gateway.skebby.it/api/send/smseasy/advanced/http.php
6
+ body:
7
+ encoding: UTF-8
8
+ string: method=send_sms_classic_report&username=username&password=password&sender_string=company&text=Lorem%20ipsum&recipients[]=
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Date:
16
+ - Mon, 11 Nov 2013 10:48:22 GMT
17
+ Server:
18
+ - Apache
19
+ Vary:
20
+ - Accept-Encoding
21
+ Content-Length:
22
+ - '105'
23
+ Content-Type:
24
+ - text/html
25
+ body:
26
+ encoding: UTF-8
27
+ string: status=failed&code=25&message=Recipient+not+valid+%28must+be+in+international+format+like+393401234567%29
28
+ http_version:
29
+ recorded_at: Mon, 11 Nov 2013 10:48:22 GMT
30
+ recorded_with: VCR 2.7.0
@@ -0,0 +1,30 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://gateway.skebby.it/api/send/smseasy/advanced/http.php
6
+ body:
7
+ encoding: UTF-8
8
+ string: method=send_sms_classic_report&username=username&password=wrong_password&sender_string=company&text=Lorem%20ipsum&recipients[]=393290000000
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Date:
16
+ - Mon, 11 Nov 2013 10:56:48 GMT
17
+ Server:
18
+ - Apache
19
+ Vary:
20
+ - Accept-Encoding
21
+ Content-Length:
22
+ - '144'
23
+ Content-Type:
24
+ - text/html
25
+ body:
26
+ encoding: UTF-8
27
+ string: status=failed&code=21&message=Username+or+password+not+valid%2C+you+cannot+use+your+email+or+phone+number%2C+only+username+is+allowed+on+gateway
28
+ http_version:
29
+ recorded_at: Mon, 11 Nov 2013 10:56:48 GMT
30
+ recorded_with: VCR 2.7.0
@@ -0,0 +1,82 @@
1
+ require 'spec_helper'
2
+
3
+ describe Skuby::Gateway do
4
+
5
+ before do
6
+ Skuby.setup do |config|
7
+ config.username = 'username'
8
+ config.password = 'password'
9
+ config.sender_string = 'company'
10
+ end
11
+ end
12
+
13
+ context "with send sms classic" do
14
+ before { Skuby.setup do |config| config.method = 'send_sms_classic' end }
15
+
16
+ it "successfully send an sms" do
17
+ VCR.use_cassette('send_sms_classic', match_requests_on: [:body]) do
18
+ response = Skuby::Gateway.send_sms('Lorem ipsum', '393290000000')
19
+ expect(response.success?).to be_true
20
+ expect(response.sms_id?).to be_false
21
+ expect(response.remaining_sms).to eq(152)
22
+ end
23
+ end
24
+ end
25
+
26
+ context "with send sms basic" do
27
+ before { Skuby.setup do |config| config.method = 'send_sms_basic' end }
28
+
29
+ it "successfully send an sms" do
30
+ VCR.use_cassette('send_sms_basic', match_requests_on: [:body]) do
31
+ response = Skuby::Gateway.send_sms('Lorem ipsum', '393290000000')
32
+ expect(response.success?).to be_true
33
+ expect(response.sms_id?).to be_false
34
+ expect(response.remaining_sms).to eq(207)
35
+ end
36
+ end
37
+ end
38
+
39
+ context "with send sms classic report" do
40
+ before { Skuby.setup do |config| config.method = 'send_sms_classic_report' end }
41
+
42
+ it "successfully send an sms" do
43
+ VCR.use_cassette('send_sms_classic_report', match_requests_on: [:body]) do
44
+ response = Skuby::Gateway.send_sms('Lorem ipsum', '393290000000')
45
+ expect(response.success?).to be_true
46
+ expect(response.sms_id?).to be_true
47
+ expect(response.sms_id).to eq('64608933')
48
+ expect(response.remaining_sms).to eq(150)
49
+ end
50
+ end
51
+ end
52
+
53
+ context "with errors in request" do
54
+ before { Skuby.setup do |config| config.method = 'send_sms_classic_report' end }
55
+
56
+ context "no recipient" do
57
+ it "returns an error" do
58
+ VCR.use_cassette('send_sms_no_recipient', match_requests_on: [:body]) do
59
+ response = Skuby::Gateway.send_sms('Lorem ipsum')
60
+ expect(response.success?).to be_false
61
+ expect(response.error_code).to eq(25)
62
+ expect(response.error_message).to be_present
63
+ end
64
+ end
65
+ end
66
+
67
+ context "with wrong credentials" do
68
+ before { Skuby.setup do |config| config.password = 'wrong_password' end }
69
+
70
+ it "returns an error" do
71
+ VCR.use_cassette('send_sms_wrong_credentials', match_requests_on: [:body]) do
72
+ response = Skuby::Gateway.send_sms('Lorem ipsum', '393290000000')
73
+ expect(response.success?).to be_false
74
+ expect(response.error_code).to eq(21)
75
+ expect(response.error_message).to be_present
76
+ end
77
+ end
78
+ end
79
+
80
+ end
81
+ end
82
+
@@ -0,0 +1,26 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+
4
+ require 'webmock/rspec'
5
+ require 'mocha/api'
6
+ require 'vcr'
7
+ require 'pry'
8
+
9
+ require 'skuby'
10
+
11
+ RSpec.configure do |config|
12
+ config.expect_with :rspec do |c|
13
+ c.syntax = :expect
14
+ end
15
+ config.treat_symbols_as_metadata_keys_with_true_values = true
16
+ config.run_all_when_everything_filtered = true
17
+ config.filter_run :focus
18
+ config.mock_framework = :mocha
19
+ config.order = 'random'
20
+ end
21
+
22
+ VCR.configure do |c|
23
+ c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
24
+ c.hook_into :webmock
25
+ end
26
+
metadata ADDED
@@ -0,0 +1,222 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: skuby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Fabrizio Monti
8
+ - Filippo Gangi Dino
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-11-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httparty
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - '>='
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - '>='
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: activesupport
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: bundler
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ~>
47
+ - !ruby/object:Gem::Version
48
+ version: '1.3'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: '1.3'
56
+ - !ruby/object:Gem::Dependency
57
+ name: pry-plus
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rake
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: rspec
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: mocha
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: webmock
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: vcr
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - '>='
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ - !ruby/object:Gem::Dependency
141
+ name: coveralls
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - '>='
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ type: :development
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - '>='
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ description: A Ruby interface to Skebby
155
+ email:
156
+ - fabrizio.monti@welaika.com
157
+ - filippo.gangidino@welaika.com
158
+ executables: []
159
+ extensions: []
160
+ extra_rdoc_files: []
161
+ files:
162
+ - .gitignore
163
+ - .rspec
164
+ - .travis.yml
165
+ - Gemfile
166
+ - LICENSE.txt
167
+ - README.md
168
+ - Rakefile
169
+ - lib/skuby.rb
170
+ - lib/skuby/configuration.rb
171
+ - lib/skuby/credit.rb
172
+ - lib/skuby/gateway.rb
173
+ - lib/skuby/report.rb
174
+ - lib/skuby/sms_response.rb
175
+ - lib/skuby/version.rb
176
+ - skuby.gemspec
177
+ - spec/credit_spec.rb
178
+ - spec/fixtures/vcr_cassettes/get_credit.yml
179
+ - spec/fixtures/vcr_cassettes/get_credit_wrong_credentials.yml
180
+ - spec/fixtures/vcr_cassettes/send_sms_basic.yml
181
+ - spec/fixtures/vcr_cassettes/send_sms_classic.yml
182
+ - spec/fixtures/vcr_cassettes/send_sms_classic_report.yml
183
+ - spec/fixtures/vcr_cassettes/send_sms_no_recipient.yml
184
+ - spec/fixtures/vcr_cassettes/send_sms_wrong_credentials.yml
185
+ - spec/gateway_spec.rb
186
+ - spec/spec_helper.rb
187
+ homepage: https://github.com/welaika/skuby
188
+ licenses:
189
+ - MIT
190
+ metadata: {}
191
+ post_install_message:
192
+ rdoc_options: []
193
+ require_paths:
194
+ - lib
195
+ required_ruby_version: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - '>='
198
+ - !ruby/object:Gem::Version
199
+ version: '0'
200
+ required_rubygems_version: !ruby/object:Gem::Requirement
201
+ requirements:
202
+ - - '>='
203
+ - !ruby/object:Gem::Version
204
+ version: '0'
205
+ requirements: []
206
+ rubyforge_project:
207
+ rubygems_version: 2.0.3
208
+ signing_key:
209
+ specification_version: 4
210
+ summary: Allows you to send SMS through Skebby SMS Gateway
211
+ test_files:
212
+ - spec/credit_spec.rb
213
+ - spec/fixtures/vcr_cassettes/get_credit.yml
214
+ - spec/fixtures/vcr_cassettes/get_credit_wrong_credentials.yml
215
+ - spec/fixtures/vcr_cassettes/send_sms_basic.yml
216
+ - spec/fixtures/vcr_cassettes/send_sms_classic.yml
217
+ - spec/fixtures/vcr_cassettes/send_sms_classic_report.yml
218
+ - spec/fixtures/vcr_cassettes/send_sms_no_recipient.yml
219
+ - spec/fixtures/vcr_cassettes/send_sms_wrong_credentials.yml
220
+ - spec/gateway_spec.rb
221
+ - spec/spec_helper.rb
222
+ has_rdoc: