patch_ruby 1.9.0 → 1.11.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/Gemfile +1 -2
- data/Gemfile.lock +40 -44
- data/Makefile +2 -2
- data/lib/patch_ruby/api/estimates_api.rb +33 -25
- data/lib/patch_ruby/api/orders_api.rb +21 -16
- data/lib/patch_ruby/api/preferences_api.rb +17 -13
- data/lib/patch_ruby/api/projects_api.rb +9 -7
- data/lib/patch_ruby/api_client.rb +51 -49
- data/lib/patch_ruby/api_error.rb +1 -1
- data/lib/patch_ruby/configuration.rb +38 -9
- data/lib/patch_ruby/models/allocation.rb +21 -11
- data/lib/patch_ruby/models/create_bitcoin_estimate_request.rb +25 -19
- data/lib/patch_ruby/models/create_ethereum_estimate_request.rb +26 -21
- data/lib/patch_ruby/models/create_flight_estimate_request.rb +323 -0
- data/lib/patch_ruby/models/create_mass_estimate_request.rb +22 -13
- data/lib/patch_ruby/models/create_order_request.rb +21 -11
- data/lib/patch_ruby/models/create_preference_request.rb +21 -11
- data/lib/patch_ruby/models/create_shipping_estimate_request.rb +371 -0
- data/lib/patch_ruby/models/create_success_response.rb +247 -0
- data/lib/patch_ruby/models/create_vehicle_estimate_request.rb +326 -0
- data/lib/patch_ruby/models/error_response.rb +22 -13
- data/lib/patch_ruby/models/estimate.rb +22 -13
- data/lib/patch_ruby/models/estimate_list_response.rb +22 -13
- data/lib/patch_ruby/models/estimate_response.rb +22 -13
- data/lib/patch_ruby/models/meta_index_object.rb +23 -15
- data/lib/patch_ruby/models/order.rb +23 -15
- data/lib/patch_ruby/models/order_list_response.rb +22 -13
- data/lib/patch_ruby/models/order_response.rb +22 -13
- data/lib/patch_ruby/models/photo.rb +21 -11
- data/lib/patch_ruby/models/preference.rb +21 -11
- data/lib/patch_ruby/models/preference_list_response.rb +22 -13
- data/lib/patch_ruby/models/preference_response.rb +22 -13
- data/lib/patch_ruby/models/project.rb +24 -17
- data/lib/patch_ruby/models/project_list_response.rb +22 -13
- data/lib/patch_ruby/models/project_response.rb +22 -13
- data/lib/patch_ruby/models/sdg.rb +21 -11
- data/lib/patch_ruby/models/standard.rb +21 -11
- data/lib/patch_ruby/version.rb +2 -2
- data/lib/patch_ruby.rb +5 -1
- data/patch_ruby.gemspec +8 -3
- data/spec/api_client_spec.rb +34 -13
- data/spec/configuration_spec.rb +1 -1
- data/spec/integration/estimates_spec.rb +17 -1
- data/spec/integration/preferences_spec.rb +1 -1
- data/spec/models/create_mass_estimate_request_spec.rb +1 -1
- data/spec/models/error_response_spec.rb +1 -1
- data/spec/models/estimate_list_response_spec.rb +1 -1
- data/spec/models/estimate_response_spec.rb +1 -1
- data/spec/models/estimate_spec.rb +1 -1
- data/spec/models/meta_index_object_spec.rb +1 -1
- data/spec/models/order_list_response_spec.rb +1 -1
- data/spec/models/order_response_spec.rb +1 -1
- data/spec/models/order_spec.rb +1 -1
- data/spec/models/preference_list_response_spec.rb +1 -1
- data/spec/models/preference_response_spec.rb +1 -1
- data/spec/models/project_list_response_spec.rb +1 -1
- data/spec/models/project_response_spec.rb +1 -1
- data/spec/models/project_spec.rb +1 -1
- data/spec/spec_helper.rb +69 -61
- metadata +56 -58
- data/lib/patch_ruby/.api_client.rb.un~ +0 -0
- data/lib/patch_ruby/.configuration.rb.un~ +0 -0
- data/lib/patch_ruby/.version.rb.un~ +0 -0
- data/lib/patch_ruby/api/.orders_api.rb.un~ +0 -0
- data/lib/patch_ruby/models/.create_ethereum_estimate_request.rb.un~ +0 -0
- data/spec/.spec_helper.rb.un~ +0 -0
- data/spec/integration/.estimates_spec.rb.un~ +0 -0
- data/spec/integration/.orders_spec.rb.un~ +0 -0
- data/spec/integration/.preferences_spec.rb.un~ +0 -0
- data/spec/integration/.projects_spec.rb.un~ +0 -0
@@ -6,11 +6,12 @@
|
|
6
6
|
The version of the OpenAPI document: v1
|
7
7
|
Contact: developers@usepatch.com
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version:
|
9
|
+
OpenAPI Generator version: 5.2.1
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
13
13
|
require 'date'
|
14
|
+
require 'time'
|
14
15
|
|
15
16
|
module Patch
|
16
17
|
class CreateBitcoinEstimateRequest
|
@@ -32,6 +33,11 @@ module Patch
|
|
32
33
|
}
|
33
34
|
end
|
34
35
|
|
36
|
+
# Returns all the JSON keys this model knows about
|
37
|
+
def self.acceptable_attributes
|
38
|
+
attribute_map.values
|
39
|
+
end
|
40
|
+
|
35
41
|
# Attribute type mapping.
|
36
42
|
def self.openapi_types
|
37
43
|
{
|
@@ -42,21 +48,17 @@ module Patch
|
|
42
48
|
}
|
43
49
|
end
|
44
50
|
|
45
|
-
#
|
51
|
+
# List of attributes with nullable: true
|
46
52
|
def self.openapi_nullable
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
nullable_properties.add("project_id")
|
54
|
-
|
55
|
-
nullable_properties.add("create_order")
|
56
|
-
|
57
|
-
nullable_properties
|
53
|
+
Set.new([
|
54
|
+
:'timestamp',
|
55
|
+
:'transaction_value_btc_sats',
|
56
|
+
:'project_id',
|
57
|
+
:'create_order'
|
58
|
+
])
|
58
59
|
end
|
59
60
|
|
61
|
+
|
60
62
|
# Allows models with corresponding API classes to delegate API operations to those API classes
|
61
63
|
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
62
64
|
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
@@ -149,7 +151,9 @@ module Patch
|
|
149
151
|
def build_from_hash(attributes)
|
150
152
|
return nil unless attributes.is_a?(Hash)
|
151
153
|
self.class.openapi_types.each_pair do |key, type|
|
152
|
-
if
|
154
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
155
|
+
self.send("#{key}=", nil)
|
156
|
+
elsif type =~ /\AArray<(.*)>/i
|
153
157
|
# check to ensure the input is an array given that the attribute
|
154
158
|
# is documented as an array but the input is not
|
155
159
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
@@ -157,7 +161,7 @@ module Patch
|
|
157
161
|
end
|
158
162
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
159
163
|
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
160
|
-
end
|
164
|
+
end
|
161
165
|
end
|
162
166
|
|
163
167
|
self
|
@@ -169,8 +173,8 @@ module Patch
|
|
169
173
|
# @return [Object] Deserialized data
|
170
174
|
def _deserialize(type, value)
|
171
175
|
case type.to_sym
|
172
|
-
when :
|
173
|
-
|
176
|
+
when :Time
|
177
|
+
Time.parse(value)
|
174
178
|
when :Date
|
175
179
|
Date.parse(value)
|
176
180
|
when :String
|
@@ -200,7 +204,9 @@ module Patch
|
|
200
204
|
end
|
201
205
|
end
|
202
206
|
else # model
|
203
|
-
|
207
|
+
# models (e.g. Pet) or oneOf
|
208
|
+
klass = Patch.const_get(type)
|
209
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
204
210
|
end
|
205
211
|
end
|
206
212
|
|
@@ -226,7 +232,7 @@ module Patch
|
|
226
232
|
is_nullable = self.class.openapi_nullable.include?(attr)
|
227
233
|
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
228
234
|
end
|
229
|
-
|
235
|
+
|
230
236
|
hash[param] = _to_hash(value)
|
231
237
|
end
|
232
238
|
hash
|
@@ -6,11 +6,12 @@
|
|
6
6
|
The version of the OpenAPI document: v1
|
7
7
|
Contact: developers@usepatch.com
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version:
|
9
|
+
OpenAPI Generator version: 5.2.1
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
13
13
|
require 'date'
|
14
|
+
require 'time'
|
14
15
|
|
15
16
|
module Patch
|
16
17
|
class CreateEthereumEstimateRequest
|
@@ -35,6 +36,11 @@ module Patch
|
|
35
36
|
}
|
36
37
|
end
|
37
38
|
|
39
|
+
# Returns all the JSON keys this model knows about
|
40
|
+
def self.acceptable_attributes
|
41
|
+
attribute_map.values
|
42
|
+
end
|
43
|
+
|
38
44
|
# Attribute type mapping.
|
39
45
|
def self.openapi_types
|
40
46
|
{
|
@@ -46,23 +52,18 @@ module Patch
|
|
46
52
|
}
|
47
53
|
end
|
48
54
|
|
49
|
-
#
|
55
|
+
# List of attributes with nullable: true
|
50
56
|
def self.openapi_nullable
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
nullable_properties.add("project_id")
|
60
|
-
|
61
|
-
nullable_properties.add("create_order")
|
62
|
-
|
63
|
-
nullable_properties
|
57
|
+
Set.new([
|
58
|
+
:'timestamp',
|
59
|
+
:'gas_used',
|
60
|
+
:'transaction_value_eth_gwei',
|
61
|
+
:'project_id',
|
62
|
+
:'create_order'
|
63
|
+
])
|
64
64
|
end
|
65
65
|
|
66
|
+
|
66
67
|
# Allows models with corresponding API classes to delegate API operations to those API classes
|
67
68
|
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
68
69
|
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
@@ -160,7 +161,9 @@ module Patch
|
|
160
161
|
def build_from_hash(attributes)
|
161
162
|
return nil unless attributes.is_a?(Hash)
|
162
163
|
self.class.openapi_types.each_pair do |key, type|
|
163
|
-
if
|
164
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
165
|
+
self.send("#{key}=", nil)
|
166
|
+
elsif type =~ /\AArray<(.*)>/i
|
164
167
|
# check to ensure the input is an array given that the attribute
|
165
168
|
# is documented as an array but the input is not
|
166
169
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
@@ -168,7 +171,7 @@ module Patch
|
|
168
171
|
end
|
169
172
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
170
173
|
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
171
|
-
end
|
174
|
+
end
|
172
175
|
end
|
173
176
|
|
174
177
|
self
|
@@ -180,8 +183,8 @@ module Patch
|
|
180
183
|
# @return [Object] Deserialized data
|
181
184
|
def _deserialize(type, value)
|
182
185
|
case type.to_sym
|
183
|
-
when :
|
184
|
-
|
186
|
+
when :Time
|
187
|
+
Time.parse(value)
|
185
188
|
when :Date
|
186
189
|
Date.parse(value)
|
187
190
|
when :String
|
@@ -211,7 +214,9 @@ module Patch
|
|
211
214
|
end
|
212
215
|
end
|
213
216
|
else # model
|
214
|
-
|
217
|
+
# models (e.g. Pet) or oneOf
|
218
|
+
klass = Patch.const_get(type)
|
219
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
215
220
|
end
|
216
221
|
end
|
217
222
|
|
@@ -237,7 +242,7 @@ module Patch
|
|
237
242
|
is_nullable = self.class.openapi_nullable.include?(attr)
|
238
243
|
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
239
244
|
end
|
240
|
-
|
245
|
+
|
241
246
|
hash[param] = _to_hash(value)
|
242
247
|
end
|
243
248
|
hash
|
@@ -0,0 +1,323 @@
|
|
1
|
+
=begin
|
2
|
+
#Patch API V1
|
3
|
+
|
4
|
+
#The core API used to integrate with Patch's service
|
5
|
+
|
6
|
+
The version of the OpenAPI document: v1
|
7
|
+
Contact: developers@usepatch.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 5.2.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module Patch
|
17
|
+
class CreateFlightEstimateRequest
|
18
|
+
attr_accessor :distance_m
|
19
|
+
|
20
|
+
attr_accessor :origin_airport
|
21
|
+
|
22
|
+
attr_accessor :destination_airport
|
23
|
+
|
24
|
+
attr_accessor :aircraft_code
|
25
|
+
|
26
|
+
attr_accessor :cabin_class
|
27
|
+
|
28
|
+
attr_accessor :passenger_count
|
29
|
+
|
30
|
+
attr_accessor :project_id
|
31
|
+
|
32
|
+
attr_accessor :create_order
|
33
|
+
|
34
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
35
|
+
def self.attribute_map
|
36
|
+
{
|
37
|
+
:'distance_m' => :'distance_m',
|
38
|
+
:'origin_airport' => :'origin_airport',
|
39
|
+
:'destination_airport' => :'destination_airport',
|
40
|
+
:'aircraft_code' => :'aircraft_code',
|
41
|
+
:'cabin_class' => :'cabin_class',
|
42
|
+
:'passenger_count' => :'passenger_count',
|
43
|
+
:'project_id' => :'project_id',
|
44
|
+
:'create_order' => :'create_order'
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
# Returns all the JSON keys this model knows about
|
49
|
+
def self.acceptable_attributes
|
50
|
+
attribute_map.values
|
51
|
+
end
|
52
|
+
|
53
|
+
# Attribute type mapping.
|
54
|
+
def self.openapi_types
|
55
|
+
{
|
56
|
+
:'distance_m' => :'Integer',
|
57
|
+
:'origin_airport' => :'String',
|
58
|
+
:'destination_airport' => :'String',
|
59
|
+
:'aircraft_code' => :'String',
|
60
|
+
:'cabin_class' => :'String',
|
61
|
+
:'passenger_count' => :'Integer',
|
62
|
+
:'project_id' => :'String',
|
63
|
+
:'create_order' => :'Boolean'
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
# List of attributes with nullable: true
|
68
|
+
def self.openapi_nullable
|
69
|
+
Set.new([
|
70
|
+
:'distance_m',
|
71
|
+
:'origin_airport',
|
72
|
+
:'destination_airport',
|
73
|
+
:'aircraft_code',
|
74
|
+
:'cabin_class',
|
75
|
+
:'passenger_count',
|
76
|
+
:'project_id',
|
77
|
+
:'create_order'
|
78
|
+
])
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
# Allows models with corresponding API classes to delegate API operations to those API classes
|
83
|
+
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
84
|
+
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
85
|
+
def self.method_missing(message, *args, &block)
|
86
|
+
if Object.const_defined?('Patch::CreateFlightEstimateRequestsApi::OPERATIONS') && Patch::CreateFlightEstimateRequestsApi::OPERATIONS.include?(message)
|
87
|
+
Patch::CreateFlightEstimateRequestsApi.new.send(message, *args)
|
88
|
+
else
|
89
|
+
super
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
# Initializes the object
|
94
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
95
|
+
def initialize(attributes = {})
|
96
|
+
if (!attributes.is_a?(Hash))
|
97
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::CreateFlightEstimateRequest` initialize method"
|
98
|
+
end
|
99
|
+
|
100
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
101
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
102
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
103
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::CreateFlightEstimateRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
104
|
+
end
|
105
|
+
h[k.to_sym] = v
|
106
|
+
}
|
107
|
+
|
108
|
+
if attributes.key?(:'distance_m')
|
109
|
+
self.distance_m = attributes[:'distance_m']
|
110
|
+
end
|
111
|
+
|
112
|
+
if attributes.key?(:'origin_airport')
|
113
|
+
self.origin_airport = attributes[:'origin_airport']
|
114
|
+
end
|
115
|
+
|
116
|
+
if attributes.key?(:'destination_airport')
|
117
|
+
self.destination_airport = attributes[:'destination_airport']
|
118
|
+
end
|
119
|
+
|
120
|
+
if attributes.key?(:'aircraft_code')
|
121
|
+
self.aircraft_code = attributes[:'aircraft_code']
|
122
|
+
end
|
123
|
+
|
124
|
+
if attributes.key?(:'cabin_class')
|
125
|
+
self.cabin_class = attributes[:'cabin_class']
|
126
|
+
end
|
127
|
+
|
128
|
+
if attributes.key?(:'passenger_count')
|
129
|
+
self.passenger_count = attributes[:'passenger_count']
|
130
|
+
end
|
131
|
+
|
132
|
+
if attributes.key?(:'project_id')
|
133
|
+
self.project_id = attributes[:'project_id']
|
134
|
+
end
|
135
|
+
|
136
|
+
if attributes.key?(:'create_order')
|
137
|
+
self.create_order = attributes[:'create_order']
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
142
|
+
# @return Array for valid properties with the reasons
|
143
|
+
def list_invalid_properties
|
144
|
+
invalid_properties = Array.new
|
145
|
+
if !@distance_m.nil? && @distance_m > 400000000
|
146
|
+
invalid_properties.push('invalid value for "distance_m", must be smaller than or equal to 400000000.')
|
147
|
+
end
|
148
|
+
|
149
|
+
if !@distance_m.nil? && @distance_m < 0
|
150
|
+
invalid_properties.push('invalid value for "distance_m", must be greater than or equal to 0.')
|
151
|
+
end
|
152
|
+
|
153
|
+
invalid_properties
|
154
|
+
end
|
155
|
+
|
156
|
+
# Check to see if the all the properties in the model are valid
|
157
|
+
# @return true if the model is valid
|
158
|
+
def valid?
|
159
|
+
return false if !@distance_m.nil? && @distance_m > 400000000
|
160
|
+
return false if !@distance_m.nil? && @distance_m < 0
|
161
|
+
true
|
162
|
+
end
|
163
|
+
|
164
|
+
# Custom attribute writer method with validation
|
165
|
+
# @param [Object] distance_m Value to be assigned
|
166
|
+
def distance_m=(distance_m)
|
167
|
+
if !distance_m.nil? && distance_m > 400000000
|
168
|
+
fail ArgumentError, 'invalid value for "distance_m", must be smaller than or equal to 400000000.'
|
169
|
+
end
|
170
|
+
|
171
|
+
if !distance_m.nil? && distance_m < 0
|
172
|
+
fail ArgumentError, 'invalid value for "distance_m", must be greater than or equal to 0.'
|
173
|
+
end
|
174
|
+
|
175
|
+
@distance_m = distance_m
|
176
|
+
end
|
177
|
+
|
178
|
+
# Checks equality by comparing each attribute.
|
179
|
+
# @param [Object] Object to be compared
|
180
|
+
def ==(o)
|
181
|
+
return true if self.equal?(o)
|
182
|
+
self.class == o.class &&
|
183
|
+
distance_m == o.distance_m &&
|
184
|
+
origin_airport == o.origin_airport &&
|
185
|
+
destination_airport == o.destination_airport &&
|
186
|
+
aircraft_code == o.aircraft_code &&
|
187
|
+
cabin_class == o.cabin_class &&
|
188
|
+
passenger_count == o.passenger_count &&
|
189
|
+
project_id == o.project_id &&
|
190
|
+
create_order == o.create_order
|
191
|
+
end
|
192
|
+
|
193
|
+
# @see the `==` method
|
194
|
+
# @param [Object] Object to be compared
|
195
|
+
def eql?(o)
|
196
|
+
self == o
|
197
|
+
end
|
198
|
+
|
199
|
+
# Calculates hash code according to all attributes.
|
200
|
+
# @return [Integer] Hash code
|
201
|
+
def hash
|
202
|
+
[distance_m, origin_airport, destination_airport, aircraft_code, cabin_class, passenger_count, project_id, create_order].hash
|
203
|
+
end
|
204
|
+
|
205
|
+
# Builds the object from hash
|
206
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
207
|
+
# @return [Object] Returns the model itself
|
208
|
+
def self.build_from_hash(attributes)
|
209
|
+
new.build_from_hash(attributes)
|
210
|
+
end
|
211
|
+
|
212
|
+
# Builds the object from hash
|
213
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
214
|
+
# @return [Object] Returns the model itself
|
215
|
+
def build_from_hash(attributes)
|
216
|
+
return nil unless attributes.is_a?(Hash)
|
217
|
+
self.class.openapi_types.each_pair do |key, type|
|
218
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
219
|
+
self.send("#{key}=", nil)
|
220
|
+
elsif type =~ /\AArray<(.*)>/i
|
221
|
+
# check to ensure the input is an array given that the attribute
|
222
|
+
# is documented as an array but the input is not
|
223
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
224
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
225
|
+
end
|
226
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
227
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
self
|
232
|
+
end
|
233
|
+
|
234
|
+
# Deserializes the data based on type
|
235
|
+
# @param string type Data type
|
236
|
+
# @param string value Value to be deserialized
|
237
|
+
# @return [Object] Deserialized data
|
238
|
+
def _deserialize(type, value)
|
239
|
+
case type.to_sym
|
240
|
+
when :Time
|
241
|
+
Time.parse(value)
|
242
|
+
when :Date
|
243
|
+
Date.parse(value)
|
244
|
+
when :String
|
245
|
+
value.to_s
|
246
|
+
when :Integer
|
247
|
+
value.to_i
|
248
|
+
when :Float
|
249
|
+
value.to_f
|
250
|
+
when :Boolean
|
251
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
252
|
+
true
|
253
|
+
else
|
254
|
+
false
|
255
|
+
end
|
256
|
+
when :Object
|
257
|
+
# generic object (usually a Hash), return directly
|
258
|
+
value
|
259
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
260
|
+
inner_type = Regexp.last_match[:inner_type]
|
261
|
+
value.map { |v| _deserialize(inner_type, v) }
|
262
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
263
|
+
k_type = Regexp.last_match[:k_type]
|
264
|
+
v_type = Regexp.last_match[:v_type]
|
265
|
+
{}.tap do |hash|
|
266
|
+
value.each do |k, v|
|
267
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
268
|
+
end
|
269
|
+
end
|
270
|
+
else # model
|
271
|
+
# models (e.g. Pet) or oneOf
|
272
|
+
klass = Patch.const_get(type)
|
273
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
# Returns the string representation of the object
|
278
|
+
# @return [String] String presentation of the object
|
279
|
+
def to_s
|
280
|
+
to_hash.to_s
|
281
|
+
end
|
282
|
+
|
283
|
+
# to_body is an alias to to_hash (backward compatibility)
|
284
|
+
# @return [Hash] Returns the object in the form of hash
|
285
|
+
def to_body
|
286
|
+
to_hash
|
287
|
+
end
|
288
|
+
|
289
|
+
# Returns the object in the form of hash
|
290
|
+
# @return [Hash] Returns the object in the form of hash
|
291
|
+
def to_hash
|
292
|
+
hash = {}
|
293
|
+
self.class.attribute_map.each_pair do |attr, param|
|
294
|
+
value = self.send(attr)
|
295
|
+
if value.nil?
|
296
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
297
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
298
|
+
end
|
299
|
+
|
300
|
+
hash[param] = _to_hash(value)
|
301
|
+
end
|
302
|
+
hash
|
303
|
+
end
|
304
|
+
|
305
|
+
# Outputs non-array value in the form of hash
|
306
|
+
# For object, use to_hash. Otherwise, just return the value
|
307
|
+
# @param [Object] value Any valid value
|
308
|
+
# @return [Hash] Returns the value in the form of hash
|
309
|
+
def _to_hash(value)
|
310
|
+
if value.is_a?(Array)
|
311
|
+
value.compact.map { |v| _to_hash(v) }
|
312
|
+
elsif value.is_a?(Hash)
|
313
|
+
{}.tap do |hash|
|
314
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
315
|
+
end
|
316
|
+
elsif value.respond_to? :to_hash
|
317
|
+
value.to_hash
|
318
|
+
else
|
319
|
+
value
|
320
|
+
end
|
321
|
+
end
|
322
|
+
end
|
323
|
+
end
|