class Yapstone::AddressResource

The address of the application, asset, bank, etc.

Attributes

city[RW]

The name of the city.

country_code[RW]

The 3-letter countryCode of the address.

postal_code[RW]

The postal code of the address.

state[RW]

The state or province where the address resides.

street1[RW]

The street address line 1.

street2[RW]

The street address line 2.

street3[RW]

The street address line 3.

street4[RW]

The street address line 4.

Public Class Methods

attribute_map() click to toggle source

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

# File lib/yapstone-so/models/address_resource.rb, line 43
def self.attribute_map
  {
    :'street1' => :'street1',
    :'street2' => :'street2',
    :'street3' => :'street3',
    :'street4' => :'street4',
    :'city' => :'city',
    :'state' => :'state',
    :'postal_code' => :'postalCode',
    :'country_code' => :'countryCode'
  }
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/yapstone-so/models/address_resource.rb, line 337
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/yapstone-so/models/address_resource.rb, line 72
def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Yapstone::AddressResource` 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 `Yapstone::AddressResource`. 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?(:'street1')
    self.street1 = attributes[:'street1']
  end

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

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

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

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

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

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

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

Attribute type mapping.

# File lib/yapstone-so/models/address_resource.rb, line 57
def self.openapi_types
  {
    :'street1' => :'String',
    :'street2' => :'String',
    :'street3' => :'String',
    :'street4' => :'String',
    :'city' => :'String',
    :'state' => :'String',
    :'postal_code' => :'String',
    :'country_code' => :'String'
  }
end

Public Instance Methods

==(o) click to toggle source

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

# File lib/yapstone-so/models/address_resource.rb, line 309
def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      street1 == o.street1 &&
      street2 == o.street2 &&
      street3 == o.street3 &&
      street4 == o.street4 &&
      city == o.city &&
      state == o.state &&
      postal_code == o.postal_code &&
      country_code == o.country_code
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/yapstone-so/models/address_resource.rb, line 365
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
    Yapstone.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/yapstone-so/models/address_resource.rb, line 430
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
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/yapstone-so/models/address_resource.rb, line 344
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
city=(city) click to toggle source

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

# File lib/yapstone-so/models/address_resource.rb, line 244
def city=(city)
  if !city.nil? && city.to_s.length > 255
    fail ArgumentError, 'invalid value for "city", the character length must be smaller than or equal to 255.'
  end

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

  @city = city
end
country_code=(country_code) click to toggle source

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

# File lib/yapstone-so/models/address_resource.rb, line 291
def country_code=(country_code)
  if country_code.nil?
    fail ArgumentError, 'country_code cannot be nil'
  end

  if country_code.to_s.length > 3
    fail ArgumentError, 'invalid value for "country_code", the character length must be smaller than or equal to 3.'
  end

  if country_code.to_s.length < 3
    fail ArgumentError, 'invalid value for "country_code", the character length must be great than or equal to 3.'
  end

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

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

# File lib/yapstone-so/models/address_resource.rb, line 324
def eql?(o)
  self == o
end
hash() click to toggle source

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

# File lib/yapstone-so/models/address_resource.rb, line 330
def hash
  [street1, street2, street3, street4, city, state, postal_code, country_code].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/yapstone-so/models/address_resource.rb, line 120
def list_invalid_properties
  invalid_properties = Array.new
  if !@street1.nil? && @street1.to_s.length > 2048
    invalid_properties.push('invalid value for "street1", the character length must be smaller than or equal to 2048.')
  end

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

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

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

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

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

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

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

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

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

  pattern = Regexp.new(/.*[^\s].*/)
  if !@postal_code.nil? && @postal_code !~ pattern
    invalid_properties.push("invalid value for \"postal_code\", must conform to the pattern #{pattern}.")
  end

  if @country_code.nil?
    invalid_properties.push('invalid value for "country_code", country_code cannot be nil.')
  end

  if @country_code.to_s.length > 3
    invalid_properties.push('invalid value for "country_code", the character length must be smaller than or equal to 3.')
  end

  if @country_code.to_s.length < 3
    invalid_properties.push('invalid value for "country_code", the character length must be great than or equal to 3.')
  end

  invalid_properties
end
postal_code=(postal_code) click to toggle source

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

# File lib/yapstone-so/models/address_resource.rb, line 272
def postal_code=(postal_code)
  if !postal_code.nil? && postal_code.to_s.length > 64
    fail ArgumentError, 'invalid value for "postal_code", the character length must be smaller than or equal to 64.'
  end

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

  pattern = Regexp.new(/.*[^\s].*/)
  if !postal_code.nil? && postal_code !~ pattern
    fail ArgumentError, "invalid value for \"postal_code\", must conform to the pattern #{pattern}."
  end

  @postal_code = postal_code
end
state=(state) click to toggle source

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

# File lib/yapstone-so/models/address_resource.rb, line 258
def state=(state)
  if !state.nil? && state.to_s.length > 255
    fail ArgumentError, 'invalid value for "state", the character length must be smaller than or equal to 255.'
  end

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

  @state = state
end
street1=(street1) click to toggle source

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

# File lib/yapstone-so/models/address_resource.rb, line 204
def street1=(street1)
  if !street1.nil? && street1.to_s.length > 2048
    fail ArgumentError, 'invalid value for "street1", the character length must be smaller than or equal to 2048.'
  end

  @street1 = street1
end
street2=(street2) click to toggle source

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

# File lib/yapstone-so/models/address_resource.rb, line 214
def street2=(street2)
  if !street2.nil? && street2.to_s.length > 2048
    fail ArgumentError, 'invalid value for "street2", the character length must be smaller than or equal to 2048.'
  end

  @street2 = street2
end
street3=(street3) click to toggle source

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

# File lib/yapstone-so/models/address_resource.rb, line 224
def street3=(street3)
  if !street3.nil? && street3.to_s.length > 2048
    fail ArgumentError, 'invalid value for "street3", the character length must be smaller than or equal to 2048.'
  end

  @street3 = street3
end
street4=(street4) click to toggle source

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

# File lib/yapstone-so/models/address_resource.rb, line 234
def street4=(street4)
  if !street4.nil? && street4.to_s.length > 2048
    fail ArgumentError, 'invalid value for "street4", the character length must be smaller than or equal to 2048.'
  end

  @street4 = street4
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/yapstone-so/models/address_resource.rb, line 410
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/yapstone-so/models/address_resource.rb, line 416
def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    next if value.nil?
    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/yapstone-so/models/address_resource.rb, line 404
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/yapstone-so/models/address_resource.rb, line 184
def valid?
  return false if !@street1.nil? && @street1.to_s.length > 2048
  return false if !@street2.nil? && @street2.to_s.length > 2048
  return false if !@street3.nil? && @street3.to_s.length > 2048
  return false if !@street4.nil? && @street4.to_s.length > 2048
  return false if !@city.nil? && @city.to_s.length > 255
  return false if !@city.nil? && @city.to_s.length < 2
  return false if !@state.nil? && @state.to_s.length > 255
  return false if !@state.nil? && @state.to_s.length < 2
  return false if !@postal_code.nil? && @postal_code.to_s.length > 64
  return false if !@postal_code.nil? && @postal_code.to_s.length < 1
  return false if !@postal_code.nil? && @postal_code !~ Regexp.new(/.*[^\s].*/)
  return false if @country_code.nil?
  return false if @country_code.to_s.length > 3
  return false if @country_code.to_s.length < 3
  true
end