# mundi_api
#
# This file was automatically generated by APIMATIC v2.0 (
# https://apimatic.io ).

module MundiApi
  # Checkout card payment request
  class CreateCheckoutCreditCardPaymentRequest < BaseModel
    # Card invoice text descriptor
    # @return [String]
    attr_accessor :statement_descriptor

    # Payment installment options
    # @return [List of CreateCheckoutCardInstallmentOptionRequest]
    attr_accessor :installments

    # Creates payment authentication
    # @return [CreatePaymentAuthenticationRequest]
    attr_accessor :authentication

    # Authorize and capture?
    # @return [Boolean]
    attr_accessor :capture

    # A mapping from model property names to API property names.
    def self.names
      @_hash = {} if @_hash.nil?
      @_hash['statement_descriptor'] = 'statement_descriptor'
      @_hash['installments'] = 'installments'
      @_hash['authentication'] = 'authentication'
      @_hash['capture'] = 'capture'
      @_hash
    end

    def initialize(statement_descriptor = nil,
                   installments = nil,
                   authentication = nil,
                   capture = nil)
      @statement_descriptor = statement_descriptor
      @installments = installments
      @authentication = authentication
      @capture = capture
    end

    # Creates an instance of the object from a hash.
    def self.from_hash(hash)
      return nil unless hash

      # Extract variables from the hash.
      statement_descriptor = hash['statement_descriptor']
      # Parameter is an array, so we need to iterate through it
      installments = nil
      unless hash['installments'].nil?
        installments = []
        hash['installments'].each do |structure|
          installments << (CreateCheckoutCardInstallmentOptionRequest.from_hash(structure) if structure)
        end
      end
      if hash['authentication']
        authentication = CreatePaymentAuthenticationRequest.from_hash(hash['authentication'])
      end
      capture = hash['capture']

      # Create object from extracted values.
      CreateCheckoutCreditCardPaymentRequest.new(statement_descriptor,
                                                 installments,
                                                 authentication,
                                                 capture)
    end
  end
end
