patch_ruby 1.14.0 → 1.16.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 +24 -0
- data/Gemfile.lock +3 -2
- data/README.md +11 -12
- data/lib/patch_ruby/api/estimates_api.rb +1 -1
- data/lib/patch_ruby/api/orders_api.rb +1 -1
- data/lib/patch_ruby/api/projects_api.rb +1 -1
- data/lib/patch_ruby/api/technology_types_api.rb +84 -0
- data/lib/patch_ruby/api_client.rb +2 -2
- data/lib/patch_ruby/api_error.rb +1 -1
- data/lib/patch_ruby/configuration.rb +4 -4
- data/lib/patch_ruby/models/allocation.rb +1 -1
- data/lib/patch_ruby/models/create_bitcoin_estimate_request.rb +1 -1
- data/lib/patch_ruby/models/create_ethereum_estimate_request.rb +1 -1
- data/lib/patch_ruby/models/create_flight_estimate_request.rb +1 -1
- data/lib/patch_ruby/models/create_mass_estimate_request.rb +6 -6
- data/lib/patch_ruby/models/create_order_request.rb +6 -6
- data/lib/patch_ruby/models/create_shipping_estimate_request.rb +1 -1
- data/lib/patch_ruby/models/create_success_response.rb +1 -1
- data/lib/patch_ruby/models/create_vehicle_estimate_request.rb +1 -1
- data/lib/patch_ruby/models/error_response.rb +1 -1
- data/lib/patch_ruby/models/estimate.rb +1 -1
- data/lib/patch_ruby/models/estimate_list_response.rb +1 -1
- data/lib/patch_ruby/models/estimate_response.rb +1 -1
- data/lib/patch_ruby/models/{create_preference_request.rb → highlight.rb} +47 -16
- data/lib/patch_ruby/models/meta_index_object.rb +1 -1
- data/lib/patch_ruby/models/order.rb +7 -7
- data/lib/patch_ruby/models/order_list_response.rb +1 -1
- data/lib/patch_ruby/models/order_response.rb +1 -1
- data/lib/patch_ruby/models/parent_technology_type.rb +2 -1
- data/lib/patch_ruby/models/photo.rb +1 -1
- data/lib/patch_ruby/models/project.rb +44 -25
- data/lib/patch_ruby/models/project_list_response.rb +1 -1
- data/lib/patch_ruby/models/project_response.rb +1 -1
- data/lib/patch_ruby/models/sdg.rb +1 -1
- data/lib/patch_ruby/models/standard.rb +1 -1
- data/lib/patch_ruby/models/technology_type.rb +13 -2
- data/lib/patch_ruby/models/{preference_response.rb → technology_type_list_response.rb} +10 -8
- data/lib/patch_ruby/version.rb +2 -2
- data/lib/patch_ruby.rb +4 -6
- data/patch_ruby.gemspec +1 -1
- data/spec/api/technology_types_api_spec.rb +46 -0
- data/spec/api_client_spec.rb +1 -1
- data/spec/configuration_spec.rb +1 -1
- data/spec/integration/orders_spec.rb +1 -3
- data/spec/integration/projects/technology_types_spec.rb +14 -0
- data/spec/integration/projects_spec.rb +2 -1
- data/spec/models/project_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +30 -47
- data/lib/patch_ruby/models/preference.rb +0 -264
- data/lib/patch_ruby/models/preference_list_response.rb +0 -273
- data/spec/api/preferences_api_spec.rb +0 -82
- data/spec/factories/create_preference_requests.rb +0 -5
- data/spec/factories/preference_list_responses.rb +0 -8
- data/spec/factories/preference_responses.rb +0 -7
- data/spec/factories/preferences.rb +0 -7
- data/spec/integration/preferences_spec.rb +0 -32
- data/spec/models/create_preference_request_spec.rb +0 -47
- data/spec/models/preference_list_response_spec.rb +0 -64
- data/spec/models/preference_response_spec.rb +0 -58
- data/spec/models/preference_spec.rb +0 -58
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: patch_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patch Technology
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- lib/patch_ruby/api/orders_api.rb
|
98
98
|
- lib/patch_ruby/api/preferences_api.rb
|
99
99
|
- lib/patch_ruby/api/projects_api.rb
|
100
|
+
- lib/patch_ruby/api/technology_types_api.rb
|
100
101
|
- lib/patch_ruby/api_client.rb
|
101
102
|
- lib/patch_ruby/api_error.rb
|
102
103
|
- lib/patch_ruby/configuration.rb
|
@@ -106,7 +107,6 @@ files:
|
|
106
107
|
- lib/patch_ruby/models/create_flight_estimate_request.rb
|
107
108
|
- lib/patch_ruby/models/create_mass_estimate_request.rb
|
108
109
|
- lib/patch_ruby/models/create_order_request.rb
|
109
|
-
- lib/patch_ruby/models/create_preference_request.rb
|
110
110
|
- lib/patch_ruby/models/create_shipping_estimate_request.rb
|
111
111
|
- lib/patch_ruby/models/create_success_response.rb
|
112
112
|
- lib/patch_ruby/models/create_vehicle_estimate_request.rb
|
@@ -114,34 +114,32 @@ files:
|
|
114
114
|
- lib/patch_ruby/models/estimate.rb
|
115
115
|
- lib/patch_ruby/models/estimate_list_response.rb
|
116
116
|
- lib/patch_ruby/models/estimate_response.rb
|
117
|
+
- lib/patch_ruby/models/highlight.rb
|
117
118
|
- lib/patch_ruby/models/meta_index_object.rb
|
118
119
|
- lib/patch_ruby/models/order.rb
|
119
120
|
- lib/patch_ruby/models/order_list_response.rb
|
120
121
|
- lib/patch_ruby/models/order_response.rb
|
121
122
|
- lib/patch_ruby/models/parent_technology_type.rb
|
122
123
|
- lib/patch_ruby/models/photo.rb
|
123
|
-
- lib/patch_ruby/models/preference.rb
|
124
|
-
- lib/patch_ruby/models/preference_list_response.rb
|
125
|
-
- lib/patch_ruby/models/preference_response.rb
|
126
124
|
- lib/patch_ruby/models/project.rb
|
127
125
|
- lib/patch_ruby/models/project_list_response.rb
|
128
126
|
- lib/patch_ruby/models/project_response.rb
|
129
127
|
- lib/patch_ruby/models/sdg.rb
|
130
128
|
- lib/patch_ruby/models/standard.rb
|
131
129
|
- lib/patch_ruby/models/technology_type.rb
|
130
|
+
- lib/patch_ruby/models/technology_type_list_response.rb
|
132
131
|
- lib/patch_ruby/version.rb
|
133
132
|
- patch_ruby.gemspec
|
134
133
|
- spec/api/estimates_api_spec.rb
|
135
134
|
- spec/api/orders_api_spec.rb
|
136
|
-
- spec/api/preferences_api_spec.rb
|
137
135
|
- spec/api/projects_api_spec.rb
|
136
|
+
- spec/api/technology_types_api_spec.rb
|
138
137
|
- spec/api_client_spec.rb
|
139
138
|
- spec/configuration_spec.rb
|
140
139
|
- spec/constants.rb
|
141
140
|
- spec/factories/allocations.rb
|
142
141
|
- spec/factories/create_mass_estimate_requests.rb
|
143
142
|
- spec/factories/create_order_requests.rb
|
144
|
-
- spec/factories/create_preference_requests.rb
|
145
143
|
- spec/factories/error_responses.rb
|
146
144
|
- spec/factories/estimate_list_responses.rb
|
147
145
|
- spec/factories/estimate_responses.rb
|
@@ -151,9 +149,6 @@ files:
|
|
151
149
|
- spec/factories/order_responses.rb
|
152
150
|
- spec/factories/orders.rb
|
153
151
|
- spec/factories/parent_technology_type.rb
|
154
|
-
- spec/factories/preference_list_responses.rb
|
155
|
-
- spec/factories/preference_responses.rb
|
156
|
-
- spec/factories/preferences.rb
|
157
152
|
- spec/factories/project_list_responses.rb
|
158
153
|
- spec/factories/project_responses.rb
|
159
154
|
- spec/factories/projects.rb
|
@@ -161,12 +156,11 @@ files:
|
|
161
156
|
- spec/factories/technology_type.rb
|
162
157
|
- spec/integration/estimates_spec.rb
|
163
158
|
- spec/integration/orders_spec.rb
|
164
|
-
- spec/integration/
|
159
|
+
- spec/integration/projects/technology_types_spec.rb
|
165
160
|
- spec/integration/projects_spec.rb
|
166
161
|
- spec/models/allocation_spec.rb
|
167
162
|
- spec/models/create_mass_estimate_request_spec.rb
|
168
163
|
- spec/models/create_order_request_spec.rb
|
169
|
-
- spec/models/create_preference_request_spec.rb
|
170
164
|
- spec/models/error_response_spec.rb
|
171
165
|
- spec/models/estimate_list_response_spec.rb
|
172
166
|
- spec/models/estimate_response_spec.rb
|
@@ -175,9 +169,6 @@ files:
|
|
175
169
|
- spec/models/order_list_response_spec.rb
|
176
170
|
- spec/models/order_response_spec.rb
|
177
171
|
- spec/models/order_spec.rb
|
178
|
-
- spec/models/preference_list_response_spec.rb
|
179
|
-
- spec/models/preference_response_spec.rb
|
180
|
-
- spec/models/preference_spec.rb
|
181
172
|
- spec/models/project_list_response_spec.rb
|
182
173
|
- spec/models/project_response_spec.rb
|
183
174
|
- spec/models/project_spec.rb
|
@@ -208,56 +199,48 @@ signing_key:
|
|
208
199
|
specification_version: 4
|
209
200
|
summary: Ruby wrapper for the Patch API
|
210
201
|
test_files:
|
211
|
-
- spec/api/
|
202
|
+
- spec/api/technology_types_api_spec.rb
|
212
203
|
- spec/api/estimates_api_spec.rb
|
213
|
-
- spec/api/preferences_api_spec.rb
|
214
204
|
- spec/api/orders_api_spec.rb
|
205
|
+
- spec/api/projects_api_spec.rb
|
215
206
|
- spec/api_client_spec.rb
|
216
207
|
- spec/configuration_spec.rb
|
217
208
|
- spec/constants.rb
|
218
|
-
- spec/factories/
|
219
|
-
- spec/factories/preference_list_responses.rb
|
209
|
+
- spec/factories/orders.rb
|
220
210
|
- spec/factories/allocations.rb
|
221
|
-
- spec/factories/estimates.rb
|
222
|
-
- spec/factories/create_mass_estimate_requests.rb
|
223
|
-
- spec/factories/project_responses.rb
|
224
|
-
- spec/factories/estimate_list_responses.rb
|
225
211
|
- spec/factories/meta_index_objects.rb
|
212
|
+
- spec/factories/estimates.rb
|
213
|
+
- spec/factories/order_responses.rb
|
214
|
+
- spec/factories/create_order_requests.rb
|
215
|
+
- spec/factories/projects.rb
|
216
|
+
- spec/factories/order_list_responses.rb
|
226
217
|
- spec/factories/project_list_responses.rb
|
227
|
-
- spec/factories/
|
228
|
-
- spec/factories/preference_responses.rb
|
229
|
-
- spec/factories/error_responses.rb
|
218
|
+
- spec/factories/create_mass_estimate_requests.rb
|
230
219
|
- spec/factories/estimate_responses.rb
|
231
|
-
- spec/factories/
|
220
|
+
- spec/factories/estimate_list_responses.rb
|
221
|
+
- spec/factories/project_responses.rb
|
232
222
|
- spec/factories/technology_type.rb
|
233
|
-
- spec/factories/preferences.rb
|
234
|
-
- spec/factories/order_list_responses.rb
|
235
|
-
- spec/factories/projects.rb
|
236
|
-
- spec/factories/create_order_requests.rb
|
237
|
-
- spec/factories/parent_technology_type.rb
|
238
223
|
- spec/factories/sdgs.rb
|
239
|
-
- spec/
|
224
|
+
- spec/factories/parent_technology_type.rb
|
225
|
+
- spec/factories/error_responses.rb
|
226
|
+
- spec/integration/projects/technology_types_spec.rb
|
240
227
|
- spec/integration/projects_spec.rb
|
241
|
-
- spec/integration/
|
228
|
+
- spec/integration/estimates_spec.rb
|
242
229
|
- spec/integration/orders_spec.rb
|
243
|
-
- spec/models/
|
230
|
+
- spec/models/meta_index_object_spec.rb
|
231
|
+
- spec/models/estimate_response_spec.rb
|
244
232
|
- spec/models/project_list_response_spec.rb
|
245
|
-
- spec/models/preference_list_response_spec.rb
|
246
233
|
- spec/models/order_list_response_spec.rb
|
247
|
-
- spec/models/project_response_spec.rb
|
248
|
-
- spec/models/create_mass_estimate_request_spec.rb
|
249
|
-
- spec/models/order_spec.rb
|
250
|
-
- spec/models/preference_spec.rb
|
251
|
-
- spec/models/error_response_spec.rb
|
252
234
|
- spec/models/allocation_spec.rb
|
253
235
|
- spec/models/order_response_spec.rb
|
254
|
-
- spec/models/
|
255
|
-
- spec/models/create_preference_request_spec.rb
|
256
|
-
- spec/models/project_spec.rb
|
236
|
+
- spec/models/error_response_spec.rb
|
257
237
|
- spec/models/estimate_list_response_spec.rb
|
238
|
+
- spec/models/create_order_request_spec.rb
|
239
|
+
- spec/models/create_mass_estimate_request_spec.rb
|
240
|
+
- spec/models/project_spec.rb
|
241
|
+
- spec/models/project_response_spec.rb
|
258
242
|
- spec/models/estimate_spec.rb
|
259
|
-
- spec/models/
|
260
|
-
- spec/models/preference_response_spec.rb
|
243
|
+
- spec/models/order_spec.rb
|
261
244
|
- spec/patch_ruby_spec.rb
|
262
245
|
- spec/spec_helper.rb
|
263
246
|
- spec/support/shared/generated_classes.rb
|
@@ -1,264 +0,0 @@
|
|
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 Preference
|
18
|
-
# A unique uid for the record. UIDs will be prepended by pre_prod or pre_test depending on the mode it was created in.
|
19
|
-
attr_accessor :id
|
20
|
-
|
21
|
-
# Percentage of total purchased offsets that should go to a project. Default is 100%.
|
22
|
-
attr_accessor :allocation_percentage
|
23
|
-
|
24
|
-
# An object returning the Project record this Preference is associated with. See the [Project section](/?id=projects) for the full schema.
|
25
|
-
attr_accessor :project
|
26
|
-
|
27
|
-
# Attribute mapping from ruby-style variable name to JSON key.
|
28
|
-
def self.attribute_map
|
29
|
-
{
|
30
|
-
:'id' => :'id',
|
31
|
-
:'allocation_percentage' => :'allocation_percentage',
|
32
|
-
:'project' => :'project'
|
33
|
-
}
|
34
|
-
end
|
35
|
-
|
36
|
-
# Returns all the JSON keys this model knows about
|
37
|
-
def self.acceptable_attributes
|
38
|
-
attribute_map.values
|
39
|
-
end
|
40
|
-
|
41
|
-
# Attribute type mapping.
|
42
|
-
def self.openapi_types
|
43
|
-
{
|
44
|
-
:'id' => :'String',
|
45
|
-
:'allocation_percentage' => :'Integer',
|
46
|
-
:'project' => :'Project'
|
47
|
-
}
|
48
|
-
end
|
49
|
-
|
50
|
-
# List of attributes with nullable: true
|
51
|
-
def self.openapi_nullable
|
52
|
-
Set.new([
|
53
|
-
])
|
54
|
-
end
|
55
|
-
|
56
|
-
|
57
|
-
# Allows models with corresponding API classes to delegate API operations to those API classes
|
58
|
-
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
59
|
-
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
60
|
-
def self.method_missing(message, *args, &block)
|
61
|
-
if Object.const_defined?('Patch::PreferencesApi::OPERATIONS') && Patch::PreferencesApi::OPERATIONS.include?(message)
|
62
|
-
Patch::PreferencesApi.new.send(message, *args)
|
63
|
-
else
|
64
|
-
super
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
# Initializes the object
|
69
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
70
|
-
def initialize(attributes = {})
|
71
|
-
if (!attributes.is_a?(Hash))
|
72
|
-
fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::Preference` initialize method"
|
73
|
-
end
|
74
|
-
|
75
|
-
# check to see if the attribute exists and convert string to symbol for hash key
|
76
|
-
attributes = attributes.each_with_object({}) { |(k, v), h|
|
77
|
-
if (!self.class.attribute_map.key?(k.to_sym))
|
78
|
-
fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::Preference`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
79
|
-
end
|
80
|
-
h[k.to_sym] = v
|
81
|
-
}
|
82
|
-
|
83
|
-
if attributes.key?(:'id')
|
84
|
-
self.id = attributes[:'id']
|
85
|
-
end
|
86
|
-
|
87
|
-
if attributes.key?(:'allocation_percentage')
|
88
|
-
self.allocation_percentage = attributes[:'allocation_percentage']
|
89
|
-
end
|
90
|
-
|
91
|
-
if attributes.key?(:'project')
|
92
|
-
self.project = attributes[:'project']
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
# Show invalid properties with the reasons. Usually used together with valid?
|
97
|
-
# @return Array for valid properties with the reasons
|
98
|
-
def list_invalid_properties
|
99
|
-
invalid_properties = Array.new
|
100
|
-
if @id.nil?
|
101
|
-
invalid_properties.push('invalid value for "id", id cannot be nil.')
|
102
|
-
end
|
103
|
-
|
104
|
-
if @allocation_percentage.nil?
|
105
|
-
invalid_properties.push('invalid value for "allocation_percentage", allocation_percentage cannot be nil.')
|
106
|
-
end
|
107
|
-
|
108
|
-
if @project.nil?
|
109
|
-
invalid_properties.push('invalid value for "project", project cannot be nil.')
|
110
|
-
end
|
111
|
-
|
112
|
-
invalid_properties
|
113
|
-
end
|
114
|
-
|
115
|
-
# Check to see if the all the properties in the model are valid
|
116
|
-
# @return true if the model is valid
|
117
|
-
def valid?
|
118
|
-
return false if @id.nil?
|
119
|
-
return false if @allocation_percentage.nil?
|
120
|
-
return false if @project.nil?
|
121
|
-
true
|
122
|
-
end
|
123
|
-
|
124
|
-
# Checks equality by comparing each attribute.
|
125
|
-
# @param [Object] Object to be compared
|
126
|
-
def ==(o)
|
127
|
-
return true if self.equal?(o)
|
128
|
-
self.class == o.class &&
|
129
|
-
id == o.id &&
|
130
|
-
allocation_percentage == o.allocation_percentage &&
|
131
|
-
project == o.project
|
132
|
-
end
|
133
|
-
|
134
|
-
# @see the `==` method
|
135
|
-
# @param [Object] Object to be compared
|
136
|
-
def eql?(o)
|
137
|
-
self == o
|
138
|
-
end
|
139
|
-
|
140
|
-
# Calculates hash code according to all attributes.
|
141
|
-
# @return [Integer] Hash code
|
142
|
-
def hash
|
143
|
-
[id, allocation_percentage, project].hash
|
144
|
-
end
|
145
|
-
|
146
|
-
# Builds the object from hash
|
147
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
148
|
-
# @return [Object] Returns the model itself
|
149
|
-
def self.build_from_hash(attributes)
|
150
|
-
new.build_from_hash(attributes)
|
151
|
-
end
|
152
|
-
|
153
|
-
# Builds the object from hash
|
154
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
155
|
-
# @return [Object] Returns the model itself
|
156
|
-
def build_from_hash(attributes)
|
157
|
-
return nil unless attributes.is_a?(Hash)
|
158
|
-
self.class.openapi_types.each_pair do |key, type|
|
159
|
-
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
160
|
-
self.send("#{key}=", nil)
|
161
|
-
elsif type =~ /\AArray<(.*)>/i
|
162
|
-
# check to ensure the input is an array given that the attribute
|
163
|
-
# is documented as an array but the input is not
|
164
|
-
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
165
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
166
|
-
end
|
167
|
-
elsif !attributes[self.class.attribute_map[key]].nil?
|
168
|
-
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
self
|
173
|
-
end
|
174
|
-
|
175
|
-
# Deserializes the data based on type
|
176
|
-
# @param string type Data type
|
177
|
-
# @param string value Value to be deserialized
|
178
|
-
# @return [Object] Deserialized data
|
179
|
-
def _deserialize(type, value)
|
180
|
-
case type.to_sym
|
181
|
-
when :Time
|
182
|
-
Time.parse(value)
|
183
|
-
when :Date
|
184
|
-
Date.parse(value)
|
185
|
-
when :String
|
186
|
-
value.to_s
|
187
|
-
when :Integer
|
188
|
-
value.to_i
|
189
|
-
when :Float
|
190
|
-
value.to_f
|
191
|
-
when :Boolean
|
192
|
-
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
193
|
-
true
|
194
|
-
else
|
195
|
-
false
|
196
|
-
end
|
197
|
-
when :Object
|
198
|
-
# generic object (usually a Hash), return directly
|
199
|
-
value
|
200
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
201
|
-
inner_type = Regexp.last_match[:inner_type]
|
202
|
-
value.map { |v| _deserialize(inner_type, v) }
|
203
|
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
204
|
-
k_type = Regexp.last_match[:k_type]
|
205
|
-
v_type = Regexp.last_match[:v_type]
|
206
|
-
{}.tap do |hash|
|
207
|
-
value.each do |k, v|
|
208
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
209
|
-
end
|
210
|
-
end
|
211
|
-
else # model
|
212
|
-
# models (e.g. Pet) or oneOf
|
213
|
-
klass = Patch.const_get(type)
|
214
|
-
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
# Returns the string representation of the object
|
219
|
-
# @return [String] String presentation of the object
|
220
|
-
def to_s
|
221
|
-
to_hash.to_s
|
222
|
-
end
|
223
|
-
|
224
|
-
# to_body is an alias to to_hash (backward compatibility)
|
225
|
-
# @return [Hash] Returns the object in the form of hash
|
226
|
-
def to_body
|
227
|
-
to_hash
|
228
|
-
end
|
229
|
-
|
230
|
-
# Returns the object in the form of hash
|
231
|
-
# @return [Hash] Returns the object in the form of hash
|
232
|
-
def to_hash
|
233
|
-
hash = {}
|
234
|
-
self.class.attribute_map.each_pair do |attr, param|
|
235
|
-
value = self.send(attr)
|
236
|
-
if value.nil?
|
237
|
-
is_nullable = self.class.openapi_nullable.include?(attr)
|
238
|
-
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
239
|
-
end
|
240
|
-
|
241
|
-
hash[param] = _to_hash(value)
|
242
|
-
end
|
243
|
-
hash
|
244
|
-
end
|
245
|
-
|
246
|
-
# Outputs non-array value in the form of hash
|
247
|
-
# For object, use to_hash. Otherwise, just return the value
|
248
|
-
# @param [Object] value Any valid value
|
249
|
-
# @return [Hash] Returns the value in the form of hash
|
250
|
-
def _to_hash(value)
|
251
|
-
if value.is_a?(Array)
|
252
|
-
value.compact.map { |v| _to_hash(v) }
|
253
|
-
elsif value.is_a?(Hash)
|
254
|
-
{}.tap do |hash|
|
255
|
-
value.each { |k, v| hash[k] = _to_hash(v) }
|
256
|
-
end
|
257
|
-
elsif value.respond_to? :to_hash
|
258
|
-
value.to_hash
|
259
|
-
else
|
260
|
-
value
|
261
|
-
end
|
262
|
-
end
|
263
|
-
end
|
264
|
-
end
|