Class: AdvancedBilling::InvoicePayer

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

Overview

InvoicePayer Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

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

Returns a new instance of InvoicePayer.



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/advanced_billing/models/invoice_payer.rb', line 68

def initialize(chargify_id: SKIP, first_name: SKIP, last_name: SKIP,
               organization: SKIP, email: SKIP, vat_number: SKIP,
               additional_properties: {})
  @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

  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end
end

Instance Attribute Details

#chargify_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


14
15
16
# File 'lib/advanced_billing/models/invoice_payer.rb', line 14

def chargify_id
  @chargify_id
end

#emailString

TODO: Write general description for this method

Returns:

  • (String)


30
31
32
# File 'lib/advanced_billing/models/invoice_payer.rb', line 30

def email
  @email
end

#first_nameString

TODO: Write general description for this method

Returns:

  • (String)


18
19
20
# File 'lib/advanced_billing/models/invoice_payer.rb', line 18

def first_name
  @first_name
end

#last_nameString

TODO: Write general description for this method

Returns:

  • (String)


22
23
24
# File 'lib/advanced_billing/models/invoice_payer.rb', line 22

def last_name
  @last_name
end

#organizationString

TODO: Write general description for this method

Returns:

  • (String)


26
27
28
# File 'lib/advanced_billing/models/invoice_payer.rb', line 26

def organization
  @organization
end

#vat_numberString

TODO: Write general description for this method

Returns:

  • (String)


34
35
36
# File 'lib/advanced_billing/models/invoice_payer.rb', line 34

def vat_number
  @vat_number
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/advanced_billing/models/invoice_payer.rb', line 85

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

  # Clean out expected properties from Hash.
  names.each_value { |k| hash.delete(k) }

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

.namesObject

A mapping from model property names to API property names.



37
38
39
40
41
42
43
44
45
46
# File 'lib/advanced_billing/models/invoice_payer.rb', line 37

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
end

.nullablesObject

An array for nullable fields



61
62
63
64
65
66
# File 'lib/advanced_billing/models/invoice_payer.rb', line 61

def self.nullables
  %w[
    organization
    vat_number
  ]
end

.optionalsObject

An array for optional fields



49
50
51
52
53
54
55
56
57
58
# File 'lib/advanced_billing/models/invoice_payer.rb', line 49

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

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (InvoicePayer | Hash)

    value against the validation is performed.



111
112
113
114
115
116
117
# File 'lib/advanced_billing/models/invoice_payer.rb', line 111

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

  return false unless value.instance_of? Hash

  true
end