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

require 'date'
module MundiApi
  # Recipient response
  class GetRecipientResponse < BaseModel
    # Id
    # @return [String]
    attr_accessor :id

    # Name
    # @return [String]
    attr_accessor :name

    # Email
    # @return [String]
    attr_accessor :email

    # Document
    # @return [String]
    attr_accessor :document

    # Description
    # @return [String]
    attr_accessor :description

    # Type
    # @return [String]
    attr_accessor :type

    # Status
    # @return [String]
    attr_accessor :status

    # Creation date
    # @return [DateTime]
    attr_accessor :created_at

    # Last update date
    # @return [DateTime]
    attr_accessor :updated_at

    # Deletion date
    # @return [DateTime]
    attr_accessor :deleted_at

    # Default bank account
    # @return [GetBankAccountResponse]
    attr_accessor :default_bank_account

    # Info about the recipient on the gateway
    # @return [List of GetGatewayRecipientResponse]
    attr_accessor :gateway_recipients

    # Metadata
    # @return [Array<String, String>]
    attr_accessor :metadata

    # Metadata
    # @return [GetAutomaticAnticipationResponse]
    attr_accessor :automatic_anticipation_settings

    # Metadata
    # @return [GetTransferSettingsResponse]
    attr_accessor :transfer_settings

    # Recipient code
    # @return [String]
    attr_accessor :code

    # Payment mode
    # @return [String]
    attr_accessor :payment_mode

    # A mapping from model property names to API property names.
    def self.names
      @_hash = {} if @_hash.nil?
      @_hash['id'] = 'id'
      @_hash['name'] = 'name'
      @_hash['email'] = 'email'
      @_hash['document'] = 'document'
      @_hash['description'] = 'description'
      @_hash['type'] = 'type'
      @_hash['status'] = 'status'
      @_hash['created_at'] = 'created_at'
      @_hash['updated_at'] = 'updated_at'
      @_hash['deleted_at'] = 'deleted_at'
      @_hash['default_bank_account'] = 'default_bank_account'
      @_hash['gateway_recipients'] = 'gateway_recipients'
      @_hash['metadata'] = 'metadata'
      @_hash['automatic_anticipation_settings'] =
        'automatic_anticipation_settings'
      @_hash['transfer_settings'] = 'transfer_settings'
      @_hash['code'] = 'code'
      @_hash['payment_mode'] = 'payment_mode'
      @_hash
    end

    def initialize(id = nil,
                   name = nil,
                   email = nil,
                   document = nil,
                   description = nil,
                   type = nil,
                   status = nil,
                   created_at = nil,
                   updated_at = nil,
                   deleted_at = nil,
                   default_bank_account = nil,
                   gateway_recipients = nil,
                   metadata = nil,
                   code = nil,
                   payment_mode = 'bank_transfer',
                   automatic_anticipation_settings = nil,
                   transfer_settings = nil)
      @id = id
      @name = name
      @email = email
      @document = document
      @description = description
      @type = type
      @status = status
      @created_at = created_at
      @updated_at = updated_at
      @deleted_at = deleted_at
      @default_bank_account = default_bank_account
      @gateway_recipients = gateway_recipients
      @metadata = metadata
      @automatic_anticipation_settings = automatic_anticipation_settings
      @transfer_settings = transfer_settings
      @code = code
      @payment_mode = payment_mode
    end

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

      # Extract variables from the hash.
      id = hash['id']
      name = hash['name']
      email = hash['email']
      document = hash['document']
      description = hash['description']
      type = hash['type']
      status = hash['status']
      created_at = APIHelper.rfc3339(hash['created_at']) if hash['created_at']
      updated_at = APIHelper.rfc3339(hash['updated_at']) if hash['updated_at']
      deleted_at = APIHelper.rfc3339(hash['deleted_at']) if hash['deleted_at']
      if hash['default_bank_account']
        default_bank_account = GetBankAccountResponse.from_hash(hash['default_bank_account'])
      end
      # Parameter is an array, so we need to iterate through it
      gateway_recipients = nil
      unless hash['gateway_recipients'].nil?
        gateway_recipients = []
        hash['gateway_recipients'].each do |structure|
          gateway_recipients << (GetGatewayRecipientResponse.from_hash(structure) if structure)
        end
      end
      metadata = hash['metadata']
      code = hash['code']
      payment_mode = hash['payment_mode'] ||= 'bank_transfer'
      if hash['automatic_anticipation_settings']
        automatic_anticipation_settings = GetAutomaticAnticipationResponse.from_hash(hash['automatic_anticipation_settings'])
      end
      if hash['transfer_settings']
        transfer_settings = GetTransferSettingsResponse.from_hash(hash['transfer_settings'])
      end

      # Create object from extracted values.
      GetRecipientResponse.new(id,
                               name,
                               email,
                               document,
                               description,
                               type,
                               status,
                               created_at,
                               updated_at,
                               deleted_at,
                               default_bank_account,
                               gateway_recipients,
                               metadata,
                               code,
                               payment_mode,
                               automatic_anticipation_settings,
                               transfer_settings)
    end
  end
end
