Class: Lighthouse::DirectDeposit::ErrorResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/lighthouse/direct_deposit/error_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, errors) ⇒ ErrorResponse

Returns a new instance of ErrorResponse.



8
9
10
11
# File 'lib/lighthouse/direct_deposit/error_response.rb', line 8

def initialize(status, errors)
  @status = status
  @errors = errors || []
end

Instance Attribute Details

#errorsObject

Returns the value of attribute errors.



6
7
8
# File 'lib/lighthouse/direct_deposit/error_response.rb', line 6

def errors
  @errors
end

#statusObject

Returns the value of attribute status.



6
7
8
# File 'lib/lighthouse/direct_deposit/error_response.rb', line 6

def status
  @status
end

Instance Method Details

#bodyObject



20
21
22
# File 'lib/lighthouse/direct_deposit/error_response.rb', line 20

def body
  { errors: @errors }
end

#codeObject



28
29
30
# File 'lib/lighthouse/direct_deposit/error_response.rb', line 28

def code
  errors.first[:code]
end

#code=(code) ⇒ Object



24
25
26
# File 'lib/lighthouse/direct_deposit/error_response.rb', line 24

def code=(code)
  errors.first[:code] = code
end

#detailObject



36
37
38
# File 'lib/lighthouse/direct_deposit/error_response.rb', line 36

def detail
  errors.first[:detail]
end

#error?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/lighthouse/direct_deposit/error_response.rb', line 44

def error?
  true
end

#messageObject



40
41
42
# File 'lib/lighthouse/direct_deposit/error_response.rb', line 40

def message
  "#{code}: #{title} - #{detail}"
end

#responseObject



13
14
15
16
17
18
# File 'lib/lighthouse/direct_deposit/error_response.rb', line 13

def response
  {
    status: @status,
    body:
  }
end

#titleObject



32
33
34
# File 'lib/lighthouse/direct_deposit/error_response.rb', line 32

def title
  errors.first[:title]
end