postfinancecheckout-ruby-sdk 3.1.4 → 3.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +4 -4
  3. data/lib/postfinancecheckout-ruby-sdk/api/analytics_query_service_api.rb +381 -0
  4. data/lib/postfinancecheckout-ruby-sdk/models/analytics_query.rb +272 -0
  5. data/lib/postfinancecheckout-ruby-sdk/models/analytics_query_execution.rb +293 -0
  6. data/lib/postfinancecheckout-ruby-sdk/models/analytics_query_execution_state.rb +37 -0
  7. data/lib/postfinancecheckout-ruby-sdk/models/analytics_query_result_batch.rb +225 -0
  8. data/lib/postfinancecheckout-ruby-sdk/models/analytics_schema_column.rb +263 -0
  9. data/lib/postfinancecheckout-ruby-sdk/models/analytics_schema_table.rb +215 -0
  10. data/lib/postfinancecheckout-ruby-sdk/models/rendered_document.rb +17 -5
  11. data/lib/postfinancecheckout-ruby-sdk/models/rendered_terminal_receipt.rb +17 -5
  12. data/lib/postfinancecheckout-ruby-sdk/models/rendered_terminal_transaction_summary.rb +17 -5
  13. data/lib/postfinancecheckout-ruby-sdk/version.rb +1 -1
  14. data/lib/postfinancecheckout-ruby-sdk.rb +7 -0
  15. data/vendor/bundle/ruby/2.4.0/cache/addressable-2.8.1.gem +0 -0
  16. data/vendor/bundle/ruby/2.4.0/extensions/x86_64-linux/2.4.0/ffi-1.15.5/gem_make.out +2 -2
  17. data/vendor/bundle/ruby/2.4.0/extensions/x86_64-linux/2.4.0/json-2.6.2/gem_make.out +1 -1
  18. data/vendor/bundle/ruby/2.4.0/extensions/x86_64-linux/2.4.0/json-2.6.2/mkmf.log +1 -1
  19. data/vendor/bundle/ruby/2.4.0/gems/{addressable-2.8.0 → addressable-2.8.1}/CHANGELOG.md +16 -0
  20. data/vendor/bundle/ruby/2.4.0/gems/{addressable-2.8.0 → addressable-2.8.1}/Gemfile +4 -2
  21. data/vendor/bundle/ruby/2.4.0/gems/{addressable-2.8.0 → addressable-2.8.1}/LICENSE.txt +0 -0
  22. data/vendor/bundle/ruby/2.4.0/gems/{addressable-2.8.0 → addressable-2.8.1}/README.md +0 -0
  23. data/vendor/bundle/ruby/2.4.0/gems/{addressable-2.8.0 → addressable-2.8.1}/Rakefile +0 -0
  24. data/vendor/bundle/ruby/2.4.0/gems/{addressable-2.8.0 → addressable-2.8.1}/data/unicode.data +0 -0
  25. data/vendor/bundle/ruby/2.4.0/gems/{addressable-2.8.0 → addressable-2.8.1}/lib/addressable/idna/native.rb +0 -1
  26. data/vendor/bundle/ruby/2.4.0/gems/{addressable-2.8.0 → addressable-2.8.1}/lib/addressable/idna/pure.rb +0 -1
  27. data/vendor/bundle/ruby/2.4.0/gems/{addressable-2.8.0 → addressable-2.8.1}/lib/addressable/idna.rb +0 -1
  28. data/vendor/bundle/ruby/2.4.0/gems/{addressable-2.8.0 → addressable-2.8.1}/lib/addressable/template.rb +3 -4
  29. data/vendor/bundle/ruby/2.4.0/gems/{addressable-2.8.0 → addressable-2.8.1}/lib/addressable/uri.rb +57 -53
  30. data/vendor/bundle/ruby/2.4.0/gems/{addressable-2.8.0 → addressable-2.8.1}/lib/addressable/version.rb +1 -2
  31. data/vendor/bundle/ruby/2.4.0/gems/{addressable-2.8.0 → addressable-2.8.1}/lib/addressable.rb +0 -0
  32. data/vendor/bundle/ruby/2.4.0/gems/{addressable-2.8.0 → addressable-2.8.1}/spec/addressable/idna_spec.rb +0 -1
  33. data/vendor/bundle/ruby/2.4.0/gems/{addressable-2.8.0 → addressable-2.8.1}/spec/addressable/net_http_compat_spec.rb +0 -1
  34. data/vendor/bundle/ruby/2.4.0/gems/{addressable-2.8.0 → addressable-2.8.1}/spec/addressable/security_spec.rb +0 -1
  35. data/vendor/bundle/ruby/2.4.0/gems/{addressable-2.8.0 → addressable-2.8.1}/spec/addressable/template_spec.rb +9 -1
  36. data/vendor/bundle/ruby/2.4.0/gems/{addressable-2.8.0 → addressable-2.8.1}/spec/addressable/uri_spec.rb +81 -1
  37. data/vendor/bundle/ruby/2.4.0/gems/{addressable-2.8.0 → addressable-2.8.1}/spec/spec_helper.rb +0 -0
  38. data/vendor/bundle/ruby/2.4.0/gems/{addressable-2.8.0 → addressable-2.8.1}/tasks/clobber.rake +0 -0
  39. data/vendor/bundle/ruby/2.4.0/gems/{addressable-2.8.0 → addressable-2.8.1}/tasks/gem.rake +5 -2
  40. data/vendor/bundle/ruby/2.4.0/gems/{addressable-2.8.0 → addressable-2.8.1}/tasks/git.rake +0 -0
  41. data/vendor/bundle/ruby/2.4.0/gems/{addressable-2.8.0 → addressable-2.8.1}/tasks/metrics.rake +0 -0
  42. data/vendor/bundle/ruby/2.4.0/gems/{addressable-2.8.0 → addressable-2.8.1}/tasks/profile.rake +0 -0
  43. data/vendor/bundle/ruby/2.4.0/gems/{addressable-2.8.0 → addressable-2.8.1}/tasks/rspec.rake +0 -0
  44. data/vendor/bundle/ruby/2.4.0/gems/{addressable-2.8.0 → addressable-2.8.1}/tasks/yard.rake +0 -0
  45. data/vendor/bundle/ruby/2.4.0/gems/ffi-1.15.5/ext/ffi_c/Makefile +3 -3
  46. data/vendor/bundle/ruby/2.4.0/gems/json-2.6.2/ext/json/Makefile +2 -2
  47. data/vendor/bundle/ruby/2.4.0/gems/json-2.6.2/ext/json/ext/generator/Makefile +2 -2
  48. data/vendor/bundle/ruby/2.4.0/gems/json-2.6.2/ext/json/ext/parser/Makefile +2 -2
  49. data/vendor/bundle/ruby/2.4.0/specifications/{addressable-2.8.0.gemspec → addressable-2.8.1.gemspec} +8 -7
  50. metadata +37 -31
  51. data/vendor/bundle/ruby/2.4.0/cache/addressable-2.8.0.gem +0 -0
  52. data/vendor/bundle/ruby/2.4.0/gems/addressable-2.8.0/addressable.gemspec +0 -37
@@ -0,0 +1,293 @@
1
+ =begin
2
+ The PostFinance Checkout API allows an easy interaction with the PostFinance Checkout web service.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+
16
+ =end
17
+
18
+ require 'date'
19
+
20
+ module PostFinanceCheckout
21
+ # Represents the execution of a query which has been submitted to Analytics.
22
+ class AnalyticsQueryExecution
23
+ # The account in which the query has been executed.
24
+ attr_accessor :account
25
+
26
+ # The External ID of the query if one had been specified; otherwise null.
27
+ attr_accessor :external_id
28
+
29
+ # The reason of the failure if and only if the query has failed, otherwise null.
30
+ attr_accessor :failure_reason
31
+
32
+ # The ID is the primary key of the entity. The ID identifies the entity uniquely.
33
+ attr_accessor :id
34
+
35
+ # The time at which processing of the query has finished (either successfully or by failure or by cancelation). Will be null if the query execution has not finished yet.
36
+ attr_accessor :processing_end_time
37
+
38
+ # The time at which processing of the query has started (never null).
39
+ attr_accessor :processing_start_time
40
+
41
+ # The SQL statement which has been submitted for execution.
42
+ attr_accessor :query_string
43
+
44
+ # The amount of data scanned while processing the query (in GB). (Note that this amount may increase over time while the query is still being processed and not finished yet.)
45
+ attr_accessor :scanned_data_in_gb
46
+
47
+ # The maximal amount of scanned data that this query is allowed to scan. After this limit is reached query will be canceled by the system.
48
+ attr_accessor :scanned_data_limit
49
+
50
+ # The spaces in which the query has been executed. May be empty if all spaces of the specified account have been queried.
51
+ attr_accessor :spaces
52
+
53
+ # The current state of the query execution.
54
+ attr_accessor :state
55
+
56
+ # Attribute mapping from ruby-style variable name to JSON key.
57
+ def self.attribute_map
58
+ {
59
+ :'account' => :'account',
60
+ :'external_id' => :'externalId',
61
+ :'failure_reason' => :'failureReason',
62
+ :'id' => :'id',
63
+ :'processing_end_time' => :'processingEndTime',
64
+ :'processing_start_time' => :'processingStartTime',
65
+ :'query_string' => :'queryString',
66
+ :'scanned_data_in_gb' => :'scannedDataInGb',
67
+ :'scanned_data_limit' => :'scannedDataLimit',
68
+ :'spaces' => :'spaces',
69
+ :'state' => :'state'
70
+ }
71
+ end
72
+
73
+ # Attribute type mapping.
74
+ def self.swagger_types
75
+ {
76
+ :'account' => :'Integer',
77
+ :'external_id' => :'String',
78
+ :'failure_reason' => :'FailureReason',
79
+ :'id' => :'Integer',
80
+ :'processing_end_time' => :'DateTime',
81
+ :'processing_start_time' => :'DateTime',
82
+ :'query_string' => :'String',
83
+ :'scanned_data_in_gb' => :'Float',
84
+ :'scanned_data_limit' => :'Float',
85
+ :'spaces' => :'Array<Integer>',
86
+ :'state' => :'AnalyticsQueryExecutionState'
87
+ }
88
+ end
89
+
90
+ # Initializes the object
91
+ # @param [Hash] attributes Model attributes in the form of hash
92
+ def initialize(attributes = {})
93
+ return unless attributes.is_a?(Hash)
94
+
95
+ # convert string to symbol for hash key
96
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
97
+
98
+ if attributes.has_key?(:'account')
99
+ self.account = attributes[:'account']
100
+ end
101
+
102
+ if attributes.has_key?(:'externalId')
103
+ self.external_id = attributes[:'externalId']
104
+ end
105
+
106
+ if attributes.has_key?(:'failureReason')
107
+ self.failure_reason = attributes[:'failureReason']
108
+ end
109
+
110
+ if attributes.has_key?(:'id')
111
+ self.id = attributes[:'id']
112
+ end
113
+
114
+ if attributes.has_key?(:'processingEndTime')
115
+ self.processing_end_time = attributes[:'processingEndTime']
116
+ end
117
+
118
+ if attributes.has_key?(:'processingStartTime')
119
+ self.processing_start_time = attributes[:'processingStartTime']
120
+ end
121
+
122
+ if attributes.has_key?(:'queryString')
123
+ self.query_string = attributes[:'queryString']
124
+ end
125
+
126
+ if attributes.has_key?(:'scannedDataInGb')
127
+ self.scanned_data_in_gb = attributes[:'scannedDataInGb']
128
+ end
129
+
130
+ if attributes.has_key?(:'scannedDataLimit')
131
+ self.scanned_data_limit = attributes[:'scannedDataLimit']
132
+ end
133
+
134
+ if attributes.has_key?(:'spaces')
135
+ if (value = attributes[:'spaces']).is_a?(Array)
136
+ self.spaces = value
137
+ end
138
+ end
139
+
140
+ if attributes.has_key?(:'state')
141
+ self.state = attributes[:'state']
142
+ end
143
+ end
144
+
145
+ # Show invalid properties with the reasons. Usually used together with valid?
146
+ # @return Array for valid properties with the reasons
147
+ def list_invalid_properties
148
+ invalid_properties = Array.new
149
+ invalid_properties
150
+ end
151
+
152
+ # Check to see if the all the properties in the model are valid
153
+ # @return true if the model is valid
154
+ def valid?
155
+ true
156
+ end
157
+
158
+ # Checks equality by comparing each attribute.
159
+ # @param [Object] Object to be compared
160
+ def ==(o)
161
+ return true if self.equal?(o)
162
+ self.class == o.class &&
163
+ account == o.account &&
164
+ external_id == o.external_id &&
165
+ failure_reason == o.failure_reason &&
166
+ id == o.id &&
167
+ processing_end_time == o.processing_end_time &&
168
+ processing_start_time == o.processing_start_time &&
169
+ query_string == o.query_string &&
170
+ scanned_data_in_gb == o.scanned_data_in_gb &&
171
+ scanned_data_limit == o.scanned_data_limit &&
172
+ spaces == o.spaces &&
173
+ state == o.state
174
+ end
175
+
176
+ # @see the `==` method
177
+ # @param [Object] Object to be compared
178
+ def eql?(o)
179
+ self == o
180
+ end
181
+
182
+ # Calculates hash code according to all attributes.
183
+ # @return [Fixnum] Hash code
184
+ def hash
185
+ [account, external_id, failure_reason, id, processing_end_time, processing_start_time, query_string, scanned_data_in_gb, scanned_data_limit, spaces, state].hash
186
+ end
187
+
188
+ # Builds the object from hash
189
+ # @param [Hash] attributes Model attributes in the form of hash
190
+ # @return [Object] Returns the model itself
191
+ def build_from_hash(attributes)
192
+ return nil unless attributes.is_a?(Hash)
193
+ self.class.swagger_types.each_pair do |key, type|
194
+ if type =~ /\AArray<(.*)>/i
195
+ # check to ensure the input is an array given that the attribute
196
+ # is documented as an array but the input is not
197
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
198
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
199
+ end
200
+ elsif !attributes[self.class.attribute_map[key]].nil?
201
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
202
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
203
+ end
204
+
205
+ self
206
+ end
207
+
208
+ # Deserializes the data based on type
209
+ # @param string type Data type
210
+ # @param string value Value to be deserialized
211
+ # @return [Object] Deserialized data
212
+ def _deserialize(type, value)
213
+ case type.to_sym
214
+ when :DateTime
215
+ DateTime.parse(value)
216
+ when :Date
217
+ Date.parse(value)
218
+ when :String
219
+ value.to_s
220
+ when :Integer
221
+ value.to_i
222
+ when :Float
223
+ value.to_f
224
+ when :BOOLEAN
225
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
226
+ true
227
+ else
228
+ false
229
+ end
230
+ when :Object
231
+ # generic object (usually a Hash), return directly
232
+ value
233
+ when /\AArray<(?<inner_type>.+)>\z/
234
+ inner_type = Regexp.last_match[:inner_type]
235
+ value.map { |v| _deserialize(inner_type, v) }
236
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
237
+ k_type = Regexp.last_match[:k_type]
238
+ v_type = Regexp.last_match[:v_type]
239
+ {}.tap do |hash|
240
+ value.each do |k, v|
241
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
242
+ end
243
+ end
244
+ else # model
245
+ temp_model = PostFinanceCheckout.const_get(type).new
246
+ temp_model.build_from_hash(value)
247
+ end
248
+ end
249
+
250
+ # Returns the string representation of the object
251
+ # @return [String] String presentation of the object
252
+ def to_s
253
+ to_hash.to_s
254
+ end
255
+
256
+ # to_body is an alias to to_hash (backward compatibility)
257
+ # @return [Hash] Returns the object in the form of hash
258
+ def to_body
259
+ to_hash
260
+ end
261
+
262
+ # Returns the object in the form of hash
263
+ # @return [Hash] Returns the object in the form of hash
264
+ def to_hash
265
+ hash = {}
266
+ self.class.attribute_map.each_pair do |attr, param|
267
+ value = self.send(attr)
268
+ next if value.nil?
269
+ hash[param] = _to_hash(value)
270
+ end
271
+ hash
272
+ end
273
+
274
+ # Outputs non-array value in the form of hash
275
+ # For object, use to_hash. Otherwise, just return the value
276
+ # @param [Object] value Any valid value
277
+ # @return [Hash] Returns the value in the form of hash
278
+ def _to_hash(value)
279
+ if value.is_a?(Array)
280
+ value.compact.map{ |v| _to_hash(v) }
281
+ elsif value.is_a?(Hash)
282
+ {}.tap do |hash|
283
+ value.each { |k, v| hash[k] = _to_hash(v) }
284
+ end
285
+ elsif value.respond_to? :to_hash
286
+ value.to_hash
287
+ else
288
+ value
289
+ end
290
+ end
291
+
292
+ end
293
+ end
@@ -0,0 +1,37 @@
1
+ =begin
2
+ The PostFinance Checkout API allows an easy interaction with the PostFinance Checkout web service.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+
16
+ =end
17
+
18
+ require 'date'
19
+
20
+ module PostFinanceCheckout
21
+ class AnalyticsQueryExecutionState
22
+
23
+ PROCESSING = 'PROCESSING'.freeze
24
+ PROCESSED = 'PROCESSED'.freeze
25
+ FAILED = 'FAILED'.freeze
26
+ CANCELED = 'CANCELED'.freeze
27
+
28
+ # Builds the enum from string
29
+ # @param [String] The enum value in the form of the string
30
+ # @return [String] The enum value
31
+ def build_from_hash(value)
32
+ constantValues = AnalyticsQueryExecutionState.constants.select { |c| AnalyticsQueryExecutionState::const_get(c) == value }
33
+ raise "Invalid ENUM value #{value} for class #AnalyticsQueryExecutionState" if constantValues.empty?
34
+ value
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,225 @@
1
+ =begin
2
+ The PostFinance Checkout API allows an easy interaction with the PostFinance Checkout web service.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+
16
+ =end
17
+
18
+ require 'date'
19
+
20
+ module PostFinanceCheckout
21
+ # A batch of the result of a query executed in Analytics.
22
+ class AnalyticsQueryResultBatch
23
+ # The schemas of the columns returned by the query (in order). Will be null if the results of the query are not (yet) available.
24
+ attr_accessor :columns
25
+
26
+ # The token to be provided to fetch the next batch of results. May be null if no more result batches are available.
27
+ attr_accessor :next_token
28
+
29
+ # The query execution which produced the result.
30
+ attr_accessor :query_execution
31
+
32
+ # The rows of the result set contained in this batch where each row is a list of column values (in order of the columns specified in the query). Will be null if the results of the query are not (yet) available.
33
+ attr_accessor :rows
34
+
35
+ # Attribute mapping from ruby-style variable name to JSON key.
36
+ def self.attribute_map
37
+ {
38
+ :'columns' => :'columns',
39
+ :'next_token' => :'nextToken',
40
+ :'query_execution' => :'queryExecution',
41
+ :'rows' => :'rows'
42
+ }
43
+ end
44
+
45
+ # Attribute type mapping.
46
+ def self.swagger_types
47
+ {
48
+ :'columns' => :'Array<AnalyticsSchemaColumn>',
49
+ :'next_token' => :'String',
50
+ :'query_execution' => :'AnalyticsQueryExecution',
51
+ :'rows' => :'Array<Array<String>>'
52
+ }
53
+ end
54
+
55
+ # Initializes the object
56
+ # @param [Hash] attributes Model attributes in the form of hash
57
+ def initialize(attributes = {})
58
+ return unless attributes.is_a?(Hash)
59
+
60
+ # convert string to symbol for hash key
61
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
62
+
63
+ if attributes.has_key?(:'columns')
64
+ if (value = attributes[:'columns']).is_a?(Array)
65
+ self.columns = value
66
+ end
67
+ end
68
+
69
+ if attributes.has_key?(:'nextToken')
70
+ self.next_token = attributes[:'nextToken']
71
+ end
72
+
73
+ if attributes.has_key?(:'queryExecution')
74
+ self.query_execution = attributes[:'queryExecution']
75
+ end
76
+
77
+ if attributes.has_key?(:'rows')
78
+ if (value = attributes[:'rows']).is_a?(Array)
79
+ self.rows = value
80
+ end
81
+ end
82
+ end
83
+
84
+ # Show invalid properties with the reasons. Usually used together with valid?
85
+ # @return Array for valid properties with the reasons
86
+ def list_invalid_properties
87
+ invalid_properties = Array.new
88
+ invalid_properties
89
+ end
90
+
91
+ # Check to see if the all the properties in the model are valid
92
+ # @return true if the model is valid
93
+ def valid?
94
+ true
95
+ end
96
+
97
+ # Checks equality by comparing each attribute.
98
+ # @param [Object] Object to be compared
99
+ def ==(o)
100
+ return true if self.equal?(o)
101
+ self.class == o.class &&
102
+ columns == o.columns &&
103
+ next_token == o.next_token &&
104
+ query_execution == o.query_execution &&
105
+ rows == o.rows
106
+ end
107
+
108
+ # @see the `==` method
109
+ # @param [Object] Object to be compared
110
+ def eql?(o)
111
+ self == o
112
+ end
113
+
114
+ # Calculates hash code according to all attributes.
115
+ # @return [Fixnum] Hash code
116
+ def hash
117
+ [columns, next_token, query_execution, rows].hash
118
+ end
119
+
120
+ # Builds the object from hash
121
+ # @param [Hash] attributes Model attributes in the form of hash
122
+ # @return [Object] Returns the model itself
123
+ def build_from_hash(attributes)
124
+ return nil unless attributes.is_a?(Hash)
125
+ self.class.swagger_types.each_pair do |key, type|
126
+ if type =~ /\AArray<(.*)>/i
127
+ # check to ensure the input is an array given that the attribute
128
+ # is documented as an array but the input is not
129
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
130
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
131
+ end
132
+ elsif !attributes[self.class.attribute_map[key]].nil?
133
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
134
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
135
+ end
136
+
137
+ self
138
+ end
139
+
140
+ # Deserializes the data based on type
141
+ # @param string type Data type
142
+ # @param string value Value to be deserialized
143
+ # @return [Object] Deserialized data
144
+ def _deserialize(type, value)
145
+ case type.to_sym
146
+ when :DateTime
147
+ DateTime.parse(value)
148
+ when :Date
149
+ Date.parse(value)
150
+ when :String
151
+ value.to_s
152
+ when :Integer
153
+ value.to_i
154
+ when :Float
155
+ value.to_f
156
+ when :BOOLEAN
157
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
158
+ true
159
+ else
160
+ false
161
+ end
162
+ when :Object
163
+ # generic object (usually a Hash), return directly
164
+ value
165
+ when /\AArray<(?<inner_type>.+)>\z/
166
+ inner_type = Regexp.last_match[:inner_type]
167
+ value.map { |v| _deserialize(inner_type, v) }
168
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
169
+ k_type = Regexp.last_match[:k_type]
170
+ v_type = Regexp.last_match[:v_type]
171
+ {}.tap do |hash|
172
+ value.each do |k, v|
173
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
174
+ end
175
+ end
176
+ else # model
177
+ temp_model = PostFinanceCheckout.const_get(type).new
178
+ temp_model.build_from_hash(value)
179
+ end
180
+ end
181
+
182
+ # Returns the string representation of the object
183
+ # @return [String] String presentation of the object
184
+ def to_s
185
+ to_hash.to_s
186
+ end
187
+
188
+ # to_body is an alias to to_hash (backward compatibility)
189
+ # @return [Hash] Returns the object in the form of hash
190
+ def to_body
191
+ to_hash
192
+ end
193
+
194
+ # Returns the object in the form of hash
195
+ # @return [Hash] Returns the object in the form of hash
196
+ def to_hash
197
+ hash = {}
198
+ self.class.attribute_map.each_pair do |attr, param|
199
+ value = self.send(attr)
200
+ next if value.nil?
201
+ hash[param] = _to_hash(value)
202
+ end
203
+ hash
204
+ end
205
+
206
+ # Outputs non-array value in the form of hash
207
+ # For object, use to_hash. Otherwise, just return the value
208
+ # @param [Object] value Any valid value
209
+ # @return [Hash] Returns the value in the form of hash
210
+ def _to_hash(value)
211
+ if value.is_a?(Array)
212
+ value.compact.map{ |v| _to_hash(v) }
213
+ elsif value.is_a?(Hash)
214
+ {}.tap do |hash|
215
+ value.each { |k, v| hash[k] = _to_hash(v) }
216
+ end
217
+ elsif value.respond_to? :to_hash
218
+ value.to_hash
219
+ else
220
+ value
221
+ end
222
+ end
223
+
224
+ end
225
+ end