tops_connect 0.4.2.1 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tops_connect/client.rb +6 -24
- data/lib/tops_connect/errors.rb +33 -0
- data/lib/tops_connect/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 013f848e5f60161529ada485d46c4bd65c2bc206
|
4
|
+
data.tar.gz: 33169982d13dbbbfd3f939b76ab4fd939864a628
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be35e62c4e0d288a7384f0e9ca237175c6cb886364bd9590eff4bbcdb2a60f2efbc430b5eb48b4c42f8dcf2406b8a865a6fe9600c49f7de4277a6a5ec6afc3e8
|
7
|
+
data.tar.gz: c24da508faa7388ac874ee043832b8896044b43d188f18e1b3f551b01303f6781cd3225e16e772dd88f57b2800f36dfbe6df39262fd18793d621761f662e7d9a
|
data/lib/tops_connect/client.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
module TopsConnect
|
3
3
|
class Client
|
4
4
|
include HTTParty
|
5
|
+
include TopsConnect::Errors
|
5
6
|
include TopsConnect::Communities
|
6
7
|
include TopsConnect::Owners
|
7
8
|
include TopsConnect::Properties
|
@@ -47,6 +48,11 @@ module TopsConnect
|
|
47
48
|
when 400..499
|
48
49
|
raise TopsConnect::ClientError, response
|
49
50
|
when 500..599
|
51
|
+
message = response.parsed_response&.dig('Message') || ''
|
52
|
+
|
53
|
+
# These errors can largely be ignored - it's not our fault
|
54
|
+
raise TopsConnect::TimeoutError, response if message['Timeout expired']
|
55
|
+
|
50
56
|
raise TopsConnect::InternalError, response
|
51
57
|
else
|
52
58
|
# As far as I'm aware, Tops does not return 100 - 199 or 201 - 399.
|
@@ -54,28 +60,4 @@ module TopsConnect
|
|
54
60
|
end
|
55
61
|
end
|
56
62
|
end
|
57
|
-
|
58
|
-
class ApiError < ::RuntimeError
|
59
|
-
def initialize(response)
|
60
|
-
@response = response
|
61
|
-
end
|
62
|
-
|
63
|
-
def to_s
|
64
|
-
format(
|
65
|
-
'%{code}: %{message} (%{uri})',
|
66
|
-
code: @response.code,
|
67
|
-
message: @response.parsed_response&.dig('Message'),
|
68
|
-
uri: @response.request.last_uri.to_s
|
69
|
-
)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
class ClientError < ApiError
|
74
|
-
end
|
75
|
-
|
76
|
-
class NotFoundError < ClientError
|
77
|
-
end
|
78
|
-
|
79
|
-
class InternalError < ApiError
|
80
|
-
end
|
81
63
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module TopsConnect
|
3
|
+
class ApiError < ::RuntimeError
|
4
|
+
def initialize(response)
|
5
|
+
@response = response
|
6
|
+
end
|
7
|
+
|
8
|
+
def to_s
|
9
|
+
format(
|
10
|
+
'%{code}: %{message} (%{uri})',
|
11
|
+
code: @response.code,
|
12
|
+
message: @response.parsed_response&.dig('Message'),
|
13
|
+
uri: @response.request.last_uri.to_s
|
14
|
+
)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# The client submitted invalid information.
|
19
|
+
class ClientError < ApiError
|
20
|
+
end
|
21
|
+
|
22
|
+
# A request was made for a key/query that doesn't exist.
|
23
|
+
class NotFoundError < ClientError
|
24
|
+
end
|
25
|
+
|
26
|
+
# Something happened but we don't know what and it's probably not our fault.
|
27
|
+
class InternalError < ApiError
|
28
|
+
end
|
29
|
+
|
30
|
+
# The API took too long to respond, but everything might be fine later.
|
31
|
+
class TimeoutError < InternalError
|
32
|
+
end
|
33
|
+
end
|
data/lib/tops_connect/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tops_connect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Hoffman
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -102,6 +102,7 @@ files:
|
|
102
102
|
- lib/tops_connect/communities.rb
|
103
103
|
- lib/tops_connect/community.rb
|
104
104
|
- lib/tops_connect/configuration.rb
|
105
|
+
- lib/tops_connect/errors.rb
|
105
106
|
- lib/tops_connect/owner.rb
|
106
107
|
- lib/tops_connect/owners.rb
|
107
108
|
- lib/tops_connect/properties.rb
|