Class: EVSS::Letters::LettersResponse

Inherits:
Response show all
Defined in:
lib/evss/letters/letters_response.rb

Overview

Model for a letter service response, containing the recipient’s name and an array of letter objects

Constant Summary

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

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

Instance Attribute Summary collapse

Attributes inherited from Common::Base

#errors_hash, #metadata

Instance Method Summary collapse

Methods inherited from Response

#cache?, #metadata, #ok?, #response_status

Methods inherited from Common::Base

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

Constructor Details

#initialize(status, response = nil) ⇒ LettersResponse

Returns a new instance of LettersResponse.



25
26
27
28
29
30
31
32
33
# File 'lib/evss/letters/letters_response.rb', line 25

def initialize(status, response = nil)
  if response
    attributes = {
      letters: response.body['letters'],
      full_name: response.body.dig('letter_destination', 'full_name')
    }
  end
  super(status, attributes)
end

Instance Attribute Details

#full_nameString

Returns The recipient’s full name.

Returns:

  • (String)

    The recipient’s full name



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/evss/letters/letters_response.rb', line 21

class LettersResponse < EVSS::Response
  attribute :letters, Array[EVSS::Letters::Letter]
  attribute :full_name, String

  def initialize(status, response = nil)
    if response
      attributes = {
        letters: response.body['letters'],
        full_name: response.body.dig('letter_destination', 'full_name')
      }
    end
    super(status, attributes)
  end
end

#lettersArray[EVSS::Letters::Letter]

Returns An array of the user’s letters.

Returns:



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/evss/letters/letters_response.rb', line 21

class LettersResponse < EVSS::Response
  attribute :letters, Array[EVSS::Letters::Letter]
  attribute :full_name, String

  def initialize(status, response = nil)
    if response
      attributes = {
        letters: response.body['letters'],
        full_name: response.body.dig('letter_destination', 'full_name')
      }
    end
    super(status, attributes)
  end
end