storecove 1.0.9 → 1.0.10

Sign up to get free protection for your applications and to get access to all the features.
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,284 @@
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 PeppolIdentifier
18
+ # The identifier.
19
+ attr_accessor :identifier
20
+
21
+ # The scheme of the identifier. See <<_company>> for a list.
22
+ attr_accessor :scheme
23
+
24
+ # The superscheme of the identifier. Should always be \"iso6523-actorid-upis\".
25
+ attr_accessor :superscheme
26
+
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'identifier' => :'identifier',
32
+ :'scheme' => :'scheme',
33
+ :'superscheme' => :'superscheme'
34
+ }
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.swagger_types
39
+ {
40
+ :'identifier' => :'String',
41
+ :'scheme' => :'String',
42
+ :'superscheme' => :'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?(:'identifier')
55
+ self.identifier = attributes[:'identifier']
56
+ end
57
+
58
+ if attributes.has_key?(:'scheme')
59
+ self.scheme = attributes[:'scheme']
60
+ end
61
+
62
+ if attributes.has_key?(:'superscheme')
63
+ self.superscheme = attributes[:'superscheme']
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
+ if !@identifier.nil? && @identifier.to_s.length > 64
73
+ invalid_properties.push("invalid value for 'identifier', the character length must be smaller than or equal to 64.")
74
+ end
75
+
76
+ if !@identifier.nil? && @identifier.to_s.length < 2
77
+ invalid_properties.push("invalid value for 'identifier', the character length must be great than or equal to 2.")
78
+ end
79
+
80
+ if !@scheme.nil? && @scheme.to_s.length > 64
81
+ invalid_properties.push("invalid value for 'scheme', the character length must be smaller than or equal to 64.")
82
+ end
83
+
84
+ if !@scheme.nil? && @scheme.to_s.length < 2
85
+ invalid_properties.push("invalid value for 'scheme', the character length must be great than or equal to 2.")
86
+ end
87
+
88
+ if !@superscheme.nil? && @superscheme.to_s.length > 64
89
+ invalid_properties.push("invalid value for 'superscheme', the character length must be smaller than or equal to 64.")
90
+ end
91
+
92
+ if !@superscheme.nil? && @superscheme.to_s.length < 2
93
+ invalid_properties.push("invalid value for 'superscheme', the character length must be great than or equal to 2.")
94
+ end
95
+
96
+ return invalid_properties
97
+ end
98
+
99
+ # Check to see if the all the properties in the model are valid
100
+ # @return true if the model is valid
101
+ def valid?
102
+ return false if !@identifier.nil? && @identifier.to_s.length > 64
103
+ return false if !@identifier.nil? && @identifier.to_s.length < 2
104
+ return false if !@scheme.nil? && @scheme.to_s.length > 64
105
+ return false if !@scheme.nil? && @scheme.to_s.length < 2
106
+ return false if !@superscheme.nil? && @superscheme.to_s.length > 64
107
+ return false if !@superscheme.nil? && @superscheme.to_s.length < 2
108
+ return true
109
+ end
110
+
111
+ # Custom attribute writer method with validation
112
+ # @param [Object] identifier Value to be assigned
113
+ def identifier=(identifier)
114
+
115
+ if !identifier.nil? && identifier.to_s.length > 64
116
+ fail ArgumentError, "invalid value for 'identifier', the character length must be smaller than or equal to 64."
117
+ end
118
+
119
+ if !identifier.nil? && identifier.to_s.length < 2
120
+ fail ArgumentError, "invalid value for 'identifier', the character length must be great than or equal to 2."
121
+ end
122
+
123
+ @identifier = identifier
124
+ end
125
+
126
+ # Custom attribute writer method with validation
127
+ # @param [Object] scheme Value to be assigned
128
+ def scheme=(scheme)
129
+
130
+ if !scheme.nil? && scheme.to_s.length > 64
131
+ fail ArgumentError, "invalid value for 'scheme', the character length must be smaller than or equal to 64."
132
+ end
133
+
134
+ if !scheme.nil? && scheme.to_s.length < 2
135
+ fail ArgumentError, "invalid value for 'scheme', the character length must be great than or equal to 2."
136
+ end
137
+
138
+ @scheme = scheme
139
+ end
140
+
141
+ # Custom attribute writer method with validation
142
+ # @param [Object] superscheme Value to be assigned
143
+ def superscheme=(superscheme)
144
+
145
+ if !superscheme.nil? && superscheme.to_s.length > 64
146
+ fail ArgumentError, "invalid value for 'superscheme', the character length must be smaller than or equal to 64."
147
+ end
148
+
149
+ if !superscheme.nil? && superscheme.to_s.length < 2
150
+ fail ArgumentError, "invalid value for 'superscheme', the character length must be great than or equal to 2."
151
+ end
152
+
153
+ @superscheme = superscheme
154
+ end
155
+
156
+ # Checks equality by comparing each attribute.
157
+ # @param [Object] Object to be compared
158
+ def ==(o)
159
+ return true if self.equal?(o)
160
+ self.class == o.class &&
161
+ identifier == o.identifier &&
162
+ scheme == o.scheme &&
163
+ superscheme == o.superscheme
164
+ end
165
+
166
+ # @see the `==` method
167
+ # @param [Object] Object to be compared
168
+ def eql?(o)
169
+ self == o
170
+ end
171
+
172
+ # Calculates hash code according to all attributes.
173
+ # @return [Fixnum] Hash code
174
+ def hash
175
+ [identifier, scheme, superscheme].hash
176
+ end
177
+
178
+ # Builds the object from hash
179
+ # @param [Hash] attributes Model attributes in the form of hash
180
+ # @return [Object] Returns the model itself
181
+ def build_from_hash(attributes)
182
+ return nil unless attributes.is_a?(Hash)
183
+ self.class.swagger_types.each_pair do |key, type|
184
+ if type =~ /\AArray<(.*)>/i
185
+ # check to ensure the input is an array given that the the attribute
186
+ # is documented as an array but the input is not
187
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
188
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
189
+ end
190
+ elsif !attributes[self.class.attribute_map[key]].nil?
191
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
192
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
193
+ end
194
+
195
+ self
196
+ end
197
+
198
+ # Deserializes the data based on type
199
+ # @param string type Data type
200
+ # @param string value Value to be deserialized
201
+ # @return [Object] Deserialized data
202
+ def _deserialize(type, value)
203
+ case type.to_sym
204
+ when :DateTime
205
+ DateTime.parse(value)
206
+ when :Date
207
+ Date.parse(value)
208
+ when :String
209
+ value.to_s
210
+ when :Integer
211
+ value.to_i
212
+ when :Float
213
+ value.to_f
214
+ when :BOOLEAN
215
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
216
+ true
217
+ else
218
+ false
219
+ end
220
+ when :Object
221
+ # generic object (usually a Hash), return directly
222
+ value
223
+ when /\AArray<(?<inner_type>.+)>\z/
224
+ inner_type = Regexp.last_match[:inner_type]
225
+ value.map { |v| _deserialize(inner_type, v) }
226
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
227
+ k_type = Regexp.last_match[:k_type]
228
+ v_type = Regexp.last_match[:v_type]
229
+ {}.tap do |hash|
230
+ value.each do |k, v|
231
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
232
+ end
233
+ end
234
+ else # model
235
+ temp_model = StorecoveApi.const_get(type).new
236
+ temp_model.build_from_hash(value)
237
+ end
238
+ end
239
+
240
+ # Returns the string representation of the object
241
+ # @return [String] String presentation of the object
242
+ def to_s
243
+ to_hash.to_s
244
+ end
245
+
246
+ # to_body is an alias to to_hash (backward compatibility)
247
+ # @return [Hash] Returns the object in the form of hash
248
+ def to_body
249
+ to_hash
250
+ end
251
+
252
+ # Returns the object in the form of hash
253
+ # @return [Hash] Returns the object in the form of hash
254
+ def to_hash
255
+ hash = {}
256
+ self.class.attribute_map.each_pair do |attr, param|
257
+ value = self.send(attr)
258
+ next if value.nil?
259
+ hash[param] = _to_hash(value)
260
+ end
261
+ hash
262
+ end
263
+
264
+ # Outputs non-array value in the form of hash
265
+ # For object, use to_hash. Otherwise, just return the value
266
+ # @param [Object] value Any valid value
267
+ # @return [Hash] Returns the value in the form of hash
268
+ def _to_hash(value)
269
+ if value.is_a?(Array)
270
+ value.compact.map{ |v| _to_hash(v) }
271
+ elsif value.is_a?(Hash)
272
+ {}.tap do |hash|
273
+ value.each { |k, v| hash[k] = _to_hash(v) }
274
+ end
275
+ elsif value.respond_to? :to_hash
276
+ value.to_hash
277
+ else
278
+ value
279
+ end
280
+ end
281
+
282
+ end
283
+
284
+ end
@@ -0,0 +1,308 @@
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 PeppolIdentifierCreate
18
+ # The identifier.
19
+ attr_accessor :identifier
20
+
21
+ # The scheme of the identifier. See <<_company>> for a list.
22
+ attr_accessor :scheme
23
+
24
+ # The superscheme of the identifier. Should always be \"iso6523-actorid-upis\".
25
+ attr_accessor :superscheme
26
+
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'identifier' => :'identifier',
32
+ :'scheme' => :'scheme',
33
+ :'superscheme' => :'superscheme'
34
+ }
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.swagger_types
39
+ {
40
+ :'identifier' => :'String',
41
+ :'scheme' => :'String',
42
+ :'superscheme' => :'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?(:'identifier')
55
+ self.identifier = attributes[:'identifier']
56
+ end
57
+
58
+ if attributes.has_key?(:'scheme')
59
+ self.scheme = attributes[:'scheme']
60
+ end
61
+
62
+ if attributes.has_key?(:'superscheme')
63
+ self.superscheme = attributes[:'superscheme']
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
+ if @identifier.nil?
73
+ invalid_properties.push("invalid value for 'identifier', identifier cannot be nil.")
74
+ end
75
+
76
+ if @identifier.to_s.length > 64
77
+ invalid_properties.push("invalid value for 'identifier', the character length must be smaller than or equal to 64.")
78
+ end
79
+
80
+ if @identifier.to_s.length < 2
81
+ invalid_properties.push("invalid value for 'identifier', the character length must be great than or equal to 2.")
82
+ end
83
+
84
+ if @scheme.nil?
85
+ invalid_properties.push("invalid value for 'scheme', scheme cannot be nil.")
86
+ end
87
+
88
+ if @scheme.to_s.length > 64
89
+ invalid_properties.push("invalid value for 'scheme', the character length must be smaller than or equal to 64.")
90
+ end
91
+
92
+ if @scheme.to_s.length < 2
93
+ invalid_properties.push("invalid value for 'scheme', the character length must be great than or equal to 2.")
94
+ end
95
+
96
+ if @superscheme.nil?
97
+ invalid_properties.push("invalid value for 'superscheme', superscheme cannot be nil.")
98
+ end
99
+
100
+ if @superscheme.to_s.length > 64
101
+ invalid_properties.push("invalid value for 'superscheme', the character length must be smaller than or equal to 64.")
102
+ end
103
+
104
+ if @superscheme.to_s.length < 2
105
+ invalid_properties.push("invalid value for 'superscheme', the character length must be great than or equal to 2.")
106
+ end
107
+
108
+ return invalid_properties
109
+ end
110
+
111
+ # Check to see if the all the properties in the model are valid
112
+ # @return true if the model is valid
113
+ def valid?
114
+ return false if @identifier.nil?
115
+ return false if @identifier.to_s.length > 64
116
+ return false if @identifier.to_s.length < 2
117
+ return false if @scheme.nil?
118
+ return false if @scheme.to_s.length > 64
119
+ return false if @scheme.to_s.length < 2
120
+ return false if @superscheme.nil?
121
+ return false if @superscheme.to_s.length > 64
122
+ return false if @superscheme.to_s.length < 2
123
+ return true
124
+ end
125
+
126
+ # Custom attribute writer method with validation
127
+ # @param [Object] identifier Value to be assigned
128
+ def identifier=(identifier)
129
+ if identifier.nil?
130
+ fail ArgumentError, "identifier cannot be nil"
131
+ end
132
+
133
+ if identifier.to_s.length > 64
134
+ fail ArgumentError, "invalid value for 'identifier', the character length must be smaller than or equal to 64."
135
+ end
136
+
137
+ if identifier.to_s.length < 2
138
+ fail ArgumentError, "invalid value for 'identifier', the character length must be great than or equal to 2."
139
+ end
140
+
141
+ @identifier = identifier
142
+ end
143
+
144
+ # Custom attribute writer method with validation
145
+ # @param [Object] scheme Value to be assigned
146
+ def scheme=(scheme)
147
+ if scheme.nil?
148
+ fail ArgumentError, "scheme cannot be nil"
149
+ end
150
+
151
+ if scheme.to_s.length > 64
152
+ fail ArgumentError, "invalid value for 'scheme', the character length must be smaller than or equal to 64."
153
+ end
154
+
155
+ if scheme.to_s.length < 2
156
+ fail ArgumentError, "invalid value for 'scheme', the character length must be great than or equal to 2."
157
+ end
158
+
159
+ @scheme = scheme
160
+ end
161
+
162
+ # Custom attribute writer method with validation
163
+ # @param [Object] superscheme Value to be assigned
164
+ def superscheme=(superscheme)
165
+ if superscheme.nil?
166
+ fail ArgumentError, "superscheme cannot be nil"
167
+ end
168
+
169
+ if superscheme.to_s.length > 64
170
+ fail ArgumentError, "invalid value for 'superscheme', the character length must be smaller than or equal to 64."
171
+ end
172
+
173
+ if superscheme.to_s.length < 2
174
+ fail ArgumentError, "invalid value for 'superscheme', the character length must be great than or equal to 2."
175
+ end
176
+
177
+ @superscheme = superscheme
178
+ end
179
+
180
+ # Checks equality by comparing each attribute.
181
+ # @param [Object] Object to be compared
182
+ def ==(o)
183
+ return true if self.equal?(o)
184
+ self.class == o.class &&
185
+ identifier == o.identifier &&
186
+ scheme == o.scheme &&
187
+ superscheme == o.superscheme
188
+ end
189
+
190
+ # @see the `==` method
191
+ # @param [Object] Object to be compared
192
+ def eql?(o)
193
+ self == o
194
+ end
195
+
196
+ # Calculates hash code according to all attributes.
197
+ # @return [Fixnum] Hash code
198
+ def hash
199
+ [identifier, scheme, superscheme].hash
200
+ end
201
+
202
+ # Builds the object from hash
203
+ # @param [Hash] attributes Model attributes in the form of hash
204
+ # @return [Object] Returns the model itself
205
+ def build_from_hash(attributes)
206
+ return nil unless attributes.is_a?(Hash)
207
+ self.class.swagger_types.each_pair do |key, type|
208
+ if type =~ /\AArray<(.*)>/i
209
+ # check to ensure the input is an array given that the the attribute
210
+ # is documented as an array but the input is not
211
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
212
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
213
+ end
214
+ elsif !attributes[self.class.attribute_map[key]].nil?
215
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
216
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
217
+ end
218
+
219
+ self
220
+ end
221
+
222
+ # Deserializes the data based on type
223
+ # @param string type Data type
224
+ # @param string value Value to be deserialized
225
+ # @return [Object] Deserialized data
226
+ def _deserialize(type, value)
227
+ case type.to_sym
228
+ when :DateTime
229
+ DateTime.parse(value)
230
+ when :Date
231
+ Date.parse(value)
232
+ when :String
233
+ value.to_s
234
+ when :Integer
235
+ value.to_i
236
+ when :Float
237
+ value.to_f
238
+ when :BOOLEAN
239
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
240
+ true
241
+ else
242
+ false
243
+ end
244
+ when :Object
245
+ # generic object (usually a Hash), return directly
246
+ value
247
+ when /\AArray<(?<inner_type>.+)>\z/
248
+ inner_type = Regexp.last_match[:inner_type]
249
+ value.map { |v| _deserialize(inner_type, v) }
250
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
251
+ k_type = Regexp.last_match[:k_type]
252
+ v_type = Regexp.last_match[:v_type]
253
+ {}.tap do |hash|
254
+ value.each do |k, v|
255
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
256
+ end
257
+ end
258
+ else # model
259
+ temp_model = StorecoveApi.const_get(type).new
260
+ temp_model.build_from_hash(value)
261
+ end
262
+ end
263
+
264
+ # Returns the string representation of the object
265
+ # @return [String] String presentation of the object
266
+ def to_s
267
+ to_hash.to_s
268
+ end
269
+
270
+ # to_body is an alias to to_hash (backward compatibility)
271
+ # @return [Hash] Returns the object in the form of hash
272
+ def to_body
273
+ to_hash
274
+ end
275
+
276
+ # Returns the object in the form of hash
277
+ # @return [Hash] Returns the object in the form of hash
278
+ def to_hash
279
+ hash = {}
280
+ self.class.attribute_map.each_pair do |attr, param|
281
+ value = self.send(attr)
282
+ next if value.nil?
283
+ hash[param] = _to_hash(value)
284
+ end
285
+ hash
286
+ end
287
+
288
+ # Outputs non-array value in the form of hash
289
+ # For object, use to_hash. Otherwise, just return the value
290
+ # @param [Object] value Any valid value
291
+ # @return [Hash] Returns the value in the form of hash
292
+ def _to_hash(value)
293
+ if value.is_a?(Array)
294
+ value.compact.map{ |v| _to_hash(v) }
295
+ elsif value.is_a?(Hash)
296
+ {}.tap do |hash|
297
+ value.each { |k, v| hash[k] = _to_hash(v) }
298
+ end
299
+ elsif value.respond_to? :to_hash
300
+ value.to_hash
301
+ else
302
+ value
303
+ end
304
+ end
305
+
306
+ end
307
+
308
+ end