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
@@ -0,0 +1,247 @@
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
+
17
+ class PurchaseInvoiceInvoiceLine
18
+ # The description for the invoice line.
19
+ attr_accessor :description
20
+
21
+ # The price for one item, excluding VAT.
22
+ attr_accessor :price_amount
23
+
24
+ # The quantity of the item.
25
+ attr_accessor :quantity
26
+
27
+ # The adjustment to the price, for instance a discount.
28
+ attr_accessor :allowance_charge
29
+
30
+ # The amount excluding VAT. This is equal to quantity x price_amount + allowance_charge. This property is redundant and provided only to make invoice processing more easy. You can also choose to only store this property, instead of the underlying fields.
31
+ attr_accessor :amount_excluding_vat
32
+
33
+ attr_accessor :vat
34
+
35
+ attr_accessor :accounting
36
+
37
+
38
+ # Attribute mapping from ruby-style variable name to JSON key.
39
+ def self.attribute_map
40
+ {
41
+ :'description' => :'description',
42
+ :'price_amount' => :'price_amount',
43
+ :'quantity' => :'quantity',
44
+ :'allowance_charge' => :'allowance_charge',
45
+ :'amount_excluding_vat' => :'amount_excluding_vat',
46
+ :'vat' => :'vat',
47
+ :'accounting' => :'accounting'
48
+ }
49
+ end
50
+
51
+ # Attribute type mapping.
52
+ def self.swagger_types
53
+ {
54
+ :'description' => :'String',
55
+ :'price_amount' => :'Float',
56
+ :'quantity' => :'Float',
57
+ :'allowance_charge' => :'Float',
58
+ :'amount_excluding_vat' => :'Float',
59
+ :'vat' => :'VATDetails',
60
+ :'accounting' => :'AccountingDetails1'
61
+ }
62
+ end
63
+
64
+ # Initializes the object
65
+ # @param [Hash] attributes Model attributes in the form of hash
66
+ def initialize(attributes = {})
67
+ return unless attributes.is_a?(Hash)
68
+
69
+ # convert string to symbol for hash key
70
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
71
+
72
+ if attributes.has_key?(:'description')
73
+ self.description = attributes[:'description']
74
+ end
75
+
76
+ if attributes.has_key?(:'price_amount')
77
+ self.price_amount = attributes[:'price_amount']
78
+ end
79
+
80
+ if attributes.has_key?(:'quantity')
81
+ self.quantity = attributes[:'quantity']
82
+ end
83
+
84
+ if attributes.has_key?(:'allowance_charge')
85
+ self.allowance_charge = attributes[:'allowance_charge']
86
+ end
87
+
88
+ if attributes.has_key?(:'amount_excluding_vat')
89
+ self.amount_excluding_vat = attributes[:'amount_excluding_vat']
90
+ end
91
+
92
+ if attributes.has_key?(:'vat')
93
+ self.vat = attributes[:'vat']
94
+ end
95
+
96
+ if attributes.has_key?(:'accounting')
97
+ self.accounting = attributes[:'accounting']
98
+ end
99
+
100
+ end
101
+
102
+ # Show invalid properties with the reasons. Usually used together with valid?
103
+ # @return Array for valid properties with the reasons
104
+ def list_invalid_properties
105
+ invalid_properties = Array.new
106
+ return invalid_properties
107
+ end
108
+
109
+ # Check to see if the all the properties in the model are valid
110
+ # @return true if the model is valid
111
+ def valid?
112
+ return true
113
+ end
114
+
115
+ # Checks equality by comparing each attribute.
116
+ # @param [Object] Object to be compared
117
+ def ==(o)
118
+ return true if self.equal?(o)
119
+ self.class == o.class &&
120
+ description == o.description &&
121
+ price_amount == o.price_amount &&
122
+ quantity == o.quantity &&
123
+ allowance_charge == o.allowance_charge &&
124
+ amount_excluding_vat == o.amount_excluding_vat &&
125
+ vat == o.vat &&
126
+ accounting == o.accounting
127
+ end
128
+
129
+ # @see the `==` method
130
+ # @param [Object] Object to be compared
131
+ def eql?(o)
132
+ self == o
133
+ end
134
+
135
+ # Calculates hash code according to all attributes.
136
+ # @return [Fixnum] Hash code
137
+ def hash
138
+ [description, price_amount, quantity, allowance_charge, amount_excluding_vat, vat, accounting].hash
139
+ end
140
+
141
+ # Builds the object from hash
142
+ # @param [Hash] attributes Model attributes in the form of hash
143
+ # @return [Object] Returns the model itself
144
+ def build_from_hash(attributes)
145
+ return nil unless attributes.is_a?(Hash)
146
+ self.class.swagger_types.each_pair do |key, type|
147
+ if type =~ /\AArray<(.*)>/i
148
+ # check to ensure the input is an array given that the the attribute
149
+ # is documented as an array but the input is not
150
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
151
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
152
+ end
153
+ elsif !attributes[self.class.attribute_map[key]].nil?
154
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
155
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
156
+ end
157
+
158
+ self
159
+ end
160
+
161
+ # Deserializes the data based on type
162
+ # @param string type Data type
163
+ # @param string value Value to be deserialized
164
+ # @return [Object] Deserialized data
165
+ def _deserialize(type, value)
166
+ case type.to_sym
167
+ when :DateTime
168
+ DateTime.parse(value)
169
+ when :Date
170
+ Date.parse(value)
171
+ when :String
172
+ value.to_s
173
+ when :Integer
174
+ value.to_i
175
+ when :Float
176
+ value.to_f
177
+ when :BOOLEAN
178
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
179
+ true
180
+ else
181
+ false
182
+ end
183
+ when :Object
184
+ # generic object (usually a Hash), return directly
185
+ value
186
+ when /\AArray<(?<inner_type>.+)>\z/
187
+ inner_type = Regexp.last_match[:inner_type]
188
+ value.map { |v| _deserialize(inner_type, v) }
189
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
190
+ k_type = Regexp.last_match[:k_type]
191
+ v_type = Regexp.last_match[:v_type]
192
+ {}.tap do |hash|
193
+ value.each do |k, v|
194
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
195
+ end
196
+ end
197
+ else # model
198
+ temp_model = StorecoveApi.const_get(type).new
199
+ temp_model.build_from_hash(value)
200
+ end
201
+ end
202
+
203
+ # Returns the string representation of the object
204
+ # @return [String] String presentation of the object
205
+ def to_s
206
+ to_hash.to_s
207
+ end
208
+
209
+ # to_body is an alias to to_hash (backward compatibility)
210
+ # @return [Hash] Returns the object in the form of hash
211
+ def to_body
212
+ to_hash
213
+ end
214
+
215
+ # Returns the object in the form of hash
216
+ # @return [Hash] Returns the object in the form of hash
217
+ def to_hash
218
+ hash = {}
219
+ self.class.attribute_map.each_pair do |attr, param|
220
+ value = self.send(attr)
221
+ next if value.nil?
222
+ hash[param] = _to_hash(value)
223
+ end
224
+ hash
225
+ end
226
+
227
+ # Outputs non-array value in the form of hash
228
+ # For object, use to_hash. Otherwise, just return the value
229
+ # @param [Object] value Any valid value
230
+ # @return [Hash] Returns the value in the form of hash
231
+ def _to_hash(value)
232
+ if value.is_a?(Array)
233
+ value.compact.map{ |v| _to_hash(v) }
234
+ elsif value.is_a?(Hash)
235
+ {}.tap do |hash|
236
+ value.each { |k, v| hash[k] = _to_hash(v) }
237
+ end
238
+ elsif value.respond_to? :to_hash
239
+ value.to_hash
240
+ else
241
+ value
242
+ end
243
+ end
244
+
245
+ end
246
+
247
+ end
@@ -0,0 +1,280 @@
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
+
17
+ class PurchaseInvoiceSender
18
+ # The party who sent the invoice.
19
+ attr_accessor :party_name
20
+
21
+ # The department who sent the invoice.
22
+ attr_accessor :department
23
+
24
+ # The address
25
+ attr_accessor :line1
26
+
27
+ # The address, line 2
28
+ attr_accessor :line2
29
+
30
+ # The zip code.
31
+ attr_accessor :zip
32
+
33
+ # The city.
34
+ attr_accessor :city
35
+
36
+ # The county.
37
+ attr_accessor :county
38
+
39
+ # The country.
40
+ attr_accessor :country
41
+
42
+ # The billing contact for the invoice.
43
+ attr_accessor :billing_contact
44
+
45
+ attr_accessor :peppol_identifiers
46
+
47
+
48
+ # Attribute mapping from ruby-style variable name to JSON key.
49
+ def self.attribute_map
50
+ {
51
+ :'party_name' => :'party_name',
52
+ :'department' => :'department',
53
+ :'line1' => :'line1',
54
+ :'line2' => :'line2',
55
+ :'zip' => :'zip',
56
+ :'city' => :'city',
57
+ :'county' => :'county',
58
+ :'country' => :'country',
59
+ :'billing_contact' => :'billing_contact',
60
+ :'peppol_identifiers' => :'peppol_identifiers'
61
+ }
62
+ end
63
+
64
+ # Attribute type mapping.
65
+ def self.swagger_types
66
+ {
67
+ :'party_name' => :'String',
68
+ :'department' => :'String',
69
+ :'line1' => :'String',
70
+ :'line2' => :'String',
71
+ :'zip' => :'String',
72
+ :'city' => :'String',
73
+ :'county' => :'String',
74
+ :'country' => :'String',
75
+ :'billing_contact' => :'PurchaseInvoiceSenderBillingContact',
76
+ :'peppol_identifiers' => :'Array<PeppolIdentifier>'
77
+ }
78
+ end
79
+
80
+ # Initializes the object
81
+ # @param [Hash] attributes Model attributes in the form of hash
82
+ def initialize(attributes = {})
83
+ return unless attributes.is_a?(Hash)
84
+
85
+ # convert string to symbol for hash key
86
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
87
+
88
+ if attributes.has_key?(:'party_name')
89
+ self.party_name = attributes[:'party_name']
90
+ end
91
+
92
+ if attributes.has_key?(:'department')
93
+ self.department = attributes[:'department']
94
+ end
95
+
96
+ if attributes.has_key?(:'line1')
97
+ self.line1 = attributes[:'line1']
98
+ end
99
+
100
+ if attributes.has_key?(:'line2')
101
+ self.line2 = attributes[:'line2']
102
+ end
103
+
104
+ if attributes.has_key?(:'zip')
105
+ self.zip = attributes[:'zip']
106
+ end
107
+
108
+ if attributes.has_key?(:'city')
109
+ self.city = attributes[:'city']
110
+ end
111
+
112
+ if attributes.has_key?(:'county')
113
+ self.county = attributes[:'county']
114
+ end
115
+
116
+ if attributes.has_key?(:'country')
117
+ self.country = attributes[:'country']
118
+ end
119
+
120
+ if attributes.has_key?(:'billing_contact')
121
+ self.billing_contact = attributes[:'billing_contact']
122
+ end
123
+
124
+ if attributes.has_key?(:'peppol_identifiers')
125
+ if (value = attributes[:'peppol_identifiers']).is_a?(Array)
126
+ self.peppol_identifiers = value
127
+ end
128
+ end
129
+
130
+ end
131
+
132
+ # Show invalid properties with the reasons. Usually used together with valid?
133
+ # @return Array for valid properties with the reasons
134
+ def list_invalid_properties
135
+ invalid_properties = Array.new
136
+ return invalid_properties
137
+ end
138
+
139
+ # Check to see if the all the properties in the model are valid
140
+ # @return true if the model is valid
141
+ def valid?
142
+ return true
143
+ end
144
+
145
+ # Checks equality by comparing each attribute.
146
+ # @param [Object] Object to be compared
147
+ def ==(o)
148
+ return true if self.equal?(o)
149
+ self.class == o.class &&
150
+ party_name == o.party_name &&
151
+ department == o.department &&
152
+ line1 == o.line1 &&
153
+ line2 == o.line2 &&
154
+ zip == o.zip &&
155
+ city == o.city &&
156
+ county == o.county &&
157
+ country == o.country &&
158
+ billing_contact == o.billing_contact &&
159
+ peppol_identifiers == o.peppol_identifiers
160
+ end
161
+
162
+ # @see the `==` method
163
+ # @param [Object] Object to be compared
164
+ def eql?(o)
165
+ self == o
166
+ end
167
+
168
+ # Calculates hash code according to all attributes.
169
+ # @return [Fixnum] Hash code
170
+ def hash
171
+ [party_name, department, line1, line2, zip, city, county, country, billing_contact, peppol_identifiers].hash
172
+ end
173
+
174
+ # Builds the object from hash
175
+ # @param [Hash] attributes Model attributes in the form of hash
176
+ # @return [Object] Returns the model itself
177
+ def build_from_hash(attributes)
178
+ return nil unless attributes.is_a?(Hash)
179
+ self.class.swagger_types.each_pair do |key, type|
180
+ if type =~ /\AArray<(.*)>/i
181
+ # check to ensure the input is an array given that the the attribute
182
+ # is documented as an array but the input is not
183
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
184
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
185
+ end
186
+ elsif !attributes[self.class.attribute_map[key]].nil?
187
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
188
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
189
+ end
190
+
191
+ self
192
+ end
193
+
194
+ # Deserializes the data based on type
195
+ # @param string type Data type
196
+ # @param string value Value to be deserialized
197
+ # @return [Object] Deserialized data
198
+ def _deserialize(type, value)
199
+ case type.to_sym
200
+ when :DateTime
201
+ DateTime.parse(value)
202
+ when :Date
203
+ Date.parse(value)
204
+ when :String
205
+ value.to_s
206
+ when :Integer
207
+ value.to_i
208
+ when :Float
209
+ value.to_f
210
+ when :BOOLEAN
211
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
212
+ true
213
+ else
214
+ false
215
+ end
216
+ when :Object
217
+ # generic object (usually a Hash), return directly
218
+ value
219
+ when /\AArray<(?<inner_type>.+)>\z/
220
+ inner_type = Regexp.last_match[:inner_type]
221
+ value.map { |v| _deserialize(inner_type, v) }
222
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
223
+ k_type = Regexp.last_match[:k_type]
224
+ v_type = Regexp.last_match[:v_type]
225
+ {}.tap do |hash|
226
+ value.each do |k, v|
227
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
228
+ end
229
+ end
230
+ else # model
231
+ temp_model = StorecoveApi.const_get(type).new
232
+ temp_model.build_from_hash(value)
233
+ end
234
+ end
235
+
236
+ # Returns the string representation of the object
237
+ # @return [String] String presentation of the object
238
+ def to_s
239
+ to_hash.to_s
240
+ end
241
+
242
+ # to_body is an alias to to_hash (backward compatibility)
243
+ # @return [Hash] Returns the object in the form of hash
244
+ def to_body
245
+ to_hash
246
+ end
247
+
248
+ # Returns the object in the form of hash
249
+ # @return [Hash] Returns the object in the form of hash
250
+ def to_hash
251
+ hash = {}
252
+ self.class.attribute_map.each_pair do |attr, param|
253
+ value = self.send(attr)
254
+ next if value.nil?
255
+ hash[param] = _to_hash(value)
256
+ end
257
+ hash
258
+ end
259
+
260
+ # Outputs non-array value in the form of hash
261
+ # For object, use to_hash. Otherwise, just return the value
262
+ # @param [Object] value Any valid value
263
+ # @return [Hash] Returns the value in the form of hash
264
+ def _to_hash(value)
265
+ if value.is_a?(Array)
266
+ value.compact.map{ |v| _to_hash(v) }
267
+ elsif value.is_a?(Hash)
268
+ {}.tap do |hash|
269
+ value.each { |k, v| hash[k] = _to_hash(v) }
270
+ end
271
+ elsif value.respond_to? :to_hash
272
+ value.to_hash
273
+ else
274
+ value
275
+ end
276
+ end
277
+
278
+ end
279
+
280
+ end