Class: Nova::API::Response
Constant Summary
Utils::BaseStruct::DATE_REGEX
Class Method Summary
collapse
#allowed_attributes
Class Method Details
.build(response, object = nil) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/nova/api/response.rb', line 13
def self.build(response, object = nil)
success = response.success?
status = response.code
parsed_response = response.parsed_response.to_h
record = nil
errors = ('error', parsed_response)
errors ||= ('errors', parsed_response)
errors ||= []
if object
record = object.class.new(object.attributes.merge(parsed_response))
end
new(success: success, errors: errors, record: record, status: status)
end
|