class CityPayApiClient::ContactDetails

Attributes

address1[RW]

The first line of the address for the card holder.

address2[RW]

The second line of the address for the card holder.

address3[RW]

The third line of the address for the card holder.

area[RW]

The area such as city, department, parish for the card holder.

company[RW]

The company name for the card holder if the contact is a corporate contact.

country[RW]

The country code in ISO 3166 format. The country value may be used for fraud analysis and for acceptance of the transaction.

email[RW]

An email address for the card holder which may be used for correspondence.

firstname[RW]

The first name of the card holder.

lastname[RW]

The last name or surname of the card holder.

mobile_no[RW]

A mobile number for the card holder the mobile number is often required by delivery companies to ensure they are able to be in contact when required.

postcode[RW]

The postcode or zip code of the address which may be used for fraud analysis.

telephone_no[RW]

A telephone number for the card holder.

title[RW]

A title for the card holder such as Mr, Mrs, Ms, M. Mme. etc.

Public Class Methods

attribute_map() click to toggle source

Attribute mapping from ruby-style variable name to JSON key.

# File lib/citypay_api_client/models/contact_details.rb, line 56
def self.attribute_map
  {
    :'address1' => :'address1',
    :'address2' => :'address2',
    :'address3' => :'address3',
    :'area' => :'area',
    :'company' => :'company',
    :'country' => :'country',
    :'email' => :'email',
    :'firstname' => :'firstname',
    :'lastname' => :'lastname',
    :'mobile_no' => :'mobile_no',
    :'postcode' => :'postcode',
    :'telephone_no' => :'telephone_no',
    :'title' => :'title'
  }
end
build_from_hash(attributes) click to toggle source

Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself

# File lib/citypay_api_client/models/contact_details.rb, line 344
def self.build_from_hash(attributes)
  new.build_from_hash(attributes)
end
new(attributes = {}) click to toggle source

Initializes the object @param [Hash] attributes Model attributes in the form of hash

# File lib/citypay_api_client/models/contact_details.rb, line 101
def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `CityPayApiClient::ContactDetails` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!self.class.attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `CityPayApiClient::ContactDetails`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'address1')
    self.address1 = attributes[:'address1']
  end

  if attributes.key?(:'address2')
    self.address2 = attributes[:'address2']
  end

  if attributes.key?(:'address3')
    self.address3 = attributes[:'address3']
  end

  if attributes.key?(:'area')
    self.area = attributes[:'area']
  end

  if attributes.key?(:'company')
    self.company = attributes[:'company']
  end

  if attributes.key?(:'country')
    self.country = attributes[:'country']
  end

  if attributes.key?(:'email')
    self.email = attributes[:'email']
  end

  if attributes.key?(:'firstname')
    self.firstname = attributes[:'firstname']
  end

  if attributes.key?(:'lastname')
    self.lastname = attributes[:'lastname']
  end

  if attributes.key?(:'mobile_no')
    self.mobile_no = attributes[:'mobile_no']
  end

  if attributes.key?(:'postcode')
    self.postcode = attributes[:'postcode']
  end

  if attributes.key?(:'telephone_no')
    self.telephone_no = attributes[:'telephone_no']
  end

  if attributes.key?(:'title')
    self.title = attributes[:'title']
  end
end
openapi_nullable() click to toggle source

List of attributes with nullable: true

# File lib/citypay_api_client/models/contact_details.rb, line 94
def self.openapi_nullable
  Set.new([
  ])
end
openapi_types() click to toggle source

Attribute type mapping.

# File lib/citypay_api_client/models/contact_details.rb, line 75
def self.openapi_types
  {
    :'address1' => :'String',
    :'address2' => :'String',
    :'address3' => :'String',
    :'area' => :'String',
    :'company' => :'String',
    :'country' => :'String',
    :'email' => :'String',
    :'firstname' => :'String',
    :'lastname' => :'String',
    :'mobile_no' => :'String',
    :'postcode' => :'String',
    :'telephone_no' => :'String',
    :'title' => :'String'
  }
end

Public Instance Methods

==(o) click to toggle source

Checks equality by comparing each attribute. @param [Object] Object to be compared

# File lib/citypay_api_client/models/contact_details.rb, line 311
def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      address1 == o.address1 &&
      address2 == o.address2 &&
      address3 == o.address3 &&
      area == o.area &&
      company == o.company &&
      country == o.country &&
      email == o.email &&
      firstname == o.firstname &&
      lastname == o.lastname &&
      mobile_no == o.mobile_no &&
      postcode == o.postcode &&
      telephone_no == o.telephone_no &&
      title == o.title
end
_deserialize(type, value) click to toggle source

Deserializes the data based on type @param string type Data type @param string value Value to be deserialized @return [Object] Deserialized data

# File lib/citypay_api_client/models/contact_details.rb, line 372
def _deserialize(type, value)
  case type.to_sym
  when :DateTime
    DateTime.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    CityPayApiClient.const_get(type).build_from_hash(value)
  end
end
_to_hash(value) click to toggle source

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value @param [Object] value Any valid value @return [Hash] Returns the value in the form of hash

# File lib/citypay_api_client/models/contact_details.rb, line 441
def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end
address1=(address1) click to toggle source

Custom attribute writer method with validation @param [Object] address1 Value to be assigned

# File lib/citypay_api_client/models/contact_details.rb, line 227
def address1=(address1)
  if !address1.nil? && address1.to_s.length > 40
    fail ArgumentError, 'invalid value for "address1", the character length must be smaller than or equal to 40.'
  end

  @address1 = address1
end
address2=(address2) click to toggle source

Custom attribute writer method with validation @param [Object] address2 Value to be assigned

# File lib/citypay_api_client/models/contact_details.rb, line 237
def address2=(address2)
  if !address2.nil? && address2.to_s.length > 30
    fail ArgumentError, 'invalid value for "address2", the character length must be smaller than or equal to 30.'
  end

  @address2 = address2
end
address3=(address3) click to toggle source

Custom attribute writer method with validation @param [Object] address3 Value to be assigned

# File lib/citypay_api_client/models/contact_details.rb, line 247
def address3=(address3)
  if !address3.nil? && address3.to_s.length > 20
    fail ArgumentError, 'invalid value for "address3", the character length must be smaller than or equal to 20.'
  end

  @address3 = address3
end
area=(area) click to toggle source

Custom attribute writer method with validation @param [Object] area Value to be assigned

# File lib/citypay_api_client/models/contact_details.rb, line 257
def area=(area)
  if !area.nil? && area.to_s.length > 20
    fail ArgumentError, 'invalid value for "area", the character length must be smaller than or equal to 20.'
  end

  @area = area
end
build_from_hash(attributes) click to toggle source

Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself

# File lib/citypay_api_client/models/contact_details.rb, line 351
def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.openapi_types.each_pair do |key, type|
    if type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end
country=(country) click to toggle source

Custom attribute writer method with validation @param [Object] country Value to be assigned

# File lib/citypay_api_client/models/contact_details.rb, line 267
def country=(country)
  if !country.nil? && country.to_s.length > 2
    fail ArgumentError, 'invalid value for "country", the character length must be smaller than or equal to 2.'
  end

  if !country.nil? && country.to_s.length < 2
    fail ArgumentError, 'invalid value for "country", the character length must be great than or equal to 2.'
  end

  @country = country
end
eql?(o) click to toggle source

@see the `==` method @param [Object] Object to be compared

# File lib/citypay_api_client/models/contact_details.rb, line 331
def eql?(o)
  self == o
end
hash() click to toggle source

Calculates hash code according to all attributes. @return [Integer] Hash code

# File lib/citypay_api_client/models/contact_details.rb, line 337
def hash
  [address1, address2, address3, area, company, country, email, firstname, lastname, mobile_no, postcode, telephone_no, title].hash
end
list_invalid_properties() click to toggle source

Show invalid properties with the reasons. Usually used together with valid? @return Array for valid properties with the reasons

# File lib/citypay_api_client/models/contact_details.rb, line 169
def list_invalid_properties
  invalid_properties = Array.new
  if !@address1.nil? && @address1.to_s.length > 40
    invalid_properties.push('invalid value for "address1", the character length must be smaller than or equal to 40.')
  end

  if !@address2.nil? && @address2.to_s.length > 30
    invalid_properties.push('invalid value for "address2", the character length must be smaller than or equal to 30.')
  end

  if !@address3.nil? && @address3.to_s.length > 20
    invalid_properties.push('invalid value for "address3", the character length must be smaller than or equal to 20.')
  end

  if !@area.nil? && @area.to_s.length > 20
    invalid_properties.push('invalid value for "area", the character length must be smaller than or equal to 20.')
  end

  if !@country.nil? && @country.to_s.length > 2
    invalid_properties.push('invalid value for "country", the character length must be smaller than or equal to 2.')
  end

  if !@country.nil? && @country.to_s.length < 2
    invalid_properties.push('invalid value for "country", the character length must be great than or equal to 2.')
  end

  if !@mobile_no.nil? && @mobile_no.to_s.length > 20
    invalid_properties.push('invalid value for "mobile_no", the character length must be smaller than or equal to 20.')
  end

  if !@postcode.nil? && @postcode.to_s.length > 10
    invalid_properties.push('invalid value for "postcode", the character length must be smaller than or equal to 10.')
  end

  if !@telephone_no.nil? && @telephone_no.to_s.length > 20
    invalid_properties.push('invalid value for "telephone_no", the character length must be smaller than or equal to 20.')
  end

  invalid_properties
end
mobile_no=(mobile_no) click to toggle source

Custom attribute writer method with validation @param [Object] mobile_no Value to be assigned

# File lib/citypay_api_client/models/contact_details.rb, line 281
def mobile_no=(mobile_no)
  if !mobile_no.nil? && mobile_no.to_s.length > 20
    fail ArgumentError, 'invalid value for "mobile_no", the character length must be smaller than or equal to 20.'
  end

  @mobile_no = mobile_no
end
postcode=(postcode) click to toggle source

Custom attribute writer method with validation @param [Object] postcode Value to be assigned

# File lib/citypay_api_client/models/contact_details.rb, line 291
def postcode=(postcode)
  if !postcode.nil? && postcode.to_s.length > 10
    fail ArgumentError, 'invalid value for "postcode", the character length must be smaller than or equal to 10.'
  end

  @postcode = postcode
end
telephone_no=(telephone_no) click to toggle source

Custom attribute writer method with validation @param [Object] telephone_no Value to be assigned

# File lib/citypay_api_client/models/contact_details.rb, line 301
def telephone_no=(telephone_no)
  if !telephone_no.nil? && telephone_no.to_s.length > 20
    fail ArgumentError, 'invalid value for "telephone_no", the character length must be smaller than or equal to 20.'
  end

  @telephone_no = telephone_no
end
to_body() click to toggle source

to_body is an alias to to_hash (backward compatibility) @return [Hash] Returns the object in the form of hash

# File lib/citypay_api_client/models/contact_details.rb, line 417
def to_body
  to_hash
end
to_hash() click to toggle source

Returns the object in the form of hash @return [Hash] Returns the object in the form of hash

# File lib/citypay_api_client/models/contact_details.rb, line 423
def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end
    
    hash[param] = _to_hash(value)
  end
  hash
end
to_s() click to toggle source

Returns the string representation of the object @return [String] String presentation of the object

# File lib/citypay_api_client/models/contact_details.rb, line 411
def to_s
  to_hash.to_s
end
valid?() click to toggle source

Check to see if the all the properties in the model are valid @return true if the model is valid

# File lib/citypay_api_client/models/contact_details.rb, line 212
def valid?
  return false if !@address1.nil? && @address1.to_s.length > 40
  return false if !@address2.nil? && @address2.to_s.length > 30
  return false if !@address3.nil? && @address3.to_s.length > 20
  return false if !@area.nil? && @area.to_s.length > 20
  return false if !@country.nil? && @country.to_s.length > 2
  return false if !@country.nil? && @country.to_s.length < 2
  return false if !@mobile_no.nil? && @mobile_no.to_s.length > 20
  return false if !@postcode.nil? && @postcode.to_s.length > 10
  return false if !@telephone_no.nil? && @telephone_no.to_s.length > 20
  true
end