Class: Asdawqw::Payment

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

Overview

Payment Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(payment_type = nil, credit_card = nil) ⇒ Payment

Returns a new instance of Payment.



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

def initialize(payment_type = nil,
               credit_card = nil)
  @payment_type = payment_type
  @credit_card = credit_card
end

Instance Attribute Details

#credit_cardCreditCard

Model. Mandatory if CREDIT_CARD type is selected.

Returns:



16
17
18
# File 'lib/asdawqw/models/payment.rb', line 16

def credit_card
  @credit_card
end

#payment_typePaymentTypeEnum

Type how payment will be processed. CREDIT_CARD,MAIL_CHECK,BOOKING_PAL_MOR

Returns:



12
13
14
# File 'lib/asdawqw/models/payment.rb', line 12

def payment_type
  @payment_type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/asdawqw/models/payment.rb', line 33

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  payment_type = hash['paymentType']
  credit_card = CreditCard.from_hash(hash['creditCard']) if
    hash['creditCard']

  # Create object from extracted values.
  Payment.new(payment_type,
              credit_card)
end

.namesObject

A mapping from model property names to API property names.



19
20
21
22
23
24
# File 'lib/asdawqw/models/payment.rb', line 19

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['payment_type'] = 'paymentType'
  @_hash['credit_card'] = 'creditCard'
  @_hash
end