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 +4 -4
- data/lib/rumour-ruby/client.rb +27 -12
- data/lib/rumour-ruby/errors.rb +7 -0
- data/lib/rumour-ruby/version.rb +1 -1
- data/lib/{rumour.rb → rumour-ruby.rb} +1 -0
- data/rumour-ruby.gemspec +1 -0
- data/spec/client_spec.rb +3 -2
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa24ca89f5552cb7c69cabfc888e5ec71792cbcb
|
4
|
+
data.tar.gz: 73ee0ad55471bdd276622ccdbce91a7a49ddc232
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6df32bfc1cd8cac9dbc71c0010919a8a9e1d325bf4e576d405378ba5ddd0e3e66401d5c02cce8c51a7f02f6f3d1f480fbc7314ea06abffb13760a4391697e233
|
7
|
+
data.tar.gz: a84a4bde48fea637ef61390c88c906b834b29e5fd37abae1da03e8e069cd674d03fafc15f52723ff8c3bf1005f11c4ecc4a740bc14c38c4729d25c76ecf78cd5
|
data/lib/rumour-ruby/client.rb
CHANGED
@@ -24,17 +24,32 @@ module Rumour
|
|
24
24
|
|
25
25
|
private
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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
|
data/lib/rumour-ruby/version.rb
CHANGED
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
|
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.
|
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-
|
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:
|
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.
|
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
|