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 ⇒ String
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 ⇒ String
The timestamp of when the Billing Portal entry was created at for the customer.
-
#portal_invite_last_accepted_at ⇒ String
The timestamp of when the Billing Portal invite was last accepted.
-
#portal_invite_last_sent_at ⇒ String
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.
-
#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 ⇒ String
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
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) ⇒ Customer
Returns a new instance of Customer.
223 224 225 226 227 228 229 230 231 232 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 |
# File 'lib/advanced_billing/models/customer.rb', line 223 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) @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 end |
Instance Attribute Details
#address ⇒ String
The customer’s shipping street address (i.e. “123 Main St.”)
51 52 53 |
# File 'lib/advanced_billing/models/customer.rb', line 51 def address @address end |
#address_2 ⇒ String
Second line of the customer’s shipping address i.e. “Apt. 100”
55 56 57 |
# File 'lib/advanced_billing/models/customer.rb', line 55 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]”)
27 28 29 |
# File 'lib/advanced_billing/models/customer.rb', line 27 def cc_emails @cc_emails end |
#city ⇒ String
The customer’s shipping address city (i.e. “Boston”)
59 60 61 |
# File 'lib/advanced_billing/models/customer.rb', line 59 def city @city end |
#country ⇒ String
The customer shipping address country
75 76 77 |
# File 'lib/advanced_billing/models/customer.rb', line 75 def country @country end |
#country_name ⇒ String
The customer’s full name of country
79 80 81 |
# File 'lib/advanced_billing/models/customer.rb', line 79 def country_name @country_name end |
#created_at ⇒ String
The timestamp in which the customer object was created in Chargify
43 44 45 |
# File 'lib/advanced_billing/models/customer.rb', line 43 def created_at @created_at end |
#default_subscription_group_uid ⇒ String
The locale for the customer to identify language-region
127 128 129 |
# File 'lib/advanced_billing/models/customer.rb', line 127 def default_subscription_group_uid @default_subscription_group_uid end |
#email ⇒ String
The email address of the customer
22 23 24 |
# File 'lib/advanced_billing/models/customer.rb', line 22 def email @email end |
#first_name ⇒ String
The first name of the customer
14 15 16 |
# File 'lib/advanced_billing/models/customer.rb', line 14 def first_name @first_name end |
#id ⇒ Integer
The customer ID in Chargify
39 40 41 |
# File 'lib/advanced_billing/models/customer.rb', line 39 def id @id end |
#last_name ⇒ String
The last name of the customer
18 19 20 |
# File 'lib/advanced_billing/models/customer.rb', line 18 def last_name @last_name end |
#locale ⇒ String
The locale for the customer to identify language-region
123 124 125 |
# File 'lib/advanced_billing/models/customer.rb', line 123 def locale @locale end |
#organization ⇒ String
The organization of the customer
31 32 33 |
# File 'lib/advanced_billing/models/customer.rb', line 31 def organization @organization end |
#parent_id ⇒ Integer
The parent ID in Chargify if applicable. Parent is another Customer object.
119 120 121 |
# File 'lib/advanced_billing/models/customer.rb', line 119 def parent_id @parent_id end |
#phone ⇒ String
The phone number of the customer
83 84 85 |
# File 'lib/advanced_billing/models/customer.rb', line 83 def phone @phone end |
#portal_customer_created_at ⇒ String
The timestamp of when the Billing Portal entry was created at for the customer
93 94 95 |
# File 'lib/advanced_billing/models/customer.rb', line 93 def portal_customer_created_at @portal_customer_created_at end |
#portal_invite_last_accepted_at ⇒ String
The timestamp of when the Billing Portal invite was last accepted
101 102 103 |
# File 'lib/advanced_billing/models/customer.rb', line 101 def portal_invite_last_accepted_at @portal_invite_last_accepted_at end |
#portal_invite_last_sent_at ⇒ String
The timestamp of when the Billing Portal invite was last sent at
97 98 99 |
# File 'lib/advanced_billing/models/customer.rb', line 97 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
35 36 37 |
# File 'lib/advanced_billing/models/customer.rb', line 35 def reference @reference end |
#state ⇒ String
The customer’s shipping address state (i.e. “MA”)
63 64 65 |
# File 'lib/advanced_billing/models/customer.rb', line 63 def state @state end |
#state_name ⇒ String
The customer’s full name of state
67 68 69 |
# File 'lib/advanced_billing/models/customer.rb', line 67 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.
106 107 108 |
# File 'lib/advanced_billing/models/customer.rb', line 106 def tax_exempt @tax_exempt end |
#updated_at ⇒ String
The timestamp in which the customer object was last edited
47 48 49 |
# File 'lib/advanced_billing/models/customer.rb', line 47 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.
114 115 116 |
# File 'lib/advanced_billing/models/customer.rb', line 114 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
88 89 90 |
# File 'lib/advanced_billing/models/customer.rb', line 88 def verified @verified end |
#zip ⇒ String
The customer’s shipping address zip code (i.e. “12345”)
71 72 73 |
# File 'lib/advanced_billing/models/customer.rb', line 71 def zip @zip end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 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 |
# File 'lib/advanced_billing/models/customer.rb', line 276 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 = hash.key?('created_at') ? hash['created_at'] : SKIP updated_at = hash.key?('updated_at') ? hash['updated_at'] : SKIP 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 = hash.key?('portal_customer_created_at') ? hash['portal_customer_created_at'] : SKIP portal_invite_last_sent_at = hash.key?('portal_invite_last_sent_at') ? hash['portal_invite_last_sent_at'] : SKIP portal_invite_last_accepted_at = hash.key?('portal_invite_last_accepted_at') ? hash['portal_invite_last_accepted_at'] : SKIP 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 # Create object from extracted values. Customer.new(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) end |
.names ⇒ Object
A mapping from model property names to API property names.
130 131 132 133 134 135 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 |
# File 'lib/advanced_billing/models/customer.rb', line 130 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 end |
.nullables ⇒ Object
An array for nullable fields
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/advanced_billing/models/customer.rb', line 198 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 ] end |
.optionals ⇒ Object
An array for optional fields
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/customer.rb', line 165 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 ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
344 345 346 347 348 349 350 |
# File 'lib/advanced_billing/models/customer.rb', line 344 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |