Class: IHub::Appointments::Response
Constant Summary
Common::Client::Concerns::ServiceStatus::RESPONSE_STATUS
Instance Attribute Summary
Attributes inherited from Common::Base
#errors_hash
Class Method Summary
collapse
Instance Method Summary
collapse
#changed, #changed?, #changes, default_sort, filterable_attributes, max_per_page, per_page, sortable_attributes
Constructor Details
#initialize(attributes = nil) ⇒ Response
Returns a new instance of Response.
15
16
17
18
|
# File 'lib/ihub/appointments/response.rb', line 15
def initialize(attributes = nil)
super(attributes) if attributes
self.status = attributes[:status]
end
|
Class Method Details
.from(response) ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'lib/ihub/appointments/response.rb', line 20
def self.from(response)
all_appointments = response.body&.fetch('data', [])
new(
status: response.status,
appointments: IHub::Models::Appointment.build_all(all_appointments)
)
end
|
Instance Method Details
#cache? ⇒ Boolean
33
34
35
|
# File 'lib/ihub/appointments/response.rb', line 33
def cache?
ok?
end
|
37
38
39
|
# File 'lib/ihub/appointments/response.rb', line 37
def metadata
{ status: response_status }
end
|
#ok? ⇒ Boolean
29
30
31
|
# File 'lib/ihub/appointments/response.rb', line 29
def ok?
status == 200
end
|
#response_status ⇒ Object