json_api_client 1.21.0 → 1.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/json_api_client/errors.rb +11 -4
- data/lib/json_api_client/included_data.rb +1 -1
- data/lib/json_api_client/middleware/status.rb +1 -1
- data/lib/json_api_client/query/builder.rb +2 -2
- data/lib/json_api_client/utils.rb +5 -0
- data/lib/json_api_client/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50ee381b7fb9cdebf8538c162a5dab717e8e2e23fffdc293ef7738728f45f9c3
|
4
|
+
data.tar.gz: 1be6e62baf09fc3bc78c7c65a5a7b567b0c4a875d1e6bbe06411774ee34d059a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60b1b657a5b30630f03e461bc4d29f5c0127417c53d63da146059d7a4bfef97e294d48d3bea842811dc72366e18cca7b1ddb1f68a573d42f1571a30dc199a9f6
|
7
|
+
data.tar.gz: a99ff29dd85edb6e036538c61d9ae84359a62bd8464e4f9839c09e2d8c1859d30ee58182a962503b00134fcb20c473520157bbe52b0dba5819dfc70402054d4b
|
@@ -46,11 +46,18 @@ module JsonApiClient
|
|
46
46
|
|
47
47
|
class NotFound < ClientError
|
48
48
|
attr_reader :uri
|
49
|
-
def initialize(
|
50
|
-
|
49
|
+
def initialize(env_or_uri, msg = nil)
|
50
|
+
env = nil
|
51
|
+
|
52
|
+
if env_or_uri.kind_of?(Faraday::Env)
|
53
|
+
env = env_or_uri
|
54
|
+
@uri = env[:url]
|
55
|
+
else
|
56
|
+
@uri = env_or_uri
|
57
|
+
end
|
51
58
|
|
52
|
-
msg
|
53
|
-
super
|
59
|
+
msg ||= "Resource not found: #{uri.to_s}"
|
60
|
+
super env, msg
|
54
61
|
end
|
55
62
|
end
|
56
63
|
|
@@ -24,7 +24,7 @@ module JsonApiClient
|
|
24
24
|
end
|
25
25
|
|
26
26
|
grouped_included_set.each do |type, resources|
|
27
|
-
grouped_included_set[type] = resources.index_by
|
27
|
+
grouped_included_set[type] = resources.index_by { |resource| resource.attributes[:id] }
|
28
28
|
end
|
29
29
|
|
30
30
|
@data = grouped_included_set
|
@@ -92,7 +92,7 @@ module JsonApiClient
|
|
92
92
|
|
93
93
|
def find(args = {})
|
94
94
|
if klass.raise_on_blank_find_param && args.blank?
|
95
|
-
raise Errors::NotFound, 'blank .find param'
|
95
|
+
raise Errors::NotFound, nil, 'blank .find param'
|
96
96
|
end
|
97
97
|
|
98
98
|
case args
|
@@ -136,7 +136,7 @@ module JsonApiClient
|
|
136
136
|
primary_key: opts.fetch( :primary_key, @primary_key ),
|
137
137
|
pagination_params: @pagination_params.merge( opts.fetch( :pagination_params, {} ) ),
|
138
138
|
path_params: @path_params.merge( opts.fetch( :path_params, {} ) ),
|
139
|
-
additional_params: @additional_params.
|
139
|
+
additional_params: @additional_params.deep_merge( opts.fetch( :additional_params, {} ) ),
|
140
140
|
filters: @filters.merge( opts.fetch( :filters, {} ) ),
|
141
141
|
includes: @includes + opts.fetch( :includes, [] ),
|
142
142
|
orders: @orders + opts.fetch( :orders, [] ),
|
@@ -7,6 +7,11 @@ module JsonApiClient
|
|
7
7
|
# the type_name is an absolute reference.
|
8
8
|
return type_name.constantize if type_name.match(/^::/)
|
9
9
|
|
10
|
+
# Check the klass association definitions
|
11
|
+
association_klass_match = klass.associations.find { |a| a.attr_name.to_s.singularize == type_name.underscore }
|
12
|
+
association_klass = association_klass_match.options[:class] if association_klass_match
|
13
|
+
return association_klass if association_klass
|
14
|
+
|
10
15
|
# Build a list of candidates to search for
|
11
16
|
candidates = []
|
12
17
|
klass.name.scan(/::|$/) { candidates.unshift "#{$`}::#{type_name}" }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_api_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.22.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Ching
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -205,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
205
205
|
- !ruby/object:Gem::Version
|
206
206
|
version: '0'
|
207
207
|
requirements: []
|
208
|
-
rubygems_version: 3.0.3
|
208
|
+
rubygems_version: 3.0.3.1
|
209
209
|
signing_key:
|
210
210
|
specification_version: 4
|
211
211
|
summary: Build client libraries compliant with specification defined by jsonapi.org
|