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 (i.e. “123 Main St.”).
-
#address_2 ⇒ String
(Optional) Second line of the customer’s shipping address i.e.
-
#cc_emails ⇒ String
A list of emails that should be cc’d on all customer communications.
-
#city ⇒ String
(Optional) The customer’s shipping address city (i.e. “Boston”).
-
#country ⇒ String
(Optional) The customer shipping address country, required in [ISO_3166-1 alpha-2](en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format (i.e. “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
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
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 (i.e. “MA”).
-
#tax_exempt ⇒ TrueClass | FalseClass
(Optional) The tax_exempt status of the customer.
-
#vat_number ⇒ String
(Optional) Supplying the VAT number allows EU customer’s 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 (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, address: SKIP, address_2: SKIP, city: SKIP, state: SKIP, zip: SKIP, country: SKIP, phone: SKIP, verified: SKIP, tax_exempt: 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.
Methods inherited from BaseModel
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, 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.
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 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 175 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, vat_number: SKIP, metafields: SKIP, parent_id: SKIP, salesforce_id: SKIP, default_auto_renewal_profile_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 @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 @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 # 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
(Optional) The customer’s shipping street address (i.e. “123 Main St.”).
45 46 47 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 45 def address @address end |
#address_2 ⇒ String
(Optional) Second line of the customer’s shipping address i.e. “Apt. 100”
49 50 51 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 49 def address_2 @address_2 end |
#cc_emails ⇒ String
A list of emails that should be cc’d on all customer communications. Optional.
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 (i.e. “Boston”).
53 54 55 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 53 def city @city end |
#country ⇒ String
(Optional) The customer shipping address country, required in [ISO_3166-1 alpha-2](en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format (i.e. “US”).
70 71 72 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 70 def country @country end |
#default_auto_renewal_profile_id ⇒ Integer
(Optional) The default auto-renewal profile ID for the customer
110 111 112 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 110 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.
97 98 99 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 97 def @metafields end |
#organization ⇒ String
The organization/company of the customer. Optional.
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.
102 103 104 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 102 def parent_id @parent_id end |
#phone ⇒ String
(Optional) The phone number of the customer.
74 75 76 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 74 def phone @phone end |
#reference ⇒ String
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. Optional.
41 42 43 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 41 def reference @reference end |
#salesforce_id ⇒ String
(Optional) The Salesforce ID of the customer.
106 107 108 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 106 def salesforce_id @salesforce_id end |
#state ⇒ String
(Optional) The customer’s shipping address state (i.e. “MA”). 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.
60 61 62 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 60 def state @state 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.
83 84 85 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 83 def tax_exempt @tax_exempt end |
#vat_number ⇒ String
(Optional) Supplying the VAT number allows EU customer’s 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.
91 92 93 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 91 def vat_number @vat_number end |
#verified ⇒ TrueClass | FalseClass
(Optional) The phone number of the customer.
78 79 80 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 78 def verified @verified end |
#zip ⇒ String
(Optional) The customer’s shipping address zip code (i.e. “12345”).
64 65 66 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 64 def zip @zip end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
214 215 216 217 218 219 220 221 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 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 214 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 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. names.each_value { |k| hash.delete(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, 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: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 113 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['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
166 167 168 169 170 171 172 173 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 166 def self.nullables %w[ address_2 parent_id salesforce_id default_auto_renewal_profile_id ] end |
.optionals ⇒ Object
An array for optional fields
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 140 def self.optionals %w[ first_name last_name email cc_emails organization reference address address_2 city state zip country phone verified tax_exempt 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.
269 270 271 272 273 274 275 |
# File 'lib/advanced_billing/models/customer_attributes.rb', line 269 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |