factpulse 2.0.5 → 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +3 -3
  3. data/Gemfile.lock +1 -1
  4. data/docs/Destinataire.md +4 -0
  5. data/docs/FactureFacturX.md +2 -0
  6. data/docs/Fournisseur.md +2 -0
  7. data/docs/LigneDePoste.md +6 -6
  8. data/docs/LigneDeTVA.md +6 -6
  9. data/docs/MontantTotal.md +12 -12
  10. data/docs/Note.md +20 -0
  11. data/docs/{Tauxmanuel.md → StatutCelery.md} +2 -2
  12. data/docs/StatutTache.md +1 -1
  13. data/docs/TraitementFactureApi.md +1 -1
  14. data/lib/factpulse/api/traitement_facture_api.rb +2 -2
  15. data/lib/factpulse/models/destinataire.rb +21 -1
  16. data/lib/factpulse/models/facture_factur_x.rb +12 -1
  17. data/lib/factpulse/models/fournisseur.rb +11 -1
  18. data/lib/factpulse/models/ligne_de_poste.rb +61 -4
  19. data/lib/factpulse/models/ligne_de_tva.rb +49 -3
  20. data/lib/factpulse/models/montant_ht_total.rb +0 -1
  21. data/lib/factpulse/models/montant_total.rb +94 -7
  22. data/lib/factpulse/models/montant_ttc_total.rb +0 -1
  23. data/lib/factpulse/models/montant_tva.rb +0 -1
  24. data/lib/factpulse/models/montant_tva1.rb +1 -1
  25. data/lib/factpulse/models/{ligne_de_poste_montant_remise_ht.rb → note.rb} +145 -74
  26. data/lib/factpulse/models/{montant_a_payer.rb → statut_celery.rb} +22 -83
  27. data/lib/factpulse/models/statut_tache.rb +25 -2
  28. data/lib/factpulse/version.rb +1 -1
  29. data/lib/factpulse.rb +2 -8
  30. metadata +5 -17
  31. data/docs/LigneDePosteMontantRemiseHt.md +0 -15
  32. data/docs/LigneDePosteTauxTvaManuel.md +0 -15
  33. data/docs/MontantAPayer.md +0 -15
  34. data/docs/MontantBaseHt.md +0 -15
  35. data/docs/MontantRemiseGlobaleTtc.md +0 -15
  36. data/docs/MontantTotalAcompte.md +0 -15
  37. data/docs/MontantTotalLigneHt.md +0 -15
  38. data/lib/factpulse/models/ligne_de_poste_taux_tva_manuel.rb +0 -104
  39. data/lib/factpulse/models/montant_base_ht.rb +0 -104
  40. data/lib/factpulse/models/montant_remise_globale_ttc.rb +0 -104
  41. data/lib/factpulse/models/montant_total_acompte.rb +0 -104
  42. data/lib/factpulse/models/montant_total_ligne_ht.rb +0 -104
  43. data/lib/factpulse/models/tauxmanuel.rb +0 -104
@@ -16,12 +16,15 @@ require 'time'
16
16
  module FactPulse
17
17
  # Représente une ligne de totalisation par taux de TVA.
18
18
  class LigneDeTVA < ApiModelBase
19
+ # Montant de la base HT pour cette ligne de TVA.
19
20
  attr_accessor :montant_base_ht
20
21
 
22
+ # Montant de la TVA pour cette ligne.
21
23
  attr_accessor :montant_tva
22
24
 
23
25
  attr_accessor :taux
24
26
 
27
+ # Taux de TVA avec valeur manuelle.
25
28
  attr_accessor :taux_manuel
26
29
 
27
30
  attr_accessor :categorie
@@ -72,10 +75,10 @@ module FactPulse
72
75
  # Attribute type mapping.
73
76
  def self.openapi_types
74
77
  {
75
- :'montant_base_ht' => :'MontantBaseHt',
76
- :'montant_tva' => :'MontantTva',
78
+ :'montant_base_ht' => :'Float',
79
+ :'montant_tva' => :'Float',
77
80
  :'taux' => :'String',
78
- :'taux_manuel' => :'Tauxmanuel',
81
+ :'taux_manuel' => :'Float',
79
82
  :'categorie' => :'CategorieTVA'
80
83
  }
81
84
  end
@@ -138,10 +141,25 @@ module FactPulse
138
141
  invalid_properties.push('invalid value for "montant_base_ht", montant_base_ht cannot be nil.')
139
142
  end
140
143
 
144
+ pattern = Regexp.new(/^(?!^[-+.]*$)[+-]?0*(?:\d{0,8}|(?=[\d.]{1,13}0*$)\d{0,8}\.\d{0,4}0*$)/)
145
+ if @montant_base_ht !~ pattern
146
+ invalid_properties.push("invalid value for \"montant_base_ht\", must conform to the pattern #{pattern}.")
147
+ end
148
+
141
149
  if @montant_tva.nil?
142
150
  invalid_properties.push('invalid value for "montant_tva", montant_tva cannot be nil.')
143
151
  end
144
152
 
153
+ pattern = Regexp.new(/^(?!^[-+.]*$)[+-]?0*(?:\d{0,8}|(?=[\d.]{1,13}0*$)\d{0,8}\.\d{0,4}0*$)/)
154
+ if @montant_tva !~ pattern
155
+ invalid_properties.push("invalid value for \"montant_tva\", must conform to the pattern #{pattern}.")
156
+ end
157
+
158
+ pattern = Regexp.new(/^(?!^[-+.]*$)[+-]?0*(?:\d{0,8}|(?=[\d.]{1,13}0*$)\d{0,8}\.\d{0,4}0*$)/)
159
+ if !@taux_manuel.nil? && @taux_manuel !~ pattern
160
+ invalid_properties.push("invalid value for \"taux_manuel\", must conform to the pattern #{pattern}.")
161
+ end
162
+
145
163
  invalid_properties
146
164
  end
147
165
 
@@ -150,7 +168,10 @@ module FactPulse
150
168
  def valid?
151
169
  warn '[DEPRECATED] the `valid?` method is obsolete'
152
170
  return false if @montant_base_ht.nil?
171
+ return false if @montant_base_ht !~ Regexp.new(/^(?!^[-+.]*$)[+-]?0*(?:\d{0,8}|(?=[\d.]{1,13}0*$)\d{0,8}\.\d{0,4}0*$)/)
153
172
  return false if @montant_tva.nil?
173
+ return false if @montant_tva !~ Regexp.new(/^(?!^[-+.]*$)[+-]?0*(?:\d{0,8}|(?=[\d.]{1,13}0*$)\d{0,8}\.\d{0,4}0*$)/)
174
+ return false if !@taux_manuel.nil? && @taux_manuel !~ Regexp.new(/^(?!^[-+.]*$)[+-]?0*(?:\d{0,8}|(?=[\d.]{1,13}0*$)\d{0,8}\.\d{0,4}0*$)/)
154
175
  true
155
176
  end
156
177
 
@@ -161,6 +182,11 @@ module FactPulse
161
182
  fail ArgumentError, 'montant_base_ht cannot be nil'
162
183
  end
163
184
 
185
+ pattern = Regexp.new(/^(?!^[-+.]*$)[+-]?0*(?:\d{0,8}|(?=[\d.]{1,13}0*$)\d{0,8}\.\d{0,4}0*$)/)
186
+ if montant_base_ht !~ pattern
187
+ fail ArgumentError, "invalid value for \"montant_base_ht\", must conform to the pattern #{pattern}."
188
+ end
189
+
164
190
  @montant_base_ht = montant_base_ht
165
191
  end
166
192
 
@@ -171,9 +197,29 @@ module FactPulse
171
197
  fail ArgumentError, 'montant_tva cannot be nil'
172
198
  end
173
199
 
200
+ pattern = Regexp.new(/^(?!^[-+.]*$)[+-]?0*(?:\d{0,8}|(?=[\d.]{1,13}0*$)\d{0,8}\.\d{0,4}0*$)/)
201
+ if montant_tva !~ pattern
202
+ fail ArgumentError, "invalid value for \"montant_tva\", must conform to the pattern #{pattern}."
203
+ end
204
+
174
205
  @montant_tva = montant_tva
175
206
  end
176
207
 
208
+ # Custom attribute writer method with validation
209
+ # @param [Object] taux_manuel Value to be assigned
210
+ def taux_manuel=(taux_manuel)
211
+ if taux_manuel.nil?
212
+ fail ArgumentError, 'taux_manuel cannot be nil'
213
+ end
214
+
215
+ pattern = Regexp.new(/^(?!^[-+.]*$)[+-]?0*(?:\d{0,8}|(?=[\d.]{1,13}0*$)\d{0,8}\.\d{0,4}0*$)/)
216
+ if taux_manuel !~ pattern
217
+ fail ArgumentError, "invalid value for \"taux_manuel\", must conform to the pattern #{pattern}."
218
+ end
219
+
220
+ @taux_manuel = taux_manuel
221
+ end
222
+
177
223
  # Checks equality by comparing each attribute.
178
224
  # @param [Object] Object to be compared
179
225
  def ==(o)
@@ -14,7 +14,6 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module FactPulse
17
- # Montant total HT.
18
17
  module MontantHtTotal
19
18
  class << self
20
19
  # List of class defined in anyOf (OpenAPI v3)
@@ -16,16 +16,22 @@ require 'time'
16
16
  module FactPulse
17
17
  # Contient tous les montants totaux de la facture.
18
18
  class MontantTotal < ApiModelBase
19
+ # Montant total HT.
19
20
  attr_accessor :montant_ht_total
20
21
 
22
+ # Montant total de la TVA.
21
23
  attr_accessor :montant_tva
22
24
 
25
+ # Montant total TTC.
23
26
  attr_accessor :montant_ttc_total
24
27
 
28
+ # Montant à payer.
25
29
  attr_accessor :montant_a_payer
26
30
 
31
+ # Acompte versé.
27
32
  attr_accessor :acompte
28
33
 
34
+ # Montant de la remise globale TTC.
29
35
  attr_accessor :montant_remise_globale_ttc
30
36
 
31
37
  attr_accessor :motif_remise_globale_ttc
@@ -56,12 +62,12 @@ module FactPulse
56
62
  # Attribute type mapping.
57
63
  def self.openapi_types
58
64
  {
59
- :'montant_ht_total' => :'MontantHtTotal',
60
- :'montant_tva' => :'MontantTva1',
61
- :'montant_ttc_total' => :'MontantTtcTotal',
62
- :'montant_a_payer' => :'MontantAPayer',
63
- :'acompte' => :'MontantTotalAcompte',
64
- :'montant_remise_globale_ttc' => :'MontantRemiseGlobaleTtc',
65
+ :'montant_ht_total' => :'Float',
66
+ :'montant_tva' => :'Float',
67
+ :'montant_ttc_total' => :'Float',
68
+ :'montant_a_payer' => :'Float',
69
+ :'acompte' => :'Float',
70
+ :'montant_remise_globale_ttc' => :'Float',
65
71
  :'motif_remise_globale_ttc' => :'String'
66
72
  }
67
73
  end
@@ -70,7 +76,6 @@ module FactPulse
70
76
  def self.openapi_nullable
71
77
  Set.new([
72
78
  :'acompte',
73
- :'montant_remise_globale_ttc',
74
79
  :'motif_remise_globale_ttc'
75
80
  ])
76
81
  end
@@ -137,18 +142,48 @@ module FactPulse
137
142
  invalid_properties.push('invalid value for "montant_ht_total", montant_ht_total cannot be nil.')
138
143
  end
139
144
 
145
+ pattern = Regexp.new(/^(?!^[-+.]*$)[+-]?0*(?:\d{0,8}|(?=[\d.]{1,13}0*$)\d{0,8}\.\d{0,4}0*$)/)
146
+ if @montant_ht_total !~ pattern
147
+ invalid_properties.push("invalid value for \"montant_ht_total\", must conform to the pattern #{pattern}.")
148
+ end
149
+
140
150
  if @montant_tva.nil?
141
151
  invalid_properties.push('invalid value for "montant_tva", montant_tva cannot be nil.')
142
152
  end
143
153
 
154
+ pattern = Regexp.new(/^(?!^[-+.]*$)[+-]?0*(?:\d{0,8}|(?=[\d.]{1,13}0*$)\d{0,8}\.\d{0,4}0*$)/)
155
+ if @montant_tva !~ pattern
156
+ invalid_properties.push("invalid value for \"montant_tva\", must conform to the pattern #{pattern}.")
157
+ end
158
+
144
159
  if @montant_ttc_total.nil?
145
160
  invalid_properties.push('invalid value for "montant_ttc_total", montant_ttc_total cannot be nil.')
146
161
  end
147
162
 
163
+ pattern = Regexp.new(/^(?!^[-+.]*$)[+-]?0*(?:\d{0,8}|(?=[\d.]{1,13}0*$)\d{0,8}\.\d{0,4}0*$)/)
164
+ if @montant_ttc_total !~ pattern
165
+ invalid_properties.push("invalid value for \"montant_ttc_total\", must conform to the pattern #{pattern}.")
166
+ end
167
+
148
168
  if @montant_a_payer.nil?
149
169
  invalid_properties.push('invalid value for "montant_a_payer", montant_a_payer cannot be nil.')
150
170
  end
151
171
 
172
+ pattern = Regexp.new(/^(?!^[-+.]*$)[+-]?0*(?:\d{0,8}|(?=[\d.]{1,13}0*$)\d{0,8}\.\d{0,4}0*$)/)
173
+ if @montant_a_payer !~ pattern
174
+ invalid_properties.push("invalid value for \"montant_a_payer\", must conform to the pattern #{pattern}.")
175
+ end
176
+
177
+ pattern = Regexp.new(/^(?!^[-+.]*$)[+-]?0*(?:\d{0,8}|(?=[\d.]{1,13}0*$)\d{0,8}\.\d{0,4}0*$)/)
178
+ if !@acompte.nil? && @acompte !~ pattern
179
+ invalid_properties.push("invalid value for \"acompte\", must conform to the pattern #{pattern}.")
180
+ end
181
+
182
+ pattern = Regexp.new(/^(?!^[-+.]*$)[+-]?0*(?:\d{0,8}|(?=[\d.]{1,13}0*$)\d{0,8}\.\d{0,4}0*$)/)
183
+ if !@montant_remise_globale_ttc.nil? && @montant_remise_globale_ttc !~ pattern
184
+ invalid_properties.push("invalid value for \"montant_remise_globale_ttc\", must conform to the pattern #{pattern}.")
185
+ end
186
+
152
187
  invalid_properties
153
188
  end
154
189
 
@@ -157,9 +192,15 @@ module FactPulse
157
192
  def valid?
158
193
  warn '[DEPRECATED] the `valid?` method is obsolete'
159
194
  return false if @montant_ht_total.nil?
195
+ return false if @montant_ht_total !~ Regexp.new(/^(?!^[-+.]*$)[+-]?0*(?:\d{0,8}|(?=[\d.]{1,13}0*$)\d{0,8}\.\d{0,4}0*$)/)
160
196
  return false if @montant_tva.nil?
197
+ return false if @montant_tva !~ Regexp.new(/^(?!^[-+.]*$)[+-]?0*(?:\d{0,8}|(?=[\d.]{1,13}0*$)\d{0,8}\.\d{0,4}0*$)/)
161
198
  return false if @montant_ttc_total.nil?
199
+ return false if @montant_ttc_total !~ Regexp.new(/^(?!^[-+.]*$)[+-]?0*(?:\d{0,8}|(?=[\d.]{1,13}0*$)\d{0,8}\.\d{0,4}0*$)/)
162
200
  return false if @montant_a_payer.nil?
201
+ return false if @montant_a_payer !~ Regexp.new(/^(?!^[-+.]*$)[+-]?0*(?:\d{0,8}|(?=[\d.]{1,13}0*$)\d{0,8}\.\d{0,4}0*$)/)
202
+ return false if !@acompte.nil? && @acompte !~ Regexp.new(/^(?!^[-+.]*$)[+-]?0*(?:\d{0,8}|(?=[\d.]{1,13}0*$)\d{0,8}\.\d{0,4}0*$)/)
203
+ return false if !@montant_remise_globale_ttc.nil? && @montant_remise_globale_ttc !~ Regexp.new(/^(?!^[-+.]*$)[+-]?0*(?:\d{0,8}|(?=[\d.]{1,13}0*$)\d{0,8}\.\d{0,4}0*$)/)
163
204
  true
164
205
  end
165
206
 
@@ -170,6 +211,11 @@ module FactPulse
170
211
  fail ArgumentError, 'montant_ht_total cannot be nil'
171
212
  end
172
213
 
214
+ pattern = Regexp.new(/^(?!^[-+.]*$)[+-]?0*(?:\d{0,8}|(?=[\d.]{1,13}0*$)\d{0,8}\.\d{0,4}0*$)/)
215
+ if montant_ht_total !~ pattern
216
+ fail ArgumentError, "invalid value for \"montant_ht_total\", must conform to the pattern #{pattern}."
217
+ end
218
+
173
219
  @montant_ht_total = montant_ht_total
174
220
  end
175
221
 
@@ -180,6 +226,11 @@ module FactPulse
180
226
  fail ArgumentError, 'montant_tva cannot be nil'
181
227
  end
182
228
 
229
+ pattern = Regexp.new(/^(?!^[-+.]*$)[+-]?0*(?:\d{0,8}|(?=[\d.]{1,13}0*$)\d{0,8}\.\d{0,4}0*$)/)
230
+ if montant_tva !~ pattern
231
+ fail ArgumentError, "invalid value for \"montant_tva\", must conform to the pattern #{pattern}."
232
+ end
233
+
183
234
  @montant_tva = montant_tva
184
235
  end
185
236
 
@@ -190,6 +241,11 @@ module FactPulse
190
241
  fail ArgumentError, 'montant_ttc_total cannot be nil'
191
242
  end
192
243
 
244
+ pattern = Regexp.new(/^(?!^[-+.]*$)[+-]?0*(?:\d{0,8}|(?=[\d.]{1,13}0*$)\d{0,8}\.\d{0,4}0*$)/)
245
+ if montant_ttc_total !~ pattern
246
+ fail ArgumentError, "invalid value for \"montant_ttc_total\", must conform to the pattern #{pattern}."
247
+ end
248
+
193
249
  @montant_ttc_total = montant_ttc_total
194
250
  end
195
251
 
@@ -200,9 +256,40 @@ module FactPulse
200
256
  fail ArgumentError, 'montant_a_payer cannot be nil'
201
257
  end
202
258
 
259
+ pattern = Regexp.new(/^(?!^[-+.]*$)[+-]?0*(?:\d{0,8}|(?=[\d.]{1,13}0*$)\d{0,8}\.\d{0,4}0*$)/)
260
+ if montant_a_payer !~ pattern
261
+ fail ArgumentError, "invalid value for \"montant_a_payer\", must conform to the pattern #{pattern}."
262
+ end
263
+
203
264
  @montant_a_payer = montant_a_payer
204
265
  end
205
266
 
267
+ # Custom attribute writer method with validation
268
+ # @param [Object] acompte Value to be assigned
269
+ def acompte=(acompte)
270
+ pattern = Regexp.new(/^(?!^[-+.]*$)[+-]?0*(?:\d{0,8}|(?=[\d.]{1,13}0*$)\d{0,8}\.\d{0,4}0*$)/)
271
+ if !acompte.nil? && acompte !~ pattern
272
+ fail ArgumentError, "invalid value for \"acompte\", must conform to the pattern #{pattern}."
273
+ end
274
+
275
+ @acompte = acompte
276
+ end
277
+
278
+ # Custom attribute writer method with validation
279
+ # @param [Object] montant_remise_globale_ttc Value to be assigned
280
+ def montant_remise_globale_ttc=(montant_remise_globale_ttc)
281
+ if montant_remise_globale_ttc.nil?
282
+ fail ArgumentError, 'montant_remise_globale_ttc cannot be nil'
283
+ end
284
+
285
+ pattern = Regexp.new(/^(?!^[-+.]*$)[+-]?0*(?:\d{0,8}|(?=[\d.]{1,13}0*$)\d{0,8}\.\d{0,4}0*$)/)
286
+ if montant_remise_globale_ttc !~ pattern
287
+ fail ArgumentError, "invalid value for \"montant_remise_globale_ttc\", must conform to the pattern #{pattern}."
288
+ end
289
+
290
+ @montant_remise_globale_ttc = montant_remise_globale_ttc
291
+ end
292
+
206
293
  # Checks equality by comparing each attribute.
207
294
  # @param [Object] Object to be compared
208
295
  def ==(o)
@@ -14,7 +14,6 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module FactPulse
17
- # Montant total TTC.
18
17
  module MontantTtcTotal
19
18
  class << self
20
19
  # List of class defined in anyOf (OpenAPI v3)
@@ -14,7 +14,6 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module FactPulse
17
- # Montant de la TVA pour cette ligne.
18
17
  module MontantTva
19
18
  class << self
20
19
  # List of class defined in anyOf (OpenAPI v3)
@@ -14,7 +14,7 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module FactPulse
17
- # Montant total de la TVA.
17
+ # Montant TVA
18
18
  module MontantTva1
19
19
  class << self
20
20
  # List of class defined in anyOf (OpenAPI v3)
@@ -14,91 +14,162 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module FactPulse
17
- # Montant de la remise HT.
18
- module LigneDePosteMontantRemiseHt
19
- class << self
20
- # List of class defined in anyOf (OpenAPI v3)
21
- def openapi_any_of
22
- [
23
- :'Float',
24
- :'String'
25
- ]
17
+ # Note de facture (IncludedNote en Factur-X). Les notes obligatoires pour BR-FR-05 sont : - PMT : Indemnité forfaitaire pour frais de recouvrement - PMD : Pénalités de retard - AAB : Escompte pour paiement anticipé
18
+ class Note < ApiModelBase
19
+ attr_accessor :subject_code
20
+
21
+ attr_accessor :content
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'subject_code' => :'subjectCode',
27
+ :'content' => :'content'
28
+ }
29
+ end
30
+
31
+ # Returns attribute mapping this model knows about
32
+ def self.acceptable_attribute_map
33
+ attribute_map
34
+ end
35
+
36
+ # Returns all the JSON keys this model knows about
37
+ def self.acceptable_attributes
38
+ acceptable_attribute_map.values
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'subject_code' => :'String',
45
+ :'content' => :'String'
46
+ }
47
+ end
48
+
49
+ # List of attributes with nullable: true
50
+ def self.openapi_nullable
51
+ Set.new([
52
+ :'subject_code',
53
+ ])
54
+ end
55
+
56
+ # Initializes the object
57
+ # @param [Hash] attributes Model attributes in the form of hash
58
+ def initialize(attributes = {})
59
+ if (!attributes.is_a?(Hash))
60
+ fail ArgumentError, "The input argument (attributes) must be a hash in `FactPulse::Note` initialize method"
26
61
  end
27
62
 
28
- # Builds the object
29
- # @param [Mixed] Data to be matched against the list of anyOf items
30
- # @return [Object] Returns the model or the data itself
31
- def build(data)
32
- # Go through the list of anyOf items and attempt to identify the appropriate one.
33
- # Note:
34
- # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
35
- # due to the way the deserialization is made in the base_object template (it just casts without verifying).
36
- # - TODO: scalar values are de facto behaving as if they were nullable.
37
- # - TODO: logging when debugging is set.
38
- openapi_any_of.each do |klass|
39
- begin
40
- next if klass == :AnyType # "nullable: true"
41
- return find_and_cast_into_type(klass, data)
42
- rescue # rescue all errors so we keep iterating even if the current item lookup raises
43
- end
63
+ # check to see if the attribute exists and convert string to symbol for hash key
64
+ acceptable_attribute_map = self.class.acceptable_attribute_map
65
+ attributes = attributes.each_with_object({}) { |(k, v), h|
66
+ if (!acceptable_attribute_map.key?(k.to_sym))
67
+ fail ArgumentError, "`#{k}` is not a valid attribute in `FactPulse::Note`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
44
68
  end
69
+ h[k.to_sym] = v
70
+ }
45
71
 
46
- openapi_any_of.include?(:AnyType) ? data : nil
72
+ if attributes.key?(:'subject_code')
73
+ self.subject_code = attributes[:'subject_code']
47
74
  end
48
75
 
49
- private
50
-
51
- SchemaMismatchError = Class.new(StandardError)
52
-
53
- # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
54
- def find_and_cast_into_type(klass, data)
55
- return if data.nil?
56
-
57
- case klass.to_s
58
- when 'Boolean'
59
- return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
60
- when 'Float'
61
- return data if data.instance_of?(Float)
62
- when 'Integer'
63
- return data if data.instance_of?(Integer)
64
- when 'Time'
65
- return Time.parse(data)
66
- when 'Date'
67
- return Date.iso8601(data)
68
- when 'String'
69
- return data if data.instance_of?(String)
70
- when 'Object' # "type: object"
71
- return data if data.instance_of?(Hash)
72
- when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
73
- if data.instance_of?(Array)
74
- sub_type = Regexp.last_match[:sub_type]
75
- return data.map { |item| find_and_cast_into_type(sub_type, item) }
76
- end
77
- when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
78
- if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
79
- sub_type = Regexp.last_match[:sub_type]
80
- return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
81
- end
82
- else # model
83
- const = FactPulse.const_get(klass)
84
- if const
85
- if const.respond_to?(:openapi_any_of) # nested anyOf model
86
- model = const.build(data)
87
- return model if model
88
- else
89
- # raise if data contains keys that are not known to the model
90
- raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
91
- model = const.build_from_hash(data)
92
- return model if model
93
- end
76
+ if attributes.key?(:'content')
77
+ self.content = attributes[:'content']
78
+ else
79
+ self.content = nil
80
+ end
81
+ end
82
+
83
+ # Show invalid properties with the reasons. Usually used together with valid?
84
+ # @return Array for valid properties with the reasons
85
+ def list_invalid_properties
86
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
87
+ invalid_properties = Array.new
88
+ if @content.nil?
89
+ invalid_properties.push('invalid value for "content", content cannot be nil.')
90
+ end
91
+
92
+ invalid_properties
93
+ end
94
+
95
+ # Check to see if the all the properties in the model are valid
96
+ # @return true if the model is valid
97
+ def valid?
98
+ warn '[DEPRECATED] the `valid?` method is obsolete'
99
+ return false if @content.nil?
100
+ true
101
+ end
102
+
103
+ # Custom attribute writer method with validation
104
+ # @param [Object] content Value to be assigned
105
+ def content=(content)
106
+ if content.nil?
107
+ fail ArgumentError, 'content cannot be nil'
108
+ end
109
+
110
+ @content = content
111
+ end
112
+
113
+ # Checks equality by comparing each attribute.
114
+ # @param [Object] Object to be compared
115
+ def ==(o)
116
+ return true if self.equal?(o)
117
+ self.class == o.class &&
118
+ subject_code == o.subject_code &&
119
+ content == o.content
120
+ end
121
+
122
+ # @see the `==` method
123
+ # @param [Object] Object to be compared
124
+ def eql?(o)
125
+ self == o
126
+ end
127
+
128
+ # Calculates hash code according to all attributes.
129
+ # @return [Integer] Hash code
130
+ def hash
131
+ [subject_code, content].hash
132
+ end
133
+
134
+ # Builds the object from hash
135
+ # @param [Hash] attributes Model attributes in the form of hash
136
+ # @return [Object] Returns the model itself
137
+ def self.build_from_hash(attributes)
138
+ return nil unless attributes.is_a?(Hash)
139
+ attributes = attributes.transform_keys(&:to_sym)
140
+ transformed_hash = {}
141
+ openapi_types.each_pair do |key, type|
142
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
143
+ transformed_hash["#{key}"] = nil
144
+ elsif type =~ /\AArray<(.*)>/i
145
+ # check to ensure the input is an array given that the attribute
146
+ # is documented as an array but the input is not
147
+ if attributes[attribute_map[key]].is_a?(Array)
148
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
94
149
  end
150
+ elsif !attributes[attribute_map[key]].nil?
151
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
152
+ end
153
+ end
154
+ new(transformed_hash)
155
+ end
156
+
157
+ # Returns the object in the form of hash
158
+ # @return [Hash] Returns the object in the form of hash
159
+ def to_hash
160
+ hash = {}
161
+ self.class.attribute_map.each_pair do |attr, param|
162
+ value = self.send(attr)
163
+ if value.nil?
164
+ is_nullable = self.class.openapi_nullable.include?(attr)
165
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
95
166
  end
96
167
 
97
- raise # if no match by now, raise
98
- rescue
99
- raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
168
+ hash[param] = _to_hash(value)
100
169
  end
170
+ hash
101
171
  end
172
+
102
173
  end
103
174
 
104
175
  end