restful_resource 2.3.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +20 -0
- data/.codeclimate.yml +3 -0
- data/.rubocop.yml +5 -0
- data/.rubocop_todo.yml +203 -0
- data/CHANGELOG.md +5 -0
- data/README.md +1 -1
- data/Rakefile +5 -5
- data/lib/restful_resource/associations.rb +10 -8
- data/lib/restful_resource/base.rb +36 -33
- data/lib/restful_resource/http_client.rb +50 -48
- data/lib/restful_resource/instrumentation.rb +17 -20
- data/lib/restful_resource/null_logger.rb +1 -2
- data/lib/restful_resource/open_object.rb +2 -2
- data/lib/restful_resource/paginated_array.rb +3 -1
- data/lib/restful_resource/rails_validations.rb +12 -12
- data/lib/restful_resource/redirections.rb +5 -6
- data/lib/restful_resource/request.rb +0 -1
- data/lib/restful_resource/resource_id_missing_error.rb +1 -1
- data/lib/restful_resource/response.rb +4 -2
- data/lib/restful_resource/version.rb +1 -1
- data/restful_resource.gemspec +26 -25
- data/spec/fixtures.rb +7 -7
- data/spec/restful_resource/associations_spec.rb +23 -21
- data/spec/restful_resource/base_authorization_spec.rb +6 -7
- data/spec/restful_resource/base_spec.rb +134 -117
- data/spec/restful_resource/http_client_configuration_spec.rb +20 -19
- data/spec/restful_resource/http_client_spec.rb +38 -38
- data/spec/restful_resource/open_object_spec.rb +8 -8
- data/spec/restful_resource/rails_validations_spec.rb +68 -68
- data/spec/restful_resource/redirections_spec.rb +26 -26
- data/spec/spec_helper.rb +3 -4
- metadata +44 -13
- data/circle.yml +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f5f98400c48167cdb639a07e34ec5556d6d3ee4120686e1c97b1a21f46c1288
|
4
|
+
data.tar.gz: bf34cb96327e7420f7efd0c08bac8ffee01efea9ae104eef4bb24c03da0265a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '04010962bd8ad44f0ed445641997bf8604fad6b0b694f181040e552856730cbdf26b4e30b3cd62bd90b4e4ec152dd1811d67fad63b8efe4bfb5c6687e27e0b55'
|
7
|
+
data.tar.gz: cc0f65d304132e7eb25d601e19e491c12e584ef896681862ca4a3bda1e97e2500efb80afa5e783ab55a09d468ce87baeec1880280dd1ece333a61efc7503df8b
|
@@ -0,0 +1,20 @@
|
|
1
|
+
version: 2
|
2
|
+
jobs:
|
3
|
+
build:
|
4
|
+
docker:
|
5
|
+
- image: circleci/ruby:2.4.4
|
6
|
+
steps:
|
7
|
+
- checkout
|
8
|
+
- run:
|
9
|
+
name: Bundle Install
|
10
|
+
command: bundle check || bundle install
|
11
|
+
- run:
|
12
|
+
name: Run rspec in parallel
|
13
|
+
command: |
|
14
|
+
bundle exec rspec --profile 10 \
|
15
|
+
--format RspecJunitFormatter \
|
16
|
+
--out test_results/rspec.xml \
|
17
|
+
--format progress \
|
18
|
+
$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
|
19
|
+
- store_test_results:
|
20
|
+
path: test_results
|
data/.codeclimate.yml
ADDED
data/.rubocop.yml
ADDED
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,203 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2018-09-11 09:24:50 +0000 using RuboCop version 0.59.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 2
|
10
|
+
# Cop supports --auto-correct.
|
11
|
+
Layout/RescueEnsureAlignment:
|
12
|
+
Exclude:
|
13
|
+
- 'lib/restful_resource/associations.rb'
|
14
|
+
|
15
|
+
# Offense count: 10
|
16
|
+
Lint/IneffectiveAccessModifier:
|
17
|
+
Exclude:
|
18
|
+
- 'lib/restful_resource/base.rb'
|
19
|
+
|
20
|
+
# Offense count: 1
|
21
|
+
Lint/Loop:
|
22
|
+
Exclude:
|
23
|
+
- 'lib/restful_resource/base.rb'
|
24
|
+
|
25
|
+
# Offense count: 2
|
26
|
+
Lint/ParenthesesAsGroupedExpression:
|
27
|
+
Exclude:
|
28
|
+
- 'spec/restful_resource/base_spec.rb'
|
29
|
+
|
30
|
+
# Offense count: 2
|
31
|
+
# Cop supports --auto-correct.
|
32
|
+
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
|
33
|
+
Lint/UnusedMethodArgument:
|
34
|
+
Exclude:
|
35
|
+
- 'lib/restful_resource/redirections.rb'
|
36
|
+
|
37
|
+
# Offense count: 3
|
38
|
+
# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
|
39
|
+
Lint/UselessAccessModifier:
|
40
|
+
Exclude:
|
41
|
+
- 'lib/restful_resource/base.rb'
|
42
|
+
- 'lib/restful_resource/redirections.rb'
|
43
|
+
|
44
|
+
# Offense count: 5
|
45
|
+
Lint/UselessAssignment:
|
46
|
+
Exclude:
|
47
|
+
- 'lib/restful_resource/rails_validations.rb'
|
48
|
+
- 'lib/restful_resource/redirections.rb'
|
49
|
+
- 'spec/restful_resource/base_spec.rb'
|
50
|
+
- 'spec/restful_resource/redirections_spec.rb'
|
51
|
+
|
52
|
+
# Offense count: 8
|
53
|
+
Metrics/AbcSize:
|
54
|
+
Max: 101
|
55
|
+
|
56
|
+
# Offense count: 1
|
57
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
58
|
+
# ExcludedMethods: refine
|
59
|
+
Metrics/BlockLength:
|
60
|
+
Max: 27
|
61
|
+
|
62
|
+
# Offense count: 2
|
63
|
+
# Configuration parameters: CountComments.
|
64
|
+
Metrics/ClassLength:
|
65
|
+
Max: 162
|
66
|
+
|
67
|
+
# Offense count: 2
|
68
|
+
Metrics/CyclomaticComplexity:
|
69
|
+
Max: 13
|
70
|
+
|
71
|
+
# Offense count: 42
|
72
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
73
|
+
# URISchemes: http, https
|
74
|
+
Metrics/LineLength:
|
75
|
+
Max: 201
|
76
|
+
|
77
|
+
# Offense count: 10
|
78
|
+
# Configuration parameters: CountComments.
|
79
|
+
Metrics/MethodLength:
|
80
|
+
Max: 56
|
81
|
+
|
82
|
+
# Offense count: 8
|
83
|
+
# Configuration parameters: CountKeywordArgs.
|
84
|
+
Metrics/ParameterLists:
|
85
|
+
Max: 10
|
86
|
+
|
87
|
+
# Offense count: 1
|
88
|
+
Metrics/PerceivedComplexity:
|
89
|
+
Max: 8
|
90
|
+
|
91
|
+
# Offense count: 2
|
92
|
+
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist, MethodDefinitionMacros.
|
93
|
+
# NamePrefix: is_, has_, have_
|
94
|
+
# NamePrefixBlacklist: is_, has_, have_
|
95
|
+
# NameWhitelist: is_a?
|
96
|
+
# MethodDefinitionMacros: define_method, define_singleton_method
|
97
|
+
Naming/PredicateName:
|
98
|
+
Exclude:
|
99
|
+
- 'spec/**/*'
|
100
|
+
- 'lib/restful_resource/associations.rb'
|
101
|
+
|
102
|
+
# Offense count: 14
|
103
|
+
# Configuration parameters: Prefixes.
|
104
|
+
# Prefixes: when, with, without
|
105
|
+
RSpec/ContextWording:
|
106
|
+
Exclude:
|
107
|
+
- 'spec/restful_resource/http_client_configuration_spec.rb'
|
108
|
+
- 'spec/restful_resource/rails_validations_spec.rb'
|
109
|
+
- 'spec/restful_resource/request_spec.rb'
|
110
|
+
|
111
|
+
# Offense count: 1
|
112
|
+
RSpec/DescribeMethod:
|
113
|
+
Exclude:
|
114
|
+
- 'spec/restful_resource/base_authorization_spec.rb'
|
115
|
+
|
116
|
+
# Offense count: 19
|
117
|
+
# Configuration parameters: Max.
|
118
|
+
RSpec/ExampleLength:
|
119
|
+
Exclude:
|
120
|
+
- 'spec/restful_resource/base_spec.rb'
|
121
|
+
- 'spec/restful_resource/http_client_configuration_spec.rb'
|
122
|
+
- 'spec/restful_resource/http_client_spec.rb'
|
123
|
+
- 'spec/restful_resource/open_object_spec.rb'
|
124
|
+
- 'spec/restful_resource/rails_validations_spec.rb'
|
125
|
+
- 'spec/restful_resource/redirections_spec.rb'
|
126
|
+
|
127
|
+
# Offense count: 53
|
128
|
+
# Configuration parameters: AssignmentOnly.
|
129
|
+
RSpec/InstanceVariable:
|
130
|
+
Exclude:
|
131
|
+
- 'spec/restful_resource/associations_spec.rb'
|
132
|
+
- 'spec/restful_resource/base_spec.rb'
|
133
|
+
- 'spec/restful_resource/http_client_configuration_spec.rb'
|
134
|
+
- 'spec/restful_resource/rails_validations_spec.rb'
|
135
|
+
- 'spec/restful_resource/redirections_spec.rb'
|
136
|
+
|
137
|
+
# Offense count: 14
|
138
|
+
# Configuration parameters: EnforcedStyle.
|
139
|
+
# SupportedStyles: have_received, receive
|
140
|
+
RSpec/MessageSpies:
|
141
|
+
Exclude:
|
142
|
+
- 'spec/restful_resource/base_spec.rb'
|
143
|
+
- 'spec/restful_resource/redirections_spec.rb'
|
144
|
+
- 'spec/spec_helper.rb'
|
145
|
+
|
146
|
+
# Offense count: 22
|
147
|
+
# Configuration parameters: AggregateFailuresByDefault.
|
148
|
+
RSpec/MultipleExpectations:
|
149
|
+
Max: 7
|
150
|
+
|
151
|
+
# Offense count: 6
|
152
|
+
RSpec/NamedSubject:
|
153
|
+
Exclude:
|
154
|
+
- 'spec/restful_resource/redirections_spec.rb'
|
155
|
+
|
156
|
+
# Offense count: 10
|
157
|
+
RSpec/NestedGroups:
|
158
|
+
Max: 5
|
159
|
+
|
160
|
+
# Offense count: 2
|
161
|
+
RSpec/RepeatedDescription:
|
162
|
+
Exclude:
|
163
|
+
- 'spec/restful_resource/base_spec.rb'
|
164
|
+
|
165
|
+
# Offense count: 3
|
166
|
+
# Configuration parameters: IgnoreSymbolicNames.
|
167
|
+
RSpec/VerifiedDoubles:
|
168
|
+
Exclude:
|
169
|
+
- 'spec/restful_resource/base_spec.rb'
|
170
|
+
- 'spec/restful_resource/rails_validations_spec.rb'
|
171
|
+
- 'spec/restful_resource/redirections_spec.rb'
|
172
|
+
|
173
|
+
# Offense count: 1
|
174
|
+
# Configuration parameters: AllowedChars.
|
175
|
+
Style/AsciiComments:
|
176
|
+
Exclude:
|
177
|
+
- 'lib/restful_resource/instrumentation.rb'
|
178
|
+
|
179
|
+
# Offense count: 1
|
180
|
+
Style/MethodMissingSuper:
|
181
|
+
Exclude:
|
182
|
+
- 'lib/restful_resource/open_object.rb'
|
183
|
+
|
184
|
+
# Offense count: 1
|
185
|
+
Style/MissingRespondToMissing:
|
186
|
+
Exclude:
|
187
|
+
- 'lib/restful_resource/open_object.rb'
|
188
|
+
|
189
|
+
# Offense count: 1
|
190
|
+
# Cop supports --auto-correct.
|
191
|
+
# Configuration parameters: EnforcedStyle, AllowInnerSlashes.
|
192
|
+
# SupportedStyles: slashes, percent_r, mixed
|
193
|
+
Style/RegexpLiteral:
|
194
|
+
Exclude:
|
195
|
+
- 'lib/restful_resource/base.rb'
|
196
|
+
|
197
|
+
# Offense count: 1
|
198
|
+
# Cop supports --auto-correct.
|
199
|
+
# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, Whitelist.
|
200
|
+
# Whitelist: to_ary, to_a, to_c, to_enum, to_h, to_hash, to_i, to_int, to_io, to_open, to_path, to_proc, to_r, to_regexp, to_str, to_s, to_sym
|
201
|
+
Style/TrivialAccessors:
|
202
|
+
Exclude:
|
203
|
+
- 'lib/restful_resource/base.rb'
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# RestfulResource ![build status](https://circleci.com/gh/carwow/restful_resource.svg?style=shield&circle-token=0558310359000e8786d1fe42774b0e30b2b0e12c)
|
1
|
+
# RestfulResource ![build status](https://circleci.com/gh/carwow/restful_resource.svg?style=shield&circle-token=0558310359000e8786d1fe42774b0e30b2b0e12c) [![Maintainability](https://api.codeclimate.com/v1/badges/61c85db718d559aa97c5/maintainability)](https://codeclimate.com/github/carwow/restful_resource/maintainability)
|
2
2
|
|
3
3
|
Provides an ActiveResource like interface to JSON API's
|
4
4
|
|
data/Rakefile
CHANGED
@@ -9,12 +9,12 @@ desc "Upload to rubygems"
|
|
9
9
|
task :upload => :build do
|
10
10
|
# Check if tag with v#{ResearchSiteApiClient::VERSION} version exists, if so, return with error
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
if tag_exists?(current_tag_name)
|
13
|
+
puts "Tag exists, did you run rake increase_revision_number after merging with master?"
|
14
|
+
exit 1
|
15
|
+
end
|
16
16
|
|
17
|
-
|
17
|
+
create_tag(current_tag_name)
|
18
18
|
Rake::Task[:release].invoke
|
19
19
|
end
|
20
20
|
|
@@ -1,37 +1,39 @@
|
|
1
1
|
module RestfulResource
|
2
2
|
module Associations
|
3
3
|
def has_many(nested_resource_type)
|
4
|
-
namespace =
|
5
|
-
klass_name =
|
4
|
+
namespace = to_s.deconstantize
|
5
|
+
klass_name = nested_resource_type.to_s.singularize.camelize.to_s
|
6
6
|
klass_name = "#{namespace}::#{klass_name}" if namespace.present?
|
7
7
|
|
8
|
-
|
8
|
+
send(:define_method, nested_resource_type) do
|
9
9
|
klass = begin
|
10
10
|
klass_name.safe_constantize
|
11
11
|
rescue NameError
|
12
12
|
nil
|
13
13
|
end
|
14
|
-
klass = RestfulResource::OpenObject if
|
14
|
+
klass = RestfulResource::OpenObject if klass.nil? || !(klass < RestfulResource::OpenObject)
|
15
15
|
nested_resource = @inner_object.send(nested_resource_type)
|
16
16
|
return nil if nested_resource.nil?
|
17
|
+
|
17
18
|
nested_resource.map { |obj| klass.new(obj) }
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
21
22
|
def has_one(nested_resource_type)
|
22
|
-
namespace =
|
23
|
-
klass_name =
|
23
|
+
namespace = to_s.deconstantize
|
24
|
+
klass_name = nested_resource_type.to_s.camelize.to_s
|
24
25
|
klass_name = "#{namespace}::#{klass_name}" if namespace.present?
|
25
26
|
|
26
|
-
|
27
|
+
send(:define_method, nested_resource_type) do
|
27
28
|
klass = begin
|
28
29
|
klass_name.safe_constantize
|
29
30
|
rescue NameError
|
30
31
|
nil
|
31
32
|
end
|
32
|
-
klass = RestfulResource::OpenObject if
|
33
|
+
klass = RestfulResource::OpenObject if klass.nil? || !(klass < RestfulResource::OpenObject)
|
33
34
|
nested_resource = @inner_object.send(nested_resource_type)
|
34
35
|
return nil if nested_resource.nil?
|
36
|
+
|
35
37
|
klass.new(@inner_object.send(nested_resource_type))
|
36
38
|
end
|
37
39
|
end
|
@@ -3,13 +3,14 @@ module RestfulResource
|
|
3
3
|
extend RestfulResource::Associations
|
4
4
|
|
5
5
|
def self.configure(base_url: nil,
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
username: nil,
|
7
|
+
password: nil,
|
8
|
+
auth_token: nil,
|
9
|
+
logger: nil,
|
10
|
+
cache_store: nil,
|
11
|
+
instrumentation: {},
|
12
|
+
faraday_config: nil,
|
13
|
+
faraday_options: nil)
|
13
14
|
|
14
15
|
@base_url = URI.parse(base_url)
|
15
16
|
|
@@ -19,33 +20,35 @@ module RestfulResource
|
|
19
20
|
logger: logger,
|
20
21
|
cache_store: cache_store,
|
21
22
|
instrumentation: instrumentation,
|
22
|
-
faraday_config: faraday_config
|
23
|
+
faraday_config: faraday_config,
|
24
|
+
faraday_options: faraday_options
|
25
|
+
)
|
23
26
|
end
|
24
27
|
|
25
28
|
def self.resource_path(url)
|
26
29
|
@resource_path = url
|
27
30
|
end
|
28
31
|
|
29
|
-
def self.find(id, params={})
|
32
|
+
def self.find(id, params = {})
|
30
33
|
params_without_options, options = format_params(params)
|
31
34
|
|
32
35
|
response = http.get(member_url(id, params_without_options), **options)
|
33
|
-
|
36
|
+
new(parse_json(response.body))
|
34
37
|
end
|
35
38
|
|
36
|
-
def self.where(params={})
|
39
|
+
def self.where(params = {})
|
37
40
|
params_without_options, options = format_params(params)
|
38
41
|
|
39
42
|
url = collection_url(params_without_options)
|
40
43
|
response = http.get(url, **options)
|
41
|
-
|
44
|
+
paginate_response(response)
|
42
45
|
end
|
43
46
|
|
44
47
|
def self.get(params = {})
|
45
48
|
params_without_options, options = format_params(params)
|
46
49
|
|
47
50
|
response = http.get(collection_url(params_without_options), **options)
|
48
|
-
|
51
|
+
new(parse_json(response.body))
|
49
52
|
end
|
50
53
|
|
51
54
|
def self.delete(id, **params)
|
@@ -61,7 +64,7 @@ module RestfulResource
|
|
61
64
|
url = member_url(id, params_without_options)
|
62
65
|
|
63
66
|
response = http.put(url, data: data, headers: headers, **options)
|
64
|
-
|
67
|
+
new(parse_json(response.body))
|
65
68
|
end
|
66
69
|
|
67
70
|
def self.post(data: {}, headers: {}, **params)
|
@@ -72,11 +75,11 @@ module RestfulResource
|
|
72
75
|
|
73
76
|
response = http.post(url, data: data, headers: headers, **options)
|
74
77
|
|
75
|
-
|
78
|
+
new(parse_json(response.body))
|
76
79
|
end
|
77
80
|
|
78
81
|
def self.all(params = {})
|
79
|
-
|
82
|
+
where(params)
|
80
83
|
end
|
81
84
|
|
82
85
|
def self.action(action_name)
|
@@ -89,30 +92,30 @@ module RestfulResource
|
|
89
92
|
@action_prefix = action_prefix.to_s
|
90
93
|
end
|
91
94
|
|
92
|
-
def self.fetch_all!(conditions={})
|
95
|
+
def self.fetch_all!(conditions = {})
|
93
96
|
Enumerator.new do |y|
|
94
97
|
next_page = 1
|
95
98
|
begin
|
96
|
-
resources =
|
99
|
+
resources = where(conditions.merge(page: next_page))
|
97
100
|
resources.each do |resource|
|
98
101
|
y << resource
|
99
102
|
end
|
100
103
|
next_page = resources.next_page
|
101
|
-
end while
|
104
|
+
end while !next_page.nil?
|
102
105
|
end
|
103
106
|
end
|
104
107
|
|
105
108
|
protected
|
109
|
+
|
106
110
|
def self.http
|
107
111
|
@http || superclass.http
|
108
112
|
end
|
109
113
|
|
110
114
|
def self.base_url
|
111
115
|
result = @base_url
|
112
|
-
if result.nil? && superclass.respond_to?(:base_url)
|
113
|
-
|
114
|
-
|
115
|
-
raise "Base url missing" if result.nil?
|
116
|
+
result = superclass.base_url if result.nil? && superclass.respond_to?(:base_url)
|
117
|
+
raise 'Base url missing' if result.nil?
|
118
|
+
|
116
119
|
result
|
117
120
|
end
|
118
121
|
|
@@ -126,7 +129,7 @@ module RestfulResource
|
|
126
129
|
def self.format_params(params = {})
|
127
130
|
headers = params.delete(:headers) || {}
|
128
131
|
|
129
|
-
headers
|
132
|
+
headers[:cache_control] = 'no-cache' if params.delete(:no_cache)
|
130
133
|
open_timeout = params.delete(:open_timeout)
|
131
134
|
timeout = params.delete(:timeout)
|
132
135
|
|
@@ -139,18 +142,20 @@ module RestfulResource
|
|
139
142
|
|
140
143
|
def self.member_url(id, params)
|
141
144
|
raise ResourceIdMissingError if id.blank?
|
145
|
+
|
142
146
|
url = merge_url_paths(base_url, @resource_path, CGI.escape(id.to_s), @action_prefix)
|
143
147
|
replace_parameters(url, params)
|
144
148
|
end
|
145
149
|
|
146
150
|
def self.new_collection(json)
|
147
151
|
json.map do |element|
|
148
|
-
|
152
|
+
new(element)
|
149
153
|
end
|
150
154
|
end
|
151
155
|
|
152
156
|
def self.parse_json(json)
|
153
157
|
return nil if json.strip.empty?
|
158
|
+
|
154
159
|
ActiveSupport::JSON.decode(json)
|
155
160
|
end
|
156
161
|
|
@@ -164,15 +169,13 @@ module RestfulResource
|
|
164
169
|
if value.nil?
|
165
170
|
missing_params << key
|
166
171
|
else
|
167
|
-
url = url.gsub(':'+key, CGI.escape(value.to_s))
|
172
|
+
url = url.gsub(':' + key, CGI.escape(value.to_s))
|
168
173
|
end
|
169
174
|
end
|
170
175
|
|
171
|
-
if missing_params.any?
|
172
|
-
raise ParameterMissingError.new(missing_params)
|
173
|
-
end
|
176
|
+
raise ParameterMissingError, missing_params if missing_params.any?
|
174
177
|
|
175
|
-
url
|
178
|
+
url += "?#{params.to_query}" unless params.empty?
|
176
179
|
url
|
177
180
|
end
|
178
181
|
|
@@ -180,10 +183,10 @@ module RestfulResource
|
|
180
183
|
links_header = response.headers[:links]
|
181
184
|
links = LinkHeader.parse(links_header)
|
182
185
|
|
183
|
-
prev_url = links.find_link([
|
184
|
-
next_url = links.find_link([
|
186
|
+
prev_url = links.find_link(%w[rel prev]).try(:href)
|
187
|
+
next_url = links.find_link(%w[rel next]).try(:href)
|
185
188
|
|
186
|
-
array = parse_json(response.body).map { |attributes|
|
189
|
+
array = parse_json(response.body).map { |attributes| new(attributes) }
|
187
190
|
PaginatedArray.new(array, previous_page_url: prev_url, next_page_url: next_url, total_count: response.headers[:x_total_count])
|
188
191
|
end
|
189
192
|
end
|