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