Class: AdvancedBilling::Customer
- Defined in:
- lib/advanced_billing/models/customer.rb
Overview
Customer Model.
Instance Attribute Summary collapse
-
#address ⇒ String
The customer’s shipping street address (i.e. “123 Main St.”).
-
#address_2 ⇒ String
Second line of the customer’s shipping address i.e.
-
#cc_emails ⇒ String
A comma-separated list of emails that should be cc’d on all customer communications (i.e. “[email protected], [email protected]”).
-
#city ⇒ String
The customer’s shipping address city (i.e. “Boston”).
-
#country ⇒ String
The customer shipping address country.
-
#country_name ⇒ String
The customer’s full name of country.
-
#created_at ⇒ DateTime
The timestamp in which the customer object was created in Chargify.
-
#default_subscription_group_uid ⇒ String
The locale for the customer to identify language-region.
-
#email ⇒ String
The email address of the customer.
-
#first_name ⇒ String
The first name of the customer.
-
#id ⇒ Integer
The customer ID in Chargify.
-
#last_name ⇒ String
The last name of the customer.
-
#locale ⇒ String
The locale for the customer to identify language-region.
-
#organization ⇒ String
The organization of the customer.
-
#parent_id ⇒ Integer
The parent ID in Chargify if applicable.
-
#phone ⇒ String
The phone number of the customer.
-
#portal_customer_created_at ⇒ DateTime
The timestamp of when the Billing Portal entry was created at for the customer.
-
#portal_invite_last_accepted_at ⇒ DateTime
The timestamp of when the Billing Portal invite was last accepted.
-
#portal_invite_last_sent_at ⇒ DateTime
The timestamp of when the Billing Portal invite was last sent at.
-
#reference ⇒ String
The unique identifier used within your own application for this customer.
-
#salesforce_id ⇒ String
The Salesforce ID for the customer.
-
#state ⇒ String
The customer’s shipping address state (i.e. “MA”).
-
#state_name ⇒ String
The customer’s full name of state.
-
#tax_exempt ⇒ TrueClass | FalseClass
The tax exempt status for the customer.
-
#updated_at ⇒ DateTime
The timestamp in which the customer object was last edited.
-
#vat_number ⇒ String
The VAT business identification number for the customer.
-
#verified ⇒ TrueClass | FalseClass
Is the customer verified to use ACH as a payment method.
-
#zip ⇒ String
The customer’s shipping address zip code (i.e. “12345”).
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(first_name: SKIP, last_name: SKIP, email: SKIP, cc_emails: SKIP, organization: SKIP, reference: SKIP, id: SKIP, created_at: SKIP, updated_at: SKIP, address: SKIP, address_2: SKIP, city: SKIP, state: SKIP, state_name: SKIP, zip: SKIP, country: SKIP, country_name: SKIP, phone: SKIP, verified: SKIP, portal_customer_created_at: SKIP, portal_invite_last_sent_at: SKIP, portal_invite_last_accepted_at: SKIP, tax_exempt: SKIP, vat_number: SKIP, parent_id: SKIP, locale: SKIP, default_subscription_group_uid: SKIP, salesforce_id: SKIP, additional_properties: {}) ⇒ Customer
constructor
A new instance of Customer.
- #to_custom_created_at ⇒ Object
- #to_custom_portal_customer_created_at ⇒ Object
- #to_custom_portal_invite_last_accepted_at ⇒ Object
- #to_custom_portal_invite_last_sent_at ⇒ Object
- #to_custom_updated_at ⇒ Object
Methods inherited from BaseModel
Constructor Details
#initialize(first_name: SKIP, last_name: SKIP, email: SKIP, cc_emails: SKIP, organization: SKIP, reference: SKIP, id: SKIP, created_at: SKIP, updated_at: SKIP, address: SKIP, address_2: SKIP, city: SKIP, state: SKIP, state_name: SKIP, zip: SKIP, country: SKIP, country_name: SKIP, phone: SKIP, verified: SKIP, portal_customer_created_at: SKIP, portal_invite_last_sent_at: SKIP, portal_invite_last_accepted_at: SKIP, tax_exempt: SKIP, vat_number: SKIP, parent_id: SKIP, locale: SKIP, default_subscription_group_uid: SKIP, salesforce_id: SKIP, additional_properties: {}) ⇒ Customer
Returns a new instance of Customer.
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
# File 'lib/advanced_billing/models/customer.rb', line 233 def initialize(first_name: SKIP, last_name: SKIP, email: SKIP, cc_emails: SKIP, organization: SKIP, reference: SKIP, id: SKIP, created_at: SKIP, updated_at: SKIP, address: SKIP, address_2: SKIP, city: SKIP, state: SKIP, state_name: SKIP, zip: SKIP, country: SKIP, country_name: SKIP, phone: SKIP, verified: SKIP, portal_customer_created_at: SKIP, portal_invite_last_sent_at: SKIP, portal_invite_last_accepted_at: SKIP, tax_exempt: SKIP, vat_number: SKIP, parent_id: SKIP, locale: SKIP, default_subscription_group_uid: SKIP, salesforce_id: SKIP, additional_properties: {}) @first_name = first_name unless first_name == SKIP @last_name = last_name unless last_name == SKIP @email = email unless email == SKIP @cc_emails = cc_emails unless cc_emails == SKIP @organization = organization unless organization == SKIP @reference = reference unless reference == SKIP @id = id unless id == SKIP @created_at = created_at unless created_at == SKIP @updated_at = updated_at unless updated_at == SKIP @address = address unless address == SKIP @address_2 = address_2 unless address_2 == SKIP @city = city unless city == SKIP @state = state unless state == SKIP @state_name = state_name unless state_name == SKIP @zip = zip unless zip == SKIP @country = country unless country == SKIP @country_name = country_name unless country_name == SKIP @phone = phone unless phone == SKIP @verified = verified unless verified == SKIP unless portal_customer_created_at == SKIP @portal_customer_created_at = portal_customer_created_at end unless portal_invite_last_sent_at == SKIP @portal_invite_last_sent_at = portal_invite_last_sent_at end unless portal_invite_last_accepted_at == SKIP @portal_invite_last_accepted_at = portal_invite_last_accepted_at end @tax_exempt = tax_exempt unless tax_exempt == SKIP @vat_number = vat_number unless vat_number == SKIP @parent_id = parent_id unless parent_id == SKIP @locale = locale unless locale == SKIP unless default_subscription_group_uid == SKIP @default_subscription_group_uid = default_subscription_group_uid end @salesforce_id = salesforce_id unless salesforce_id == SKIP # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end end |
Instance Attribute Details
#address ⇒ String
The customer’s shipping street address (i.e. “123 Main St.”)
54 55 56 |
# File 'lib/advanced_billing/models/customer.rb', line 54 def address @address end |
#address_2 ⇒ String
Second line of the customer’s shipping address i.e. “Apt. 100”
58 59 60 |
# File 'lib/advanced_billing/models/customer.rb', line 58 def address_2 @address_2 end |
#cc_emails ⇒ String
A comma-separated list of emails that should be cc’d on all customer communications (i.e. “[email protected], [email protected]”)
28 29 30 |
# File 'lib/advanced_billing/models/customer.rb', line 28 def cc_emails @cc_emails end |
#city ⇒ String
The customer’s shipping address city (i.e. “Boston”)
62 63 64 |
# File 'lib/advanced_billing/models/customer.rb', line 62 def city @city end |
#country ⇒ String
The customer shipping address country
78 79 80 |
# File 'lib/advanced_billing/models/customer.rb', line 78 def country @country end |
#country_name ⇒ String
The customer’s full name of country
82 83 84 |
# File 'lib/advanced_billing/models/customer.rb', line 82 def country_name @country_name end |
#created_at ⇒ DateTime
The timestamp in which the customer object was created in Chargify
46 47 48 |
# File 'lib/advanced_billing/models/customer.rb', line 46 def created_at @created_at end |
#default_subscription_group_uid ⇒ String
The locale for the customer to identify language-region
130 131 132 |
# File 'lib/advanced_billing/models/customer.rb', line 130 def default_subscription_group_uid @default_subscription_group_uid end |
#email ⇒ String
The email address of the customer
23 24 25 |
# File 'lib/advanced_billing/models/customer.rb', line 23 def email @email end |
#first_name ⇒ String
The first name of the customer
15 16 17 |
# File 'lib/advanced_billing/models/customer.rb', line 15 def first_name @first_name end |
#id ⇒ Integer
The customer ID in Chargify
42 43 44 |
# File 'lib/advanced_billing/models/customer.rb', line 42 def id @id end |
#last_name ⇒ String
The last name of the customer
19 20 21 |
# File 'lib/advanced_billing/models/customer.rb', line 19 def last_name @last_name end |
#locale ⇒ String
The locale for the customer to identify language-region
126 127 128 |
# File 'lib/advanced_billing/models/customer.rb', line 126 def locale @locale end |
#organization ⇒ String
The organization of the customer. If no value, ‘null` or empty string is provided, `organization` will be populated with the customer’s first and last name, separated with a space.
34 35 36 |
# File 'lib/advanced_billing/models/customer.rb', line 34 def organization @organization end |
#parent_id ⇒ Integer
The parent ID in Chargify if applicable. Parent is another Customer object.
122 123 124 |
# File 'lib/advanced_billing/models/customer.rb', line 122 def parent_id @parent_id end |
#phone ⇒ String
The phone number of the customer
86 87 88 |
# File 'lib/advanced_billing/models/customer.rb', line 86 def phone @phone end |
#portal_customer_created_at ⇒ DateTime
The timestamp of when the Billing Portal entry was created at for the customer
96 97 98 |
# File 'lib/advanced_billing/models/customer.rb', line 96 def portal_customer_created_at @portal_customer_created_at end |
#portal_invite_last_accepted_at ⇒ DateTime
The timestamp of when the Billing Portal invite was last accepted
104 105 106 |
# File 'lib/advanced_billing/models/customer.rb', line 104 def portal_invite_last_accepted_at @portal_invite_last_accepted_at end |
#portal_invite_last_sent_at ⇒ DateTime
The timestamp of when the Billing Portal invite was last sent at
100 101 102 |
# File 'lib/advanced_billing/models/customer.rb', line 100 def portal_invite_last_sent_at @portal_invite_last_sent_at end |
#reference ⇒ String
The unique identifier used within your own application for this customer
38 39 40 |
# File 'lib/advanced_billing/models/customer.rb', line 38 def reference @reference end |
#salesforce_id ⇒ String
The Salesforce ID for the customer
134 135 136 |
# File 'lib/advanced_billing/models/customer.rb', line 134 def salesforce_id @salesforce_id end |
#state ⇒ String
The customer’s shipping address state (i.e. “MA”)
66 67 68 |
# File 'lib/advanced_billing/models/customer.rb', line 66 def state @state end |
#state_name ⇒ String
The customer’s full name of state
70 71 72 |
# File 'lib/advanced_billing/models/customer.rb', line 70 def state_name @state_name end |
#tax_exempt ⇒ TrueClass | FalseClass
The tax exempt status for the customer. Acceptable values are true or 1 for true and false or 0 for false.
109 110 111 |
# File 'lib/advanced_billing/models/customer.rb', line 109 def tax_exempt @tax_exempt end |
#updated_at ⇒ DateTime
The timestamp in which the customer object was last edited
50 51 52 |
# File 'lib/advanced_billing/models/customer.rb', line 50 def updated_at @updated_at end |
#vat_number ⇒ String
The VAT business identification number for the customer. This number is used to determine VAT tax opt out rules. It is not validated when added or updated on a customer record. Instead, it is validated via VIES before calculating taxes. Only valid business identification numbers will allow for VAT opt out.
117 118 119 |
# File 'lib/advanced_billing/models/customer.rb', line 117 def vat_number @vat_number end |
#verified ⇒ TrueClass | FalseClass
Is the customer verified to use ACH as a payment method. Available only on Authorize.Net gateway
91 92 93 |
# File 'lib/advanced_billing/models/customer.rb', line 91 def verified @verified end |
#zip ⇒ String
The customer’s shipping address zip code (i.e. “12345”)
74 75 76 |
# File 'lib/advanced_billing/models/customer.rb', line 74 def zip @zip end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 |
# File 'lib/advanced_billing/models/customer.rb', line 292 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 email = hash.key?('email') ? hash['email'] : SKIP cc_emails = hash.key?('cc_emails') ? hash['cc_emails'] : SKIP organization = hash.key?('organization') ? hash['organization'] : SKIP reference = hash.key?('reference') ? hash['reference'] : SKIP id = hash.key?('id') ? hash['id'] : SKIP created_at = if hash.key?('created_at') (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at']) else SKIP end updated_at = if hash.key?('updated_at') (DateTimeHelper.from_rfc3339(hash['updated_at']) if hash['updated_at']) else SKIP end address = hash.key?('address') ? hash['address'] : SKIP address_2 = hash.key?('address_2') ? hash['address_2'] : SKIP city = hash.key?('city') ? hash['city'] : SKIP state = hash.key?('state') ? hash['state'] : SKIP state_name = hash.key?('state_name') ? hash['state_name'] : SKIP zip = hash.key?('zip') ? hash['zip'] : SKIP country = hash.key?('country') ? hash['country'] : SKIP country_name = hash.key?('country_name') ? hash['country_name'] : SKIP phone = hash.key?('phone') ? hash['phone'] : SKIP verified = hash.key?('verified') ? hash['verified'] : SKIP portal_customer_created_at = if hash.key?('portal_customer_created_at') (DateTimeHelper.from_rfc3339(hash['portal_customer_created_at']) if hash['portal_customer_created_at']) else SKIP end portal_invite_last_sent_at = if hash.key?('portal_invite_last_sent_at') (DateTimeHelper.from_rfc3339(hash['portal_invite_last_sent_at']) if hash['portal_invite_last_sent_at']) else SKIP end portal_invite_last_accepted_at = if hash.key?('portal_invite_last_accepted_at') (DateTimeHelper.from_rfc3339(hash['portal_invite_last_accepted_at']) if hash['portal_invite_last_accepted_at']) else SKIP end tax_exempt = hash.key?('tax_exempt') ? hash['tax_exempt'] : SKIP vat_number = hash.key?('vat_number') ? hash['vat_number'] : SKIP parent_id = hash.key?('parent_id') ? hash['parent_id'] : SKIP locale = hash.key?('locale') ? hash['locale'] : SKIP default_subscription_group_uid = hash.key?('default_subscription_group_uid') ? hash['default_subscription_group_uid'] : SKIP salesforce_id = hash.key?('salesforce_id') ? hash['salesforce_id'] : SKIP # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. Customer.new(first_name: first_name, last_name: last_name, email: email, cc_emails: cc_emails, organization: organization, reference: reference, id: id, created_at: created_at, updated_at: updated_at, address: address, address_2: address_2, city: city, state: state, state_name: state_name, zip: zip, country: country, country_name: country_name, phone: phone, verified: verified, portal_customer_created_at: portal_customer_created_at, portal_invite_last_sent_at: portal_invite_last_sent_at, portal_invite_last_accepted_at: portal_invite_last_accepted_at, tax_exempt: tax_exempt, vat_number: vat_number, parent_id: parent_id, locale: locale, default_subscription_group_uid: default_subscription_group_uid, salesforce_id: salesforce_id, additional_properties: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
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 166 167 168 169 170 |
# File 'lib/advanced_billing/models/customer.rb', line 137 def self.names @_hash = {} if @_hash.nil? @_hash['first_name'] = 'first_name' @_hash['last_name'] = 'last_name' @_hash['email'] = 'email' @_hash['cc_emails'] = 'cc_emails' @_hash['organization'] = 'organization' @_hash['reference'] = 'reference' @_hash['id'] = 'id' @_hash['created_at'] = 'created_at' @_hash['updated_at'] = 'updated_at' @_hash['address'] = 'address' @_hash['address_2'] = 'address_2' @_hash['city'] = 'city' @_hash['state'] = 'state' @_hash['state_name'] = 'state_name' @_hash['zip'] = 'zip' @_hash['country'] = 'country' @_hash['country_name'] = 'country_name' @_hash['phone'] = 'phone' @_hash['verified'] = 'verified' @_hash['portal_customer_created_at'] = 'portal_customer_created_at' @_hash['portal_invite_last_sent_at'] = 'portal_invite_last_sent_at' @_hash['portal_invite_last_accepted_at'] = 'portal_invite_last_accepted_at' @_hash['tax_exempt'] = 'tax_exempt' @_hash['vat_number'] = 'vat_number' @_hash['parent_id'] = 'parent_id' @_hash['locale'] = 'locale' @_hash['default_subscription_group_uid'] = 'default_subscription_group_uid' @_hash['salesforce_id'] = 'salesforce_id' @_hash end |
.nullables ⇒ Object
An array for nullable fields
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/advanced_billing/models/customer.rb', line 207 def self.nullables %w[ cc_emails organization reference address address_2 city state state_name zip country country_name phone verified portal_customer_created_at portal_invite_last_sent_at portal_invite_last_accepted_at vat_number parent_id locale default_subscription_group_uid salesforce_id ] end |
.optionals ⇒ Object
An array for optional fields
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 |
# File 'lib/advanced_billing/models/customer.rb', line 173 def self.optionals %w[ first_name last_name email cc_emails organization reference id created_at updated_at address address_2 city state state_name zip country country_name phone verified portal_customer_created_at portal_invite_last_sent_at portal_invite_last_accepted_at tax_exempt vat_number parent_id locale default_subscription_group_uid salesforce_id ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
403 404 405 406 407 408 409 |
# File 'lib/advanced_billing/models/customer.rb', line 403 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |
Instance Method Details
#to_custom_created_at ⇒ Object
381 382 383 |
# File 'lib/advanced_billing/models/customer.rb', line 381 def to_custom_created_at DateTimeHelper.to_rfc3339(created_at) end |
#to_custom_portal_customer_created_at ⇒ Object
389 390 391 |
# File 'lib/advanced_billing/models/customer.rb', line 389 def to_custom_portal_customer_created_at DateTimeHelper.to_rfc3339(portal_customer_created_at) end |
#to_custom_portal_invite_last_accepted_at ⇒ Object
397 398 399 |
# File 'lib/advanced_billing/models/customer.rb', line 397 def to_custom_portal_invite_last_accepted_at DateTimeHelper.to_rfc3339(portal_invite_last_accepted_at) end |
#to_custom_portal_invite_last_sent_at ⇒ Object
393 394 395 |
# File 'lib/advanced_billing/models/customer.rb', line 393 def to_custom_portal_invite_last_sent_at DateTimeHelper.to_rfc3339(portal_invite_last_sent_at) end |
#to_custom_updated_at ⇒ Object
385 386 387 |
# File 'lib/advanced_billing/models/customer.rb', line 385 def to_custom_updated_at DateTimeHelper.to_rfc3339(updated_at) end |