Class: Raas::CreditCardModel

Inherits:
BaseModel show all
Defined in:
lib/raas/models/credit_card_model.rb

Overview

Represents 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, token = nil, label = nil, last_four_digits = nil, expiration_date = nil, status = nil, created_date = nil, activation_date = nil, contact_information = nil) ⇒ CreditCardModel

Returns a new instance of CreditCardModel.



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/raas/models/credit_card_model.rb', line 64

def initialize(customer_identifier = nil,
                = nil,
               token = nil,
               label = nil,
               last_four_digits = nil,
               expiration_date = nil,
               status = nil,
               created_date = nil,
               activation_date = nil,
               contact_information = nil)
  @customer_identifier = customer_identifier
  @account_identifier = 
  @token = token
  @label = label
  @last_four_digits = last_four_digits
  @expiration_date = expiration_date
  @status = status
  @created_date = created_date
  @activation_date = activation_date
  @contact_information = contact_information
end

Instance Attribute Details

#account_identifierString

The account identifier

Returns:



14
15
16
# File 'lib/raas/models/credit_card_model.rb', line 14

def 
  @account_identifier
end

#activation_dateDateTime

The date the card will be available for use

Returns:

  • (DateTime)


42
43
44
# File 'lib/raas/models/credit_card_model.rb', line 42

def activation_date
  @activation_date
end

#contact_informationList of FullNameEmailModel

An optional array of FullNameEmail objects

Returns:



46
47
48
# File 'lib/raas/models/credit_card_model.rb', line 46

def contact_information
  @contact_information
end

#created_dateDateTime

The date the card was added

Returns:

  • (DateTime)


38
39
40
# File 'lib/raas/models/credit_card_model.rb', line 38

def created_date
  @created_date
end

#customer_identifierString

The customer identifier

Returns:



10
11
12
# File 'lib/raas/models/credit_card_model.rb', line 10

def customer_identifier
  @customer_identifier
end

#expiration_dateString

The credit card’s expiration date

Returns:



30
31
32
# File 'lib/raas/models/credit_card_model.rb', line 30

def expiration_date
  @expiration_date
end

#labelString

The label/nickname for the credit card

Returns:



22
23
24
# File 'lib/raas/models/credit_card_model.rb', line 22

def label
  @label
end

#last_four_digitsString

The last four digits of the credit card number

Returns:



26
27
28
# File 'lib/raas/models/credit_card_model.rb', line 26

def last_four_digits
  @last_four_digits
end

#statusString

The status of the credit card

Returns:



34
35
36
# File 'lib/raas/models/credit_card_model.rb', line 34

def status
  @status
end

#tokenString

The credit card token

Returns:



18
19
20
# File 'lib/raas/models/credit_card_model.rb', line 18

def token
  @token
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/raas/models/credit_card_model.rb', line 87

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.

  customer_identifier = hash['customerIdentifier']
   = hash['accountIdentifier']
  token = hash['token']
  label = hash['label']
  last_four_digits = hash['lastFourDigits']
  expiration_date = hash['expirationDate']
  status = hash['status']
  created_date = APIHelper.rfc3339(hash['createdDate']) if
    hash['createdDate']
  activation_date = APIHelper.rfc3339(hash['activationDate']) if
    hash['activationDate']
  # 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.

  CreditCardModel.new(customer_identifier,
                      ,
                      token,
                      label,
                      last_four_digits,
                      expiration_date,
                      status,
                      created_date,
                      activation_date,
                      contact_information)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['customer_identifier'] = 'customerIdentifier'
  @_hash['account_identifier'] = 'accountIdentifier'
  @_hash['token'] = 'token'
  @_hash['label'] = 'label'
  @_hash['last_four_digits'] = 'lastFourDigits'
  @_hash['expiration_date'] = 'expirationDate'
  @_hash['status'] = 'status'
  @_hash['created_date'] = 'createdDate'
  @_hash['activation_date'] = 'activationDate'
  @_hash['contact_information'] = 'contactInformation'
  @_hash
end