storecove 1.0.9 → 1.0.10

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 (113) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +7 -0
  3. data/Gemfile.lock +69 -0
  4. data/lib/storecove.rb +20 -1
  5. data/lib/storecove/api/invoice_submissions_api.rb +9 -4
  6. data/lib/storecove/api/legal_entities_api.rb +248 -0
  7. data/lib/storecove/api/peppol_identifiers_api.rb +156 -0
  8. data/lib/storecove/api/purchase_invoices_api.rb +133 -0
  9. data/lib/storecove/api/shop_account_requests_api.rb +24 -11
  10. data/lib/storecove/api/shop_accounts_api.rb +25 -12
  11. data/lib/storecove/api/shops_api.rb +2 -1
  12. data/lib/storecove/api_client.rb +39 -26
  13. data/lib/storecove/api_error.rb +1 -0
  14. data/lib/storecove/configuration.rb +7 -0
  15. data/lib/storecove/models/accounting_cost_code.rb +2 -1
  16. data/lib/storecove/models/accounting_customer_party.rb +2 -1
  17. data/lib/storecove/models/accounting_details.rb +219 -0
  18. data/lib/storecove/models/accounting_details_1.rb +219 -0
  19. data/lib/storecove/models/address.rb +2 -1
  20. data/lib/storecove/models/contact.rb +2 -6
  21. data/lib/storecove/models/country.rb +10 -0
  22. data/lib/storecove/models/currency_code.rb +10 -0
  23. data/lib/storecove/models/error_model.rb +2 -1
  24. data/lib/storecove/models/invoice.rb +16 -3
  25. data/lib/storecove/models/invoice_line.rb +251 -6
  26. data/lib/storecove/models/invoice_recipient.rb +24 -11
  27. data/lib/storecove/models/invoice_recipient_preflight.rb +21 -19
  28. data/lib/storecove/models/invoice_submission.rb +20 -9
  29. data/lib/storecove/models/invoice_submission_result.rb +2 -1
  30. data/lib/storecove/models/legal_entity.rb +164 -25
  31. data/lib/storecove/models/legal_entity_create.rb +417 -0
  32. data/lib/storecove/models/legal_entity_identifier.rb +2 -1
  33. data/lib/storecove/models/legal_entity_shop.rb +253 -0
  34. data/lib/storecove/models/legal_entity_update.rb +380 -0
  35. data/lib/storecove/models/logos.rb +2 -1
  36. data/lib/storecove/models/party.rb +7 -1
  37. data/lib/storecove/models/payment_means.rb +199 -0
  38. data/lib/storecove/models/peppol_identifier.rb +284 -0
  39. data/lib/storecove/models/peppol_identifier_create.rb +308 -0
  40. data/lib/storecove/models/preflight_invoice_recipient_result.rb +2 -1
  41. data/lib/storecove/models/public_identifier.rb +3 -2
  42. data/lib/storecove/models/public_identifiers.rb +2 -1
  43. data/lib/storecove/models/purchase_invoice.rb +463 -0
  44. data/lib/storecove/models/purchase_invoice_invoice_line.rb +247 -0
  45. data/lib/storecove/models/purchase_invoice_sender.rb +280 -0
  46. data/lib/storecove/models/purchase_invoice_sender_billing_contact.rb +209 -0
  47. data/lib/storecove/models/purchase_invoice_ubl.rb +209 -0
  48. data/lib/storecove/models/shop.rb +3 -2
  49. data/lib/storecove/models/shop_account_input.rb +2 -1
  50. data/lib/storecove/models/shop_account_request_input.rb +2 -1
  51. data/lib/storecove/models/shop_account_request_result.rb +2 -1
  52. data/lib/storecove/models/shop_account_request_update.rb +2 -1
  53. data/lib/storecove/models/shop_account_result.rb +2 -1
  54. data/lib/storecove/models/shop_account_update.rb +2 -1
  55. data/lib/storecove/models/tax.rb +2 -1
  56. data/lib/storecove/models/vat_details.rb +209 -0
  57. data/lib/storecove/models/widget_identification.rb +228 -0
  58. data/lib/storecove/version.rb +2 -1
  59. data/spec/api/invoice_submissions_api_spec.rb +9 -20
  60. data/spec/api/legal_entities_api_spec.rb +84 -0
  61. data/spec/api/peppol_identifiers_api_spec.rb +63 -0
  62. data/spec/api/purchase_invoices_api_spec.rb +59 -0
  63. data/spec/api/shop_account_requests_api_spec.rb +30 -41
  64. data/spec/api/shop_accounts_api_spec.rb +34 -45
  65. data/spec/api/shops_api_spec.rb +6 -17
  66. data/spec/api_client_spec.rb +2 -13
  67. data/spec/configuration_spec.rb +2 -13
  68. data/spec/models/accounting_cost_code_spec.rb +3 -14
  69. data/spec/models/accounting_customer_party_spec.rb +3 -14
  70. data/spec/models/accounting_details_1_spec.rb +60 -0
  71. data/spec/models/accounting_details_spec.rb +60 -0
  72. data/spec/models/{party_address_spec.rb → address_spec.rb} +8 -19
  73. data/spec/models/{party_contact_spec.rb → contact_spec.rb} +8 -19
  74. data/spec/models/country_spec.rb +3 -14
  75. data/spec/models/currency_code_spec.rb +3 -14
  76. data/spec/models/error_model_spec.rb +3 -14
  77. data/spec/models/invoice_line_spec.rb +69 -14
  78. data/spec/models/invoice_recipient_preflight_spec.rb +10 -15
  79. data/spec/models/invoice_recipient_spec.rb +15 -14
  80. data/spec/models/{invoice_submission_invoice_spec.rb → invoice_spec.rb} +20 -19
  81. data/spec/models/invoice_submission_result_spec.rb +4 -15
  82. data/spec/models/invoice_submission_spec.rb +4 -15
  83. data/spec/models/legal_entity_create_spec.rb +78 -0
  84. data/spec/models/legal_entity_identifier_spec.rb +3 -14
  85. data/spec/models/legal_entity_shop_spec.rb +84 -0
  86. data/spec/models/legal_entity_spec.rb +7 -18
  87. data/spec/models/legal_entity_update_spec.rb +78 -0
  88. data/spec/models/logos_spec.rb +3 -14
  89. data/spec/models/party_spec.rb +3 -14
  90. data/spec/models/payment_means_spec.rb +48 -0
  91. data/spec/models/peppol_identifier_create_spec.rb +54 -0
  92. data/spec/models/peppol_identifier_spec.rb +54 -0
  93. data/spec/models/preflight_invoice_recipient_result_spec.rb +3 -14
  94. data/spec/models/public_identifier_spec.rb +3 -14
  95. data/spec/models/public_identifiers_spec.rb +3 -14
  96. data/spec/models/purchase_invoice_invoice_line_spec.rb +78 -0
  97. data/spec/models/purchase_invoice_sender_billing_contact_spec.rb +54 -0
  98. data/spec/models/purchase_invoice_sender_spec.rb +96 -0
  99. data/spec/models/purchase_invoice_spec.rb +188 -0
  100. data/spec/models/purchase_invoice_ubl_spec.rb +54 -0
  101. data/spec/models/shop_account_input_spec.rb +3 -14
  102. data/spec/models/shop_account_request_input_spec.rb +3 -14
  103. data/spec/models/{shop_account_request_spec.rb → shop_account_request_result_spec.rb} +8 -19
  104. data/spec/models/shop_account_request_update_spec.rb +3 -14
  105. data/spec/models/shop_account_result_spec.rb +3 -14
  106. data/spec/models/shop_account_update_spec.rb +3 -14
  107. data/spec/models/shop_spec.rb +3 -14
  108. data/spec/models/{invoice_line_tax_spec.rb → tax_spec.rb} +8 -19
  109. data/spec/models/vat_details_spec.rb +54 -0
  110. data/spec/models/widget_identification_spec.rb +48 -0
  111. data/spec/spec_helper.rb +2 -13
  112. data/storecove.gemspec +10 -19
  113. metadata +83 -28
@@ -6,6 +6,7 @@
6
6
  OpenAPI spec version: 2.0.1
7
7
  Contact: apisupport@storecove.nl
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.3.1
9
10
 
10
11
  =end
11
12
 
@@ -78,7 +79,7 @@ module StorecoveApi
78
79
  end
79
80
 
80
81
  # Show invalid properties with the reasons. Usually used together with valid?
81
- # @return Array for valid properies with the reasons
82
+ # @return Array for valid properties with the reasons
82
83
  def list_invalid_properties
83
84
  invalid_properties = Array.new
84
85
  if @username.nil?
@@ -6,6 +6,7 @@
6
6
  OpenAPI spec version: 2.0.1
7
7
  Contact: apisupport@storecove.nl
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.3.1
9
10
 
10
11
  =end
11
12
 
@@ -78,7 +79,7 @@ module StorecoveApi
78
79
  end
79
80
 
80
81
  # Show invalid properties with the reasons. Usually used together with valid?
81
- # @return Array for valid properies with the reasons
82
+ # @return Array for valid properties with the reasons
82
83
  def list_invalid_properties
83
84
  invalid_properties = Array.new
84
85
  return invalid_properties
@@ -6,6 +6,7 @@
6
6
  OpenAPI spec version: 2.0.1
7
7
  Contact: apisupport@storecove.nl
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.3.1
9
10
 
10
11
  =end
11
12
 
@@ -70,7 +71,7 @@ module StorecoveApi
70
71
  end
71
72
 
72
73
  # Show invalid properties with the reasons. Usually used together with valid?
73
- # @return Array for valid properies with the reasons
74
+ # @return Array for valid properties with the reasons
74
75
  def list_invalid_properties
75
76
  invalid_properties = Array.new
76
77
  return invalid_properties
@@ -6,6 +6,7 @@
6
6
  OpenAPI spec version: 2.0.1
7
7
  Contact: apisupport@storecove.nl
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.3.1
9
10
 
10
11
  =end
11
12
 
@@ -110,7 +111,7 @@ module StorecoveApi
110
111
  end
111
112
 
112
113
  # Show invalid properties with the reasons. Usually used together with valid?
113
- # @return Array for valid properies with the reasons
114
+ # @return Array for valid properties with the reasons
114
115
  def list_invalid_properties
115
116
  invalid_properties = Array.new
116
117
  return invalid_properties
@@ -6,6 +6,7 @@
6
6
  OpenAPI spec version: 2.0.1
7
7
  Contact: apisupport@storecove.nl
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.3.1
9
10
 
10
11
  =end
11
12
 
@@ -65,7 +66,7 @@ module StorecoveApi
65
66
  end
66
67
 
67
68
  # Show invalid properties with the reasons. Usually used together with valid?
68
- # @return Array for valid properies with the reasons
69
+ # @return Array for valid properties with the reasons
69
70
  def list_invalid_properties
70
71
  invalid_properties = Array.new
71
72
  return invalid_properties
@@ -6,6 +6,7 @@
6
6
  OpenAPI spec version: 2.0.1
7
7
  Contact: apisupport@storecove.nl
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.3.1
9
10
 
10
11
  =end
11
12
 
@@ -64,7 +65,7 @@ module StorecoveApi
64
65
  end
65
66
 
66
67
  # Show invalid properties with the reasons. Usually used together with valid?
67
- # @return Array for valid properies with the reasons
68
+ # @return Array for valid properties with the reasons
68
69
  def list_invalid_properties
69
70
  invalid_properties = Array.new
70
71
  if @amount.nil?
@@ -0,0 +1,209 @@
1
+ =begin
2
+ #Storecove API
3
+
4
+ #Storecove API
5
+
6
+ OpenAPI spec version: 2.0.1
7
+ Contact: apisupport@storecove.nl
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module StorecoveApi
16
+ # The VAT details for the invoice line.
17
+ class VATDetails
18
+ # The amount of VAT for the invoice line.
19
+ attr_accessor :amount
20
+
21
+ # The percentage of VAT for the invoice line.
22
+ attr_accessor :percentage
23
+
24
+ # The ISO 3166 country of the VAT for the invoice line.
25
+ attr_accessor :country
26
+
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'amount' => :'amount',
32
+ :'percentage' => :'percentage',
33
+ :'country' => :'country'
34
+ }
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.swagger_types
39
+ {
40
+ :'amount' => :'Float',
41
+ :'percentage' => :'Float',
42
+ :'country' => :'String'
43
+ }
44
+ end
45
+
46
+ # Initializes the object
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ def initialize(attributes = {})
49
+ return unless attributes.is_a?(Hash)
50
+
51
+ # convert string to symbol for hash key
52
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
53
+
54
+ if attributes.has_key?(:'amount')
55
+ self.amount = attributes[:'amount']
56
+ end
57
+
58
+ if attributes.has_key?(:'percentage')
59
+ self.percentage = attributes[:'percentage']
60
+ end
61
+
62
+ if attributes.has_key?(:'country')
63
+ self.country = attributes[:'country']
64
+ end
65
+
66
+ end
67
+
68
+ # Show invalid properties with the reasons. Usually used together with valid?
69
+ # @return Array for valid properties with the reasons
70
+ def list_invalid_properties
71
+ invalid_properties = Array.new
72
+ return invalid_properties
73
+ end
74
+
75
+ # Check to see if the all the properties in the model are valid
76
+ # @return true if the model is valid
77
+ def valid?
78
+ return true
79
+ end
80
+
81
+ # Checks equality by comparing each attribute.
82
+ # @param [Object] Object to be compared
83
+ def ==(o)
84
+ return true if self.equal?(o)
85
+ self.class == o.class &&
86
+ amount == o.amount &&
87
+ percentage == o.percentage &&
88
+ country == o.country
89
+ end
90
+
91
+ # @see the `==` method
92
+ # @param [Object] Object to be compared
93
+ def eql?(o)
94
+ self == o
95
+ end
96
+
97
+ # Calculates hash code according to all attributes.
98
+ # @return [Fixnum] Hash code
99
+ def hash
100
+ [amount, percentage, country].hash
101
+ end
102
+
103
+ # Builds the object from hash
104
+ # @param [Hash] attributes Model attributes in the form of hash
105
+ # @return [Object] Returns the model itself
106
+ def build_from_hash(attributes)
107
+ return nil unless attributes.is_a?(Hash)
108
+ self.class.swagger_types.each_pair do |key, type|
109
+ if type =~ /\AArray<(.*)>/i
110
+ # check to ensure the input is an array given that the the attribute
111
+ # is documented as an array but the input is not
112
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
113
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
114
+ end
115
+ elsif !attributes[self.class.attribute_map[key]].nil?
116
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
117
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
118
+ end
119
+
120
+ self
121
+ end
122
+
123
+ # Deserializes the data based on type
124
+ # @param string type Data type
125
+ # @param string value Value to be deserialized
126
+ # @return [Object] Deserialized data
127
+ def _deserialize(type, value)
128
+ case type.to_sym
129
+ when :DateTime
130
+ DateTime.parse(value)
131
+ when :Date
132
+ Date.parse(value)
133
+ when :String
134
+ value.to_s
135
+ when :Integer
136
+ value.to_i
137
+ when :Float
138
+ value.to_f
139
+ when :BOOLEAN
140
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
141
+ true
142
+ else
143
+ false
144
+ end
145
+ when :Object
146
+ # generic object (usually a Hash), return directly
147
+ value
148
+ when /\AArray<(?<inner_type>.+)>\z/
149
+ inner_type = Regexp.last_match[:inner_type]
150
+ value.map { |v| _deserialize(inner_type, v) }
151
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
152
+ k_type = Regexp.last_match[:k_type]
153
+ v_type = Regexp.last_match[:v_type]
154
+ {}.tap do |hash|
155
+ value.each do |k, v|
156
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
157
+ end
158
+ end
159
+ else # model
160
+ temp_model = StorecoveApi.const_get(type).new
161
+ temp_model.build_from_hash(value)
162
+ end
163
+ end
164
+
165
+ # Returns the string representation of the object
166
+ # @return [String] String presentation of the object
167
+ def to_s
168
+ to_hash.to_s
169
+ end
170
+
171
+ # to_body is an alias to to_hash (backward compatibility)
172
+ # @return [Hash] Returns the object in the form of hash
173
+ def to_body
174
+ to_hash
175
+ end
176
+
177
+ # Returns the object in the form of hash
178
+ # @return [Hash] Returns the object in the form of hash
179
+ def to_hash
180
+ hash = {}
181
+ self.class.attribute_map.each_pair do |attr, param|
182
+ value = self.send(attr)
183
+ next if value.nil?
184
+ hash[param] = _to_hash(value)
185
+ end
186
+ hash
187
+ end
188
+
189
+ # Outputs non-array value in the form of hash
190
+ # For object, use to_hash. Otherwise, just return the value
191
+ # @param [Object] value Any valid value
192
+ # @return [Hash] Returns the value in the form of hash
193
+ def _to_hash(value)
194
+ if value.is_a?(Array)
195
+ value.compact.map{ |v| _to_hash(v) }
196
+ elsif value.is_a?(Hash)
197
+ {}.tap do |hash|
198
+ value.each { |k, v| hash[k] = _to_hash(v) }
199
+ end
200
+ elsif value.respond_to? :to_hash
201
+ value.to_hash
202
+ else
203
+ value
204
+ end
205
+ end
206
+
207
+ end
208
+
209
+ end
@@ -0,0 +1,228 @@
1
+ =begin
2
+ #Storecove API
3
+
4
+ #Storecove API
5
+
6
+ OpenAPI spec version: 2.0.1
7
+ Contact: apisupport@storecove.nl
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module StorecoveApi
16
+ # The identification for the identifier related to the Storecove Destination Configuration widget.
17
+ class WidgetIdentification
18
+ # The id of the LegalEntity this invoice should be sent for.
19
+ attr_accessor :legal_entity_id
20
+
21
+ # Your id for this organization. This should match the id that you use for the Storecove widget (if you use that).
22
+ attr_accessor :id
23
+
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'legal_entity_id' => :'legalEntityId',
29
+ :'id' => :'id'
30
+ }
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.swagger_types
35
+ {
36
+ :'legal_entity_id' => :'Integer',
37
+ :'id' => :'String'
38
+ }
39
+ end
40
+
41
+ # Initializes the object
42
+ # @param [Hash] attributes Model attributes in the form of hash
43
+ def initialize(attributes = {})
44
+ return unless attributes.is_a?(Hash)
45
+
46
+ # convert string to symbol for hash key
47
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
48
+
49
+ if attributes.has_key?(:'legalEntityId')
50
+ self.legal_entity_id = attributes[:'legalEntityId']
51
+ end
52
+
53
+ if attributes.has_key?(:'id')
54
+ self.id = attributes[:'id']
55
+ end
56
+
57
+ end
58
+
59
+ # Show invalid properties with the reasons. Usually used together with valid?
60
+ # @return Array for valid properties with the reasons
61
+ def list_invalid_properties
62
+ invalid_properties = Array.new
63
+ if @legal_entity_id.nil?
64
+ invalid_properties.push("invalid value for 'legal_entity_id', legal_entity_id cannot be nil.")
65
+ end
66
+
67
+ if @id.nil?
68
+ invalid_properties.push("invalid value for 'id', id cannot be nil.")
69
+ end
70
+
71
+ if @id.to_s.length < 2
72
+ invalid_properties.push("invalid value for 'id', the character length must be great than or equal to 2.")
73
+ end
74
+
75
+ return invalid_properties
76
+ end
77
+
78
+ # Check to see if the all the properties in the model are valid
79
+ # @return true if the model is valid
80
+ def valid?
81
+ return false if @legal_entity_id.nil?
82
+ return false if @id.nil?
83
+ return false if @id.to_s.length < 2
84
+ return true
85
+ end
86
+
87
+ # Custom attribute writer method with validation
88
+ # @param [Object] id Value to be assigned
89
+ def id=(id)
90
+ if id.nil?
91
+ fail ArgumentError, "id cannot be nil"
92
+ end
93
+
94
+ if id.to_s.length < 2
95
+ fail ArgumentError, "invalid value for 'id', the character length must be great than or equal to 2."
96
+ end
97
+
98
+ @id = id
99
+ end
100
+
101
+ # Checks equality by comparing each attribute.
102
+ # @param [Object] Object to be compared
103
+ def ==(o)
104
+ return true if self.equal?(o)
105
+ self.class == o.class &&
106
+ legal_entity_id == o.legal_entity_id &&
107
+ id == o.id
108
+ end
109
+
110
+ # @see the `==` method
111
+ # @param [Object] Object to be compared
112
+ def eql?(o)
113
+ self == o
114
+ end
115
+
116
+ # Calculates hash code according to all attributes.
117
+ # @return [Fixnum] Hash code
118
+ def hash
119
+ [legal_entity_id, id].hash
120
+ end
121
+
122
+ # Builds the object from hash
123
+ # @param [Hash] attributes Model attributes in the form of hash
124
+ # @return [Object] Returns the model itself
125
+ def build_from_hash(attributes)
126
+ return nil unless attributes.is_a?(Hash)
127
+ self.class.swagger_types.each_pair do |key, type|
128
+ if type =~ /\AArray<(.*)>/i
129
+ # check to ensure the input is an array given that the the attribute
130
+ # is documented as an array but the input is not
131
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
132
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
133
+ end
134
+ elsif !attributes[self.class.attribute_map[key]].nil?
135
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
136
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
137
+ end
138
+
139
+ self
140
+ end
141
+
142
+ # Deserializes the data based on type
143
+ # @param string type Data type
144
+ # @param string value Value to be deserialized
145
+ # @return [Object] Deserialized data
146
+ def _deserialize(type, value)
147
+ case type.to_sym
148
+ when :DateTime
149
+ DateTime.parse(value)
150
+ when :Date
151
+ Date.parse(value)
152
+ when :String
153
+ value.to_s
154
+ when :Integer
155
+ value.to_i
156
+ when :Float
157
+ value.to_f
158
+ when :BOOLEAN
159
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
160
+ true
161
+ else
162
+ false
163
+ end
164
+ when :Object
165
+ # generic object (usually a Hash), return directly
166
+ value
167
+ when /\AArray<(?<inner_type>.+)>\z/
168
+ inner_type = Regexp.last_match[:inner_type]
169
+ value.map { |v| _deserialize(inner_type, v) }
170
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
171
+ k_type = Regexp.last_match[:k_type]
172
+ v_type = Regexp.last_match[:v_type]
173
+ {}.tap do |hash|
174
+ value.each do |k, v|
175
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
176
+ end
177
+ end
178
+ else # model
179
+ temp_model = StorecoveApi.const_get(type).new
180
+ temp_model.build_from_hash(value)
181
+ end
182
+ end
183
+
184
+ # Returns the string representation of the object
185
+ # @return [String] String presentation of the object
186
+ def to_s
187
+ to_hash.to_s
188
+ end
189
+
190
+ # to_body is an alias to to_hash (backward compatibility)
191
+ # @return [Hash] Returns the object in the form of hash
192
+ def to_body
193
+ to_hash
194
+ end
195
+
196
+ # Returns the object in the form of hash
197
+ # @return [Hash] Returns the object in the form of hash
198
+ def to_hash
199
+ hash = {}
200
+ self.class.attribute_map.each_pair do |attr, param|
201
+ value = self.send(attr)
202
+ next if value.nil?
203
+ hash[param] = _to_hash(value)
204
+ end
205
+ hash
206
+ end
207
+
208
+ # Outputs non-array value in the form of hash
209
+ # For object, use to_hash. Otherwise, just return the value
210
+ # @param [Object] value Any valid value
211
+ # @return [Hash] Returns the value in the form of hash
212
+ def _to_hash(value)
213
+ if value.is_a?(Array)
214
+ value.compact.map{ |v| _to_hash(v) }
215
+ elsif value.is_a?(Hash)
216
+ {}.tap do |hash|
217
+ value.each { |k, v| hash[k] = _to_hash(v) }
218
+ end
219
+ elsif value.respond_to? :to_hash
220
+ value.to_hash
221
+ else
222
+ value
223
+ end
224
+ end
225
+
226
+ end
227
+
228
+ end