Class: AdvancedBilling::InvoiceCustomer

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

Overview

Information about the customer who is owner or recipient the invoiced subscription.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(chargify_id: SKIP, first_name: SKIP, last_name: SKIP, organization: SKIP, email: SKIP, vat_number: SKIP, reference: SKIP, additional_properties: {}) ⇒ InvoiceCustomer

Returns a new instance of InvoiceCustomer.



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/advanced_billing/models/invoice_customer.rb', line 77

def initialize(chargify_id: SKIP, first_name: SKIP, last_name: SKIP,
               organization: SKIP, email: SKIP, vat_number: SKIP,
               reference: SKIP, additional_properties: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

  @chargify_id = chargify_id unless chargify_id == SKIP
  @first_name = first_name unless first_name == SKIP
  @last_name = last_name unless last_name == SKIP
  @organization = organization unless organization == SKIP
  @email = email unless email == SKIP
  @vat_number = vat_number unless vat_number == SKIP
  @reference = reference unless reference == SKIP
end

Instance Attribute Details

#chargify_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


15
16
17
# File 'lib/advanced_billing/models/invoice_customer.rb', line 15

def chargify_id
  @chargify_id
end

#emailString

TODO: Write general description for this method

Returns:

  • (String)


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

def email
  @email
end

#first_nameString

TODO: Write general description for this method

Returns:

  • (String)


19
20
21
# File 'lib/advanced_billing/models/invoice_customer.rb', line 19

def first_name
  @first_name
end

#last_nameString

TODO: Write general description for this method

Returns:

  • (String)


23
24
25
# File 'lib/advanced_billing/models/invoice_customer.rb', line 23

def last_name
  @last_name
end

#organizationString

TODO: Write general description for this method

Returns:

  • (String)


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

def organization
  @organization
end

#referenceString

TODO: Write general description for this method

Returns:

  • (String)


39
40
41
# File 'lib/advanced_billing/models/invoice_customer.rb', line 39

def reference
  @reference
end

#vat_numberString

TODO: Write general description for this method

Returns:

  • (String)


35
36
37
# File 'lib/advanced_billing/models/invoice_customer.rb', line 35

def vat_number
  @vat_number
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/advanced_billing/models/invoice_customer.rb', line 95

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  chargify_id = hash.key?('chargify_id') ? hash['chargify_id'] : SKIP
  first_name = hash.key?('first_name') ? hash['first_name'] : SKIP
  last_name = hash.key?('last_name') ? hash['last_name'] : SKIP
  organization = hash.key?('organization') ? hash['organization'] : SKIP
  email = hash.key?('email') ? hash['email'] : SKIP
  vat_number = hash.key?('vat_number') ? hash['vat_number'] : SKIP
  reference = hash.key?('reference') ? hash['reference'] : SKIP

  # Clean out expected properties from Hash.
  additional_properties = hash.reject { |k, _| names.value?(k) }

  # Create object from extracted values.
  InvoiceCustomer.new(chargify_id: chargify_id,
                      first_name: first_name,
                      last_name: last_name,
                      organization: organization,
                      email: email,
                      vat_number: vat_number,
                      reference: reference,
                      additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/advanced_billing/models/invoice_customer.rb', line 42

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['chargify_id'] = 'chargify_id'
  @_hash['first_name'] = 'first_name'
  @_hash['last_name'] = 'last_name'
  @_hash['organization'] = 'organization'
  @_hash['email'] = 'email'
  @_hash['vat_number'] = 'vat_number'
  @_hash['reference'] = 'reference'
  @_hash
end

.nullablesObject

An array for nullable fields



68
69
70
71
72
73
74
75
# File 'lib/advanced_billing/models/invoice_customer.rb', line 68

def self.nullables
  %w[
    chargify_id
    organization
    vat_number
    reference
  ]
end

.optionalsObject

An array for optional fields



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/advanced_billing/models/invoice_customer.rb', line 55

def self.optionals
  %w[
    chargify_id
    first_name
    last_name
    organization
    email
    vat_number
    reference
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (InvoiceCustomer | Hash)

    value against the validation is performed.



123
124
125
126
127
128
129
# File 'lib/advanced_billing/models/invoice_customer.rb', line 123

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end