pacer_api 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pacer_api/authenticator.rb +1 -1
- data/lib/pacer_api/error.rb +10 -0
- data/lib/pacer_api/immediate/case_search.rb +7 -2
- data/lib/pacer_api/immediate/paginated_response.rb +8 -0
- data/lib/pacer_api/immediate/party_search.rb +7 -2
- data/lib/pacer_api/response_translator.rb +1 -0
- data/lib/pacer_api/session.rb +8 -0
- data/lib/pacer_api/translation.rb +11 -6
- data/lib/pacer_api/version.rb +1 -1
- data/lib/pacer_api.rb +0 -6
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 629a5c4d6afebb3ff0c9d1c3e6e94d83e2d8ce55d8c8864ac328a015b0cc1e68
|
4
|
+
data.tar.gz: 1359f7aaccc43f1cb90c5aaddc0feb4174cfc73826dd9d76677b324fb3246fc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2232c99c39e6293ff923e37c211735802462acb3f3748924ffcaebc43b17b9844eb8cf0a3ce346c2d6bf15d763b090bb3b0ced4867a9d6a9b63edfa572982a44
|
7
|
+
data.tar.gz: 2b1636aefceedda6db5d3a8b8e6be319912de540ec833da0113952585c3d69605a27b090510418b0d109bea461e0d734abaf40d69e92fe4698c99560c3ef5e7c
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PacerApi
|
4
|
+
Error = Class.new(StandardError)
|
5
|
+
AuthenticationError = Class.new(Error)
|
6
|
+
NotImplementedError = Class.new(StandardError)
|
7
|
+
ResponseError = Class.new(Error)
|
8
|
+
EncodeError = Class.new(Error)
|
9
|
+
DecodeError = Class.new(Error)
|
10
|
+
end
|
@@ -13,7 +13,7 @@ module PacerApi
|
|
13
13
|
@params = params
|
14
14
|
end
|
15
15
|
|
16
|
-
def fetch(page =
|
16
|
+
def fetch(page = 0)
|
17
17
|
path = format(PATH, page)
|
18
18
|
payload = @session.post(path, @params)
|
19
19
|
Page.new(payload)
|
@@ -21,7 +21,12 @@ module PacerApi
|
|
21
21
|
|
22
22
|
class Page < PaginatedResponse
|
23
23
|
def cases
|
24
|
-
|
24
|
+
@cases ||=
|
25
|
+
if payload.key?(:content)
|
26
|
+
payload.fetch(:content).map { |h| CaseInfo.new(h) }
|
27
|
+
else
|
28
|
+
[]
|
29
|
+
end
|
25
30
|
end
|
26
31
|
end
|
27
32
|
end
|
@@ -13,7 +13,7 @@ module PacerApi
|
|
13
13
|
@params = params
|
14
14
|
end
|
15
15
|
|
16
|
-
def fetch(page =
|
16
|
+
def fetch(page = 0)
|
17
17
|
path = format(PATH, page)
|
18
18
|
payload = @session.post(path, @params)
|
19
19
|
Page.new(payload)
|
@@ -21,7 +21,12 @@ module PacerApi
|
|
21
21
|
|
22
22
|
class Page < PaginatedResponse
|
23
23
|
def parties
|
24
|
-
|
24
|
+
@parties ||=
|
25
|
+
if payload.key?(:content)
|
26
|
+
payload.fetch(:content).map { |h| PartyInfo.new(h) }
|
27
|
+
else
|
28
|
+
[]
|
29
|
+
end
|
25
30
|
end
|
26
31
|
end
|
27
32
|
end
|
data/lib/pacer_api/session.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require "faraday"
|
4
4
|
|
5
|
+
require "pacer_api/error"
|
5
6
|
require "pacer_api/translation"
|
6
7
|
|
7
8
|
module PacerApi
|
@@ -26,6 +27,9 @@ module PacerApi
|
|
26
27
|
def get(path)
|
27
28
|
res = request(:get, path)
|
28
29
|
decode_response(res.body)
|
30
|
+
rescue PacerApi::Error => e
|
31
|
+
raise ResponseError,
|
32
|
+
"Error in GET #{path}: #{e.message}", e.backtrace
|
29
33
|
end
|
30
34
|
|
31
35
|
def post(path, doc)
|
@@ -34,6 +38,10 @@ module PacerApi
|
|
34
38
|
req.body = encode_request(doc)
|
35
39
|
}
|
36
40
|
decode_response(res.body)
|
41
|
+
rescue PacerApi::Error => e
|
42
|
+
raise ResponseError,
|
43
|
+
"Error in POST #{path} with #{doc.inspect}: #{e.message}",
|
44
|
+
e.backtrace
|
37
45
|
end
|
38
46
|
|
39
47
|
def delete(path)
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require "json"
|
4
4
|
require "pp" if ENV.key?("DEBUG")
|
5
5
|
|
6
|
+
require "pacer_api/error"
|
6
7
|
require "pacer_api/request_translator"
|
7
8
|
require "pacer_api/response_translator"
|
8
9
|
|
@@ -14,15 +15,19 @@ module PacerApi
|
|
14
15
|
pp obj
|
15
16
|
end
|
16
17
|
JSON.generate(RequestTranslator.translate(obj))
|
18
|
+
rescue JSON::ParserError => e
|
19
|
+
raise PacerApi::EncodeError, "#{e.class} #{e.message}", e.backtrace
|
17
20
|
end
|
18
21
|
|
19
22
|
def decode_response(body)
|
20
|
-
ResponseTranslator.translate(JSON.parse(body))
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
result = ResponseTranslator.translate(JSON.parse(body))
|
24
|
+
if ENV.key?("DEBUG")
|
25
|
+
puts "<<<<"
|
26
|
+
pp result
|
27
|
+
end
|
28
|
+
result
|
29
|
+
rescue JSON::ParserError => e
|
30
|
+
raise PacerApi::DecodeError, "#{e.class} #{e.message}", e.backtrace
|
26
31
|
end
|
27
32
|
end
|
28
33
|
end
|
data/lib/pacer_api/version.rb
CHANGED
data/lib/pacer_api.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pacer_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Battley
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -158,6 +158,7 @@ files:
|
|
158
158
|
- lib/pacer_api/batch/status.rb
|
159
159
|
- lib/pacer_api/batch_job.rb
|
160
160
|
- lib/pacer_api/case_info.rb
|
161
|
+
- lib/pacer_api/error.rb
|
161
162
|
- lib/pacer_api/immediate/case_search.rb
|
162
163
|
- lib/pacer_api/immediate/paginated_response.rb
|
163
164
|
- lib/pacer_api/immediate/party_search.rb
|
@@ -174,7 +175,7 @@ licenses:
|
|
174
175
|
metadata:
|
175
176
|
homepage_uri: https://github.com/gtd/pacer_api
|
176
177
|
source_code_uri: https://github.com/gtd/pacer_api
|
177
|
-
post_install_message:
|
178
|
+
post_install_message:
|
178
179
|
rdoc_options: []
|
179
180
|
require_paths:
|
180
181
|
- lib
|
@@ -189,9 +190,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
190
|
- !ruby/object:Gem::Version
|
190
191
|
version: '0'
|
191
192
|
requirements: []
|
192
|
-
|
193
|
-
|
194
|
-
signing_key:
|
193
|
+
rubygems_version: 3.2.22
|
194
|
+
signing_key:
|
195
195
|
specification_version: 4
|
196
196
|
summary: PACER Case Locator API
|
197
197
|
test_files: []
|