Class: AdvancedBilling::ReasonCode

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

Overview

ReasonCode 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, site_id: SKIP, code: SKIP, description: SKIP, position: SKIP, created_at: SKIP, updated_at: SKIP, additional_properties: {}) ⇒ ReasonCode

Returns a new instance of ReasonCode.



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

def initialize(id: SKIP, site_id: SKIP, code: SKIP, description: SKIP,
               position: SKIP, created_at: SKIP, updated_at: SKIP,
               additional_properties: {})
  @id = id unless id == SKIP
  @site_id = site_id unless site_id == SKIP
  @code = code unless code == SKIP
  @description = description unless description == SKIP
  @position = position unless position == SKIP
  @created_at = created_at unless created_at == SKIP
  @updated_at = updated_at unless updated_at == SKIP

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

Instance Attribute Details

#codeString

TODO: Write general description for this method

Returns:

  • (String)


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

def code
  @code
end

#created_atDateTime

TODO: Write general description for this method

Returns:

  • (DateTime)


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

def created_at
  @created_at
end

#descriptionString

TODO: Write general description for this method

Returns:

  • (String)


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

def description
  @description
end

#idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def id
  @id
end

#positionInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def position
  @position
end

#site_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def site_id
  @site_id
end

#updated_atDateTime

TODO: Write general description for this method

Returns:

  • (DateTime)


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

def updated_at
  @updated_at
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
116
117
118
119
120
121
122
# File 'lib/advanced_billing/models/reason_code.rb', line 90

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : SKIP
  site_id = hash.key?('site_id') ? hash['site_id'] : SKIP
  code = hash.key?('code') ? hash['code'] : SKIP
  description = hash.key?('description') ? hash['description'] : SKIP
  position = hash.key?('position') ? hash['position'] : SKIP
  created_at = if hash.key?('created_at')
                 (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at'])
               else
                 SKIP
               end
  updated_at = if hash.key?('updated_at')
                 (DateTimeHelper.from_rfc3339(hash['updated_at']) if hash['updated_at'])
               else
                 SKIP
               end

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

  # Create object from extracted values.
  ReasonCode.new(id: id,
                 site_id: site_id,
                 code: code,
                 description: description,
                 position: position,
                 created_at: created_at,
                 updated_at: updated_at,
                 additional_properties: hash)
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/reason_code.rb', line 42

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['site_id'] = 'site_id'
  @_hash['code'] = 'code'
  @_hash['description'] = 'description'
  @_hash['position'] = 'position'
  @_hash['created_at'] = 'created_at'
  @_hash['updated_at'] = 'updated_at'
  @_hash
end

.nullablesObject

An array for nullable fields



68
69
70
# File 'lib/advanced_billing/models/reason_code.rb', line 68

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    id
    site_id
    code
    description
    position
    created_at
    updated_at
  ]
end

Instance Method Details

#to_custom_created_atObject



124
125
126
# File 'lib/advanced_billing/models/reason_code.rb', line 124

def to_custom_created_at
  DateTimeHelper.to_rfc3339(created_at)
end

#to_custom_updated_atObject



128
129
130
# File 'lib/advanced_billing/models/reason_code.rb', line 128

def to_custom_updated_at
  DateTimeHelper.to_rfc3339(updated_at)
end