Class: VAProfile::Response

Inherits:
Common::Base show all
Includes:
Common::Client::Concerns::ServiceStatus
Defined in:
lib/va_profile/response.rb

Constant Summary

Constants included from Common::Client::Concerns::ServiceStatus

Common::Client::Concerns::ServiceStatus::RESPONSE_STATUS

Instance Attribute Summary

Attributes inherited from Common::Base

#errors_hash

Instance Method Summary collapse

Methods inherited from Common::Base

#changed, #changed?, #changes, default_sort, filterable_attributes, max_per_page, per_page, sortable_attributes

Constructor Details

#initialize(status, attributes = nil) ⇒ Response

Returns a new instance of Response.



12
13
14
15
# File 'lib/va_profile/response.rb', line 12

def initialize(status, attributes = nil)
  super(attributes) if attributes
  self.status = status
end

Instance Method Details

#cache?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/va_profile/response.rb', line 21

def cache?
  ok?
end

#metadataObject



25
26
27
# File 'lib/va_profile/response.rb', line 25

def 
  { status: response_status }
end

#ok?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/va_profile/response.rb', line 17

def ok?
  status == 200
end

#response_statusObject



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/va_profile/response.rb', line 29

def response_status
  case status
  when 200
    RESPONSE_STATUS[:ok]
  when 403
    RESPONSE_STATUS[:not_authorized]
  when 404
    RESPONSE_STATUS[:not_found]
  else
    RESPONSE_STATUS[:server_error]
  end
end