Class: Verizon::CustomerName

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/verizon/models/customer_name.rb

Overview

The customer name to be used for line usage taxation.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(first_name = nil, last_name = nil, title = SKIP, middle_name = SKIP, suffix = SKIP) ⇒ CustomerName

Returns a new instance of CustomerName.



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/verizon/models/customer_name.rb', line 57

def initialize(first_name = nil,
               last_name = nil,
               title = SKIP,
               middle_name = SKIP,
               suffix = SKIP)
  @title = title unless title == SKIP
  @first_name = first_name
  @middle_name = middle_name unless middle_name == SKIP
  @last_name = last_name
  @suffix = suffix unless suffix == SKIP
end

Instance Attribute Details

#first_nameString

The customer’s first name.

Returns:

  • (String)


18
19
20
# File 'lib/verizon/models/customer_name.rb', line 18

def first_name
  @first_name
end

#last_nameString

The customer’s last name.

Returns:

  • (String)


26
27
28
# File 'lib/verizon/models/customer_name.rb', line 26

def last_name
  @last_name
end

#middle_nameString

The customer’s middle name.

Returns:

  • (String)


22
23
24
# File 'lib/verizon/models/customer_name.rb', line 22

def middle_name
  @middle_name
end

#suffixString

An optional suffix for the customer name, such as “Jr.” or “III.”

Returns:

  • (String)


30
31
32
# File 'lib/verizon/models/customer_name.rb', line 30

def suffix
  @suffix
end

#titleString

An optional title for the customer, such as “Mr.” or “Dr.”

Returns:

  • (String)


14
15
16
# File 'lib/verizon/models/customer_name.rb', line 14

def title
  @title
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/verizon/models/customer_name.rb', line 70

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  first_name = hash.key?('firstName') ? hash['firstName'] : nil
  last_name = hash.key?('lastName') ? hash['lastName'] : nil
  title = hash.key?('title') ? hash['title'] : SKIP
  middle_name = hash.key?('middleName') ? hash['middleName'] : SKIP
  suffix = hash.key?('suffix') ? hash['suffix'] : SKIP

  # Create object from extracted values.
  CustomerName.new(first_name,
                   last_name,
                   title,
                   middle_name,
                   suffix)
end

.namesObject

A mapping from model property names to API property names.



33
34
35
36
37
38
39
40
41
# File 'lib/verizon/models/customer_name.rb', line 33

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['title'] = 'title'
  @_hash['first_name'] = 'firstName'
  @_hash['middle_name'] = 'middleName'
  @_hash['last_name'] = 'lastName'
  @_hash['suffix'] = 'suffix'
  @_hash
end

.nullablesObject

An array for nullable fields



53
54
55
# File 'lib/verizon/models/customer_name.rb', line 53

def self.nullables
  []
end

.optionalsObject

An array for optional fields



44
45
46
47
48
49
50
# File 'lib/verizon/models/customer_name.rb', line 44

def self.optionals
  %w[
    title
    middle_name
    suffix
  ]
end