send_with_us 1.0.1 → 1.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/CHANGELOG.md +1 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/send_with_us/api_request.rb +14 -4
- data/lib/send_with_us/config.rb +2 -2
- data/lib/send_with_us/version.rb +1 -1
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e80a927fbda0bc2deba7b51792a25a1dfbbb347d
|
4
|
+
data.tar.gz: 5d690b0be9df8cf6978ca3bf00100b91187c453f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d556742dcf3c279878663654b2a37993a2f961c26cf0ed30a9a357d586bedb41391a276997ce2b668930941a29bfb5745a9afb57c25c8e22c87d9fa1ca64db0
|
7
|
+
data.tar.gz: 53fe3041bf2245bcac0dc669ebef11279afcafcbcd83cc14348ea0b67020128c3d410eb189ae5e4489fc9fb38787ed3e13f6d9350876b1b83848307de81078c9
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module SendWithUs
|
2
2
|
class ApiInvalidEndpoint < StandardError; end
|
3
3
|
class ApiConnectionRefused < StandardError; end
|
4
|
+
class ApiBadRequest < StandardError; end
|
5
|
+
class ApiInvalidKey < StandardError; end
|
4
6
|
class ApiUnknownError < StandardError; end
|
5
7
|
|
6
8
|
class ApiRequest
|
@@ -25,14 +27,18 @@ module SendWithUs
|
|
25
27
|
case @response
|
26
28
|
when Net::HTTPNotFound then
|
27
29
|
raise SendWithUs::ApiInvalidEndpoint, path
|
30
|
+
when Net::HTTPForbidden then
|
31
|
+
raise SendWithUs::ApiInvalidKey, 'Invalid api key: ' + @configuration.api_key
|
32
|
+
when Net::HTTPBadRequest then
|
33
|
+
raise SendWithUs::ApiBadRequest, @response.body
|
28
34
|
when Net::HTTPSuccess then
|
29
35
|
puts @response.body if @configuration.debug
|
30
36
|
@response
|
31
37
|
else
|
32
|
-
raise SendWithUs::ApiUnknownError
|
38
|
+
raise SendWithUs::ApiUnknownError, 'An unknown error has occurred'
|
33
39
|
end
|
34
40
|
rescue Errno::ECONNREFUSED
|
35
|
-
raise SendWithUs::ApiConnectionRefused
|
41
|
+
raise SendWithUs::ApiConnectionRefused, 'The connection was refused'
|
36
42
|
end
|
37
43
|
|
38
44
|
def get(endpoint)
|
@@ -50,14 +56,18 @@ module SendWithUs
|
|
50
56
|
case @response
|
51
57
|
when Net::HTTPNotFound then
|
52
58
|
raise SendWithUs::ApiInvalidEndpoint, path
|
59
|
+
when Net::HTTPForbidden then
|
60
|
+
raise SendWithUs::ApiInvalidKey, 'Invalid api key: ' + @configuration.api_key
|
61
|
+
when Net::HTTPBadRequest then
|
62
|
+
raise SendWithUs::ApiBadRequest, @response.body
|
53
63
|
when Net::HTTPSuccess
|
54
64
|
puts @response.body if @configuration.debug
|
55
65
|
@response
|
56
66
|
else
|
57
|
-
raise SendWithUs::ApiUnknownError
|
67
|
+
raise SendWithUs::ApiUnknownError, 'An unknown error has occurred'
|
58
68
|
end
|
59
69
|
rescue Errno::ECONNREFUSED
|
60
|
-
raise SendWithUs::ApiConnectionRefused
|
70
|
+
raise SendWithUs::ApiConnectionRefused, 'The connection was refused'
|
61
71
|
end
|
62
72
|
|
63
73
|
private
|
data/lib/send_with_us/config.rb
CHANGED
@@ -5,7 +5,7 @@ module SendWithUs
|
|
5
5
|
attr_accessor :settings
|
6
6
|
#attr_writer :url, :api_key, :protocol, :host, :port, :api_version, :debug
|
7
7
|
|
8
|
-
DEFAULT_URL = 'https://
|
8
|
+
DEFAULT_URL = 'https://api.sendwithus.com'
|
9
9
|
|
10
10
|
def self.defaults
|
11
11
|
source = URI.parse(DEFAULT_URL)
|
@@ -16,7 +16,7 @@ module SendWithUs
|
|
16
16
|
protocol: source.scheme,
|
17
17
|
host: source.host,
|
18
18
|
port: source.port,
|
19
|
-
api_version: '
|
19
|
+
api_version: '1',
|
20
20
|
debug: true,
|
21
21
|
client_stub: "ruby-#{VERSION}"
|
22
22
|
}
|
data/lib/send_with_us/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: send_with_us
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Harris
|
@@ -9,48 +9,48 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-11-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - '>='
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '0'
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - '>='
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: shoulda
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - '>='
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - '>='
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: mocha
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - '>='
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - '>='
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
description: SendWithUs.com Ruby Client
|
@@ -88,17 +88,17 @@ require_paths:
|
|
88
88
|
- lib
|
89
89
|
required_ruby_version: !ruby/object:Gem::Requirement
|
90
90
|
requirements:
|
91
|
-
- -
|
91
|
+
- - '>='
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
95
|
requirements:
|
96
|
-
- -
|
96
|
+
- - '>='
|
97
97
|
- !ruby/object:Gem::Version
|
98
98
|
version: '0'
|
99
99
|
requirements: []
|
100
100
|
rubyforge_project:
|
101
|
-
rubygems_version: 2.0.
|
101
|
+
rubygems_version: 2.0.6
|
102
102
|
signing_key:
|
103
103
|
specification_version: 4
|
104
104
|
summary: SendWithUs.com Ruby Client
|