Class: Asdawqw::CreditCard

Inherits:
BaseModel show all
Defined in:
lib/asdawqw/models/credit_card.rb

Overview

CreditCard Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(credit_card_type = nil, payment_gateways = nil, credit_card_list = nil) ⇒ CreditCard

Returns a new instance of CreditCard.



34
35
36
37
38
39
40
# File 'lib/asdawqw/models/credit_card.rb', line 34

def initialize(credit_card_type = nil,
               payment_gateways = nil,
               credit_card_list = nil)
  @credit_card_type = credit_card_type
  @payment_gateways = payment_gateways
  @credit_card_list = credit_card_list
end

Instance Attribute Details

#credit_card_listList of CreditCardListEnum

List of acceptable credit cards. Allowed only if type is TRANSMIT. MASTER_CARD,VISA,AMERICAN_EXPRESS,DINERS_CLUB,DISCOVER. If POST method selected it will select all creditCardList.

Returns:



23
24
25
# File 'lib/asdawqw/models/credit_card.rb', line 23

def credit_card_list
  @credit_card_list
end

#credit_card_typeCreditCardTypeEnum

Type of payment - will payment be processed over API (in reservation request - transmit), or will payment be processed over payment gateway (post). TRANSMIT,POST

Returns:



13
14
15
# File 'lib/asdawqw/models/credit_card.rb', line 13

def credit_card_type
  @credit_card_type
end

#payment_gatewaysPaymentGateways

Model. Mandatory if POST type is selected

Returns:



17
18
19
# File 'lib/asdawqw/models/credit_card.rb', line 17

def payment_gateways
  @payment_gateways
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/asdawqw/models/credit_card.rb', line 43

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  credit_card_type = hash['creditCardType']
  payment_gateways = PaymentGateways.from_hash(hash['paymentGateways']) if
    hash['paymentGateways']
  credit_card_list = hash['creditCardList']

  # Create object from extracted values.
  CreditCard.new(credit_card_type,
                 payment_gateways,
                 credit_card_list)
end

.namesObject

A mapping from model property names to API property names.



26
27
28
29
30
31
32
# File 'lib/asdawqw/models/credit_card.rb', line 26

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['credit_card_type'] = 'creditCardType'
  @_hash['payment_gateways'] = 'paymentGateways'
  @_hash['credit_card_list'] = 'creditCardList'
  @_hash
end