Class: EVSS::PCIU::PhoneNumberResponse

Inherits:
Response show all
Defined in:
lib/evss/pciu/phone_number_response.rb

Overview

Model for PCIU phone number response

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) ⇒ PhoneNumberResponse

Returns a new instance of PhoneNumberResponse.



28
29
30
31
32
33
34
35
36
37
# File 'lib/evss/pciu/phone_number_response.rb', line 28

def initialize(status, response = nil)
  attributes = {
    country_code: response&.body&.dig('cnp_phone', 'country_code'),
    number: response&.body&.dig('cnp_phone', 'number'),
    extension: response&.body&.dig('cnp_phone', 'extension'),
    effective_date: response&.body&.dig('cnp_phone', 'effective_date')
  }

  super(status, attributes)
end

Instance Attribute Details

#country_codeString

Returns The country code at the beginning of the phone number.

Returns:

  • (String)

    The country code at the beginning of the phone number



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/evss/pciu/phone_number_response.rb', line 22

class PhoneNumberResponse < EVSS::Response
  attribute :country_code, String
  attribute :number, String
  attribute :extension, String
  attribute :effective_date, String

  def initialize(status, response = nil)
    attributes = {
      country_code: response&.body&.dig('cnp_phone', 'country_code'),
      number: response&.body&.dig('cnp_phone', 'number'),
      extension: response&.body&.dig('cnp_phone', 'extension'),
      effective_date: response&.body&.dig('cnp_phone', 'effective_date')
    }

    super(status, attributes)
  end

  def to_s
    "#{country_code}#{number}#{extension}".gsub(/[^\d]/, '')
  end
end

#effective_dateString

Returns Date at which the number was known to be valid.

Returns:

  • (String)

    Date at which the number was known to be valid



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/evss/pciu/phone_number_response.rb', line 22

class PhoneNumberResponse < EVSS::Response
  attribute :country_code, String
  attribute :number, String
  attribute :extension, String
  attribute :effective_date, String

  def initialize(status, response = nil)
    attributes = {
      country_code: response&.body&.dig('cnp_phone', 'country_code'),
      number: response&.body&.dig('cnp_phone', 'number'),
      extension: response&.body&.dig('cnp_phone', 'extension'),
      effective_date: response&.body&.dig('cnp_phone', 'effective_date')
    }

    super(status, attributes)
  end

  def to_s
    "#{country_code}#{number}#{extension}".gsub(/[^\d]/, '')
  end
end

#extensionString

Returns The extension at the end of the phone number.

Returns:

  • (String)

    The extension at the end of the phone number



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/evss/pciu/phone_number_response.rb', line 22

class PhoneNumberResponse < EVSS::Response
  attribute :country_code, String
  attribute :number, String
  attribute :extension, String
  attribute :effective_date, String

  def initialize(status, response = nil)
    attributes = {
      country_code: response&.body&.dig('cnp_phone', 'country_code'),
      number: response&.body&.dig('cnp_phone', 'number'),
      extension: response&.body&.dig('cnp_phone', 'extension'),
      effective_date: response&.body&.dig('cnp_phone', 'effective_date')
    }

    super(status, attributes)
  end

  def to_s
    "#{country_code}#{number}#{extension}".gsub(/[^\d]/, '')
  end
end

#numberString

Returns The main phone number.

Returns:

  • (String)

    The main phone number



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/evss/pciu/phone_number_response.rb', line 22

class PhoneNumberResponse < EVSS::Response
  attribute :country_code, String
  attribute :number, String
  attribute :extension, String
  attribute :effective_date, String

  def initialize(status, response = nil)
    attributes = {
      country_code: response&.body&.dig('cnp_phone', 'country_code'),
      number: response&.body&.dig('cnp_phone', 'number'),
      extension: response&.body&.dig('cnp_phone', 'extension'),
      effective_date: response&.body&.dig('cnp_phone', 'effective_date')
    }

    super(status, attributes)
  end

  def to_s
    "#{country_code}#{number}#{extension}".gsub(/[^\d]/, '')
  end
end

Instance Method Details

#to_sObject



39
40
41
# File 'lib/evss/pciu/phone_number_response.rb', line 39

def to_s
  "#{country_code}#{number}#{extension}".gsub(/[^\d]/, '')
end