Class: ApiReference::CreditNoteSummary

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/api_reference/models/credit_note_summary.rb

Overview

CreditNoteSummary Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(id:, credit_note_number:, reason:, total:, voided_at:, type:, memo:, additional_properties: nil) ⇒ CreditNoteSummary

Returns a new instance of CreditNoteSummary.



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

def initialize(id:, credit_note_number:, reason:, total:, voided_at:, type:,
               memo:, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @id = id
  @credit_note_number = credit_note_number
  @reason = reason
  @total = total
  @voided_at = voided_at
  @type = type
  @memo = memo
  @additional_properties = additional_properties
end

Instance Attribute Details

#credit_note_numberString

TODO: Write general description for this method

Returns:

  • (String)


19
20
21
# File 'lib/api_reference/models/credit_note_summary.rb', line 19

def credit_note_number
  @credit_note_number
end

#idString

TODO: Write general description for this method

Returns:

  • (String)


15
16
17
# File 'lib/api_reference/models/credit_note_summary.rb', line 15

def id
  @id
end

#memoString

An optional memo supplied on the credit note.

Returns:

  • (String)


41
42
43
# File 'lib/api_reference/models/credit_note_summary.rb', line 41

def memo
  @memo
end

#reasonString

TODO: Write general description for this method

Returns:

  • (String)


23
24
25
# File 'lib/api_reference/models/credit_note_summary.rb', line 23

def reason
  @reason
end

#totalString

TODO: Write general description for this method

Returns:

  • (String)


27
28
29
# File 'lib/api_reference/models/credit_note_summary.rb', line 27

def total
  @total
end

#typeString

If the credit note has a status of void, this gives a timestamp when the credit note was voided.

Returns:

  • (String)


37
38
39
# File 'lib/api_reference/models/credit_note_summary.rb', line 37

def type
  @type
end

#voided_atDateTime

If the credit note has a status of void, this gives a timestamp when the credit note was voided.

Returns:

  • (DateTime)


32
33
34
# File 'lib/api_reference/models/credit_note_summary.rb', line 32

def voided_at
  @voided_at
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
108
109
110
111
112
113
114
115
116
# File 'lib/api_reference/models/credit_note_summary.rb', line 85

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : nil
  credit_note_number =
    hash.key?('credit_note_number') ? hash['credit_note_number'] : nil
  reason = hash.key?('reason') ? hash['reason'] : nil
  total = hash.key?('total') ? hash['total'] : nil
  voided_at = if hash.key?('voided_at')
                (DateTimeHelper.from_rfc3339(hash['voided_at']) if hash['voided_at'])
              end
  type = hash.key?('type') ? hash['type'] : nil
  memo = hash.key?('memo') ? hash['memo'] : nil

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  CreditNoteSummary.new(id: id,
                        credit_note_number: credit_note_number,
                        reason: reason,
                        total: total,
                        voided_at: voided_at,
                        type: type,
                        memo: memo,
                        additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/api_reference/models/credit_note_summary.rb', line 44

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['credit_note_number'] = 'credit_note_number'
  @_hash['reason'] = 'reason'
  @_hash['total'] = 'total'
  @_hash['voided_at'] = 'voided_at'
  @_hash['type'] = 'type'
  @_hash['memo'] = 'memo'
  @_hash
end

.nullablesObject

An array for nullable fields



62
63
64
65
66
67
# File 'lib/api_reference/models/credit_note_summary.rb', line 62

def self.nullables
  %w[
    voided_at
    memo
  ]
end

.optionalsObject

An array for optional fields



57
58
59
# File 'lib/api_reference/models/credit_note_summary.rb', line 57

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/api_reference/models/credit_note_summary.rb', line 124

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.id,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.credit_note_number,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.reason,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.total,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.voided_at,
                              ->(val) { val.instance_of? DateTime }) and
        APIHelper.valid_type?(value.type,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.memo,
                              ->(val) { val.instance_of? String })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['id'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['credit_note_number'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['reason'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['total'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['voided_at'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['type'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['memo'],
                            ->(val) { val.instance_of? String })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



173
174
175
176
177
178
179
# File 'lib/api_reference/models/credit_note_summary.rb', line 173

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id.inspect}, credit_note_number: #{@credit_note_number.inspect},"\
  " reason: #{@reason.inspect}, total: #{@total.inspect}, voided_at: #{@voided_at.inspect},"\
  " type: #{@type.inspect}, memo: #{@memo.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_custom_voided_atObject



118
119
120
# File 'lib/api_reference/models/credit_note_summary.rb', line 118

def to_custom_voided_at
  DateTimeHelper.to_rfc3339(voided_at)
end

#to_sObject

Provides a human-readable string representation of the object.



165
166
167
168
169
170
# File 'lib/api_reference/models/credit_note_summary.rb', line 165

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, credit_note_number: #{@credit_note_number}, reason: #{@reason},"\
  " total: #{@total}, voided_at: #{@voided_at}, type: #{@type}, memo: #{@memo},"\
  " additional_properties: #{@additional_properties}>"
end