Class: Raas::CreateCreditCardRequestModel

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/raas/models/create_credit_card_request_model.rb

Overview

Represents the request to register a credit card

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(customer_identifier = nil, account_identifier = nil, label = nil, ip_address = nil, credit_card = nil, billing_address = nil, contact_information = nil) ⇒ CreateCreditCardRequestModel

Returns a new instance of CreateCreditCardRequestModel.



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/raas/models/create_credit_card_request_model.rb', line 48

def initialize(customer_identifier = nil,
                = nil,
               label = nil,
               ip_address = nil,
               credit_card = nil,
               billing_address = nil,
               contact_information = nil)
  @customer_identifier = customer_identifier
  @account_identifier = 
  @label = label
  @ip_address = ip_address
  @credit_card = credit_card
  @billing_address = billing_address
  @contact_information = contact_information
end

Instance Attribute Details

#account_identifierString

The account identifier

Returns:



13
14
15
# File 'lib/raas/models/create_credit_card_request_model.rb', line 13

def 
  @account_identifier
end

#billing_addressBillingAddressModel

A BillingAddress object

Returns:



29
30
31
# File 'lib/raas/models/create_credit_card_request_model.rb', line 29

def billing_address
  @billing_address
end

#contact_informationList of FullNameEmailModel

An optional array of FullNameEmail objects

Returns:



33
34
35
# File 'lib/raas/models/create_credit_card_request_model.rb', line 33

def contact_information
  @contact_information
end

#credit_cardNewCreditCardModel

A NewCreditCard object

Returns:



25
26
27
# File 'lib/raas/models/create_credit_card_request_model.rb', line 25

def credit_card
  @credit_card
end

#customer_identifierString

The customer identifier

Returns:



9
10
11
# File 'lib/raas/models/create_credit_card_request_model.rb', line 9

def customer_identifier
  @customer_identifier
end

#ip_addressString

The IP address of the user registering the card

Returns:



21
22
23
# File 'lib/raas/models/create_credit_card_request_model.rb', line 21

def ip_address
  @ip_address
end

#labelString

The credit card’s label/nickname

Returns:



17
18
19
# File 'lib/raas/models/create_credit_card_request_model.rb', line 17

def label
  @label
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/raas/models/create_credit_card_request_model.rb', line 65

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  customer_identifier = hash['customerIdentifier']
   = hash['accountIdentifier']
  label = hash['label']
  ip_address = hash['ipAddress']
  credit_card = NewCreditCardModel.from_hash(hash['creditCard']) if
    hash['creditCard']
  billing_address = BillingAddressModel.from_hash(hash['billingAddress']) if
    hash['billingAddress']
  # Parameter is an array, so we need to iterate through it
  contact_information = nil
  unless hash['contactInformation'].nil?
    contact_information = []
    hash['contactInformation'].each do |structure|
      contact_information << (FullNameEmailModel.from_hash(structure) if structure)
    end
  end

  # Create object from extracted values.
  CreateCreditCardRequestModel.new(customer_identifier,
                                   ,
                                   label,
                                   ip_address,
                                   credit_card,
                                   billing_address,
                                   contact_information)
end

.namesObject

A mapping from model property names to API property names.



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/raas/models/create_credit_card_request_model.rb', line 36

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['customer_identifier'] = 'customerIdentifier'
  @_hash['account_identifier'] = 'accountIdentifier'
  @_hash['label'] = 'label'
  @_hash['ip_address'] = 'ipAddress'
  @_hash['credit_card'] = 'creditCard'
  @_hash['billing_address'] = 'billingAddress'
  @_hash['contact_information'] = 'contactInformation'
  @_hash
end