Class: UspsApi::CommonContact
- Defined in:
- lib/usps_api/models/common_contact.rb
Overview
CommonContact Model.
Instance Attribute Summary collapse
-
#contact_id ⇒ ContactId
Identification details for the appointment requestor.
-
#contact_name ⇒ String
Contact name.
-
#contact_type ⇒ ContactType
Carrier contact type.
-
#email ⇒ String
Email address of contact.
-
#fax ⇒ String
Fax number of the contact, numbers only, no delimeters, optional +.
-
#mobile_phone ⇒ String
Cell phone number of contact, numbers only, no delimeters, optional + sign.
-
#telephone ⇒ String
Phone number of contact, numbers only, no delimeters, optional + sign.
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.
Instance Method Summary collapse
-
#initialize(contact_name: SKIP, telephone: SKIP, mobile_phone: SKIP, email: SKIP, fax: SKIP, contact_id: SKIP, contact_type: SKIP, additional_properties: nil) ⇒ CommonContact
constructor
A new instance of CommonContact.
-
#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(contact_name: SKIP, telephone: SKIP, mobile_phone: SKIP, email: SKIP, fax: SKIP, contact_id: SKIP, contact_type: SKIP, additional_properties: nil) ⇒ CommonContact
Returns a new instance of CommonContact.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/usps_api/models/common_contact.rb', line 71 def initialize(contact_name: SKIP, telephone: SKIP, mobile_phone: SKIP, email: SKIP, fax: SKIP, contact_id: SKIP, contact_type: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @contact_name = contact_name unless contact_name == SKIP @telephone = telephone unless telephone == SKIP @mobile_phone = mobile_phone unless mobile_phone == SKIP @email = email unless email == SKIP @fax = fax unless fax == SKIP @contact_id = contact_id unless contact_id == SKIP @contact_type = contact_type unless contact_type == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#contact_id ⇒ ContactId
Identification details for the appointment requestor.
34 35 36 |
# File 'lib/usps_api/models/common_contact.rb', line 34 def contact_id @contact_id end |
#contact_name ⇒ String
Contact name
14 15 16 |
# File 'lib/usps_api/models/common_contact.rb', line 14 def contact_name @contact_name end |
#contact_type ⇒ ContactType
Carrier contact type
38 39 40 |
# File 'lib/usps_api/models/common_contact.rb', line 38 def contact_type @contact_type end |
#email ⇒ String
Email address of contact
26 27 28 |
# File 'lib/usps_api/models/common_contact.rb', line 26 def email @email end |
#fax ⇒ String
Fax number of the contact, numbers only, no delimeters, optional +
30 31 32 |
# File 'lib/usps_api/models/common_contact.rb', line 30 def fax @fax end |
#mobile_phone ⇒ String
Cell phone number of contact, numbers only, no delimeters, optional + sign
22 23 24 |
# File 'lib/usps_api/models/common_contact.rb', line 22 def mobile_phone @mobile_phone end |
#telephone ⇒ String
Phone number of contact, numbers only, no delimeters, optional + sign
18 19 20 |
# File 'lib/usps_api/models/common_contact.rb', line 18 def telephone @telephone end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/usps_api/models/common_contact.rb', line 88 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. contact_name = hash.key?('contactName') ? hash['contactName'] : SKIP telephone = hash.key?('telephone') ? hash['telephone'] : SKIP mobile_phone = hash.key?('mobilePhone') ? hash['mobilePhone'] : SKIP email = hash.key?('email') ? hash['email'] : SKIP fax = hash.key?('fax') ? hash['fax'] : SKIP contact_id = ContactId.from_hash(hash['contactID']) if hash['contactID'] contact_type = hash.key?('contactType') ? hash['contactType'] : 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. CommonContact.new(contact_name: contact_name, telephone: telephone, mobile_phone: mobile_phone, email: email, fax: fax, contact_id: contact_id, contact_type: contact_type, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/usps_api/models/common_contact.rb', line 41 def self.names @_hash = {} if @_hash.nil? @_hash['contact_name'] = 'contactName' @_hash['telephone'] = 'telephone' @_hash['mobile_phone'] = 'mobilePhone' @_hash['email'] = 'email' @_hash['fax'] = 'fax' @_hash['contact_id'] = 'contactID' @_hash['contact_type'] = 'contactType' @_hash end |
.nullables ⇒ Object
An array for nullable fields
67 68 69 |
# File 'lib/usps_api/models/common_contact.rb', line 67 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/usps_api/models/common_contact.rb', line 54 def self.optionals %w[ contact_name telephone mobile_phone email fax contact_id contact_type ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
127 128 129 130 131 132 133 |
# File 'lib/usps_api/models/common_contact.rb', line 127 def inspect class_name = self.class.name.split('::').last "<#{class_name} contact_name: #{@contact_name.inspect}, telephone: #{@telephone.inspect},"\ " mobile_phone: #{@mobile_phone.inspect}, email: #{@email.inspect}, fax: #{@fax.inspect},"\ " contact_id: #{@contact_id.inspect}, contact_type: #{@contact_type.inspect},"\ " additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
119 120 121 122 123 124 |
# File 'lib/usps_api/models/common_contact.rb', line 119 def to_s class_name = self.class.name.split('::').last "<#{class_name} contact_name: #{@contact_name}, telephone: #{@telephone}, mobile_phone:"\ " #{@mobile_phone}, email: #{@email}, fax: #{@fax}, contact_id: #{@contact_id},"\ " contact_type: #{@contact_type}, additional_properties: #{@additional_properties}>" end |