lib/conekta/models/order_response.rb in conekta-6.0.0 vs lib/conekta/models/order_response.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' @@ -50,10 +50,12 @@ attr_accessor :livemode # Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. attr_accessor :metadata + attr_accessor :next_action + # String representing the object’s type. Objects of the same type share the same value. attr_accessor :object # The payment status of the order. attr_accessor :payment_status @@ -82,10 +84,11 @@ :'id' => :'id', :'is_refundable' => :'is_refundable', :'line_items' => :'line_items', :'livemode' => :'livemode', :'metadata' => :'metadata', + :'next_action' => :'next_action', :'object' => :'object', :'payment_status' => :'payment_status', :'processing_mode' => :'processing_mode', :'shipping_contact' => :'shipping_contact', :'updated_at' => :'updated_at' @@ -107,16 +110,17 @@ :'checkout' => :'OrderResponseCheckout', :'created_at' => :'Integer', :'currency' => :'String', :'customer_info' => :'OrderResponseCustomerInfo', :'discount_lines' => :'OrderResponseDiscountLines', - :'fiscal_entity' => :'OrderResponseFiscalEntity', + :'fiscal_entity' => :'OrderFiscalEntityResponse', :'id' => :'String', :'is_refundable' => :'Boolean', :'line_items' => :'OrderResponseProducts', :'livemode' => :'Boolean', :'metadata' => :'Hash<String, Object>', + :'next_action' => :'OrderNextActionResponse', :'object' => :'String', :'payment_status' => :'String', :'processing_mode' => :'String', :'shipping_contact' => :'OrderResponseShippingContact', :'updated_at' => :'Integer' @@ -124,10 +128,11 @@ end # List of attributes with nullable: true def self.openapi_nullable Set.new([ + :'fiscal_entity', ]) end # Initializes the object # @param [Hash] attributes Model attributes in the form of hash @@ -204,10 +209,14 @@ if (value = attributes[:'metadata']).is_a?(Hash) self.metadata = value end end + if attributes.key?(:'next_action') + self.next_action = attributes[:'next_action'] + end + if attributes.key?(:'object') self.object = attributes[:'object'] end if attributes.key?(:'payment_status') @@ -228,10 +237,11 @@ 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 !@metadata.nil? && @metadata.length > 100 invalid_properties.push('invalid value for "metadata", number of items must be less than or equal to 100.') end @@ -239,18 +249,23 @@ 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 !@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? && metadata.length > 100 + 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 @@ -273,10 +288,11 @@ id == o.id && is_refundable == o.is_refundable && line_items == o.line_items && livemode == o.livemode && metadata == o.metadata && + next_action == o.next_action && object == o.object && payment_status == o.payment_status && processing_mode == o.processing_mode && shipping_contact == o.shipping_contact && updated_at == o.updated_at @@ -289,48 +305,41 @@ end # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [amount, amount_refunded, channel, charges, checkout, created_at, currency, customer_info, discount_lines, fiscal_entity, id, is_refundable, line_items, livemode, metadata, object, payment_status, processing_mode, shipping_contact, updated_at].hash + [amount, amount_refunded, channel, charges, checkout, created_at, currency, customer_info, discount_lines, fiscal_entity, id, is_refundable, line_items, livemode, metadata, next_action, object, payment_status, processing_mode, shipping_contact, updated_at].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) @@ -361,10 +370,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