rumour-ruby 0.0.1 → 0.0.2

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: 6dce269781a3e3baca936962fd4bc3a5361e5e24
4
- data.tar.gz: 49b07e0be76d9e1d86d1fe1761fbb1d6aa2d0a57
3
+ metadata.gz: aa24ca89f5552cb7c69cabfc888e5ec71792cbcb
4
+ data.tar.gz: 73ee0ad55471bdd276622ccdbce91a7a49ddc232
5
5
  SHA512:
6
- metadata.gz: e9a5ef57ce68307f6ebedd489313994a084ebaeb7250a809ae4ad68f26b83dc0caf4ed89782b3cbaa430de78c3b30612356423cf7efcf1224f6bfb674abec7cc
7
- data.tar.gz: dbf604cbb49de4dcee5101ad05636f119ef007e39fb146c410593a537f32b655b74210a57e24ae0e34fac883cb9d7e547c8b7a331506176de44c144b9938230a
6
+ metadata.gz: 6df32bfc1cd8cac9dbc71c0010919a8a9e1d325bf4e576d405378ba5ddd0e3e66401d5c02cce8c51a7f02f6f3d1f480fbc7314ea06abffb13760a4391697e233
7
+ data.tar.gz: a84a4bde48fea637ef61390c88c906b834b29e5fd37abae1da03e8e069cd674d03fafc15f52723ff8c3bf1005f11c4ecc4a740bc14c38c4729d25c76ecf78cd5
@@ -24,17 +24,32 @@ module Rumour
24
24
 
25
25
  private
26
26
 
27
- def post(url, params = {}, headers = {})
28
- response = self.class.post(url, query: params, headers: headers.merge(auth_header))
29
- JSON.parse(response.body)
30
- end
31
-
32
- def auth_header
33
- { 'Authorization' => "Bearer #{credentials}" }
34
- end
35
-
36
- def credentials
37
- Base64.urlsafe_encode64(@access_token)
38
- end
27
+ def post(url, params = {}, headers = {})
28
+ response = self.class.post(url, query: params, headers: headers.merge(auth_header))
29
+ evaluate_response(response)
30
+ end
31
+
32
+ def auth_header
33
+ { 'Authorization' => "Bearer #{credentials}" }
34
+ end
35
+
36
+ def credentials
37
+ Base64.urlsafe_encode64(@access_token)
38
+ end
39
+
40
+ def evaluate_response(response)
41
+ response_body = JSON.parse(response.body)
42
+
43
+ case response.code
44
+ when 201
45
+ response_body
46
+ when 400
47
+ raise Rumour::Errors::RequestError.new response_body['message']
48
+ when 401
49
+ raise Rumour::Errors::AuthenticationError.new response_body['message']
50
+ when 500
51
+ raise Rumour::Errors::AuthenticationError.new response_body['message']
52
+ end
53
+ end
39
54
  end
40
55
  end
@@ -0,0 +1,7 @@
1
+ module Rumour
2
+ class Errors
3
+ class ServerError < StandardError; end
4
+ class AuthenticationError < StandardError; end
5
+ class RequestError < StandardError; end
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module Rumour
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -1,5 +1,6 @@
1
1
  require 'rumour-ruby/version'
2
2
  require 'rumour-ruby/configuration'
3
+ require 'rumour-ruby/errors'
3
4
  require 'rumour-ruby/client'
4
5
 
5
6
  module Rumour
data/rumour-ruby.gemspec CHANGED
@@ -17,6 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
+ spec.required_ruby_version = '>= 1.9.3'
20
21
 
21
22
  spec.add_dependency 'httparty', '~> 0.13.3'
22
23
 
data/spec/client_spec.rb CHANGED
@@ -36,9 +36,10 @@ RSpec.describe Rumour::Client do
36
36
  describe '.send_text_message with invalid data' do
37
37
  it 'creates and retrieves a new message as a hash' do
38
38
  rumour_client = Rumour::Client.new(RUMOUR_TEST_ACCESS_TOKEN)
39
- text_message = rumour_client.send_text_message('+351123456789', '+351123456789', 'Hello from rumour-ruby!')
40
39
 
41
- expect(text_message['message']).to_not be_nil
40
+ expect {
41
+ text_message = rumour_client.send_text_message('+351123456789', '+351123456789', 'Hello from rumour-ruby!')
42
+ }.to raise_error(Rumour::Errors::RequestError)
42
43
  end
43
44
  end
44
45
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rumour-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joao Diogo Costa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-16 00:00:00.000000000 Z
11
+ date: 2015-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -66,10 +66,11 @@ files:
66
66
  - LICENSE.txt
67
67
  - README.md
68
68
  - Rakefile
69
+ - lib/rumour-ruby.rb
69
70
  - lib/rumour-ruby/client.rb
70
71
  - lib/rumour-ruby/configuration.rb
72
+ - lib/rumour-ruby/errors.rb
71
73
  - lib/rumour-ruby/version.rb
72
- - lib/rumour.rb
73
74
  - rumour-ruby.gemspec
74
75
  - spec/client_spec.rb
75
76
  - spec/configuration_spec.rb
@@ -86,7 +87,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
86
87
  requirements:
87
88
  - - ">="
88
89
  - !ruby/object:Gem::Version
89
- version: '0'
90
+ version: 1.9.3
90
91
  required_rubygems_version: !ruby/object:Gem::Requirement
91
92
  requirements:
92
93
  - - ">="
@@ -94,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
95
  version: '0'
95
96
  requirements: []
96
97
  rubyforge_project:
97
- rubygems_version: 2.4.3
98
+ rubygems_version: 2.4.5
98
99
  signing_key:
99
100
  specification_version: 4
100
101
  summary: Ruby wrapper for the Rumour REST API