Class: ApiReference::ChangedSubscriptionResources

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

Overview

ChangedSubscriptionResources 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(created_credit_notes:, voided_credit_notes:, created_invoices:, voided_invoices:, additional_properties: nil) ⇒ ChangedSubscriptionResources

Returns a new instance of ChangedSubscriptionResources.



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/api_reference/models/changed_subscription_resources.rb', line 48

def initialize(created_credit_notes:, voided_credit_notes:,
               created_invoices:, voided_invoices:,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @created_credit_notes = created_credit_notes
  @voided_credit_notes = voided_credit_notes
  @created_invoices = created_invoices
  @voided_invoices = voided_invoices
  @additional_properties = additional_properties
end

Instance Attribute Details

#created_credit_notesArray[CreditNote]

The credit notes that were created as part of this operation.

Returns:



14
15
16
# File 'lib/api_reference/models/changed_subscription_resources.rb', line 14

def created_credit_notes
  @created_credit_notes
end

#created_invoicesArray[CreatedInvoice]

The invoices that were created as part of this operation.

Returns:



22
23
24
# File 'lib/api_reference/models/changed_subscription_resources.rb', line 22

def created_invoices
  @created_invoices
end

#voided_credit_notesArray[CreditNote]

The credit notes that were voided as part of this operation.

Returns:



18
19
20
# File 'lib/api_reference/models/changed_subscription_resources.rb', line 18

def voided_credit_notes
  @voided_credit_notes
end

#voided_invoicesArray[Invoice]

The invoices that were voided as part of this operation.

Returns:



26
27
28
# File 'lib/api_reference/models/changed_subscription_resources.rb', line 26

def voided_invoices
  @voided_invoices
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
77
78
79
80
81
82
83
84
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
117
118
119
120
# File 'lib/api_reference/models/changed_subscription_resources.rb', line 62

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  # Parameter is an array, so we need to iterate through it
  created_credit_notes = nil
  unless hash['created_credit_notes'].nil?
    created_credit_notes = []
    hash['created_credit_notes'].each do |structure|
      created_credit_notes << (CreditNote.from_hash(structure) if structure)
    end
  end

  created_credit_notes = nil unless hash.key?('created_credit_notes')
  # Parameter is an array, so we need to iterate through it
  voided_credit_notes = nil
  unless hash['voided_credit_notes'].nil?
    voided_credit_notes = []
    hash['voided_credit_notes'].each do |structure|
      voided_credit_notes << (CreditNote.from_hash(structure) if structure)
    end
  end

  voided_credit_notes = nil unless hash.key?('voided_credit_notes')
  # Parameter is an array, so we need to iterate through it
  created_invoices = nil
  unless hash['created_invoices'].nil?
    created_invoices = []
    hash['created_invoices'].each do |structure|
      created_invoices << (CreatedInvoice.from_hash(structure) if structure)
    end
  end

  created_invoices = nil unless hash.key?('created_invoices')
  # Parameter is an array, so we need to iterate through it
  voided_invoices = nil
  unless hash['voided_invoices'].nil?
    voided_invoices = []
    hash['voided_invoices'].each do |structure|
      voided_invoices << (Invoice.from_hash(structure) if structure)
    end
  end

  voided_invoices = nil unless hash.key?('voided_invoices')

  # 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.
  ChangedSubscriptionResources.new(created_credit_notes: created_credit_notes,
                                   voided_credit_notes: voided_credit_notes,
                                   created_invoices: created_invoices,
                                   voided_invoices: voided_invoices,
                                   additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['created_credit_notes'] = 'created_credit_notes'
  @_hash['voided_credit_notes'] = 'voided_credit_notes'
  @_hash['created_invoices'] = 'created_invoices'
  @_hash['voided_invoices'] = 'voided_invoices'
  @_hash
end

.nullablesObject

An array for nullable fields



44
45
46
# File 'lib/api_reference/models/changed_subscription_resources.rb', line 44

def self.nullables
  []
end

.optionalsObject

An array for optional fields



39
40
41
# File 'lib/api_reference/models/changed_subscription_resources.rb', line 39

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
163
164
165
166
# File 'lib/api_reference/models/changed_subscription_resources.rb', line 124

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.created_credit_notes,
                            ->(val) { CreditNote.validate(val) },
                            is_model_hash: true,
                            is_inner_model_hash: true) and
        APIHelper.valid_type?(value.voided_credit_notes,
                              ->(val) { CreditNote.validate(val) },
                              is_model_hash: true,
                              is_inner_model_hash: true) and
        APIHelper.valid_type?(value.created_invoices,
                              ->(val) { CreatedInvoice.validate(val) },
                              is_model_hash: true,
                              is_inner_model_hash: true) and
        APIHelper.valid_type?(value.voided_invoices,
                              ->(val) { Invoice.validate(val) },
                              is_model_hash: true,
                              is_inner_model_hash: true)
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['created_credit_notes'],
                          ->(val) { CreditNote.validate(val) },
                          is_model_hash: true,
                          is_inner_model_hash: true) and
      APIHelper.valid_type?(value['voided_credit_notes'],
                            ->(val) { CreditNote.validate(val) },
                            is_model_hash: true,
                            is_inner_model_hash: true) and
      APIHelper.valid_type?(value['created_invoices'],
                            ->(val) { CreatedInvoice.validate(val) },
                            is_model_hash: true,
                            is_inner_model_hash: true) and
      APIHelper.valid_type?(value['voided_invoices'],
                            ->(val) { Invoice.validate(val) },
                            is_model_hash: true,
                            is_inner_model_hash: true)
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



177
178
179
180
181
182
183
# File 'lib/api_reference/models/changed_subscription_resources.rb', line 177

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} created_credit_notes: #{@created_credit_notes.inspect},"\
  " voided_credit_notes: #{@voided_credit_notes.inspect}, created_invoices:"\
  " #{@created_invoices.inspect}, voided_invoices: #{@voided_invoices.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



169
170
171
172
173
174
# File 'lib/api_reference/models/changed_subscription_resources.rb', line 169

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} created_credit_notes: #{@created_credit_notes}, voided_credit_notes:"\
  " #{@voided_credit_notes}, created_invoices: #{@created_invoices}, voided_invoices:"\
  " #{@voided_invoices}, additional_properties: #{@additional_properties}>"
end