Class: AdvancedBilling::ApplePayPaymentProfile

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

Overview

ApplePayPaymentProfile 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: PaymentType::APPLE_PAY, id: SKIP, first_name: SKIP, last_name: SKIP, customer_id: SKIP, current_vault: SKIP, vault_token: SKIP, billing_address: SKIP, billing_city: SKIP, billing_state: SKIP, billing_zip: SKIP, billing_country: SKIP, customer_vault_token: SKIP, billing_address_2: SKIP, site_gateway_setting_id: SKIP, gateway_handle: SKIP, additional_properties: {}) ⇒ ApplePayPaymentProfile

Returns a new instance of ApplePayPaymentProfile.



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/advanced_billing/models/apple_pay_payment_profile.rb', line 136

def initialize(payment_type: PaymentType::APPLE_PAY, id: SKIP,
               first_name: SKIP, last_name: SKIP, customer_id: SKIP,
               current_vault: SKIP, vault_token: SKIP,
               billing_address: SKIP, billing_city: SKIP,
               billing_state: SKIP, billing_zip: SKIP,
               billing_country: SKIP, customer_vault_token: SKIP,
               billing_address_2: SKIP, site_gateway_setting_id: SKIP,
               gateway_handle: SKIP, additional_properties: {})
  @id = id unless id == SKIP
  @first_name = first_name unless first_name == SKIP
  @last_name = last_name unless last_name == SKIP
  @customer_id = customer_id unless customer_id == SKIP
  @current_vault = current_vault unless current_vault == SKIP
  @vault_token = vault_token unless vault_token == 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
  @customer_vault_token = customer_vault_token unless customer_vault_token == SKIP
  @billing_address_2 = billing_address_2 unless billing_address_2 == SKIP
  @payment_type = payment_type
  @site_gateway_setting_id = site_gateway_setting_id unless site_gateway_setting_id == SKIP
  @gateway_handle = gateway_handle unless gateway_handle == 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 current billing street address for the Apple Pay account

Returns:

  • (String)


40
41
42
# File 'lib/advanced_billing/models/apple_pay_payment_profile.rb', line 40

def billing_address
  @billing_address
end

#billing_address_2String

The current billing street address, second line, for the Apple Pay account

Returns:

  • (String)


64
65
66
# File 'lib/advanced_billing/models/apple_pay_payment_profile.rb', line 64

def billing_address_2
  @billing_address_2
end

#billing_cityString

The current billing address city for the Apple Pay account

Returns:

  • (String)


44
45
46
# File 'lib/advanced_billing/models/apple_pay_payment_profile.rb', line 44

def billing_city
  @billing_city
end

#billing_countryString

The current billing address country for the Apple Pay account

Returns:

  • (String)


56
57
58
# File 'lib/advanced_billing/models/apple_pay_payment_profile.rb', line 56

def billing_country
  @billing_country
end

#billing_stateString

The current billing address state for the Apple Pay account

Returns:

  • (String)


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

def billing_state
  @billing_state
end

#billing_zipString

The current billing address zip code for the Apple Pay account

Returns:

  • (String)


52
53
54
# File 'lib/advanced_billing/models/apple_pay_payment_profile.rb', line 52

def billing_zip
  @billing_zip
end

#current_vaultApplePayVault

The vault that stores the payment profile with the provided vault_token.

Returns:



31
32
33
# File 'lib/advanced_billing/models/apple_pay_payment_profile.rb', line 31

def current_vault
  @current_vault
end

#customer_idInteger

The Chargify-assigned id for the customer record to which the Apple Pay account belongs

Returns:

  • (Integer)


27
28
29
# File 'lib/advanced_billing/models/apple_pay_payment_profile.rb', line 27

def customer_id
  @customer_id
end

#customer_vault_tokenString

The current billing address country for the Apple Pay account

Returns:

  • (String)


60
61
62
# File 'lib/advanced_billing/models/apple_pay_payment_profile.rb', line 60

def customer_vault_token
  @customer_vault_token
end

#first_nameString

The first name of the Apple Pay account holder

Returns:

  • (String)


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

def first_name
  @first_name
end

#gateway_handleString

The current billing street address, second line, for the Apple Pay account

Returns:

  • (String)


76
77
78
# File 'lib/advanced_billing/models/apple_pay_payment_profile.rb', line 76

def gateway_handle
  @gateway_handle
end

#idInteger

The Chargify-assigned ID of the Apple Pay payment profile.

Returns:

  • (Integer)


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

def id
  @id
end

#last_nameString

The last name of the Apple Pay account holder

Returns:

  • (String)


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

def last_name
  @last_name
end

#payment_typePaymentType

The current billing street address, second line, for the Apple Pay account

Returns:



68
69
70
# File 'lib/advanced_billing/models/apple_pay_payment_profile.rb', line 68

def payment_type
  @payment_type
end

#site_gateway_setting_idInteger

The current billing street address, second line, for the Apple Pay account

Returns:

  • (Integer)


72
73
74
# File 'lib/advanced_billing/models/apple_pay_payment_profile.rb', line 72

def site_gateway_setting_id
  @site_gateway_setting_id
end

#vault_tokenString

The “token” provided by your vault storage for an already stored payment profile

Returns:

  • (String)


36
37
38
# File 'lib/advanced_billing/models/apple_pay_payment_profile.rb', line 36

def vault_token
  @vault_token
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/advanced_billing/models/apple_pay_payment_profile.rb', line 168

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  payment_type = hash['payment_type'] ||= PaymentType::APPLE_PAY
  id = hash.key?('id') ? hash['id'] : SKIP
  first_name = hash.key?('first_name') ? hash['first_name'] : SKIP
  last_name = hash.key?('last_name') ? hash['last_name'] : SKIP
  customer_id = hash.key?('customer_id') ? hash['customer_id'] : SKIP
  current_vault = hash.key?('current_vault') ? hash['current_vault'] : SKIP
  vault_token = hash.key?('vault_token') ? hash['vault_token'] : 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
  customer_vault_token =
    hash.key?('customer_vault_token') ? hash['customer_vault_token'] : SKIP
  billing_address_2 =
    hash.key?('billing_address_2') ? hash['billing_address_2'] : SKIP
  site_gateway_setting_id =
    hash.key?('site_gateway_setting_id') ? hash['site_gateway_setting_id'] : SKIP
  gateway_handle =
    hash.key?('gateway_handle') ? hash['gateway_handle'] : SKIP

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

  # Create object from extracted values.
  ApplePayPaymentProfile.new(payment_type: payment_type,
                             id: id,
                             first_name: first_name,
                             last_name: last_name,
                             customer_id: customer_id,
                             current_vault: current_vault,
                             vault_token: vault_token,
                             billing_address: billing_address,
                             billing_city: billing_city,
                             billing_state: billing_state,
                             billing_zip: billing_zip,
                             billing_country: billing_country,
                             customer_vault_token: customer_vault_token,
                             billing_address_2: billing_address_2,
                             site_gateway_setting_id: site_gateway_setting_id,
                             gateway_handle: gateway_handle,
                             additional_properties: hash)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['first_name'] = 'first_name'
  @_hash['last_name'] = 'last_name'
  @_hash['customer_id'] = 'customer_id'
  @_hash['current_vault'] = 'current_vault'
  @_hash['vault_token'] = 'vault_token'
  @_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['customer_vault_token'] = 'customer_vault_token'
  @_hash['billing_address_2'] = 'billing_address_2'
  @_hash['payment_type'] = 'payment_type'
  @_hash['site_gateway_setting_id'] = 'site_gateway_setting_id'
  @_hash['gateway_handle'] = 'gateway_handle'
  @_hash
end

.nullablesObject

An array for nullable fields



122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/advanced_billing/models/apple_pay_payment_profile.rb', line 122

def self.nullables
  %w[
    billing_address
    billing_city
    billing_state
    billing_zip
    billing_country
    customer_vault_token
    billing_address_2
    site_gateway_setting_id
    gateway_handle
  ]
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    id
    first_name
    last_name
    customer_id
    current_vault
    vault_token
    billing_address
    billing_city
    billing_state
    billing_zip
    billing_country
    customer_vault_token
    billing_address_2
    site_gateway_setting_id
    gateway_handle
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



220
221
222
223
224
225
226
227
228
229
230
# File 'lib/advanced_billing/models/apple_pay_payment_profile.rb', line 220

def self.validate(value)
  if value.instance_of? self
    return APIHelper.valid_type?(value.payment_type,
                                 ->(val) { PaymentType.validate(val) })
  end

  return false unless value.instance_of? Hash

  APIHelper.valid_type?(value['payment_type'],
                        ->(val) { PaymentType.validate(val) })
end