lib/conekta/models/customer_shipping_contacts.rb in conekta-6.0.0 vs lib/conekta/models/customer_shipping_contacts.rb in conekta-6.0.1
- old
+ new
@@ -4,11 +4,11 @@
#Conekta sdk
The version of the OpenAPI document: 2.1.0
Contact: engineering@conekta.com
Generated by: https://openapi-generator.tech
-OpenAPI Generator version: 6.6.0
+OpenAPI Generator version: 7.1.0
=end
require 'date'
require 'time'
@@ -31,20 +31,24 @@
attr_accessor :default
attr_accessor :deleted
+ # Metadata associated with the shipping contact
+ attr_accessor :metadata
+
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'phone' => :'phone',
:'receiver' => :'receiver',
:'between_streets' => :'between_streets',
:'address' => :'address',
:'parent_id' => :'parent_id',
:'default' => :'default',
- :'deleted' => :'deleted'
+ :'deleted' => :'deleted',
+ :'metadata' => :'metadata'
}
end
# Returns all the JSON keys this model knows about
def self.acceptable_attributes
@@ -58,19 +62,20 @@
:'receiver' => :'String',
:'between_streets' => :'String',
:'address' => :'CustomerShippingContactsAddress',
:'parent_id' => :'String',
:'default' => :'Boolean',
- :'deleted' => :'Boolean'
+ :'deleted' => :'Boolean',
+ :'metadata' => :'Hash<String, Object>'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
:'default',
- :'deleted'
+ :'deleted',
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
@@ -99,10 +104,12 @@
self.between_streets = attributes[:'between_streets']
end
if attributes.key?(:'address')
self.address = attributes[:'address']
+ else
+ self.address = nil
end
if attributes.key?(:'parent_id')
self.parent_id = attributes[:'parent_id']
end
@@ -112,30 +119,57 @@
end
if attributes.key?(:'deleted')
self.deleted = attributes[:'deleted']
end
+
+ if attributes.key?(:'metadata')
+ if (value = attributes[:'metadata']).is_a?(Hash)
+ self.metadata = value
+ end
+ end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
invalid_properties = Array.new
if @address.nil?
invalid_properties.push('invalid value for "address", address cannot be nil.')
end
+ if !@metadata.nil? && @metadata.length > 100
+ invalid_properties.push('invalid value for "metadata", number of items must be less than or equal to 100.')
+ end
+
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
+ warn '[DEPRECATED] the `valid?` method is obsolete'
return false if @address.nil?
+ return false if !@metadata.nil? && @metadata.length > 100
true
end
+ # Custom attribute writer method with validation
+ # @param [Object] metadata Value to be assigned
+ def metadata=(metadata)
+ if metadata.nil?
+ fail ArgumentError, 'metadata cannot be nil'
+ end
+
+ if metadata.length > 100
+ fail ArgumentError, 'invalid value for "metadata", number of items must be less than or equal to 100.'
+ end
+
+ @metadata = metadata
+ end
+
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
@@ -143,11 +177,12 @@
receiver == o.receiver &&
between_streets == o.between_streets &&
address == o.address &&
parent_id == o.parent_id &&
default == o.default &&
- deleted == o.deleted
+ deleted == o.deleted &&
+ metadata == o.metadata
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
@@ -155,48 +190,41 @@
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
- [phone, receiver, between_streets, address, parent_id, default, deleted].hash
+ [phone, receiver, between_streets, address, parent_id, default, deleted, metadata].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
- new.build_from_hash(attributes)
- end
-
- # Builds the object from hash
- # @param [Hash] attributes Model attributes in the form of hash
- # @return [Object] Returns the model itself
- def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
- self.class.openapi_types.each_pair do |key, type|
- if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
- self.send("#{key}=", nil)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
+ transformed_hash["#{key}"] = nil
elsif 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) })
+ if attributes[attribute_map[key]].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[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]]))
+ elsif !attributes[attribute_map[key]].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
end
end
-
- self
+ new(transformed_hash)
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
- def _deserialize(type, value)
+ def self._deserialize(type, value)
case type.to_sym
when :Time
Time.parse(value)
when :Date
Date.parse(value)
@@ -227,10 +255,10 @@
end
end
else # model
# models (e.g. Pet) or oneOf
klass = Conekta.const_get(type)
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object