patch_ruby 1.24.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/lib/patch_ruby/api/estimates_api.rb +72 -2
  4. data/lib/patch_ruby/api/order_line_items_api.rb +269 -0
  5. data/lib/patch_ruby/api/orders_api.rb +99 -4
  6. data/lib/patch_ruby/api/projects_api.rb +12 -2
  7. data/lib/patch_ruby/api/technology_types_api.rb +7 -2
  8. data/lib/patch_ruby/api_client.rb +3 -3
  9. data/lib/patch_ruby/api_error.rb +2 -2
  10. data/lib/patch_ruby/configuration.rb +2 -2
  11. data/lib/patch_ruby/models/create_air_shipping_estimate_request.rb +2 -2
  12. data/lib/patch_ruby/models/create_bitcoin_estimate_request.rb +2 -2
  13. data/lib/patch_ruby/models/create_ecommerce_estimate_request.rb +2 -2
  14. data/lib/patch_ruby/models/create_ethereum_estimate_request.rb +2 -2
  15. data/lib/patch_ruby/models/create_flight_estimate_request.rb +2 -2
  16. data/lib/patch_ruby/models/create_hotel_estimate_request.rb +2 -2
  17. data/lib/patch_ruby/models/create_mass_estimate_request.rb +2 -2
  18. data/lib/patch_ruby/models/create_order_line_item_request.rb +375 -0
  19. data/lib/patch_ruby/models/create_order_request.rb +8 -67
  20. data/lib/patch_ruby/models/create_rail_shipping_estimate_request.rb +2 -2
  21. data/lib/patch_ruby/models/create_road_shipping_estimate_request.rb +2 -2
  22. data/lib/patch_ruby/models/create_sea_shipping_estimate_request.rb +2 -2
  23. data/lib/patch_ruby/models/create_shipping_estimate_request.rb +2 -2
  24. data/lib/patch_ruby/models/create_success_response.rb +2 -2
  25. data/lib/patch_ruby/models/create_vehicle_estimate_request.rb +2 -2
  26. data/lib/patch_ruby/models/delete_order_line_item_response.rb +257 -0
  27. data/lib/patch_ruby/models/delete_order_response.rb +257 -0
  28. data/lib/patch_ruby/models/error_response.rb +2 -2
  29. data/lib/patch_ruby/models/estimate.rb +2 -2
  30. data/lib/patch_ruby/models/estimate_list_response.rb +2 -2
  31. data/lib/patch_ruby/models/estimate_response.rb +2 -2
  32. data/lib/patch_ruby/models/highlight.rb +2 -2
  33. data/lib/patch_ruby/models/inventory.rb +2 -2
  34. data/lib/patch_ruby/models/meta_index_object.rb +2 -2
  35. data/lib/patch_ruby/models/order.rb +11 -115
  36. data/lib/patch_ruby/models/order_issued_to.rb +2 -2
  37. data/lib/patch_ruby/models/{order_inventory.rb → order_line_item.rb} +19 -9
  38. data/lib/patch_ruby/models/{order_inventory_project.rb → order_line_item_project.rb} +7 -7
  39. data/lib/patch_ruby/models/{allocation.rb → order_line_item_response.rb} +33 -40
  40. data/lib/patch_ruby/models/order_list_response.rb +2 -2
  41. data/lib/patch_ruby/models/order_response.rb +2 -2
  42. data/lib/patch_ruby/models/parent_technology_type.rb +2 -2
  43. data/lib/patch_ruby/models/photo.rb +2 -2
  44. data/lib/patch_ruby/models/place_order_request.rb +2 -2
  45. data/lib/patch_ruby/models/project.rb +13 -53
  46. data/lib/patch_ruby/models/project_list_response.rb +2 -2
  47. data/lib/patch_ruby/models/project_response.rb +2 -2
  48. data/lib/patch_ruby/models/sdg.rb +2 -2
  49. data/lib/patch_ruby/models/standard.rb +2 -2
  50. data/lib/patch_ruby/models/technology_type.rb +2 -2
  51. data/lib/patch_ruby/models/technology_type_list_response.rb +2 -2
  52. data/lib/patch_ruby/models/update_order_line_item_request.rb +366 -0
  53. data/lib/patch_ruby/version.rb +3 -3
  54. data/lib/patch_ruby.rb +10 -5
  55. data/patch_ruby.gemspec +2 -2
  56. data/spec/api/order_line_items_api_spec.rb +78 -0
  57. data/spec/api_client_spec.rb +2 -2
  58. data/spec/configuration_spec.rb +2 -2
  59. data/spec/factories/create_order_requests.rb +4 -2
  60. data/spec/factories/orders.rb +5 -4
  61. data/spec/factories/projects.rb +1 -4
  62. data/spec/integration/orders_spec.rb +85 -44
  63. data/spec/integration/projects_spec.rb +2 -4
  64. data/spec/models/create_order_request_spec.rb +10 -3
  65. data/spec/models/order_spec.rb +8 -23
  66. data/spec/models/project_spec.rb +1 -4
  67. data/spec/spec_helper.rb +2 -2
  68. metadata +34 -31
  69. data/spec/factories/allocations.rb +0 -7
  70. data/spec/models/allocation_spec.rb +0 -59
@@ -1,9 +1,9 @@
1
1
  =begin
2
- #Patch API V1
2
+ #Patch API V2
3
3
 
4
4
  #The core API used to integrate with Patch's service
5
5
 
6
- The version of the OpenAPI document: v1
6
+ The version of the OpenAPI document: 2
7
7
  Contact: engineering@usepatch.com
8
8
  Generated by: https://openapi-generator.tech
9
9
  OpenAPI Generator version: 5.3.1
@@ -27,9 +27,6 @@ module Patch
27
27
  # The description of the project.
28
28
  attr_accessor :description
29
29
 
30
- # DEPRECATED. Favor the technology_type field instead.
31
- attr_accessor :type
32
-
33
30
  # The mechanism of the project. One of: removal, avoidance, avoidance_and_removal.
34
31
  attr_accessor :mechanism
35
32
 
@@ -45,18 +42,12 @@ module Patch
45
42
  # The longitude at which this project is located.
46
43
  attr_accessor :longitude
47
44
 
48
- # The name of the project developer.
49
- attr_accessor :developer
45
+ # The name of the project project partner.
46
+ attr_accessor :project_partner
50
47
 
51
48
  # An array of URLs for photos of the project.
52
49
  attr_accessor :photos
53
50
 
54
- # DEPRECATED. The average price per tonne in USD cents for carbon offsets supplied by this project.
55
- attr_accessor :average_price_per_tonne_cents_usd
56
-
57
- # DEPRECATED. The remaining mass in grams available for purchase for this project.
58
- attr_accessor :remaining_mass_g
59
-
60
51
  # The name of the project verifier, when applicable. A verifier is the organization that verifies the calculations of the actual amount of greenhouse gas emissions that have been avoided or sequestered through implementation of the project.
61
52
  attr_accessor :verifier
62
53
 
@@ -84,16 +75,13 @@ module Patch
84
75
  :'production' => :'production',
85
76
  :'name' => :'name',
86
77
  :'description' => :'description',
87
- :'type' => :'type',
88
78
  :'mechanism' => :'mechanism',
89
79
  :'country' => :'country',
90
80
  :'state' => :'state',
91
81
  :'latitude' => :'latitude',
92
82
  :'longitude' => :'longitude',
93
- :'developer' => :'developer',
83
+ :'project_partner' => :'project_partner',
94
84
  :'photos' => :'photos',
95
- :'average_price_per_tonne_cents_usd' => :'average_price_per_tonne_cents_usd',
96
- :'remaining_mass_g' => :'remaining_mass_g',
97
85
  :'verifier' => :'verifier',
98
86
  :'standard' => :'standard',
99
87
  :'sdgs' => :'sdgs',
@@ -116,16 +104,13 @@ module Patch
116
104
  :'production' => :'Boolean',
117
105
  :'name' => :'String',
118
106
  :'description' => :'String',
119
- :'type' => :'String',
120
107
  :'mechanism' => :'String',
121
108
  :'country' => :'String',
122
109
  :'state' => :'String',
123
110
  :'latitude' => :'Float',
124
111
  :'longitude' => :'Float',
125
- :'developer' => :'String',
112
+ :'project_partner' => :'String',
126
113
  :'photos' => :'Array<Photo>',
127
- :'average_price_per_tonne_cents_usd' => :'Integer',
128
- :'remaining_mass_g' => :'Integer',
129
114
  :'verifier' => :'String',
130
115
  :'standard' => :'Standard',
131
116
  :'sdgs' => :'Array<Sdg>',
@@ -191,10 +176,6 @@ module Patch
191
176
  self.description = attributes[:'description']
192
177
  end
193
178
 
194
- if attributes.key?(:'type')
195
- self.type = attributes[:'type']
196
- end
197
-
198
179
  if attributes.key?(:'mechanism')
199
180
  self.mechanism = attributes[:'mechanism']
200
181
  end
@@ -215,8 +196,8 @@ module Patch
215
196
  self.longitude = attributes[:'longitude']
216
197
  end
217
198
 
218
- if attributes.key?(:'developer')
219
- self.developer = attributes[:'developer']
199
+ if attributes.key?(:'project_partner')
200
+ self.project_partner = attributes[:'project_partner']
220
201
  end
221
202
 
222
203
  if attributes.key?(:'photos')
@@ -225,14 +206,6 @@ module Patch
225
206
  end
226
207
  end
227
208
 
228
- if attributes.key?(:'average_price_per_tonne_cents_usd')
229
- self.average_price_per_tonne_cents_usd = attributes[:'average_price_per_tonne_cents_usd']
230
- end
231
-
232
- if attributes.key?(:'remaining_mass_g')
233
- self.remaining_mass_g = attributes[:'remaining_mass_g']
234
- end
235
-
236
209
  if attributes.key?(:'verifier')
237
210
  self.verifier = attributes[:'verifier']
238
211
  end
@@ -295,16 +268,8 @@ module Patch
295
268
  invalid_properties.push('invalid value for "country", country cannot be nil.')
296
269
  end
297
270
 
298
- if @developer.nil?
299
- invalid_properties.push('invalid value for "developer", developer cannot be nil.')
300
- end
301
-
302
- if @average_price_per_tonne_cents_usd.nil?
303
- invalid_properties.push('invalid value for "average_price_per_tonne_cents_usd", average_price_per_tonne_cents_usd cannot be nil.')
304
- end
305
-
306
- if @remaining_mass_g.nil?
307
- invalid_properties.push('invalid value for "remaining_mass_g", remaining_mass_g cannot be nil.')
271
+ if @project_partner.nil?
272
+ invalid_properties.push('invalid value for "project_partner", project_partner cannot be nil.')
308
273
  end
309
274
 
310
275
  if @technology_type.nil?
@@ -330,9 +295,7 @@ module Patch
330
295
  return false if @name.nil?
331
296
  return false if @description.nil?
332
297
  return false if @country.nil?
333
- return false if @developer.nil?
334
- return false if @average_price_per_tonne_cents_usd.nil?
335
- return false if @remaining_mass_g.nil?
298
+ return false if @project_partner.nil?
336
299
  return false if @technology_type.nil?
337
300
  return false if @highlights.nil?
338
301
  return false if @inventory.nil?
@@ -348,16 +311,13 @@ module Patch
348
311
  production == o.production &&
349
312
  name == o.name &&
350
313
  description == o.description &&
351
- type == o.type &&
352
314
  mechanism == o.mechanism &&
353
315
  country == o.country &&
354
316
  state == o.state &&
355
317
  latitude == o.latitude &&
356
318
  longitude == o.longitude &&
357
- developer == o.developer &&
319
+ project_partner == o.project_partner &&
358
320
  photos == o.photos &&
359
- average_price_per_tonne_cents_usd == o.average_price_per_tonne_cents_usd &&
360
- remaining_mass_g == o.remaining_mass_g &&
361
321
  verifier == o.verifier &&
362
322
  standard == o.standard &&
363
323
  sdgs == o.sdgs &&
@@ -376,7 +336,7 @@ module Patch
376
336
  # Calculates hash code according to all attributes.
377
337
  # @return [Integer] Hash code
378
338
  def hash
379
- [id, production, name, description, type, mechanism, country, state, latitude, longitude, developer, photos, average_price_per_tonne_cents_usd, remaining_mass_g, verifier, standard, sdgs, tagline, technology_type, highlights, inventory].hash
339
+ [id, production, name, description, mechanism, country, state, latitude, longitude, project_partner, photos, verifier, standard, sdgs, tagline, technology_type, highlights, inventory].hash
380
340
  end
381
341
 
382
342
  # Builds the object from hash
@@ -1,9 +1,9 @@
1
1
  =begin
2
- #Patch API V1
2
+ #Patch API V2
3
3
 
4
4
  #The core API used to integrate with Patch's service
5
5
 
6
- The version of the OpenAPI document: v1
6
+ The version of the OpenAPI document: 2
7
7
  Contact: engineering@usepatch.com
8
8
  Generated by: https://openapi-generator.tech
9
9
  OpenAPI Generator version: 5.3.1
@@ -1,9 +1,9 @@
1
1
  =begin
2
- #Patch API V1
2
+ #Patch API V2
3
3
 
4
4
  #The core API used to integrate with Patch's service
5
5
 
6
- The version of the OpenAPI document: v1
6
+ The version of the OpenAPI document: 2
7
7
  Contact: engineering@usepatch.com
8
8
  Generated by: https://openapi-generator.tech
9
9
  OpenAPI Generator version: 5.3.1
@@ -1,9 +1,9 @@
1
1
  =begin
2
- #Patch API V1
2
+ #Patch API V2
3
3
 
4
4
  #The core API used to integrate with Patch's service
5
5
 
6
- The version of the OpenAPI document: v1
6
+ The version of the OpenAPI document: 2
7
7
  Contact: engineering@usepatch.com
8
8
  Generated by: https://openapi-generator.tech
9
9
  OpenAPI Generator version: 5.3.1
@@ -1,9 +1,9 @@
1
1
  =begin
2
- #Patch API V1
2
+ #Patch API V2
3
3
 
4
4
  #The core API used to integrate with Patch's service
5
5
 
6
- The version of the OpenAPI document: v1
6
+ The version of the OpenAPI document: 2
7
7
  Contact: engineering@usepatch.com
8
8
  Generated by: https://openapi-generator.tech
9
9
  OpenAPI Generator version: 5.3.1
@@ -1,9 +1,9 @@
1
1
  =begin
2
- #Patch API V1
2
+ #Patch API V2
3
3
 
4
4
  #The core API used to integrate with Patch's service
5
5
 
6
- The version of the OpenAPI document: v1
6
+ The version of the OpenAPI document: 2
7
7
  Contact: engineering@usepatch.com
8
8
  Generated by: https://openapi-generator.tech
9
9
  OpenAPI Generator version: 5.3.1
@@ -1,9 +1,9 @@
1
1
  =begin
2
- #Patch API V1
2
+ #Patch API V2
3
3
 
4
4
  #The core API used to integrate with Patch's service
5
5
 
6
- The version of the OpenAPI document: v1
6
+ The version of the OpenAPI document: 2
7
7
  Contact: engineering@usepatch.com
8
8
  Generated by: https://openapi-generator.tech
9
9
  OpenAPI Generator version: 5.3.1
@@ -0,0 +1,366 @@
1
+ =begin
2
+ #Patch API V2
3
+
4
+ #The core API used to integrate with Patch's service
5
+
6
+ The version of the OpenAPI document: 2
7
+ Contact: engineering@usepatch.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Patch
17
+ class UpdateOrderLineItemRequest
18
+ attr_accessor :vintage_year
19
+
20
+ attr_accessor :price
21
+
22
+ attr_accessor :currency
23
+
24
+ attr_accessor :amount
25
+
26
+ attr_accessor :unit
27
+
28
+ class EnumAttributeValidator
29
+ attr_reader :datatype
30
+ attr_reader :allowable_values
31
+
32
+ def initialize(datatype, allowable_values)
33
+ @allowable_values = allowable_values.map do |value|
34
+ case datatype.to_s
35
+ when /Integer/i
36
+ value.to_i
37
+ when /Float/i
38
+ value.to_f
39
+ else
40
+ value
41
+ end
42
+ end
43
+ end
44
+
45
+ def valid?(value)
46
+ !value || allowable_values.include?(value)
47
+ end
48
+ end
49
+
50
+ # Attribute mapping from ruby-style variable name to JSON key.
51
+ def self.attribute_map
52
+ {
53
+ :'vintage_year' => :'vintage_year',
54
+ :'price' => :'price',
55
+ :'currency' => :'currency',
56
+ :'amount' => :'amount',
57
+ :'unit' => :'unit'
58
+ }
59
+ end
60
+
61
+ # Returns all the JSON keys this model knows about
62
+ def self.acceptable_attributes
63
+ attribute_map.values
64
+ end
65
+
66
+ # Attribute type mapping.
67
+ def self.openapi_types
68
+ {
69
+ :'vintage_year' => :'Integer',
70
+ :'price' => :'Integer',
71
+ :'currency' => :'String',
72
+ :'amount' => :'Integer',
73
+ :'unit' => :'String'
74
+ }
75
+ end
76
+
77
+ # List of attributes with nullable: true
78
+ def self.openapi_nullable
79
+ Set.new([
80
+ :'vintage_year',
81
+ :'price',
82
+ :'currency',
83
+ :'amount',
84
+ :'unit'
85
+ ])
86
+ end
87
+
88
+
89
+ # Allows models with corresponding API classes to delegate API operations to those API classes
90
+ # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
91
+ # Eg. Order.create_order delegates to OrdersApi.new.create_order
92
+ def self.method_missing(message, *args, &block)
93
+ if Object.const_defined?('Patch::UpdateOrderLineItemRequestsApi::OPERATIONS') && Patch::UpdateOrderLineItemRequestsApi::OPERATIONS.include?(message)
94
+ Patch::UpdateOrderLineItemRequestsApi.new.send(message, *args)
95
+ else
96
+ super
97
+ end
98
+ end
99
+
100
+ # Initializes the object
101
+ # @param [Hash] attributes Model attributes in the form of hash
102
+ def initialize(attributes = {})
103
+ if (!attributes.is_a?(Hash))
104
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::UpdateOrderLineItemRequest` initialize method"
105
+ end
106
+
107
+ # check to see if the attribute exists and convert string to symbol for hash key
108
+ attributes = attributes.each_with_object({}) { |(k, v), h|
109
+ if (!self.class.attribute_map.key?(k.to_sym))
110
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::UpdateOrderLineItemRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
111
+ end
112
+ h[k.to_sym] = v
113
+ }
114
+
115
+ if attributes.key?(:'vintage_year')
116
+ self.vintage_year = attributes[:'vintage_year']
117
+ end
118
+
119
+ if attributes.key?(:'price')
120
+ self.price = attributes[:'price']
121
+ end
122
+
123
+ if attributes.key?(:'currency')
124
+ self.currency = attributes[:'currency']
125
+ end
126
+
127
+ if attributes.key?(:'amount')
128
+ self.amount = attributes[:'amount']
129
+ end
130
+
131
+ if attributes.key?(:'unit')
132
+ self.unit = attributes[:'unit']
133
+ end
134
+ end
135
+
136
+ # Show invalid properties with the reasons. Usually used together with valid?
137
+ # @return Array for valid properties with the reasons
138
+ def list_invalid_properties
139
+ invalid_properties = Array.new
140
+ if !@vintage_year.nil? && @vintage_year > 2100
141
+ invalid_properties.push('invalid value for "vintage_year", must be smaller than or equal to 2100.')
142
+ end
143
+
144
+ if !@vintage_year.nil? && @vintage_year < 1900
145
+ invalid_properties.push('invalid value for "vintage_year", must be greater than or equal to 1900.')
146
+ end
147
+
148
+ if !@price.nil? && @price < 2
149
+ invalid_properties.push('invalid value for "price", must be greater than or equal to 2.')
150
+ end
151
+
152
+ if !@amount.nil? && @amount > 100000000000
153
+ invalid_properties.push('invalid value for "amount", must be smaller than or equal to 100000000000.')
154
+ end
155
+
156
+ if !@amount.nil? && @amount < 0
157
+ invalid_properties.push('invalid value for "amount", must be greater than or equal to 0.')
158
+ end
159
+
160
+ invalid_properties
161
+ end
162
+
163
+ # Check to see if the all the properties in the model are valid
164
+ # @return true if the model is valid
165
+ def valid?
166
+ return false if !@vintage_year.nil? && @vintage_year > 2100
167
+ return false if !@vintage_year.nil? && @vintage_year < 1900
168
+ return false if !@price.nil? && @price < 2
169
+ return false if !@amount.nil? && @amount > 100000000000
170
+ return false if !@amount.nil? && @amount < 0
171
+ unit_validator = EnumAttributeValidator.new('String', ["g", "Wh"])
172
+ return false unless unit_validator.valid?(@unit)
173
+ true
174
+ end
175
+
176
+ # Custom attribute writer method with validation
177
+ # @param [Object] vintage_year Value to be assigned
178
+ def vintage_year=(vintage_year)
179
+ if !vintage_year.nil? && vintage_year > 2100
180
+ fail ArgumentError, 'invalid value for "vintage_year", must be smaller than or equal to 2100.'
181
+ end
182
+
183
+ if !vintage_year.nil? && vintage_year < 1900
184
+ fail ArgumentError, 'invalid value for "vintage_year", must be greater than or equal to 1900.'
185
+ end
186
+
187
+ @vintage_year = vintage_year
188
+ end
189
+
190
+ # Custom attribute writer method with validation
191
+ # @param [Object] price Value to be assigned
192
+ def price=(price)
193
+ if !price.nil? && price < 2
194
+ fail ArgumentError, 'invalid value for "price", must be greater than or equal to 2.'
195
+ end
196
+
197
+ @price = price
198
+ end
199
+
200
+ # Custom attribute writer method with validation
201
+ # @param [Object] amount Value to be assigned
202
+ def amount=(amount)
203
+ if !amount.nil? && amount > 100000000000
204
+ fail ArgumentError, 'invalid value for "amount", must be smaller than or equal to 100000000000.'
205
+ end
206
+
207
+ if !amount.nil? && amount < 0
208
+ fail ArgumentError, 'invalid value for "amount", must be greater than or equal to 0.'
209
+ end
210
+
211
+ @amount = amount
212
+ end
213
+
214
+ # Custom attribute writer method checking allowed values (enum).
215
+ # @param [Object] unit Object to be assigned
216
+ def unit=(unit)
217
+ validator = EnumAttributeValidator.new('String', ["g", "Wh"])
218
+ unless validator.valid?(unit)
219
+ fail ArgumentError, "invalid value for \"unit\", must be one of #{validator.allowable_values}."
220
+ end
221
+ @unit = unit
222
+ end
223
+
224
+ # Checks equality by comparing each attribute.
225
+ # @param [Object] Object to be compared
226
+ def ==(o)
227
+ return true if self.equal?(o)
228
+ self.class == o.class &&
229
+ vintage_year == o.vintage_year &&
230
+ price == o.price &&
231
+ currency == o.currency &&
232
+ amount == o.amount &&
233
+ unit == o.unit
234
+ end
235
+
236
+ # @see the `==` method
237
+ # @param [Object] Object to be compared
238
+ def eql?(o)
239
+ self == o
240
+ end
241
+
242
+ # Calculates hash code according to all attributes.
243
+ # @return [Integer] Hash code
244
+ def hash
245
+ [vintage_year, price, currency, amount, unit].hash
246
+ end
247
+
248
+ # Builds the object from hash
249
+ # @param [Hash] attributes Model attributes in the form of hash
250
+ # @return [Object] Returns the model itself
251
+ def self.build_from_hash(attributes)
252
+ new.build_from_hash(attributes)
253
+ end
254
+
255
+ # Builds the object from hash
256
+ # @param [Hash] attributes Model attributes in the form of hash
257
+ # @return [Object] Returns the model itself
258
+ def build_from_hash(attributes)
259
+ return nil unless attributes.is_a?(Hash)
260
+ self.class.openapi_types.each_pair do |key, type|
261
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
262
+ self.send("#{key}=", nil)
263
+ elsif type =~ /\AArray<(.*)>/i
264
+ # check to ensure the input is an array given that the attribute
265
+ # is documented as an array but the input is not
266
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
267
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
268
+ end
269
+ elsif !attributes[self.class.attribute_map[key]].nil?
270
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
271
+ end
272
+ end
273
+
274
+ self
275
+ end
276
+
277
+ # Deserializes the data based on type
278
+ # @param string type Data type
279
+ # @param string value Value to be deserialized
280
+ # @return [Object] Deserialized data
281
+ def _deserialize(type, value)
282
+ case type.to_sym
283
+ when :Time
284
+ Time.parse(value)
285
+ when :Date
286
+ Date.parse(value)
287
+ when :String
288
+ value.to_s
289
+ when :Integer
290
+ value.to_i
291
+ when :Float
292
+ value.to_f
293
+ when :Boolean
294
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
295
+ true
296
+ else
297
+ false
298
+ end
299
+ when :Object
300
+ # generic object (usually a Hash), return directly
301
+ value
302
+ when /\AArray<(?<inner_type>.+)>\z/
303
+ inner_type = Regexp.last_match[:inner_type]
304
+ value.map { |v| _deserialize(inner_type, v) }
305
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
306
+ k_type = Regexp.last_match[:k_type]
307
+ v_type = Regexp.last_match[:v_type]
308
+ {}.tap do |hash|
309
+ value.each do |k, v|
310
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
311
+ end
312
+ end
313
+ else # model
314
+ # models (e.g. Pet) or oneOf
315
+ klass = Patch.const_get(type)
316
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
317
+ end
318
+ end
319
+
320
+ # Returns the string representation of the object
321
+ # @return [String] String presentation of the object
322
+ def to_s
323
+ to_hash.to_s
324
+ end
325
+
326
+ # to_body is an alias to to_hash (backward compatibility)
327
+ # @return [Hash] Returns the object in the form of hash
328
+ def to_body
329
+ to_hash
330
+ end
331
+
332
+ # Returns the object in the form of hash
333
+ # @return [Hash] Returns the object in the form of hash
334
+ def to_hash
335
+ hash = {}
336
+ self.class.attribute_map.each_pair do |attr, param|
337
+ value = self.send(attr)
338
+ if value.nil?
339
+ is_nullable = self.class.openapi_nullable.include?(attr)
340
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
341
+ end
342
+
343
+ hash[param] = _to_hash(value)
344
+ end
345
+ hash
346
+ end
347
+
348
+ # Outputs non-array value in the form of hash
349
+ # For object, use to_hash. Otherwise, just return the value
350
+ # @param [Object] value Any valid value
351
+ # @return [Hash] Returns the value in the form of hash
352
+ def _to_hash(value)
353
+ if value.is_a?(Array)
354
+ value.compact.map { |v| _to_hash(v) }
355
+ elsif value.is_a?(Hash)
356
+ {}.tap do |hash|
357
+ value.each { |k, v| hash[k] = _to_hash(v) }
358
+ end
359
+ elsif value.respond_to? :to_hash
360
+ value.to_hash
361
+ else
362
+ value
363
+ end
364
+ end
365
+ end
366
+ end
@@ -1,9 +1,9 @@
1
1
  =begin
2
- #Patch API V1
2
+ #Patch API V2
3
3
 
4
4
  #The core API used to integrate with Patch's service
5
5
 
6
- The version of the OpenAPI document: v1
6
+ The version of the OpenAPI document: 2
7
7
  Contact: engineering@usepatch.com
8
8
  Generated by: https://openapi-generator.tech
9
9
  OpenAPI Generator version: 5.3.1
@@ -11,5 +11,5 @@ OpenAPI Generator version: 5.3.1
11
11
  =end
12
12
 
13
13
  module Patch
14
- VERSION = '1.24.2'
14
+ VERSION = '2.0.0'
15
15
  end
data/lib/patch_ruby.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  =begin
2
- #Patch API V1
2
+ #Patch API V2
3
3
 
4
4
  #The core API used to integrate with Patch's service
5
5
 
6
- The version of the OpenAPI document: v1
6
+ The version of the OpenAPI document: 2
7
7
  Contact: engineering@usepatch.com
8
8
  Generated by: https://openapi-generator.tech
9
9
  OpenAPI Generator version: 5.3.1
@@ -17,7 +17,6 @@ require 'patch_ruby/version'
17
17
  require 'patch_ruby/configuration'
18
18
 
19
19
  # Models
20
- require 'patch_ruby/models/allocation'
21
20
  require 'patch_ruby/models/create_air_shipping_estimate_request'
22
21
  require 'patch_ruby/models/create_bitcoin_estimate_request'
23
22
  require 'patch_ruby/models/create_ecommerce_estimate_request'
@@ -25,6 +24,7 @@ require 'patch_ruby/models/create_ethereum_estimate_request'
25
24
  require 'patch_ruby/models/create_flight_estimate_request'
26
25
  require 'patch_ruby/models/create_hotel_estimate_request'
27
26
  require 'patch_ruby/models/create_mass_estimate_request'
27
+ require 'patch_ruby/models/create_order_line_item_request'
28
28
  require 'patch_ruby/models/create_order_request'
29
29
  require 'patch_ruby/models/create_rail_shipping_estimate_request'
30
30
  require 'patch_ruby/models/create_road_shipping_estimate_request'
@@ -32,6 +32,8 @@ require 'patch_ruby/models/create_sea_shipping_estimate_request'
32
32
  require 'patch_ruby/models/create_shipping_estimate_request'
33
33
  require 'patch_ruby/models/create_success_response'
34
34
  require 'patch_ruby/models/create_vehicle_estimate_request'
35
+ require 'patch_ruby/models/delete_order_line_item_response'
36
+ require 'patch_ruby/models/delete_order_response'
35
37
  require 'patch_ruby/models/error_response'
36
38
  require 'patch_ruby/models/estimate'
37
39
  require 'patch_ruby/models/estimate_list_response'
@@ -40,9 +42,10 @@ require 'patch_ruby/models/highlight'
40
42
  require 'patch_ruby/models/inventory'
41
43
  require 'patch_ruby/models/meta_index_object'
42
44
  require 'patch_ruby/models/order'
43
- require 'patch_ruby/models/order_inventory'
44
- require 'patch_ruby/models/order_inventory_project'
45
45
  require 'patch_ruby/models/order_issued_to'
46
+ require 'patch_ruby/models/order_line_item'
47
+ require 'patch_ruby/models/order_line_item_project'
48
+ require 'patch_ruby/models/order_line_item_response'
46
49
  require 'patch_ruby/models/order_list_response'
47
50
  require 'patch_ruby/models/order_response'
48
51
  require 'patch_ruby/models/parent_technology_type'
@@ -55,9 +58,11 @@ require 'patch_ruby/models/sdg'
55
58
  require 'patch_ruby/models/standard'
56
59
  require 'patch_ruby/models/technology_type'
57
60
  require 'patch_ruby/models/technology_type_list_response'
61
+ require 'patch_ruby/models/update_order_line_item_request'
58
62
 
59
63
  # APIs
60
64
  require 'patch_ruby/api/estimates_api'
65
+ require 'patch_ruby/api/order_line_items_api'
61
66
  require 'patch_ruby/api/orders_api'
62
67
  require 'patch_ruby/api/projects_api'
63
68
  require 'patch_ruby/api/technology_types_api'