bigcommerce-oauth-api 1.1.3 → 1.1.4
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 +6 -0
- data/README.md +3 -3
- data/bigcommerce-oauth-api.gemspec +1 -1
- data/lib/bigcommerce-oauth-api/error.rb +32 -1
- data/lib/bigcommerce-oauth-api/version.rb +1 -1
- data/lib/faraday/raise_http_exception.rb +16 -11
- data/spec/faraday/response_spec.rb +12 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6b19b16d59f1424fe65138a837c26e256441e86
|
4
|
+
data.tar.gz: dacf7a4298da2d2b48780358f60086f071155c14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6aa0aa5aeadbae36684915c5f0e469c17876dbfbf466715878ec579fd483aea827c946c73ccf99b8f4320b25d96dbf63e0eaec02d228e9f12c654818f0b2a3e1
|
7
|
+
data.tar.gz: 9e8da4f3979705e49209ea16a8dc5f6bc23f37e80b1301db102c07221d25bfa8bee2c2092100c7c7a51ea15c4499ace979c82211d71b0d2c9bfcfae47ab32e84
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -33,8 +33,8 @@ Or by passing options to a new client instance.
|
|
33
33
|
```
|
34
34
|
api = BigcommerceOAuthAPI::Client.new(
|
35
35
|
:store_hash => 'YOUR STORE ID',
|
36
|
-
:
|
37
|
-
:
|
36
|
+
:client_id => 'YOUR CLIENT ID',
|
37
|
+
:access_token => 'YOUR OAUTH ACCESS TOKEN'
|
38
38
|
)
|
39
39
|
```
|
40
40
|
|
@@ -52,7 +52,7 @@ Get the order with id = 101
|
|
52
52
|
```
|
53
53
|
order = api.order(101)
|
54
54
|
```
|
55
|
-
All resource attributes can be accessed both using methods or as a hash with keys as either strings or
|
55
|
+
All resource attributes can be accessed both using methods or as a hash with keys as either strings or symbols.
|
56
56
|
```
|
57
57
|
# each of the following lines return the first name listed in the order billing address
|
58
58
|
order.billing_address.first_name
|
@@ -3,7 +3,7 @@ require File.expand_path('../lib/bigcommerce-oauth-api/version', __FILE__)
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'bigcommerce-oauth-api'
|
5
5
|
s.version = BigcommerceOAuthAPI::VERSION.dup
|
6
|
-
s.date = '2014-11-
|
6
|
+
s.date = '2014-11-10'
|
7
7
|
s.summary = "Ruby wrapper for the Bigcommerce REST API using OAuth"
|
8
8
|
s.description = "Connect Ruby applications with the Bigcommerce REST API using OAuth"
|
9
9
|
s.authors = ["Christian Orthmann"]
|
@@ -8,19 +8,50 @@ module BigcommerceOAuthAPI
|
|
8
8
|
# 400 HTTP
|
9
9
|
class BadRequest < Error; end
|
10
10
|
|
11
|
+
# 401 HTTP
|
12
|
+
class Unauthorized < Error; end
|
13
|
+
|
14
|
+
# 403 HTTP
|
15
|
+
class Forbidden < Error; end
|
16
|
+
|
11
17
|
# 404 HTTP
|
12
18
|
class NotFound < Error; end
|
13
19
|
|
20
|
+
# 405 HTTP
|
21
|
+
class MethodNotAllowed < Error; end
|
22
|
+
|
23
|
+
# 406 HTTP
|
24
|
+
class NotAcceptable < Error; end
|
25
|
+
|
26
|
+
# 409 HTTP
|
27
|
+
class Conflict < Error; end
|
28
|
+
|
29
|
+
# 413 HTTP
|
30
|
+
class RequestEntityTooLarge < Error; end
|
31
|
+
|
32
|
+
# 415 HTTP
|
33
|
+
class UnsupportedMediaType < Error; end
|
34
|
+
|
14
35
|
# 429 HTTP
|
15
36
|
class TooManyRequests < Error; end
|
16
37
|
|
17
38
|
# 500 HTTP
|
18
39
|
class InternalServerError < Error; end
|
19
40
|
|
41
|
+
# 501 HTTP
|
42
|
+
class NotImplemented < Error; end
|
43
|
+
|
20
44
|
# 502 HTTP
|
21
45
|
class BadGateway < Error; end
|
22
46
|
|
47
|
+
# 503 HTTP
|
48
|
+
class ServiceUnavailable < Error; end
|
49
|
+
|
50
|
+
# 507 HTTP
|
51
|
+
class InsufficientStorage < Error; end
|
52
|
+
|
23
53
|
# Raised if the client attempts to define an api method that already is defined elsewhere.
|
24
54
|
# Specs will catch this type of error since it will be thrown upon initialization.
|
25
55
|
class MethodAlreadyDefinedError < Error; end
|
26
|
-
end
|
56
|
+
end
|
57
|
+
|
@@ -5,16 +5,21 @@ module FaradayMiddleware
|
|
5
5
|
def call(env)
|
6
6
|
@app.call(env).on_complete do |response|
|
7
7
|
case response[:status].to_i
|
8
|
-
|
9
|
-
raise BigcommerceOAuthAPI::
|
10
|
-
|
11
|
-
raise BigcommerceOAuthAPI::NotFound,
|
12
|
-
|
13
|
-
raise BigcommerceOAuthAPI::
|
14
|
-
|
15
|
-
raise BigcommerceOAuthAPI::
|
16
|
-
|
17
|
-
raise BigcommerceOAuthAPI::
|
8
|
+
when 400 then raise BigcommerceOAuthAPI::BadRequest, response[:body]
|
9
|
+
when 401 then raise BigcommerceOAuthAPI::Unauthorized, response[:body]
|
10
|
+
when 403 then raise BigcommerceOAuthAPI::Forbidden, response[:body]
|
11
|
+
when 404 then raise BigcommerceOAuthAPI::NotFound, response[:body]
|
12
|
+
when 405 then raise BigcommerceOAuthAPI::MethodNotAllowed, response[:body]
|
13
|
+
when 406 then raise BigcommerceOAuthAPI::NotAcceptable, response[:body]
|
14
|
+
when 409 then raise BigcommerceOAuthAPI::Conflict, response[:body]
|
15
|
+
when 413 then raise BigcommerceOAuthAPI::RequestEntityTooLarge, response[:body]
|
16
|
+
when 415 then raise BigcommerceOAuthAPI::UnsupportedMediaType, response[:body]
|
17
|
+
when 429 then raise BigcommerceOAuthAPI::TooManyRequests, response[:response_headers]['X-Retry-After']
|
18
|
+
when 500 then raise BigcommerceOAuthAPI::InternalServerError, response[:body]
|
19
|
+
when 501 then raise BigcommerceOAuthAPI::NotImplemented, response[:body]
|
20
|
+
when 502 then raise BigcommerceOAuthAPI::BadGateway, response[:body]
|
21
|
+
when 503 then raise BigcommerceOAuthAPI::ServiceUnavailable, response[:body]
|
22
|
+
when 507 then raise BigcommerceOAuthAPI::InsufficientStorage, response[:body]
|
18
23
|
end
|
19
24
|
end
|
20
25
|
end
|
@@ -23,4 +28,4 @@ module FaradayMiddleware
|
|
23
28
|
super app
|
24
29
|
end
|
25
30
|
end
|
26
|
-
end
|
31
|
+
end
|
@@ -10,10 +10,20 @@ describe Faraday::Response do
|
|
10
10
|
|
11
11
|
{
|
12
12
|
400 => BigcommerceOAuthAPI::BadRequest,
|
13
|
+
401 => BigcommerceOAuthAPI::Unauthorized,
|
14
|
+
403 => BigcommerceOAuthAPI::Forbidden,
|
13
15
|
404 => BigcommerceOAuthAPI::NotFound,
|
16
|
+
405 => BigcommerceOAuthAPI::MethodNotAllowed,
|
17
|
+
406 => BigcommerceOAuthAPI::NotAcceptable,
|
18
|
+
409 => BigcommerceOAuthAPI::Conflict ,
|
19
|
+
413 => BigcommerceOAuthAPI::RequestEntityTooLarge,
|
20
|
+
415 => BigcommerceOAuthAPI::UnsupportedMediaType,
|
14
21
|
429 => BigcommerceOAuthAPI::TooManyRequests,
|
15
22
|
500 => BigcommerceOAuthAPI::InternalServerError,
|
16
|
-
|
23
|
+
501 => BigcommerceOAuthAPI::NotImplemented,
|
24
|
+
502 => BigcommerceOAuthAPI::BadGateway,
|
25
|
+
503 => BigcommerceOAuthAPI::ServiceUnavailable,
|
26
|
+
507 => BigcommerceOAuthAPI::InsufficientStorage
|
17
27
|
}.each do |status, exception|
|
18
28
|
context "when HTTP status is #{status}" do
|
19
29
|
before do
|
@@ -33,4 +43,4 @@ describe Faraday::Response do
|
|
33
43
|
expect{ @client.products }.to raise_error(BigcommerceOAuthAPI::TooManyRequests, '15')
|
34
44
|
end
|
35
45
|
end
|
36
|
-
end
|
46
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bigcommerce-oauth-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Orthmann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|