storecove 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/lib/storecove/api/invoice_submissions_api.rb +148 -0
  3. data/lib/storecove/api/shop_account_requests_api.rb +323 -0
  4. data/lib/storecove/api/shop_accounts_api.rb +376 -0
  5. data/lib/storecove/api/shops_api.rb +87 -0
  6. data/lib/storecove/api_client.rb +379 -0
  7. data/lib/storecove/api_error.rb +47 -0
  8. data/lib/storecove/configuration.rb +214 -0
  9. data/lib/storecove/models/accounting_cost_code.rb +298 -0
  10. data/lib/storecove/models/accounting_customer_party.rb +210 -0
  11. data/lib/storecove/models/country.rb +280 -0
  12. data/lib/storecove/models/currency_code.rb +209 -0
  13. data/lib/storecove/models/error_model.rb +208 -0
  14. data/lib/storecove/models/invoice_line.rb +327 -0
  15. data/lib/storecove/models/invoice_line_tax.rb +222 -0
  16. data/lib/storecove/models/invoice_recipient.rb +227 -0
  17. data/lib/storecove/models/invoice_recipient_preflight.rb +211 -0
  18. data/lib/storecove/models/invoice_submission.rb +321 -0
  19. data/lib/storecove/models/invoice_submission_invoice.rb +506 -0
  20. data/lib/storecove/models/invoice_submission_result.rb +200 -0
  21. data/lib/storecove/models/legal_entity.rb +264 -0
  22. data/lib/storecove/models/legal_entity_identifier.rb +217 -0
  23. data/lib/storecove/models/logos.rb +217 -0
  24. data/lib/storecove/models/party.rb +242 -0
  25. data/lib/storecove/models/party_address.rb +331 -0
  26. data/lib/storecove/models/party_contact.rb +218 -0
  27. data/lib/storecove/models/preflight_invoice_recipient_result.rb +233 -0
  28. data/lib/storecove/models/public_identifiers.rb +190 -0
  29. data/lib/storecove/models/public_identifiers_inner.rb +258 -0
  30. data/lib/storecove/models/shop.rb +237 -0
  31. data/lib/storecove/models/shop_account.rb +270 -0
  32. data/lib/storecove/models/shop_account_input.rb +244 -0
  33. data/lib/storecove/models/shop_account_request.rb +236 -0
  34. data/lib/storecove/models/shop_account_request_input.rb +235 -0
  35. data/lib/storecove/models/shop_account_request_update.rb +226 -0
  36. data/lib/storecove/models/shop_account_update.rb +220 -0
  37. data/lib/storecove/models/swagger-codegen +2799 -0
  38. data/lib/storecove/version.rb +26 -0
  39. data/lib/storecove.rb +82 -0
  40. data/storecove.gemspec +55 -0
  41. metadata +263 -0
@@ -0,0 +1,506 @@
1
+ =begin
2
+ #Storecove API
3
+
4
+ #Storecove API
5
+
6
+ OpenAPI spec version: 2.0.0
7
+ Contact: apisupport@storecove.nl
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
24
+ require 'date'
25
+
26
+ module StorecoveApi
27
+ # The invoice to send
28
+ class InvoiceSubmissionInvoice
29
+ attr_accessor :document_currency_code
30
+
31
+ # The invoice number you assigned to the invoice. The minimum length is 1 character, to allow invoice numbers 1-9.
32
+ attr_accessor :invoice_number
33
+
34
+ # Format: yyyy-mm-dd.
35
+ attr_accessor :issue_date
36
+
37
+ attr_accessor :accounting_customer_party
38
+
39
+ # An array of invoice lines.
40
+ attr_accessor :invoice_lines
41
+
42
+ attr_accessor :accounting_cost_code
43
+
44
+ # Format: yyyy-mm-dd.
45
+ attr_accessor :due_date
46
+
47
+ # Use 380 for a regular invoice, 384 for a Corrective invoice.
48
+ attr_accessor :invoice_type
49
+
50
+ # The tax date is the date on which the supply of goods or of services was made or completed or the date on which the payment on account was made insofar as that date can be determined and differs from the date of the issue of the invoice. EU 2006-112 Article 226 Point 7. Note: For the Dutch TAX authorities the tac date should be the same as the issue date.
51
+ attr_accessor :tax_point_date
52
+
53
+ # A reference provided by the buyer used for internal routing of the document.
54
+ attr_accessor :buyer_reference
55
+
56
+ # The period (or specific date) to which the invoice applies. Format: yyyy-mm-dd - yyyy-mm-dd.
57
+ attr_accessor :invoice_period
58
+
59
+ # A reference to an order for this invoice.
60
+ attr_accessor :order_reference
61
+
62
+ # A reference to a commercial invoice or corrective invoice of which the current invoice is a correction.
63
+ attr_accessor :billing_reference
64
+
65
+ # A reference to a contract or framework agreement that this invoice relates to.
66
+ attr_accessor :contract_document_reference
67
+
68
+ # Information about the project this invoice relates to.
69
+ attr_accessor :project_reference
70
+
71
+ # The IBAN the amount payable should be transferred to
72
+ attr_accessor :payment_means_iban
73
+
74
+ # Leave empty. Defaults to 31 if an IBAN is provided, otherwise defaults to 1. But leave empty.
75
+ attr_accessor :payment_means_code
76
+
77
+ # The payment id that you will use to match the payment against the invoice.
78
+ attr_accessor :payment_means_payment_id
79
+
80
+ class EnumAttributeValidator
81
+ attr_reader :datatype
82
+ attr_reader :allowable_values
83
+
84
+ def initialize(datatype, allowable_values)
85
+ @allowable_values = allowable_values.map do |value|
86
+ case datatype.to_s
87
+ when /Integer/i
88
+ value.to_i
89
+ when /Float/i
90
+ value.to_f
91
+ else
92
+ value
93
+ end
94
+ end
95
+ end
96
+
97
+ def valid?(value)
98
+ !value || allowable_values.include?(value)
99
+ end
100
+ end
101
+
102
+ # Attribute mapping from ruby-style variable name to JSON key.
103
+ def self.attribute_map
104
+ {
105
+ :'document_currency_code' => :'documentCurrencyCode',
106
+ :'invoice_number' => :'invoiceNumber',
107
+ :'issue_date' => :'issueDate',
108
+ :'accounting_customer_party' => :'accountingCustomerParty',
109
+ :'invoice_lines' => :'invoiceLines',
110
+ :'accounting_cost_code' => :'accountingCostCode',
111
+ :'due_date' => :'dueDate',
112
+ :'invoice_type' => :'invoiceType',
113
+ :'tax_point_date' => :'taxPointDate',
114
+ :'buyer_reference' => :'buyerReference',
115
+ :'invoice_period' => :'invoicePeriod',
116
+ :'order_reference' => :'orderReference',
117
+ :'billing_reference' => :'billingReference',
118
+ :'contract_document_reference' => :'contractDocumentReference',
119
+ :'project_reference' => :'projectReference',
120
+ :'payment_means_iban' => :'paymentMeansIban',
121
+ :'payment_means_code' => :'paymentMeansCode',
122
+ :'payment_means_payment_id' => :'paymentMeansPaymentId'
123
+ }
124
+ end
125
+
126
+ # Attribute type mapping.
127
+ def self.swagger_types
128
+ {
129
+ :'document_currency_code' => :'CurrencyCode',
130
+ :'invoice_number' => :'String',
131
+ :'issue_date' => :'String',
132
+ :'accounting_customer_party' => :'AccountingCustomerParty',
133
+ :'invoice_lines' => :'Array<InvoiceLine>',
134
+ :'accounting_cost_code' => :'AccountingCostCode',
135
+ :'due_date' => :'String',
136
+ :'invoice_type' => :'String',
137
+ :'tax_point_date' => :'String',
138
+ :'buyer_reference' => :'String',
139
+ :'invoice_period' => :'String',
140
+ :'order_reference' => :'String',
141
+ :'billing_reference' => :'String',
142
+ :'contract_document_reference' => :'String',
143
+ :'project_reference' => :'String',
144
+ :'payment_means_iban' => :'String',
145
+ :'payment_means_code' => :'String',
146
+ :'payment_means_payment_id' => :'String'
147
+ }
148
+ end
149
+
150
+ # Initializes the object
151
+ # @param [Hash] attributes Model attributes in the form of hash
152
+ def initialize(attributes = {})
153
+ return unless attributes.is_a?(Hash)
154
+
155
+ # convert string to symbol for hash key
156
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
157
+
158
+ if attributes.has_key?(:'documentCurrencyCode')
159
+ self.document_currency_code = attributes[:'documentCurrencyCode']
160
+ end
161
+
162
+ if attributes.has_key?(:'invoiceNumber')
163
+ self.invoice_number = attributes[:'invoiceNumber']
164
+ end
165
+
166
+ if attributes.has_key?(:'issueDate')
167
+ self.issue_date = attributes[:'issueDate']
168
+ end
169
+
170
+ if attributes.has_key?(:'accountingCustomerParty')
171
+ self.accounting_customer_party = attributes[:'accountingCustomerParty']
172
+ end
173
+
174
+ if attributes.has_key?(:'invoiceLines')
175
+ if (value = attributes[:'invoiceLines']).is_a?(Array)
176
+ self.invoice_lines = value
177
+ end
178
+ end
179
+
180
+ if attributes.has_key?(:'accountingCostCode')
181
+ self.accounting_cost_code = attributes[:'accountingCostCode']
182
+ end
183
+
184
+ if attributes.has_key?(:'dueDate')
185
+ self.due_date = attributes[:'dueDate']
186
+ end
187
+
188
+ if attributes.has_key?(:'invoiceType')
189
+ self.invoice_type = attributes[:'invoiceType']
190
+ else
191
+ self.invoice_type = "380"
192
+ end
193
+
194
+ if attributes.has_key?(:'taxPointDate')
195
+ self.tax_point_date = attributes[:'taxPointDate']
196
+ end
197
+
198
+ if attributes.has_key?(:'buyerReference')
199
+ self.buyer_reference = attributes[:'buyerReference']
200
+ end
201
+
202
+ if attributes.has_key?(:'invoicePeriod')
203
+ self.invoice_period = attributes[:'invoicePeriod']
204
+ end
205
+
206
+ if attributes.has_key?(:'orderReference')
207
+ self.order_reference = attributes[:'orderReference']
208
+ end
209
+
210
+ if attributes.has_key?(:'billingReference')
211
+ self.billing_reference = attributes[:'billingReference']
212
+ end
213
+
214
+ if attributes.has_key?(:'contractDocumentReference')
215
+ self.contract_document_reference = attributes[:'contractDocumentReference']
216
+ end
217
+
218
+ if attributes.has_key?(:'projectReference')
219
+ self.project_reference = attributes[:'projectReference']
220
+ end
221
+
222
+ if attributes.has_key?(:'paymentMeansIban')
223
+ self.payment_means_iban = attributes[:'paymentMeansIban']
224
+ end
225
+
226
+ if attributes.has_key?(:'paymentMeansCode')
227
+ self.payment_means_code = attributes[:'paymentMeansCode']
228
+ end
229
+
230
+ if attributes.has_key?(:'paymentMeansPaymentId')
231
+ self.payment_means_payment_id = attributes[:'paymentMeansPaymentId']
232
+ end
233
+
234
+ end
235
+
236
+ # Show invalid properties with the reasons. Usually used together with valid?
237
+ # @return Array for valid properies with the reasons
238
+ def list_invalid_properties
239
+ invalid_properties = Array.new
240
+ if @invoice_number.nil?
241
+ invalid_properties.push("invalid value for 'invoice_number', invoice_number cannot be nil.")
242
+ end
243
+
244
+ if @invoice_number.to_s.length < 1
245
+ invalid_properties.push("invalid value for 'invoice_number', the character length must be great than or equal to 1.")
246
+ end
247
+
248
+ if @issue_date.nil?
249
+ invalid_properties.push("invalid value for 'issue_date', issue_date cannot be nil.")
250
+ end
251
+
252
+ if @issue_date !~ Regexp.new(/^\\d{4}-\\d{2}-\\d{2}$/)
253
+ invalid_properties.push("invalid value for 'issue_date', must conform to the pattern /^\\d{4}-\\d{2}-\\d{2}$/.")
254
+ end
255
+
256
+
257
+ if !@due_date.nil? && @due_date !~ Regexp.new(/^\\d{4}-\\d{2}-\\d{2}$/)
258
+ invalid_properties.push("invalid value for 'due_date', must conform to the pattern /^\\d{4}-\\d{2}-\\d{2}$/.")
259
+ end
260
+
261
+
262
+ if !@tax_point_date.nil? && @tax_point_date !~ Regexp.new(/^\\d{4}-\\d{2}-\\d{2}$/)
263
+ invalid_properties.push("invalid value for 'tax_point_date', must conform to the pattern /^\\d{4}-\\d{2}-\\d{2}$/.")
264
+ end
265
+
266
+
267
+ if !@invoice_period.nil? && @invoice_period !~ Regexp.new(/^\\d{4}-\\d{2}-\\d{2}\\s+-\\s+\\d{4}-\\d{2}-\\d{2}$/)
268
+ invalid_properties.push("invalid value for 'invoice_period', must conform to the pattern /^\\d{4}-\\d{2}-\\d{2}\\s+-\\s+\\d{4}-\\d{2}-\\d{2}$/.")
269
+ end
270
+
271
+ return invalid_properties
272
+ end
273
+
274
+ # Check to see if the all the properties in the model are valid
275
+ # @return true if the model is valid
276
+ def valid?
277
+ return false if @document_currency_code.nil?
278
+ return false if @invoice_number.nil?
279
+ return false if @invoice_number.to_s.length < 1
280
+ return false if @issue_date.nil?
281
+ return false if @issue_date !~ Regexp.new(/^\\d{4}-\\d{2}-\\d{2}$/)
282
+ return false if @accounting_customer_party.nil?
283
+ return false if @invoice_lines.nil?
284
+ return false if !@due_date.nil? && @due_date !~ Regexp.new(/^\\d{4}-\\d{2}-\\d{2}$/)
285
+ invoice_type_validator = EnumAttributeValidator.new('String', ["380", "384"])
286
+ return false unless invoice_type_validator.valid?(@invoice_type)
287
+ return false if !@tax_point_date.nil? && @tax_point_date !~ Regexp.new(/^\\d{4}-\\d{2}-\\d{2}$/)
288
+ return false if !@invoice_period.nil? && @invoice_period !~ Regexp.new(/^\\d{4}-\\d{2}-\\d{2}\\s+-\\s+\\d{4}-\\d{2}-\\d{2}$/)
289
+ return true
290
+ end
291
+
292
+ # Custom attribute writer method with validation
293
+ # @param [Object] invoice_number Value to be assigned
294
+ def invoice_number=(invoice_number)
295
+ if invoice_number.nil?
296
+ fail ArgumentError, "invoice_number cannot be nil"
297
+ end
298
+
299
+ if invoice_number.to_s.length < 1
300
+ fail ArgumentError, "invalid value for 'invoice_number', the character length must be great than or equal to 1."
301
+ end
302
+
303
+ @invoice_number = invoice_number
304
+ end
305
+
306
+ # Custom attribute writer method with validation
307
+ # @param [Object] issue_date Value to be assigned
308
+ def issue_date=(issue_date)
309
+ if issue_date.nil?
310
+ fail ArgumentError, "issue_date cannot be nil"
311
+ end
312
+
313
+ if issue_date !~ Regexp.new(/^\\d{4}-\\d{2}-\\d{2}$/)
314
+ fail ArgumentError, "invalid value for 'issue_date', must conform to the pattern /^\\d{4}-\\d{2}-\\d{2}$/."
315
+ end
316
+
317
+ @issue_date = issue_date
318
+ end
319
+
320
+ # Custom attribute writer method with validation
321
+ # @param [Object] due_date Value to be assigned
322
+ def due_date=(due_date)
323
+
324
+ if !due_date.nil? && due_date !~ Regexp.new(/^\\d{4}-\\d{2}-\\d{2}$/)
325
+ fail ArgumentError, "invalid value for 'due_date', must conform to the pattern /^\\d{4}-\\d{2}-\\d{2}$/."
326
+ end
327
+
328
+ @due_date = due_date
329
+ end
330
+
331
+ # Custom attribute writer method checking allowed values (enum).
332
+ # @param [Object] invoice_type Object to be assigned
333
+ def invoice_type=(invoice_type)
334
+ validator = EnumAttributeValidator.new('String', ["380", "384"])
335
+ unless validator.valid?(invoice_type)
336
+ fail ArgumentError, "invalid value for 'invoice_type', must be one of #{validator.allowable_values}."
337
+ end
338
+ @invoice_type = invoice_type
339
+ end
340
+
341
+ # Custom attribute writer method with validation
342
+ # @param [Object] tax_point_date Value to be assigned
343
+ def tax_point_date=(tax_point_date)
344
+
345
+ if !tax_point_date.nil? && tax_point_date !~ Regexp.new(/^\\d{4}-\\d{2}-\\d{2}$/)
346
+ fail ArgumentError, "invalid value for 'tax_point_date', must conform to the pattern /^\\d{4}-\\d{2}-\\d{2}$/."
347
+ end
348
+
349
+ @tax_point_date = tax_point_date
350
+ end
351
+
352
+ # Custom attribute writer method with validation
353
+ # @param [Object] invoice_period Value to be assigned
354
+ def invoice_period=(invoice_period)
355
+
356
+ if !invoice_period.nil? && invoice_period !~ Regexp.new(/^\\d{4}-\\d{2}-\\d{2}\\s+-\\s+\\d{4}-\\d{2}-\\d{2}$/)
357
+ fail ArgumentError, "invalid value for 'invoice_period', must conform to the pattern /^\\d{4}-\\d{2}-\\d{2}\\s+-\\s+\\d{4}-\\d{2}-\\d{2}$/."
358
+ end
359
+
360
+ @invoice_period = invoice_period
361
+ end
362
+
363
+ # Checks equality by comparing each attribute.
364
+ # @param [Object] Object to be compared
365
+ def ==(o)
366
+ return true if self.equal?(o)
367
+ self.class == o.class &&
368
+ document_currency_code == o.document_currency_code &&
369
+ invoice_number == o.invoice_number &&
370
+ issue_date == o.issue_date &&
371
+ accounting_customer_party == o.accounting_customer_party &&
372
+ invoice_lines == o.invoice_lines &&
373
+ accounting_cost_code == o.accounting_cost_code &&
374
+ due_date == o.due_date &&
375
+ invoice_type == o.invoice_type &&
376
+ tax_point_date == o.tax_point_date &&
377
+ buyer_reference == o.buyer_reference &&
378
+ invoice_period == o.invoice_period &&
379
+ order_reference == o.order_reference &&
380
+ billing_reference == o.billing_reference &&
381
+ contract_document_reference == o.contract_document_reference &&
382
+ project_reference == o.project_reference &&
383
+ payment_means_iban == o.payment_means_iban &&
384
+ payment_means_code == o.payment_means_code &&
385
+ payment_means_payment_id == o.payment_means_payment_id
386
+ end
387
+
388
+ # @see the `==` method
389
+ # @param [Object] Object to be compared
390
+ def eql?(o)
391
+ self == o
392
+ end
393
+
394
+ # Calculates hash code according to all attributes.
395
+ # @return [Fixnum] Hash code
396
+ def hash
397
+ [document_currency_code, invoice_number, issue_date, accounting_customer_party, invoice_lines, accounting_cost_code, due_date, invoice_type, tax_point_date, buyer_reference, invoice_period, order_reference, billing_reference, contract_document_reference, project_reference, payment_means_iban, payment_means_code, payment_means_payment_id].hash
398
+ end
399
+
400
+ # Builds the object from hash
401
+ # @param [Hash] attributes Model attributes in the form of hash
402
+ # @return [Object] Returns the model itself
403
+ def build_from_hash(attributes)
404
+ return nil unless attributes.is_a?(Hash)
405
+ self.class.swagger_types.each_pair do |key, type|
406
+ if type =~ /^Array<(.*)>/i
407
+ # check to ensure the input is an array given that the the attribute
408
+ # is documented as an array but the input is not
409
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
410
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
411
+ end
412
+ elsif !attributes[self.class.attribute_map[key]].nil?
413
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
414
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
415
+ end
416
+
417
+ self
418
+ end
419
+
420
+ # Deserializes the data based on type
421
+ # @param string type Data type
422
+ # @param string value Value to be deserialized
423
+ # @return [Object] Deserialized data
424
+ def _deserialize(type, value)
425
+ case type.to_sym
426
+ when :DateTime
427
+ DateTime.parse(value)
428
+ when :Date
429
+ Date.parse(value)
430
+ when :String
431
+ value.to_s
432
+ when :Integer
433
+ value.to_i
434
+ when :Float
435
+ value.to_f
436
+ when :BOOLEAN
437
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
438
+ true
439
+ else
440
+ false
441
+ end
442
+ when :Object
443
+ # generic object (usually a Hash), return directly
444
+ value
445
+ when /\AArray<(?<inner_type>.+)>\z/
446
+ inner_type = Regexp.last_match[:inner_type]
447
+ value.map { |v| _deserialize(inner_type, v) }
448
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
449
+ k_type = Regexp.last_match[:k_type]
450
+ v_type = Regexp.last_match[:v_type]
451
+ {}.tap do |hash|
452
+ value.each do |k, v|
453
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
454
+ end
455
+ end
456
+ else # model
457
+ temp_model = StorecoveApi.const_get(type).new
458
+ temp_model.build_from_hash(value)
459
+ end
460
+ end
461
+
462
+ # Returns the string representation of the object
463
+ # @return [String] String presentation of the object
464
+ def to_s
465
+ to_hash.to_s
466
+ end
467
+
468
+ # to_body is an alias to to_hash (backward compatibility)
469
+ # @return [Hash] Returns the object in the form of hash
470
+ def to_body
471
+ to_hash
472
+ end
473
+
474
+ # Returns the object in the form of hash
475
+ # @return [Hash] Returns the object in the form of hash
476
+ def to_hash
477
+ hash = {}
478
+ self.class.attribute_map.each_pair do |attr, param|
479
+ value = self.send(attr)
480
+ next if value.nil?
481
+ hash[param] = _to_hash(value)
482
+ end
483
+ hash
484
+ end
485
+
486
+ # Outputs non-array value in the form of hash
487
+ # For object, use to_hash. Otherwise, just return the value
488
+ # @param [Object] value Any valid value
489
+ # @return [Hash] Returns the value in the form of hash
490
+ def _to_hash(value)
491
+ if value.is_a?(Array)
492
+ value.compact.map{ |v| _to_hash(v) }
493
+ elsif value.is_a?(Hash)
494
+ {}.tap do |hash|
495
+ value.each { |k, v| hash[k] = _to_hash(v) }
496
+ end
497
+ elsif value.respond_to? :to_hash
498
+ value.to_hash
499
+ else
500
+ value
501
+ end
502
+ end
503
+
504
+ end
505
+
506
+ end
@@ -0,0 +1,200 @@
1
+ =begin
2
+ #Storecove API
3
+
4
+ #Storecove API
5
+
6
+ OpenAPI spec version: 2.0.0
7
+ Contact: apisupport@storecove.nl
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
24
+ require 'date'
25
+
26
+ module StorecoveApi
27
+ # The result of an invoice submission
28
+ class InvoiceSubmissionResult
29
+ # The submission id
30
+ attr_accessor :id
31
+
32
+
33
+ # Attribute mapping from ruby-style variable name to JSON key.
34
+ def self.attribute_map
35
+ {
36
+ :'id' => :'id'
37
+ }
38
+ end
39
+
40
+ # Attribute type mapping.
41
+ def self.swagger_types
42
+ {
43
+ :'id' => :'String'
44
+ }
45
+ end
46
+
47
+ # Initializes the object
48
+ # @param [Hash] attributes Model attributes in the form of hash
49
+ def initialize(attributes = {})
50
+ return unless attributes.is_a?(Hash)
51
+
52
+ # convert string to symbol for hash key
53
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
54
+
55
+ if attributes.has_key?(:'id')
56
+ self.id = attributes[:'id']
57
+ end
58
+
59
+ end
60
+
61
+ # Show invalid properties with the reasons. Usually used together with valid?
62
+ # @return Array for valid properies with the reasons
63
+ def list_invalid_properties
64
+ invalid_properties = Array.new
65
+ return invalid_properties
66
+ end
67
+
68
+ # Check to see if the all the properties in the model are valid
69
+ # @return true if the model is valid
70
+ def valid?
71
+ return true
72
+ end
73
+
74
+ # Checks equality by comparing each attribute.
75
+ # @param [Object] Object to be compared
76
+ def ==(o)
77
+ return true if self.equal?(o)
78
+ self.class == o.class &&
79
+ id == o.id
80
+ end
81
+
82
+ # @see the `==` method
83
+ # @param [Object] Object to be compared
84
+ def eql?(o)
85
+ self == o
86
+ end
87
+
88
+ # Calculates hash code according to all attributes.
89
+ # @return [Fixnum] Hash code
90
+ def hash
91
+ [id].hash
92
+ end
93
+
94
+ # Builds the object from hash
95
+ # @param [Hash] attributes Model attributes in the form of hash
96
+ # @return [Object] Returns the model itself
97
+ def build_from_hash(attributes)
98
+ return nil unless attributes.is_a?(Hash)
99
+ self.class.swagger_types.each_pair do |key, type|
100
+ if type =~ /^Array<(.*)>/i
101
+ # check to ensure the input is an array given that the the attribute
102
+ # is documented as an array but the input is not
103
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
104
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
105
+ end
106
+ elsif !attributes[self.class.attribute_map[key]].nil?
107
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
108
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
109
+ end
110
+
111
+ self
112
+ end
113
+
114
+ # Deserializes the data based on type
115
+ # @param string type Data type
116
+ # @param string value Value to be deserialized
117
+ # @return [Object] Deserialized data
118
+ def _deserialize(type, value)
119
+ case type.to_sym
120
+ when :DateTime
121
+ DateTime.parse(value)
122
+ when :Date
123
+ Date.parse(value)
124
+ when :String
125
+ value.to_s
126
+ when :Integer
127
+ value.to_i
128
+ when :Float
129
+ value.to_f
130
+ when :BOOLEAN
131
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
132
+ true
133
+ else
134
+ false
135
+ end
136
+ when :Object
137
+ # generic object (usually a Hash), return directly
138
+ value
139
+ when /\AArray<(?<inner_type>.+)>\z/
140
+ inner_type = Regexp.last_match[:inner_type]
141
+ value.map { |v| _deserialize(inner_type, v) }
142
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
143
+ k_type = Regexp.last_match[:k_type]
144
+ v_type = Regexp.last_match[:v_type]
145
+ {}.tap do |hash|
146
+ value.each do |k, v|
147
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
148
+ end
149
+ end
150
+ else # model
151
+ temp_model = StorecoveApi.const_get(type).new
152
+ temp_model.build_from_hash(value)
153
+ end
154
+ end
155
+
156
+ # Returns the string representation of the object
157
+ # @return [String] String presentation of the object
158
+ def to_s
159
+ to_hash.to_s
160
+ end
161
+
162
+ # to_body is an alias to to_hash (backward compatibility)
163
+ # @return [Hash] Returns the object in the form of hash
164
+ def to_body
165
+ to_hash
166
+ end
167
+
168
+ # Returns the object in the form of hash
169
+ # @return [Hash] Returns the object in the form of hash
170
+ def to_hash
171
+ hash = {}
172
+ self.class.attribute_map.each_pair do |attr, param|
173
+ value = self.send(attr)
174
+ next if value.nil?
175
+ hash[param] = _to_hash(value)
176
+ end
177
+ hash
178
+ end
179
+
180
+ # Outputs non-array value in the form of hash
181
+ # For object, use to_hash. Otherwise, just return the value
182
+ # @param [Object] value Any valid value
183
+ # @return [Hash] Returns the value in the form of hash
184
+ def _to_hash(value)
185
+ if value.is_a?(Array)
186
+ value.compact.map{ |v| _to_hash(v) }
187
+ elsif value.is_a?(Hash)
188
+ {}.tap do |hash|
189
+ value.each { |k, v| hash[k] = _to_hash(v) }
190
+ end
191
+ elsif value.respond_to? :to_hash
192
+ value.to_hash
193
+ else
194
+ value
195
+ end
196
+ end
197
+
198
+ end
199
+
200
+ end