patch_ruby 1.0.0.pre → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +69 -0
- data/Gemfile +1 -2
- data/Gemfile.lock +13 -12
- data/Makefile +10 -0
- data/README.md +144 -15
- data/lib/patch_ruby.rb +2 -0
- data/lib/patch_ruby/models/allocation.rb +15 -0
- data/lib/patch_ruby/models/create_mass_estimate_request.rb +41 -4
- data/lib/patch_ruby/models/create_order_request.rb +68 -7
- data/lib/patch_ruby/models/estimate.rb +15 -0
- data/lib/patch_ruby/models/order.rb +85 -4
- data/lib/patch_ruby/models/photo.rb +216 -0
- data/lib/patch_ruby/models/preference.rb +15 -0
- data/lib/patch_ruby/models/project.rb +119 -25
- data/lib/patch_ruby/models/standard.rb +244 -0
- data/lib/patch_ruby/version.rb +1 -1
- data/spec/api/estimates_api_spec.rb +6 -7
- data/spec/api/orders_api_spec.rb +10 -11
- data/spec/api/preferences_api_spec.rb +8 -9
- data/spec/api/projects_api_spec.rb +4 -5
- data/spec/api_client_spec.rb +12 -33
- data/spec/constants.rb +3 -0
- data/spec/integration/estimates_spec.rb +30 -23
- data/spec/integration/orders_spec.rb +85 -38
- data/spec/integration/preferences_spec.rb +24 -30
- data/spec/integration/projects_spec.rb +38 -27
- data/spec/models/allocation_spec.rb +0 -1
- data/spec/models/create_mass_estimate_request_spec.rb +0 -1
- data/spec/models/create_order_request_spec.rb +0 -1
- data/spec/models/create_preference_request_spec.rb +0 -1
- data/spec/models/error_response_spec.rb +0 -1
- data/spec/models/estimate_list_response_spec.rb +0 -1
- data/spec/models/estimate_response_spec.rb +0 -1
- data/spec/models/estimate_spec.rb +0 -1
- data/spec/models/meta_index_object_spec.rb +0 -1
- data/spec/models/order_list_response_spec.rb +0 -1
- data/spec/models/order_response_spec.rb +0 -1
- data/spec/models/order_spec.rb +0 -1
- data/spec/models/preference_list_response_spec.rb +0 -1
- data/spec/models/preference_response_spec.rb +0 -1
- data/spec/models/preference_spec.rb +0 -1
- data/spec/models/project_list_response_spec.rb +0 -1
- data/spec/models/project_response_spec.rb +0 -1
- data/spec/models/project_spec.rb +0 -1
- data/spec/spec_helper.rb +1 -11
- metadata +26 -30
- data/spec/fixtures/vcr_cassettes/estimate_orders.yml +0 -276
- data/spec/fixtures/vcr_cassettes/estimates.yml +0 -211
- data/spec/fixtures/vcr_cassettes/orders.yml +0 -229
- data/spec/fixtures/vcr_cassettes/preferences.yml +0 -352
- data/spec/fixtures/vcr_cassettes/projects.yml +0 -143
@@ -16,17 +16,29 @@ module Patch
|
|
16
16
|
class CreateOrderRequest
|
17
17
|
attr_accessor :mass_g
|
18
18
|
|
19
|
+
attr_accessor :total_price_cents_usd
|
20
|
+
|
21
|
+
attr_accessor :project_id
|
22
|
+
|
23
|
+
attr_accessor :metadata
|
24
|
+
|
19
25
|
# Attribute mapping from ruby-style variable name to JSON key.
|
20
26
|
def self.attribute_map
|
21
27
|
{
|
22
|
-
:'mass_g' => :'mass_g'
|
28
|
+
:'mass_g' => :'mass_g',
|
29
|
+
:'total_price_cents_usd' => :'total_price_cents_usd',
|
30
|
+
:'project_id' => :'project_id',
|
31
|
+
:'metadata' => :'metadata'
|
23
32
|
}
|
24
33
|
end
|
25
34
|
|
26
35
|
# Attribute type mapping.
|
27
36
|
def self.openapi_types
|
28
37
|
{
|
29
|
-
:'mass_g' => :'Integer'
|
38
|
+
:'mass_g' => :'Integer',
|
39
|
+
:'total_price_cents_usd' => :'Integer',
|
40
|
+
:'project_id' => :'String',
|
41
|
+
:'metadata' => :'Object'
|
30
42
|
}
|
31
43
|
end
|
32
44
|
|
@@ -59,14 +71,34 @@ module Patch
|
|
59
71
|
if attributes.key?(:'mass_g')
|
60
72
|
self.mass_g = attributes[:'mass_g']
|
61
73
|
end
|
74
|
+
|
75
|
+
if attributes.key?(:'total_price_cents_usd')
|
76
|
+
self.total_price_cents_usd = attributes[:'total_price_cents_usd']
|
77
|
+
end
|
78
|
+
|
79
|
+
if attributes.key?(:'project_id')
|
80
|
+
self.project_id = attributes[:'project_id']
|
81
|
+
end
|
82
|
+
|
83
|
+
if attributes.key?(:'metadata')
|
84
|
+
self.metadata = attributes[:'metadata']
|
85
|
+
end
|
62
86
|
end
|
63
87
|
|
64
88
|
# Show invalid properties with the reasons. Usually used together with valid?
|
65
89
|
# @return Array for valid properties with the reasons
|
66
90
|
def list_invalid_properties
|
67
91
|
invalid_properties = Array.new
|
68
|
-
if
|
69
|
-
invalid_properties.push('invalid value for "mass_g",
|
92
|
+
if !@mass_g.nil? && @mass_g > 2000000000
|
93
|
+
invalid_properties.push('invalid value for "mass_g", must be smaller than or equal to 2000000000.')
|
94
|
+
end
|
95
|
+
|
96
|
+
if !@mass_g.nil? && @mass_g < 1
|
97
|
+
invalid_properties.push('invalid value for "mass_g", must be greater than or equal to 1.')
|
98
|
+
end
|
99
|
+
|
100
|
+
if !@total_price_cents_usd.nil? && @total_price_cents_usd < 1
|
101
|
+
invalid_properties.push('invalid value for "total_price_cents_usd", must be greater than or equal to 1.')
|
70
102
|
end
|
71
103
|
|
72
104
|
invalid_properties
|
@@ -75,16 +107,45 @@ module Patch
|
|
75
107
|
# Check to see if the all the properties in the model are valid
|
76
108
|
# @return true if the model is valid
|
77
109
|
def valid?
|
78
|
-
return false if
|
110
|
+
return false if !@mass_g.nil? && @mass_g > 2000000000
|
111
|
+
return false if !@mass_g.nil? && @mass_g < 1
|
112
|
+
return false if !@total_price_cents_usd.nil? && @total_price_cents_usd < 1
|
79
113
|
true
|
80
114
|
end
|
81
115
|
|
116
|
+
# Custom attribute writer method with validation
|
117
|
+
# @param [Object] mass_g Value to be assigned
|
118
|
+
def mass_g=(mass_g)
|
119
|
+
if !mass_g.nil? && mass_g > 2000000000
|
120
|
+
fail ArgumentError, 'invalid value for "mass_g", must be smaller than or equal to 2000000000.'
|
121
|
+
end
|
122
|
+
|
123
|
+
if !mass_g.nil? && mass_g < 1
|
124
|
+
fail ArgumentError, 'invalid value for "mass_g", must be greater than or equal to 1.'
|
125
|
+
end
|
126
|
+
|
127
|
+
@mass_g = mass_g
|
128
|
+
end
|
129
|
+
|
130
|
+
# Custom attribute writer method with validation
|
131
|
+
# @param [Object] total_price_cents_usd Value to be assigned
|
132
|
+
def total_price_cents_usd=(total_price_cents_usd)
|
133
|
+
if !total_price_cents_usd.nil? && total_price_cents_usd < 1
|
134
|
+
fail ArgumentError, 'invalid value for "total_price_cents_usd", must be greater than or equal to 1.'
|
135
|
+
end
|
136
|
+
|
137
|
+
@total_price_cents_usd = total_price_cents_usd
|
138
|
+
end
|
139
|
+
|
82
140
|
# Checks equality by comparing each attribute.
|
83
141
|
# @param [Object] Object to be compared
|
84
142
|
def ==(o)
|
85
143
|
return true if self.equal?(o)
|
86
144
|
self.class == o.class &&
|
87
|
-
mass_g == o.mass_g
|
145
|
+
mass_g == o.mass_g &&
|
146
|
+
total_price_cents_usd == o.total_price_cents_usd &&
|
147
|
+
project_id == o.project_id &&
|
148
|
+
metadata == o.metadata
|
88
149
|
end
|
89
150
|
|
90
151
|
# @see the `==` method
|
@@ -96,7 +157,7 @@ module Patch
|
|
96
157
|
# Calculates hash code according to all attributes.
|
97
158
|
# @return [Integer] Hash code
|
98
159
|
def hash
|
99
|
-
[mass_g].hash
|
160
|
+
[mass_g, total_price_cents_usd, project_id, metadata].hash
|
100
161
|
end
|
101
162
|
|
102
163
|
# Builds the object from hash
|
@@ -89,12 +89,27 @@ module Patch
|
|
89
89
|
# @return Array for valid properties with the reasons
|
90
90
|
def list_invalid_properties
|
91
91
|
invalid_properties = Array.new
|
92
|
+
if @id.nil?
|
93
|
+
invalid_properties.push('invalid value for "id", id cannot be nil.')
|
94
|
+
end
|
95
|
+
|
96
|
+
if @production.nil?
|
97
|
+
invalid_properties.push('invalid value for "production", production cannot be nil.')
|
98
|
+
end
|
99
|
+
|
100
|
+
if @type.nil?
|
101
|
+
invalid_properties.push('invalid value for "type", type cannot be nil.')
|
102
|
+
end
|
103
|
+
|
92
104
|
invalid_properties
|
93
105
|
end
|
94
106
|
|
95
107
|
# Check to see if the all the properties in the model are valid
|
96
108
|
# @return true if the model is valid
|
97
109
|
def valid?
|
110
|
+
return false if @id.nil?
|
111
|
+
return false if @production.nil?
|
112
|
+
return false if @type.nil?
|
98
113
|
true
|
99
114
|
end
|
100
115
|
|
@@ -26,8 +26,12 @@ module Patch
|
|
26
26
|
|
27
27
|
attr_accessor :price_cents_usd
|
28
28
|
|
29
|
+
attr_accessor :patch_fee_cents_usd
|
30
|
+
|
29
31
|
attr_accessor :allocations
|
30
32
|
|
33
|
+
attr_accessor :metadata
|
34
|
+
|
31
35
|
class EnumAttributeValidator
|
32
36
|
attr_reader :datatype
|
33
37
|
attr_reader :allowable_values
|
@@ -59,7 +63,9 @@ module Patch
|
|
59
63
|
:'state' => :'state',
|
60
64
|
:'allocation_state' => :'allocation_state',
|
61
65
|
:'price_cents_usd' => :'price_cents_usd',
|
62
|
-
:'
|
66
|
+
:'patch_fee_cents_usd' => :'patch_fee_cents_usd',
|
67
|
+
:'allocations' => :'allocations',
|
68
|
+
:'metadata' => :'metadata'
|
63
69
|
}
|
64
70
|
end
|
65
71
|
|
@@ -72,7 +78,9 @@ module Patch
|
|
72
78
|
:'state' => :'String',
|
73
79
|
:'allocation_state' => :'String',
|
74
80
|
:'price_cents_usd' => :'String',
|
75
|
-
:'
|
81
|
+
:'patch_fee_cents_usd' => :'String',
|
82
|
+
:'allocations' => :'Array<Allocation>',
|
83
|
+
:'metadata' => :'Object'
|
76
84
|
}
|
77
85
|
end
|
78
86
|
|
@@ -126,30 +134,101 @@ module Patch
|
|
126
134
|
self.price_cents_usd = attributes[:'price_cents_usd']
|
127
135
|
end
|
128
136
|
|
137
|
+
if attributes.key?(:'patch_fee_cents_usd')
|
138
|
+
self.patch_fee_cents_usd = attributes[:'patch_fee_cents_usd']
|
139
|
+
end
|
140
|
+
|
129
141
|
if attributes.key?(:'allocations')
|
130
142
|
if (value = attributes[:'allocations']).is_a?(Array)
|
131
143
|
self.allocations = value
|
132
144
|
end
|
133
145
|
end
|
146
|
+
|
147
|
+
if attributes.key?(:'metadata')
|
148
|
+
self.metadata = attributes[:'metadata']
|
149
|
+
end
|
134
150
|
end
|
135
151
|
|
136
152
|
# Show invalid properties with the reasons. Usually used together with valid?
|
137
153
|
# @return Array for valid properties with the reasons
|
138
154
|
def list_invalid_properties
|
139
155
|
invalid_properties = Array.new
|
156
|
+
if @id.nil?
|
157
|
+
invalid_properties.push('invalid value for "id", id cannot be nil.')
|
158
|
+
end
|
159
|
+
|
160
|
+
if @mass_g.nil?
|
161
|
+
invalid_properties.push('invalid value for "mass_g", mass_g cannot be nil.')
|
162
|
+
end
|
163
|
+
|
164
|
+
if @mass_g > 2000000000
|
165
|
+
invalid_properties.push('invalid value for "mass_g", must be smaller than or equal to 2000000000.')
|
166
|
+
end
|
167
|
+
|
168
|
+
if @mass_g < 1
|
169
|
+
invalid_properties.push('invalid value for "mass_g", must be greater than or equal to 1.')
|
170
|
+
end
|
171
|
+
|
172
|
+
if @production.nil?
|
173
|
+
invalid_properties.push('invalid value for "production", production cannot be nil.')
|
174
|
+
end
|
175
|
+
|
176
|
+
if @state.nil?
|
177
|
+
invalid_properties.push('invalid value for "state", state cannot be nil.')
|
178
|
+
end
|
179
|
+
|
180
|
+
if @allocation_state.nil?
|
181
|
+
invalid_properties.push('invalid value for "allocation_state", allocation_state cannot be nil.')
|
182
|
+
end
|
183
|
+
|
184
|
+
if @allocations.nil?
|
185
|
+
invalid_properties.push('invalid value for "allocations", allocations cannot be nil.')
|
186
|
+
end
|
187
|
+
|
188
|
+
if @metadata.nil?
|
189
|
+
invalid_properties.push('invalid value for "metadata", metadata cannot be nil.')
|
190
|
+
end
|
191
|
+
|
140
192
|
invalid_properties
|
141
193
|
end
|
142
194
|
|
143
195
|
# Check to see if the all the properties in the model are valid
|
144
196
|
# @return true if the model is valid
|
145
197
|
def valid?
|
198
|
+
return false if @id.nil?
|
199
|
+
return false if @mass_g.nil?
|
200
|
+
return false if @mass_g > 2000000000
|
201
|
+
return false if @mass_g < 1
|
202
|
+
return false if @production.nil?
|
203
|
+
return false if @state.nil?
|
146
204
|
state_validator = EnumAttributeValidator.new('String', ["draft", "placed", "complete", "cancelled"])
|
147
205
|
return false unless state_validator.valid?(@state)
|
206
|
+
return false if @allocation_state.nil?
|
148
207
|
allocation_state_validator = EnumAttributeValidator.new('String', ["pending", "partially_allocated", "allocated"])
|
149
208
|
return false unless allocation_state_validator.valid?(@allocation_state)
|
209
|
+
return false if @allocations.nil?
|
210
|
+
return false if @metadata.nil?
|
150
211
|
true
|
151
212
|
end
|
152
213
|
|
214
|
+
# Custom attribute writer method with validation
|
215
|
+
# @param [Object] mass_g Value to be assigned
|
216
|
+
def mass_g=(mass_g)
|
217
|
+
if mass_g.nil?
|
218
|
+
fail ArgumentError, 'mass_g cannot be nil'
|
219
|
+
end
|
220
|
+
|
221
|
+
if mass_g > 2000000000
|
222
|
+
fail ArgumentError, 'invalid value for "mass_g", must be smaller than or equal to 2000000000.'
|
223
|
+
end
|
224
|
+
|
225
|
+
if mass_g < 1
|
226
|
+
fail ArgumentError, 'invalid value for "mass_g", must be greater than or equal to 1.'
|
227
|
+
end
|
228
|
+
|
229
|
+
@mass_g = mass_g
|
230
|
+
end
|
231
|
+
|
153
232
|
# Custom attribute writer method checking allowed values (enum).
|
154
233
|
# @param [Object] state Object to be assigned
|
155
234
|
def state=(state)
|
@@ -181,7 +260,9 @@ module Patch
|
|
181
260
|
state == o.state &&
|
182
261
|
allocation_state == o.allocation_state &&
|
183
262
|
price_cents_usd == o.price_cents_usd &&
|
184
|
-
|
263
|
+
patch_fee_cents_usd == o.patch_fee_cents_usd &&
|
264
|
+
allocations == o.allocations &&
|
265
|
+
metadata == o.metadata
|
185
266
|
end
|
186
267
|
|
187
268
|
# @see the `==` method
|
@@ -193,7 +274,7 @@ module Patch
|
|
193
274
|
# Calculates hash code according to all attributes.
|
194
275
|
# @return [Integer] Hash code
|
195
276
|
def hash
|
196
|
-
[id, mass_g, production, state, allocation_state, price_cents_usd, allocations].hash
|
277
|
+
[id, mass_g, production, state, allocation_state, price_cents_usd, patch_fee_cents_usd, allocations, metadata].hash
|
197
278
|
end
|
198
279
|
|
199
280
|
# Builds the object from hash
|
@@ -0,0 +1,216 @@
|
|
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: 4.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module Patch
|
16
|
+
class Photo
|
17
|
+
attr_accessor :url
|
18
|
+
|
19
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
20
|
+
def self.attribute_map
|
21
|
+
{
|
22
|
+
:'url' => :'url'
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
# Attribute type mapping.
|
27
|
+
def self.openapi_types
|
28
|
+
{
|
29
|
+
:'url' => :'String'
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# Allows models with corresponding API classes to delegate API operations to those API classes
|
34
|
+
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
35
|
+
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
36
|
+
def self.method_missing(message, *args, &block)
|
37
|
+
if Object.const_defined?('Patch::PhotosApi::OPERATIONS') && Patch::PhotosApi::OPERATIONS.include?(message)
|
38
|
+
Patch::PhotosApi.new.send(message, *args)
|
39
|
+
else
|
40
|
+
super
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Initializes the object
|
45
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
46
|
+
def initialize(attributes = {})
|
47
|
+
if (!attributes.is_a?(Hash))
|
48
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::Photo` initialize method"
|
49
|
+
end
|
50
|
+
|
51
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
52
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
53
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
54
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::Photo`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
55
|
+
end
|
56
|
+
h[k.to_sym] = v
|
57
|
+
}
|
58
|
+
|
59
|
+
if attributes.key?(:'url')
|
60
|
+
self.url = attributes[:'url']
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
65
|
+
# @return Array for valid properties with the reasons
|
66
|
+
def list_invalid_properties
|
67
|
+
invalid_properties = Array.new
|
68
|
+
if @url.nil?
|
69
|
+
invalid_properties.push('invalid value for "url", url cannot be nil.')
|
70
|
+
end
|
71
|
+
|
72
|
+
invalid_properties
|
73
|
+
end
|
74
|
+
|
75
|
+
# Check to see if the all the properties in the model are valid
|
76
|
+
# @return true if the model is valid
|
77
|
+
def valid?
|
78
|
+
return false if @url.nil?
|
79
|
+
true
|
80
|
+
end
|
81
|
+
|
82
|
+
# Checks equality by comparing each attribute.
|
83
|
+
# @param [Object] Object to be compared
|
84
|
+
def ==(o)
|
85
|
+
return true if self.equal?(o)
|
86
|
+
self.class == o.class &&
|
87
|
+
url == o.url
|
88
|
+
end
|
89
|
+
|
90
|
+
# @see the `==` method
|
91
|
+
# @param [Object] Object to be compared
|
92
|
+
def eql?(o)
|
93
|
+
self == o
|
94
|
+
end
|
95
|
+
|
96
|
+
# Calculates hash code according to all attributes.
|
97
|
+
# @return [Integer] Hash code
|
98
|
+
def hash
|
99
|
+
[url].hash
|
100
|
+
end
|
101
|
+
|
102
|
+
# Builds the object from hash
|
103
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
104
|
+
# @return [Object] Returns the model itself
|
105
|
+
def self.build_from_hash(attributes)
|
106
|
+
new.build_from_hash(attributes)
|
107
|
+
end
|
108
|
+
|
109
|
+
# Builds the object from hash
|
110
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
111
|
+
# @return [Object] Returns the model itself
|
112
|
+
def build_from_hash(attributes)
|
113
|
+
return nil unless attributes.is_a?(Hash)
|
114
|
+
self.class.openapi_types.each_pair do |key, type|
|
115
|
+
if type =~ /\AArray<(.*)>/i
|
116
|
+
# check to ensure the input is an array given that the attribute
|
117
|
+
# is documented as an array but the input is not
|
118
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
119
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
120
|
+
end
|
121
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
122
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
123
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
124
|
+
end
|
125
|
+
|
126
|
+
self
|
127
|
+
end
|
128
|
+
|
129
|
+
# Deserializes the data based on type
|
130
|
+
# @param string type Data type
|
131
|
+
# @param string value Value to be deserialized
|
132
|
+
# @return [Object] Deserialized data
|
133
|
+
def _deserialize(type, value)
|
134
|
+
case type.to_sym
|
135
|
+
when :DateTime
|
136
|
+
DateTime.parse(value)
|
137
|
+
when :Date
|
138
|
+
Date.parse(value)
|
139
|
+
when :String
|
140
|
+
value.to_s
|
141
|
+
when :Integer
|
142
|
+
value.to_i
|
143
|
+
when :Float
|
144
|
+
value.to_f
|
145
|
+
when :Boolean
|
146
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
147
|
+
true
|
148
|
+
else
|
149
|
+
false
|
150
|
+
end
|
151
|
+
when :Object
|
152
|
+
# generic object (usually a Hash), return directly
|
153
|
+
value
|
154
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
155
|
+
inner_type = Regexp.last_match[:inner_type]
|
156
|
+
value.map { |v| _deserialize(inner_type, v) }
|
157
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
158
|
+
k_type = Regexp.last_match[:k_type]
|
159
|
+
v_type = Regexp.last_match[:v_type]
|
160
|
+
{}.tap do |hash|
|
161
|
+
value.each do |k, v|
|
162
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
else # model
|
166
|
+
Patch.const_get(type).build_from_hash(value)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
# Returns the string representation of the object
|
171
|
+
# @return [String] String presentation of the object
|
172
|
+
def to_s
|
173
|
+
to_hash.to_s
|
174
|
+
end
|
175
|
+
|
176
|
+
# to_body is an alias to to_hash (backward compatibility)
|
177
|
+
# @return [Hash] Returns the object in the form of hash
|
178
|
+
def to_body
|
179
|
+
to_hash
|
180
|
+
end
|
181
|
+
|
182
|
+
# Returns the object in the form of hash
|
183
|
+
# @return [Hash] Returns the object in the form of hash
|
184
|
+
def to_hash
|
185
|
+
hash = {}
|
186
|
+
self.class.attribute_map.each_pair do |attr, param|
|
187
|
+
value = self.send(attr)
|
188
|
+
if value.nil?
|
189
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
190
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
191
|
+
end
|
192
|
+
|
193
|
+
hash[param] = _to_hash(value)
|
194
|
+
end
|
195
|
+
hash
|
196
|
+
end
|
197
|
+
|
198
|
+
# Outputs non-array value in the form of hash
|
199
|
+
# For object, use to_hash. Otherwise, just return the value
|
200
|
+
# @param [Object] value Any valid value
|
201
|
+
# @return [Hash] Returns the value in the form of hash
|
202
|
+
def _to_hash(value)
|
203
|
+
if value.is_a?(Array)
|
204
|
+
value.compact.map { |v| _to_hash(v) }
|
205
|
+
elsif value.is_a?(Hash)
|
206
|
+
{}.tap do |hash|
|
207
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
208
|
+
end
|
209
|
+
elsif value.respond_to? :to_hash
|
210
|
+
value.to_hash
|
211
|
+
else
|
212
|
+
value
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|