module MangoModel

Module for model classes.

Public Class Methods

bank_account_type(hash) click to toggle source

Asserts the type of bank account represented by a hash.

@param hash [Hash] source hash @return [Class] type of bank account represented by the hash

# File lib/mangopay/model/model.rb, line 187
def bank_account_type(hash)
  case hash['Type']
    when AccountType::IBAN.to_s
      IbanBankAccount
    when AccountType::US.to_s
      UsBankAccount
    when AccountType::CA.to_s
      CaBankAccount
    when AccountType::GB.to_s
      GbBankAccount
    else
      OtherBankAccount
  end
end
fields_of_type(type) click to toggle source

Returns an array containing all declared field names of a certain type

noinspection RubyResolve

# File lib/mangopay/model/model.rb, line 144
def fields_of_type(type)
  @fields_by_type[type]
end
pay_in_type(hash) click to toggle source

Asserts the type of pay-in represented by a hash

@param hash [Hash] source hash @return [Class] type of pay-in represented by the hash

# File lib/mangopay/model/model.rb, line 152
def pay_in_type(hash)
  if hash['PaymentType'] == PayInPaymentType::CARD.to_s\
    && hash['ExecutionType'] == PayInExecutionType::WEB.to_s
    CardWebPayIn
  elsif hash['PaymentType'] == PayInPaymentType::CARD.to_s\
    && hash['ExecutionType'] == PayInExecutionType::DIRECT.to_s
    CardDirectPayIn
  elsif hash['PaymentType'] == PayInPaymentType::PREAUTHORIZED.to_s\
    && hash['ExecutionType'] == PayInExecutionType::DIRECT.to_s
    CardPreAuthorizedPayIn
  elsif hash['PaymentType'] == PayInPaymentType::BANK_WIRE.to_s\
     && hash['ExecutionType'] == PayInExecutionType::DIRECT.to_s
    BankWireDirectPayIn
  elsif hash['PaymentType'] == PayInPaymentType::BANK_WIRE.to_s\
     && hash['ExecutionType'] == PayInExecutionType::EXTERNAL_INSTRUCTION.to_s
    BankWireExternalInstructionPayIn
  elsif hash['PaymentType'] == PayInPaymentType::DIRECT_DEBIT.to_s\
     && hash['ExecutionType'] == PayInExecutionType::WEB.to_s
    DirectDebitWebPayIn
  elsif hash['PaymentType'] == PayInPaymentType::DIRECT_DEBIT.to_s\
     && hash['ExecutionType'] == PayInExecutionType::DIRECT.to_s
    DirectDebitDirectPayIn
  elsif hash['PaymentType'] == PayInPaymentType::PAYPAL.to_s\
     && hash['ExecutionType'] == PayInExecutionType::WEB.to_s
    PaypalWebPayIn
  elsif hash['PaymentType'] == PayInPaymentType::APPLEPAY.to_s\
     && hash['ExecutionType'] == PayInExecutionType::DIRECT.to_s
    ApplePayPayIn
  end
end
user_type(hash) click to toggle source

Asserts the type of user represented by a hash.

@param hash [Hash] source hash @return [Class] type of user represented by the hash

# File lib/mangopay/model/model.rb, line 206
def user_type(hash)
  case hash['PersonType']
    when PersonType::NATURAL.to_s
      NaturalUser
    else
      LegalUser
  end
end