Class: AdvancedBilling::InvoiceCustomField

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

Overview

InvoiceCustomField Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(owner_id: SKIP, owner_type: SKIP, name: SKIP, value: SKIP, metadatum_id: SKIP, additional_properties: {}) ⇒ InvoiceCustomField

Returns a new instance of InvoiceCustomField.



59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/advanced_billing/models/invoice_custom_field.rb', line 59

def initialize(owner_id: SKIP, owner_type: SKIP, name: SKIP, value: SKIP,
               metadatum_id: SKIP, additional_properties: {})
  @owner_id = owner_id unless owner_id == SKIP
  @owner_type = owner_type unless owner_type == SKIP
  @name = name unless name == SKIP
  @value = value unless value == SKIP
  @metadatum_id = metadatum_id unless metadatum_id == SKIP

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

Instance Attribute Details

#metadatum_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def metadatum_id
  @metadatum_id
end

#nameString

TODO: Write general description for this method

Returns:

  • (String)


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

def name
  @name
end

#owner_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def owner_id
  @owner_id
end

#owner_typeCustomFieldOwner

TODO: Write general description for this method

Returns:



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

def owner_type
  @owner_type
end

#valueString

TODO: Write general description for this method

Returns:

  • (String)


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

def value
  @value
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/advanced_billing/models/invoice_custom_field.rb', line 74

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  owner_id = hash.key?('owner_id') ? hash['owner_id'] : SKIP
  owner_type = hash.key?('owner_type') ? hash['owner_type'] : SKIP
  name = hash.key?('name') ? hash['name'] : SKIP
  value = hash.key?('value') ? hash['value'] : SKIP
  metadatum_id = hash.key?('metadatum_id') ? hash['metadatum_id'] : SKIP

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

  # Create object from extracted values.
  InvoiceCustomField.new(owner_id: owner_id,
                         owner_type: owner_type,
                         name: name,
                         value: value,
                         metadatum_id: metadatum_id,
                         additional_properties: hash)
end

.namesObject

A mapping from model property names to API property names.



33
34
35
36
37
38
39
40
41
# File 'lib/advanced_billing/models/invoice_custom_field.rb', line 33

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['owner_id'] = 'owner_id'
  @_hash['owner_type'] = 'owner_type'
  @_hash['name'] = 'name'
  @_hash['value'] = 'value'
  @_hash['metadatum_id'] = 'metadatum_id'
  @_hash
end

.nullablesObject

An array for nullable fields



55
56
57
# File 'lib/advanced_billing/models/invoice_custom_field.rb', line 55

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    owner_id
    owner_type
    name
    value
    metadatum_id
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



98
99
100
101
102
103
104
# File 'lib/advanced_billing/models/invoice_custom_field.rb', line 98

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

  return false unless value.instance_of? Hash

  true
end