frederick_api 0.5 → 0.6
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9848d60ef419d88f6758574988f60f90337c64645316a0c716c12aaf497f43a9
|
4
|
+
data.tar.gz: 2e6096aeca9837b93ee25a2468bc7d3e2cf2712f6c735fb7330cf13a489f3b1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06f920d1c60e09288bb9c75ef3b9be31168b93fe24ab681c33b1e2b77fb9127172e86608da5c8f862a43965867e1e33f571a91dfb80bd768cc9b227979b084dc
|
7
|
+
data.tar.gz: 738cf8ec474b270d81e79a95499325f62f70557baf09bc16220abd4d467564ead6607bf180bb22352bd309d78fdab6ce84435863341ea8c99c89985d430939b7
|
@@ -20,7 +20,7 @@ module FrederickAPI
|
|
20
20
|
def query_builder(url)
|
21
21
|
association_class.query_builder.new(
|
22
22
|
association_class,
|
23
|
-
association_class.requestor_class.new(association_class, url)
|
23
|
+
requestor: association_class.requestor_class.new(association_class, url)
|
24
24
|
)
|
25
25
|
end
|
26
26
|
|
@@ -9,9 +9,9 @@ module FrederickAPI
|
|
9
9
|
class QueryBuilder < JsonApiClient::Query::Builder
|
10
10
|
attr_reader :requestor
|
11
11
|
|
12
|
-
def initialize(klass,
|
13
|
-
super(klass)
|
14
|
-
@requestor = requestor || klass.requestor
|
12
|
+
def initialize(klass, opts = {})
|
13
|
+
super(klass, opts)
|
14
|
+
@requestor = opts[:requestor] || klass.requestor
|
15
15
|
end
|
16
16
|
|
17
17
|
def params
|
@@ -23,17 +23,6 @@ module FrederickAPI
|
|
23
23
|
.merge(additional_params)
|
24
24
|
end
|
25
25
|
|
26
|
-
def find(args = {})
|
27
|
-
case args
|
28
|
-
when Hash
|
29
|
-
where(args)
|
30
|
-
else
|
31
|
-
@primary_key = args
|
32
|
-
end
|
33
|
-
|
34
|
-
requestor.get(params)
|
35
|
-
end
|
36
|
-
|
37
26
|
def filter_params
|
38
27
|
super_filter_params = super
|
39
28
|
|
@@ -65,6 +54,27 @@ module FrederickAPI
|
|
65
54
|
{ prefix => object }
|
66
55
|
end
|
67
56
|
end
|
57
|
+
|
58
|
+
protected
|
59
|
+
|
60
|
+
def _fetch
|
61
|
+
(requestor || klass.requestor).get(params)
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def _new_scope(opts = {})
|
67
|
+
self.class.new(@klass,
|
68
|
+
requestor: requestor,
|
69
|
+
primary_key: opts.fetch(:primary_key, @primary_key),
|
70
|
+
pagination_params: @pagination_params.merge(opts.fetch(:pagination_params, {})),
|
71
|
+
path_params: @path_params.merge(opts.fetch(:path_params, {})),
|
72
|
+
additional_params: @additional_params.merge(opts.fetch(:additional_params, {})),
|
73
|
+
filters: @filters.merge(opts.fetch(:filters, {})),
|
74
|
+
includes: @includes + opts.fetch(:includes, []),
|
75
|
+
orders: @orders + opts.fetch(:orders, []),
|
76
|
+
fields: @fields + opts.fetch(:fields, []))
|
77
|
+
end
|
68
78
|
end
|
69
79
|
end
|
70
80
|
end
|
@@ -32,8 +32,11 @@ module FrederickAPI
|
|
32
32
|
path = resource_path(params)
|
33
33
|
|
34
34
|
params.delete(klass.primary_key)
|
35
|
-
|
36
|
-
|
35
|
+
if get_via_post_path?(path)
|
36
|
+
return request(:post, path, body: params.to_json, additional_headers: { 'X-Request-Method' => 'GET' })
|
37
|
+
end
|
38
|
+
|
39
|
+
request(:get, path, params: params)
|
37
40
|
end
|
38
41
|
|
39
42
|
def linked(path)
|
@@ -42,13 +45,16 @@ module FrederickAPI
|
|
42
45
|
|
43
46
|
path_without_params = "#{uri.scheme}://#{uri.host}#{uri.path}"
|
44
47
|
params = uri.query ? CGI.parse(uri.query).each_with_object({}) { |(k, v), h| h[k] = v[0] } : {}
|
45
|
-
request(:post, path_without_params, params, 'X-Request-Method' => 'GET')
|
48
|
+
request(:post, path_without_params, params: params, additional_headers: { 'X-Request-Method' => 'GET' })
|
46
49
|
end
|
47
50
|
|
48
51
|
# Retry once on unhandled server errors
|
49
|
-
def request(type, path, params, additional_headers
|
52
|
+
def request(type, path, params: nil, body: nil, additional_headers: {})
|
50
53
|
headers = klass.custom_headers.merge(additional_headers)
|
51
|
-
make_request = proc
|
54
|
+
make_request = proc do
|
55
|
+
handle_background(handle_errors(make_request(type, path, params: params, body: body, headers: headers)))
|
56
|
+
end
|
57
|
+
|
52
58
|
begin
|
53
59
|
make_request.call
|
54
60
|
rescue JsonApiClient::Errors::ConnectionError, JsonApiClient::Errors::ServerError => ex
|
@@ -73,10 +79,12 @@ module FrederickAPI
|
|
73
79
|
raise error_klass, result
|
74
80
|
end
|
75
81
|
|
76
|
-
def make_request(type, path, params
|
77
|
-
faraday_response = connection.run(type, path, params, headers)
|
82
|
+
def make_request(type, path, params:, body:, headers:)
|
83
|
+
faraday_response = connection.run(type, path, params: params, body: body, headers: headers)
|
78
84
|
return klass.parser.parse(klass, faraday_response) unless faraday_response.status == 303
|
79
85
|
linked(faraday_response.headers['location'])
|
86
|
+
rescue JsonApiClient::Errors::ClientError => ex
|
87
|
+
klass.parser.parse(klass, ex.env.response)
|
80
88
|
end
|
81
89
|
|
82
90
|
def get_via_post_path?(path)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: frederick_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.6'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frederick Engineering
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json_api_client
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.17.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.17.1
|
27
27
|
description: Ruby client for the Frederick API
|
28
28
|
email:
|
29
29
|
- tech@hirefrederick.com
|
@@ -60,7 +60,7 @@ homepage: https://github.com/HireFrederick/frederick_api_gem
|
|
60
60
|
licenses:
|
61
61
|
- MIT
|
62
62
|
metadata: {}
|
63
|
-
post_install_message:
|
63
|
+
post_install_message:
|
64
64
|
rdoc_options: []
|
65
65
|
require_paths:
|
66
66
|
- lib
|
@@ -75,9 +75,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '0'
|
77
77
|
requirements: []
|
78
|
-
|
79
|
-
|
80
|
-
signing_key:
|
78
|
+
rubygems_version: 3.0.8
|
79
|
+
signing_key:
|
81
80
|
specification_version: 4
|
82
81
|
summary: Frederick API Client
|
83
82
|
test_files: []
|