Class: AdvancedBilling::Metadata

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

Overview

Metadata Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(id: SKIP, value: SKIP, resource_id: SKIP, name: SKIP, deleted_at: SKIP, metafield_id: SKIP, additional_properties: {}) ⇒ Metadata

Returns a new instance of Metadata.



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/advanced_billing/models/metadata.rb', line 72

def initialize(id: SKIP, value: SKIP, resource_id: SKIP, name: SKIP,
               deleted_at: SKIP, metafield_id: SKIP,
               additional_properties: {})
  @id = id unless id == SKIP
  @value = value unless value == SKIP
  @resource_id = resource_id unless resource_id == SKIP
  @name = name unless name == SKIP
  @deleted_at = deleted_at unless deleted_at == SKIP
  @metafield_id = metafield_id unless metafield_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

#deleted_atDateTime

TODO: Write general description for this method

Returns:

  • (DateTime)


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

def deleted_at
  @deleted_at
end

#idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def id
  @id
end

#metafield_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def metafield_id
  @metafield_id
end

#nameString

TODO: Write general description for this method

Returns:

  • (String)


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

def name
  @name
end

#resource_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def resource_id
  @resource_id
end

#valueString

TODO: Write general description for this method

Returns:

  • (String)


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

def value
  @value
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/advanced_billing/models/metadata.rb', line 89

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : SKIP
  value = hash.key?('value') ? hash['value'] : SKIP
  resource_id = hash.key?('resource_id') ? hash['resource_id'] : SKIP
  name = hash.key?('name') ? hash['name'] : SKIP
  deleted_at = if hash.key?('deleted_at')
                 (DateTimeHelper.from_rfc3339(hash['deleted_at']) if hash['deleted_at'])
               else
                 SKIP
               end
  metafield_id = hash.key?('metafield_id') ? hash['metafield_id'] : SKIP

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

  # Create object from extracted values.
  Metadata.new(id: id,
               value: value,
               resource_id: resource_id,
               name: name,
               deleted_at: deleted_at,
               metafield_id: metafield_id,
               additional_properties: hash)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['value'] = 'value'
  @_hash['resource_id'] = 'resource_id'
  @_hash['name'] = 'name'
  @_hash['deleted_at'] = 'deleted_at'
  @_hash['metafield_id'] = 'metafield_id'
  @_hash
end

.nullablesObject

An array for nullable fields



62
63
64
65
66
67
68
69
70
# File 'lib/advanced_billing/models/metadata.rb', line 62

def self.nullables
  %w[
    id
    value
    resource_id
    deleted_at
    metafield_id
  ]
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    id
    value
    resource_id
    name
    deleted_at
    metafield_id
  ]
end

Instance Method Details

#to_custom_deleted_atObject



117
118
119
# File 'lib/advanced_billing/models/metadata.rb', line 117

def to_custom_deleted_at
  DateTimeHelper.to_rfc3339(deleted_at)
end