Class: AdvancedBilling::CustomerAttributes
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::CustomerAttributes
- Defined in:
- lib/advanced_billing/models/customer_attributes.rb
Overview
CustomerAttributes Model.
Instance Attribute Summary collapse
-
#address ⇒ String
(Optional) The customer’s shipping street address (e.g., “123 Main St.”).
-
#address_2 ⇒ String
(Optional) Second line of the customer’s shipping address e.g., “Apt.
-
#cc_emails ⇒ String
(Optional) A list of emails that should be cc’d on all customer communications.
-
#city ⇒ String
(Optional) The customer’s shipping address city (e.g., “Boston”).
-
#country ⇒ String
“(Optional) The customer shipping address country, required in ISO_3166-1 alpha-2 format (e.g., “US”).”.
-
#default_auto_renewal_profile_id ⇒ Integer
(Optional) The default auto-renewal profile ID for the customer.
-
#email ⇒ String
The email address of the customer.
-
#first_name ⇒ String
The first name of the customer.
-
#last_name ⇒ String
The last name of the customer.
-
#metafields ⇒ Hash[String, String]
(Optional) A set of key/value pairs representing custom fields and their values.
-
#organization ⇒ String
(Optional) The organization/company of the customer.
-
#parent_id ⇒ Integer
The parent ID in Chargify if applicable.
-
#phone ⇒ String
(Optional) The phone number of the customer.
-
#reference ⇒ String
(Optional) A customer “reference”, or unique identifier from your app, stored in Chargify.
-
#salesforce_id ⇒ String
(Optional) The Salesforce ID of the customer.
-
#state ⇒ String
“(Optional) The customer’s shipping address state (e.g., “MA”).
-
#surcharging ⇒ TrueClass | FalseClass
(Optional) Whether surcharging is enabled for the customer.
-
#tax_exempt ⇒ TrueClass | FalseClass
(Optional) The tax_exempt status of the customer.
-
#vat_number ⇒ String
(Optional) Supplying the VAT number allows EU customers to opt-out of the Value Added Tax assuming the merchant address and customer billing address are not within the same EU country.
-
#verified ⇒ TrueClass | FalseClass
(Optional) The phone number of the customer.
-
#zip ⇒ String
(Optional) The customer’s shipping address zip code (e.g., “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, address: SKIP, address_2: SKIP, city: SKIP, state: SKIP, zip: SKIP, country: SKIP, phone: SKIP, verified: SKIP, tax_exempt: SKIP, surcharging: SKIP, vat_number: SKIP, metafields: SKIP, parent_id: SKIP, salesforce_id: SKIP, default_auto_renewal_profile_id: SKIP, additional_properties: {}) ⇒ CustomerAttributes
constructor
A new instance of CustomerAttributes.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #get_additional_properties, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(first_name: SKIP, last_name: SKIP, email: SKIP, cc_emails: SKIP, organization: SKIP, reference: SKIP, address: SKIP, address_2: SKIP, city: SKIP, state: SKIP, zip: SKIP, country: SKIP, phone: SKIP, verified: SKIP, tax_exempt: SKIP, surcharging: SKIP, vat_number: SKIP, metafields: SKIP, parent_id: SKIP, salesforce_id: SKIP, default_auto_renewal_profile_id: SKIP, additional_properties: {}) ⇒ CustomerAttributes
Returns a new instance of CustomerAttributes.
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 217 218 219 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 182 def initialize(first_name: SKIP, last_name: SKIP, email: SKIP, cc_emails: SKIP, organization: SKIP, reference: SKIP, address: SKIP, address_2: SKIP, city: SKIP, state: SKIP, zip: SKIP, country: SKIP, phone: SKIP, verified: SKIP, tax_exempt: SKIP, surcharging: SKIP, vat_number: SKIP, metafields: SKIP, parent_id: SKIP, salesforce_id: SKIP, default_auto_renewal_profile_id: SKIP, additional_properties: {}) # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end @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 @address = address unless address == SKIP @address_2 = address_2 unless address_2 == SKIP @city = city unless city == SKIP @state = state unless state == SKIP @zip = zip unless zip == SKIP @country = country unless country == SKIP @phone = phone unless phone == SKIP @verified = verified unless verified == SKIP @tax_exempt = tax_exempt unless tax_exempt == SKIP @surcharging = surcharging unless surcharging == SKIP @vat_number = vat_number unless vat_number == SKIP @metafields = unless == SKIP @parent_id = parent_id unless parent_id == SKIP @salesforce_id = salesforce_id unless salesforce_id == SKIP unless default_auto_renewal_profile_id == SKIP @default_auto_renewal_profile_id = default_auto_renewal_profile_id end end |
Instance Attribute Details
#address ⇒ String
(Optional) The customer’s shipping street address (e.g., “123 Main St.”).
44 45 46 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 44 def address @address end |
#address_2 ⇒ String
(Optional) Second line of the customer’s shipping address e.g., “Apt. 100”
48 49 50 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 48 def address_2 @address_2 end |
#cc_emails ⇒ String
(Optional) A list of emails that should be cc’d on all customer communications.
30 31 32 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 30 def cc_emails @cc_emails end |
#city ⇒ String
(Optional) The customer’s shipping address city (e.g., “Boston”).
52 53 54 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 52 def city @city end |
#country ⇒ String
“(Optional) The customer shipping address country, required in ISO_3166-1 alpha-2 format (e.g., “US”).”
69 70 71 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 69 def country @country end |
#default_auto_renewal_profile_id ⇒ Integer
(Optional) The default auto-renewal profile ID for the customer
115 116 117 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 115 def default_auto_renewal_profile_id @default_auto_renewal_profile_id end |
#email ⇒ String
The email address of the customer. Required when creating a customer via attributes.
25 26 27 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 25 def email @email end |
#first_name ⇒ String
The first name of the customer. Required when creating a customer via attributes.
15 16 17 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 15 def first_name @first_name end |
#last_name ⇒ String
The last name of the customer. Required when creating a customer via attributes.
20 21 22 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 20 def last_name @last_name end |
#metafields ⇒ Hash[String, String]
(Optional) A set of key/value pairs representing custom fields and their values. Metafields will be created “on-the-fly” in your site for a given key, if they have not been created yet.
102 103 104 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 102 def @metafields end |
#organization ⇒ String
(Optional) The organization/company of the customer.
34 35 36 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 34 def organization @organization end |
#parent_id ⇒ Integer
The parent ID in Chargify if applicable. Parent is another Customer object.
107 108 109 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 107 def parent_id @parent_id end |
#phone ⇒ String
(Optional) The phone number of the customer.
73 74 75 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 73 def phone @phone end |
#reference ⇒ String
(Optional) A customer “reference”, or unique identifier from your app, stored in Chargify. Can be used so that you may reference your customer’s within Chargify using the same unique value you use in your application.
40 41 42 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 40 def reference @reference end |
#salesforce_id ⇒ String
(Optional) The Salesforce ID of the customer.
111 112 113 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 111 def salesforce_id @salesforce_id end |
#state ⇒ String
“(Optional) The customer’s shipping address state (e.g., “MA”). This must conform to the ISO_3166-1 in order to be valid for tax locale purposes.”
59 60 61 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 59 def state @state end |
#surcharging ⇒ TrueClass | FalseClass
(Optional) Whether surcharging is enabled for the customer. Defaults to
true when omitted. Only applied on sites where surcharging control is
enabled.
88 89 90 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 88 def surcharging @surcharging end |
#tax_exempt ⇒ TrueClass | FalseClass
(Optional) The tax_exempt status of the customer. Acceptable values are true or 1 for true and false or 0 for false.
82 83 84 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 82 def tax_exempt @tax_exempt end |
#vat_number ⇒ String
(Optional) Supplying the VAT number allows EU customers to opt-out of the Value Added Tax assuming the merchant address and customer billing address are not within the same EU country. It’s important to omit the country code from the VAT number upon entry. Otherwise, taxes will be assessed upon the purchase.
96 97 98 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 96 def vat_number @vat_number end |
#verified ⇒ TrueClass | FalseClass
(Optional) The phone number of the customer.
77 78 79 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 77 def verified @verified end |
#zip ⇒ String
(Optional) The customer’s shipping address zip code (e.g., “12345”).
63 64 65 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 63 def zip @zip end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
222 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 274 275 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 222 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 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 zip = hash.key?('zip') ? hash['zip'] : SKIP country = hash.key?('country') ? hash['country'] : SKIP phone = hash.key?('phone') ? hash['phone'] : SKIP verified = hash.key?('verified') ? hash['verified'] : SKIP tax_exempt = hash.key?('tax_exempt') ? hash['tax_exempt'] : SKIP surcharging = hash.key?('surcharging') ? hash['surcharging'] : SKIP vat_number = hash.key?('vat_number') ? hash['vat_number'] : SKIP = hash.key?('metafields') ? hash['metafields'] : SKIP parent_id = hash.key?('parent_id') ? hash['parent_id'] : SKIP salesforce_id = hash.key?('salesforce_id') ? hash['salesforce_id'] : SKIP default_auto_renewal_profile_id = hash.key?('default_auto_renewal_profile_id') ? hash['default_auto_renewal_profile_id'] : SKIP # Clean out expected properties from Hash. additional_properties = hash.reject { |k, _| names.value?(k) } # Create object from extracted values. CustomerAttributes.new(first_name: first_name, last_name: last_name, email: email, cc_emails: cc_emails, organization: organization, reference: reference, address: address, address_2: address_2, city: city, state: state, zip: zip, country: country, phone: phone, verified: verified, tax_exempt: tax_exempt, surcharging: surcharging, vat_number: vat_number, metafields: , parent_id: parent_id, salesforce_id: salesforce_id, default_auto_renewal_profile_id: default_auto_renewal_profile_id, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 118 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['address'] = 'address' @_hash['address_2'] = 'address_2' @_hash['city'] = 'city' @_hash['state'] = 'state' @_hash['zip'] = 'zip' @_hash['country'] = 'country' @_hash['phone'] = 'phone' @_hash['verified'] = 'verified' @_hash['tax_exempt'] = 'tax_exempt' @_hash['surcharging'] = 'surcharging' @_hash['vat_number'] = 'vat_number' @_hash['metafields'] = 'metafields' @_hash['parent_id'] = 'parent_id' @_hash['salesforce_id'] = 'salesforce_id' @_hash['default_auto_renewal_profile_id'] = 'default_auto_renewal_profile_id' @_hash end |
.nullables ⇒ Object
An array for nullable fields
173 174 175 176 177 178 179 180 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 173 def self.nullables %w[ address_2 parent_id salesforce_id default_auto_renewal_profile_id ] end |
.optionals ⇒ Object
An array for optional fields
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_attributes.rb', line 146 def self.optionals %w[ first_name last_name email cc_emails organization reference address address_2 city state zip country phone verified tax_exempt surcharging vat_number metafields parent_id salesforce_id default_auto_renewal_profile_id ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
279 280 281 282 283 284 285 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 279 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 301 def inspect class_name = self.class.name.split('::').last "<#{class_name} first_name: #{@first_name.inspect}, last_name: #{@last_name.inspect},"\ " email: #{@email.inspect}, cc_emails: #{@cc_emails.inspect}, organization:"\ " #{@organization.inspect}, reference: #{@reference.inspect}, address: #{@address.inspect},"\ " address_2: #{@address_2.inspect}, city: #{@city.inspect}, state: #{@state.inspect}, zip:"\ " #{@zip.inspect}, country: #{@country.inspect}, phone: #{@phone.inspect}, verified:"\ " #{@verified.inspect}, tax_exempt: #{@tax_exempt.inspect}, surcharging:"\ " #{@surcharging.inspect}, vat_number: #{@vat_number.inspect}, metafields:"\ " #{@metafields.inspect}, parent_id: #{@parent_id.inspect}, salesforce_id:"\ " #{@salesforce_id.inspect}, default_auto_renewal_profile_id:"\ " #{@default_auto_renewal_profile_id.inspect}, additional_properties:"\ " #{get_additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 288 def to_s class_name = self.class.name.split('::').last "<#{class_name} first_name: #{@first_name}, last_name: #{@last_name}, email: #{@email},"\ " cc_emails: #{@cc_emails}, organization: #{@organization}, reference: #{@reference},"\ " address: #{@address}, address_2: #{@address_2}, city: #{@city}, state: #{@state}, zip:"\ " #{@zip}, country: #{@country}, phone: #{@phone}, verified: #{@verified}, tax_exempt:"\ " #{@tax_exempt}, surcharging: #{@surcharging}, vat_number: #{@vat_number}, metafields:"\ " #{@metafields}, parent_id: #{@parent_id}, salesforce_id: #{@salesforce_id},"\ " default_auto_renewal_profile_id: #{@default_auto_renewal_profile_id},"\ " additional_properties: #{get_additional_properties}>" end |