Class: Verizon::CustomerName
- Defined in:
- lib/verizon/models/customer_name.rb
Overview
The customer name to be used for line usage taxation.
Instance Attribute Summary collapse
-
#first_name ⇒ String
The customer’s first name.
-
#last_name ⇒ String
The customer’s last name.
-
#middle_name ⇒ String
The customer’s middle name.
-
#suffix ⇒ String
An optional suffix for the customer name, such as “Jr.” or “III.”.
-
#title ⇒ String
An optional title for the customer, such as “Mr.” or “Dr.”.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(first_name:, last_name:, title: SKIP, middle_name: SKIP, suffix: SKIP, additional_properties: nil) ⇒ CustomerName
constructor
A new instance of CustomerName.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(first_name:, last_name:, title: SKIP, middle_name: SKIP, suffix: SKIP, additional_properties: nil) ⇒ CustomerName
Returns a new instance of CustomerName.
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/verizon/models/customer_name.rb', line 57 def initialize(first_name:, last_name:, title: SKIP, middle_name: SKIP, suffix: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @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 @additional_properties = additional_properties end |
Instance Attribute Details
#first_name ⇒ String
The customer’s first name.
18 19 20 |
# File 'lib/verizon/models/customer_name.rb', line 18 def first_name @first_name end |
#last_name ⇒ String
The customer’s last name.
26 27 28 |
# File 'lib/verizon/models/customer_name.rb', line 26 def last_name @last_name end |
#middle_name ⇒ String
The customer’s middle name.
22 23 24 |
# File 'lib/verizon/models/customer_name.rb', line 22 def middle_name @middle_name end |
#suffix ⇒ String
An optional suffix for the customer name, such as “Jr.” or “III.”
30 31 32 |
# File 'lib/verizon/models/customer_name.rb', line 30 def suffix @suffix end |
#title ⇒ String
An optional title for the customer, such as “Mr.” or “Dr.”
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.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/verizon/models/customer_name.rb', line 71 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 a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. CustomerName.new(first_name: first_name, last_name: last_name, title: title, middle_name: middle_name, suffix: suffix, additional_properties: additional_properties) end |
.names ⇒ Object
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 |
.nullables ⇒ Object
An array for nullable fields
53 54 55 |
# File 'lib/verizon/models/customer_name.rb', line 53 def self.nullables [] end |
.optionals ⇒ Object
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 |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/verizon/models/customer_name.rb', line 99 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.first_name, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.last_name, ->(val) { val.instance_of? String }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['firstName'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['lastName'], ->(val) { val.instance_of? String }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
128 129 130 131 132 133 |
# File 'lib/verizon/models/customer_name.rb', line 128 def inspect class_name = self.class.name.split('::').last "<#{class_name} title: #{@title.inspect}, first_name: #{@first_name.inspect}, middle_name:"\ " #{@middle_name.inspect}, last_name: #{@last_name.inspect}, suffix: #{@suffix.inspect},"\ " additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
120 121 122 123 124 125 |
# File 'lib/verizon/models/customer_name.rb', line 120 def to_s class_name = self.class.name.split('::').last "<#{class_name} title: #{@title}, first_name: #{@first_name}, middle_name: #{@middle_name},"\ " last_name: #{@last_name}, suffix: #{@suffix}, additional_properties:"\ " #{@additional_properties}>" end |