8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/pr/pin/adapter/handlers/json_response.rb', line 8
def call(response, dataset)
result = JSON.parse(
response.body,
symbolize_names: true
)
= result.fetch(:pagination, false)
if SUCCESS_CODES.include?(response.code)
if %i(post put patch).include?(dataset.request_method)
response = result[:response]
else
response = Array([result[:response]]).flatten(1)
end
if
PaginatedResponse.new(response, )
else
Response.new(response)
end
else
raise(ResponseError.new(response, result))
end
end
|