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(name = SKIP, value = SKIP, owner_id = SKIP, owner_type = SKIP) ⇒ InvoiceCustomField



53
54
55
56
57
58
59
# File 'lib/advanced_billing/models/invoice_custom_field.rb', line 53

def initialize(name = SKIP, value = SKIP, owner_id = SKIP,
               owner_type = SKIP)
  @name = name unless name == SKIP
  @value = value unless value == SKIP
  @owner_id = owner_id unless owner_id == SKIP
  @owner_type = owner_type unless owner_type == SKIP
end

Instance Attribute Details

#nameString

TODO: Write general description for this method



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

def name
  @name
end

#owner_idFloat

TODO: Write general description for this method



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

def owner_id
  @owner_id
end

#owner_typeString

TODO: Write general description for this method



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

def owner_type
  @owner_type
end

#valueString

TODO: Write general description for this method



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

def value
  @value
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/advanced_billing/models/invoice_custom_field.rb', line 62

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.

  name = hash.key?('name') ? hash['name'] : SKIP
  value = hash.key?('value') ? hash['value'] : SKIP
  owner_id = hash.key?('owner_id') ? hash['owner_id'] : SKIP
  owner_type = hash.key?('owner_type') ? hash['owner_type'] : SKIP

  # Create object from extracted values.

  InvoiceCustomField.new(name,
                         value,
                         owner_id,
                         owner_type)
end

.namesObject

A mapping from model property names to API property names.



29
30
31
32
33
34
35
36
# File 'lib/advanced_billing/models/invoice_custom_field.rb', line 29

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

.nullablesObject

An array for nullable fields



49
50
51
# File 'lib/advanced_billing/models/invoice_custom_field.rb', line 49

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

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

.validate(value) ⇒ Object

Validates an instance of the object from a given value.



80
81
82
83
84
85
86
# File 'lib/advanced_billing/models/invoice_custom_field.rb', line 80

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

  return false unless value.instance_of? Hash

  true
end