Class: AdvancedBilling::UpdatePaymentProfile

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/advanced_billing/models/update_payment_profile.rb

Overview

UpdatePaymentProfile Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(first_name: SKIP, last_name: SKIP, full_number: SKIP, card_type: SKIP, expiration_month: SKIP, expiration_year: SKIP, current_vault: SKIP, billing_address: SKIP, billing_city: SKIP, billing_state: SKIP, billing_zip: SKIP, billing_country: SKIP, billing_address_2: SKIP, additional_properties: {}) ⇒ UpdatePaymentProfile

Returns a new instance of UpdatePaymentProfile.



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/advanced_billing/models/update_payment_profile.rb', line 126

def initialize(first_name: SKIP, last_name: SKIP, full_number: SKIP,
               card_type: SKIP, expiration_month: SKIP,
               expiration_year: SKIP, current_vault: SKIP,
               billing_address: SKIP, billing_city: SKIP,
               billing_state: SKIP, billing_zip: SKIP,
               billing_country: SKIP, billing_address_2: SKIP,
               additional_properties: {})
  @first_name = first_name unless first_name == SKIP
  @last_name = last_name unless last_name == SKIP
  @full_number = full_number unless full_number == SKIP
  @card_type = card_type unless card_type == SKIP
  @expiration_month = expiration_month unless expiration_month == SKIP
  @expiration_year = expiration_year unless expiration_year == SKIP
  @current_vault = current_vault unless current_vault == SKIP
  @billing_address = billing_address unless billing_address == SKIP
  @billing_city = billing_city unless billing_city == SKIP
  @billing_state = billing_state unless billing_state == SKIP
  @billing_zip = billing_zip unless billing_zip == SKIP
  @billing_country = billing_country unless billing_country == SKIP
  @billing_address_2 = billing_address_2 unless billing_address_2 == SKIP

  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end
end

Instance Attribute Details

#billing_addressString

The credit card or bank account billing street address (i.e. 123 Main St.). This value is merely passed through to the payment gateway.

Returns:

  • (String)


48
49
50
# File 'lib/advanced_billing/models/update_payment_profile.rb', line 48

def billing_address
  @billing_address
end

#billing_address_2String

Second line of the customer’s billing address i.e. Apt. 100

Returns:

  • (String)


79
80
81
# File 'lib/advanced_billing/models/update_payment_profile.rb', line 79

def billing_address_2
  @billing_address_2
end

#billing_cityString

The credit card or bank account billing address city (i.e. “Boston”). This value is merely passed through to the payment gateway.

Returns:

  • (String)


53
54
55
# File 'lib/advanced_billing/models/update_payment_profile.rb', line 53

def billing_city
  @billing_city
end

#billing_countryString

The credit card or bank account billing address country, required in [ISO_3166-1 alpha-2](en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format (i.e. “US”). This value is merely passed through to the payment gateway. Some gateways require country codes in a specific format. Please check your gateway’s documentation. If creating an ACH subscription, only US is supported at this time.

Returns:

  • (String)


75
76
77
# File 'lib/advanced_billing/models/update_payment_profile.rb', line 75

def billing_country
  @billing_country
end

#billing_stateString

The credit card or bank account billing address state (i.e. MA). This value is merely passed through to the payment gateway. This must conform to the [ISO_3166-1](en.wikipedia.org/wiki/ISO_3166-1#Current_codes) in order to be valid for tax locale purposes.

Returns:

  • (String)


61
62
63
# File 'lib/advanced_billing/models/update_payment_profile.rb', line 61

def billing_state
  @billing_state
end

#billing_zipString

The credit card or bank account billing address zip code (i.e. 12345). This value is merely passed through to the payment gateway.

Returns:

  • (String)


66
67
68
# File 'lib/advanced_billing/models/update_payment_profile.rb', line 66

def billing_zip
  @billing_zip
end

#card_typeCardType

The type of card used.

Returns:



26
27
28
# File 'lib/advanced_billing/models/update_payment_profile.rb', line 26

def card_type
  @card_type
end

#current_vaultAllVaults

The vault that stores the payment profile with the provided ‘vault_token`. Use `bogus` for testing.

Returns:



43
44
45
# File 'lib/advanced_billing/models/update_payment_profile.rb', line 43

def current_vault
  @current_vault
end

#expiration_monthString

(Optional when performing an Import via vault_token, required otherwise) The 1- or 2-digit credit card expiration month, as an integer or string, i.e. 5

Returns:

  • (String)


32
33
34
# File 'lib/advanced_billing/models/update_payment_profile.rb', line 32

def expiration_month
  @expiration_month
end

#expiration_yearString

(Optional when performing a Import via vault_token, required otherwise) The 4-digit credit card expiration year, as an integer or string, i.e. 2012

Returns:

  • (String)


38
39
40
# File 'lib/advanced_billing/models/update_payment_profile.rb', line 38

def expiration_year
  @expiration_year
end

#first_nameString

The first name of the card holder.

Returns:

  • (String)


14
15
16
# File 'lib/advanced_billing/models/update_payment_profile.rb', line 14

def first_name
  @first_name
end

#full_numberString

The full credit card number

Returns:

  • (String)


22
23
24
# File 'lib/advanced_billing/models/update_payment_profile.rb', line 22

def full_number
  @full_number
end

#last_nameString

The last name of the card holder.

Returns:

  • (String)


18
19
20
# File 'lib/advanced_billing/models/update_payment_profile.rb', line 18

def last_name
  @last_name
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/advanced_billing/models/update_payment_profile.rb', line 154

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  first_name = hash.key?('first_name') ? hash['first_name'] : SKIP
  last_name = hash.key?('last_name') ? hash['last_name'] : SKIP
  full_number = hash.key?('full_number') ? hash['full_number'] : SKIP
  card_type = hash.key?('card_type') ? hash['card_type'] : SKIP
  expiration_month =
    hash.key?('expiration_month') ? hash['expiration_month'] : SKIP
  expiration_year =
    hash.key?('expiration_year') ? hash['expiration_year'] : SKIP
  current_vault = hash.key?('current_vault') ? hash['current_vault'] : SKIP
  billing_address =
    hash.key?('billing_address') ? hash['billing_address'] : SKIP
  billing_city = hash.key?('billing_city') ? hash['billing_city'] : SKIP
  billing_state = hash.key?('billing_state') ? hash['billing_state'] : SKIP
  billing_zip = hash.key?('billing_zip') ? hash['billing_zip'] : SKIP
  billing_country =
    hash.key?('billing_country') ? hash['billing_country'] : SKIP
  billing_address_2 =
    hash.key?('billing_address_2') ? hash['billing_address_2'] : SKIP

  # Clean out expected properties from Hash.
  names.each_value { |k| hash.delete(k) }

  # Create object from extracted values.
  UpdatePaymentProfile.new(first_name: first_name,
                           last_name: last_name,
                           full_number: full_number,
                           card_type: card_type,
                           expiration_month: expiration_month,
                           expiration_year: expiration_year,
                           current_vault: current_vault,
                           billing_address: billing_address,
                           billing_city: billing_city,
                           billing_state: billing_state,
                           billing_zip: billing_zip,
                           billing_country: billing_country,
                           billing_address_2: billing_address_2,
                           additional_properties: hash)
end

.namesObject

A mapping from model property names to API property names.



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/advanced_billing/models/update_payment_profile.rb', line 82

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['first_name'] = 'first_name'
  @_hash['last_name'] = 'last_name'
  @_hash['full_number'] = 'full_number'
  @_hash['card_type'] = 'card_type'
  @_hash['expiration_month'] = 'expiration_month'
  @_hash['expiration_year'] = 'expiration_year'
  @_hash['current_vault'] = 'current_vault'
  @_hash['billing_address'] = 'billing_address'
  @_hash['billing_city'] = 'billing_city'
  @_hash['billing_state'] = 'billing_state'
  @_hash['billing_zip'] = 'billing_zip'
  @_hash['billing_country'] = 'billing_country'
  @_hash['billing_address_2'] = 'billing_address_2'
  @_hash
end

.nullablesObject

An array for nullable fields



120
121
122
123
124
# File 'lib/advanced_billing/models/update_payment_profile.rb', line 120

def self.nullables
  %w[
    billing_address_2
  ]
end

.optionalsObject

An array for optional fields



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/advanced_billing/models/update_payment_profile.rb', line 101

def self.optionals
  %w[
    first_name
    last_name
    full_number
    card_type
    expiration_month
    expiration_year
    current_vault
    billing_address
    billing_city
    billing_state
    billing_zip
    billing_country
    billing_address_2
  ]
end