patch_ruby 1.24.2 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -0
- data/Gemfile.lock +9 -10
- data/lib/patch_ruby/api/estimates_api.rb +72 -2
- data/lib/patch_ruby/api/order_line_items_api.rb +269 -0
- data/lib/patch_ruby/api/orders_api.rb +99 -4
- data/lib/patch_ruby/api/projects_api.rb +12 -2
- data/lib/patch_ruby/api/technology_types_api.rb +7 -2
- data/lib/patch_ruby/api_client.rb +3 -3
- data/lib/patch_ruby/api_error.rb +2 -2
- data/lib/patch_ruby/configuration.rb +3 -4
- data/lib/patch_ruby/models/create_air_shipping_estimate_request.rb +2 -2
- data/lib/patch_ruby/models/create_bitcoin_estimate_request.rb +2 -2
- data/lib/patch_ruby/models/create_ecommerce_estimate_request.rb +2 -2
- data/lib/patch_ruby/models/create_ethereum_estimate_request.rb +2 -2
- data/lib/patch_ruby/models/create_flight_estimate_request.rb +2 -2
- data/lib/patch_ruby/models/create_hotel_estimate_request.rb +2 -2
- data/lib/patch_ruby/models/create_mass_estimate_request.rb +7 -7
- data/lib/patch_ruby/models/create_order_line_item_request.rb +443 -0
- data/lib/patch_ruby/models/create_order_request.rb +79 -70
- data/lib/patch_ruby/models/create_rail_shipping_estimate_request.rb +2 -2
- data/lib/patch_ruby/models/create_road_shipping_estimate_request.rb +13 -3
- data/lib/patch_ruby/models/create_sea_shipping_estimate_request.rb +2 -2
- data/lib/patch_ruby/models/create_shipping_estimate_request.rb +2 -2
- data/lib/patch_ruby/models/create_success_response.rb +2 -2
- data/lib/patch_ruby/models/create_vehicle_estimate_request.rb +2 -2
- data/lib/patch_ruby/models/delete_order_line_item_response.rb +257 -0
- data/lib/patch_ruby/models/delete_order_response.rb +257 -0
- data/lib/patch_ruby/models/disclaimer.rb +282 -0
- data/lib/patch_ruby/models/error_response.rb +2 -2
- data/lib/patch_ruby/models/estimate.rb +2 -2
- data/lib/patch_ruby/models/estimate_list_response.rb +2 -2
- data/lib/patch_ruby/models/estimate_response.rb +2 -2
- data/lib/patch_ruby/models/highlight.rb +2 -2
- data/lib/patch_ruby/models/inventory.rb +33 -3
- data/lib/patch_ruby/models/meta_index_object.rb +2 -2
- data/lib/patch_ruby/models/order.rb +17 -121
- data/lib/patch_ruby/models/order_issued_to.rb +2 -2
- data/lib/patch_ruby/models/{order_inventory.rb → order_line_item.rb} +49 -9
- data/lib/patch_ruby/models/{order_inventory_project.rb → order_line_item_project.rb} +7 -7
- data/lib/patch_ruby/models/{allocation.rb → order_line_item_response.rb} +33 -40
- data/lib/patch_ruby/models/order_list_response.rb +2 -2
- data/lib/patch_ruby/models/order_response.rb +2 -2
- data/lib/patch_ruby/models/parent_technology_type.rb +2 -2
- data/lib/patch_ruby/models/photo.rb +2 -2
- data/lib/patch_ruby/models/place_order_request.rb +2 -2
- data/lib/patch_ruby/models/project.rb +72 -56
- data/lib/patch_ruby/models/project_list_response.rb +2 -2
- data/lib/patch_ruby/models/project_response.rb +2 -2
- data/lib/patch_ruby/models/sdg.rb +2 -2
- data/lib/patch_ruby/models/standard.rb +2 -2
- data/lib/patch_ruby/models/technology_type.rb +2 -2
- data/lib/patch_ruby/models/technology_type_list_response.rb +2 -2
- data/lib/patch_ruby/models/update_order_line_item_request.rb +434 -0
- data/lib/patch_ruby/version.rb +3 -3
- data/lib/patch_ruby.rb +11 -5
- data/patch_ruby.gemspec +2 -2
- data/spec/api/order_line_items_api_spec.rb +78 -0
- data/spec/api_client_spec.rb +2 -2
- data/spec/configuration_spec.rb +2 -2
- data/spec/factories/create_order_requests.rb +4 -2
- data/spec/factories/orders.rb +5 -4
- data/spec/factories/projects.rb +1 -4
- data/spec/integration/estimates_spec.rb +1 -1
- data/spec/integration/orders_spec.rb +121 -44
- data/spec/integration/projects_spec.rb +19 -7
- data/spec/models/create_order_request_spec.rb +10 -3
- data/spec/models/order_spec.rb +8 -23
- data/spec/models/project_spec.rb +1 -4
- data/spec/spec_helper.rb +2 -2
- metadata +35 -31
- data/spec/factories/allocations.rb +0 -7
- data/spec/models/allocation_spec.rb +0 -59
@@ -0,0 +1,434 @@
|
|
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 :vintage_start_year
|
21
|
+
|
22
|
+
attr_accessor :vintage_end_year
|
23
|
+
|
24
|
+
attr_accessor :price
|
25
|
+
|
26
|
+
attr_accessor :currency
|
27
|
+
|
28
|
+
attr_accessor :amount
|
29
|
+
|
30
|
+
attr_accessor :unit
|
31
|
+
|
32
|
+
class EnumAttributeValidator
|
33
|
+
attr_reader :datatype
|
34
|
+
attr_reader :allowable_values
|
35
|
+
|
36
|
+
def initialize(datatype, allowable_values)
|
37
|
+
@allowable_values = allowable_values.map do |value|
|
38
|
+
case datatype.to_s
|
39
|
+
when /Integer/i
|
40
|
+
value.to_i
|
41
|
+
when /Float/i
|
42
|
+
value.to_f
|
43
|
+
else
|
44
|
+
value
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def valid?(value)
|
50
|
+
!value || allowable_values.include?(value)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
55
|
+
def self.attribute_map
|
56
|
+
{
|
57
|
+
:'vintage_year' => :'vintage_year',
|
58
|
+
:'vintage_start_year' => :'vintage_start_year',
|
59
|
+
:'vintage_end_year' => :'vintage_end_year',
|
60
|
+
:'price' => :'price',
|
61
|
+
:'currency' => :'currency',
|
62
|
+
:'amount' => :'amount',
|
63
|
+
:'unit' => :'unit'
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
# Returns all the JSON keys this model knows about
|
68
|
+
def self.acceptable_attributes
|
69
|
+
attribute_map.values
|
70
|
+
end
|
71
|
+
|
72
|
+
# Attribute type mapping.
|
73
|
+
def self.openapi_types
|
74
|
+
{
|
75
|
+
:'vintage_year' => :'Integer',
|
76
|
+
:'vintage_start_year' => :'Integer',
|
77
|
+
:'vintage_end_year' => :'Integer',
|
78
|
+
:'price' => :'Integer',
|
79
|
+
:'currency' => :'String',
|
80
|
+
:'amount' => :'Integer',
|
81
|
+
:'unit' => :'String'
|
82
|
+
}
|
83
|
+
end
|
84
|
+
|
85
|
+
# List of attributes with nullable: true
|
86
|
+
def self.openapi_nullable
|
87
|
+
Set.new([
|
88
|
+
:'vintage_year',
|
89
|
+
:'vintage_start_year',
|
90
|
+
:'vintage_end_year',
|
91
|
+
:'price',
|
92
|
+
:'currency',
|
93
|
+
:'amount',
|
94
|
+
:'unit'
|
95
|
+
])
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
# Allows models with corresponding API classes to delegate API operations to those API classes
|
100
|
+
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
101
|
+
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
102
|
+
def self.method_missing(message, *args, &block)
|
103
|
+
if Object.const_defined?('Patch::UpdateOrderLineItemRequestsApi::OPERATIONS') && Patch::UpdateOrderLineItemRequestsApi::OPERATIONS.include?(message)
|
104
|
+
Patch::UpdateOrderLineItemRequestsApi.new.send(message, *args)
|
105
|
+
else
|
106
|
+
super
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
# Initializes the object
|
111
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
112
|
+
def initialize(attributes = {})
|
113
|
+
if (!attributes.is_a?(Hash))
|
114
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::UpdateOrderLineItemRequest` initialize method"
|
115
|
+
end
|
116
|
+
|
117
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
118
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
119
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
120
|
+
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
|
121
|
+
end
|
122
|
+
h[k.to_sym] = v
|
123
|
+
}
|
124
|
+
|
125
|
+
if attributes.key?(:'vintage_year')
|
126
|
+
self.vintage_year = attributes[:'vintage_year']
|
127
|
+
end
|
128
|
+
|
129
|
+
if attributes.key?(:'vintage_start_year')
|
130
|
+
self.vintage_start_year = attributes[:'vintage_start_year']
|
131
|
+
end
|
132
|
+
|
133
|
+
if attributes.key?(:'vintage_end_year')
|
134
|
+
self.vintage_end_year = attributes[:'vintage_end_year']
|
135
|
+
end
|
136
|
+
|
137
|
+
if attributes.key?(:'price')
|
138
|
+
self.price = attributes[:'price']
|
139
|
+
end
|
140
|
+
|
141
|
+
if attributes.key?(:'currency')
|
142
|
+
self.currency = attributes[:'currency']
|
143
|
+
end
|
144
|
+
|
145
|
+
if attributes.key?(:'amount')
|
146
|
+
self.amount = attributes[:'amount']
|
147
|
+
end
|
148
|
+
|
149
|
+
if attributes.key?(:'unit')
|
150
|
+
self.unit = attributes[:'unit']
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
155
|
+
# @return Array for valid properties with the reasons
|
156
|
+
def list_invalid_properties
|
157
|
+
invalid_properties = Array.new
|
158
|
+
if !@vintage_year.nil? && @vintage_year > 2100
|
159
|
+
invalid_properties.push('invalid value for "vintage_year", must be smaller than or equal to 2100.')
|
160
|
+
end
|
161
|
+
|
162
|
+
if !@vintage_year.nil? && @vintage_year < 1900
|
163
|
+
invalid_properties.push('invalid value for "vintage_year", must be greater than or equal to 1900.')
|
164
|
+
end
|
165
|
+
|
166
|
+
if !@vintage_start_year.nil? && @vintage_start_year > 2100
|
167
|
+
invalid_properties.push('invalid value for "vintage_start_year", must be smaller than or equal to 2100.')
|
168
|
+
end
|
169
|
+
|
170
|
+
if !@vintage_start_year.nil? && @vintage_start_year < 1900
|
171
|
+
invalid_properties.push('invalid value for "vintage_start_year", must be greater than or equal to 1900.')
|
172
|
+
end
|
173
|
+
|
174
|
+
if !@vintage_end_year.nil? && @vintage_end_year > 2100
|
175
|
+
invalid_properties.push('invalid value for "vintage_end_year", must be smaller than or equal to 2100.')
|
176
|
+
end
|
177
|
+
|
178
|
+
if !@vintage_end_year.nil? && @vintage_end_year < 1900
|
179
|
+
invalid_properties.push('invalid value for "vintage_end_year", must be greater than or equal to 1900.')
|
180
|
+
end
|
181
|
+
|
182
|
+
if !@price.nil? && @price < 2
|
183
|
+
invalid_properties.push('invalid value for "price", must be greater than or equal to 2.')
|
184
|
+
end
|
185
|
+
|
186
|
+
if !@amount.nil? && @amount > 100000000000000
|
187
|
+
invalid_properties.push('invalid value for "amount", must be smaller than or equal to 100000000000000.')
|
188
|
+
end
|
189
|
+
|
190
|
+
if !@amount.nil? && @amount < 0
|
191
|
+
invalid_properties.push('invalid value for "amount", must be greater than or equal to 0.')
|
192
|
+
end
|
193
|
+
|
194
|
+
invalid_properties
|
195
|
+
end
|
196
|
+
|
197
|
+
# Check to see if the all the properties in the model are valid
|
198
|
+
# @return true if the model is valid
|
199
|
+
def valid?
|
200
|
+
return false if !@vintage_year.nil? && @vintage_year > 2100
|
201
|
+
return false if !@vintage_year.nil? && @vintage_year < 1900
|
202
|
+
return false if !@vintage_start_year.nil? && @vintage_start_year > 2100
|
203
|
+
return false if !@vintage_start_year.nil? && @vintage_start_year < 1900
|
204
|
+
return false if !@vintage_end_year.nil? && @vintage_end_year > 2100
|
205
|
+
return false if !@vintage_end_year.nil? && @vintage_end_year < 1900
|
206
|
+
return false if !@price.nil? && @price < 2
|
207
|
+
return false if !@amount.nil? && @amount > 100000000000000
|
208
|
+
return false if !@amount.nil? && @amount < 0
|
209
|
+
unit_validator = EnumAttributeValidator.new('String', ["g", "Wh"])
|
210
|
+
return false unless unit_validator.valid?(@unit)
|
211
|
+
true
|
212
|
+
end
|
213
|
+
|
214
|
+
# Custom attribute writer method with validation
|
215
|
+
# @param [Object] vintage_year Value to be assigned
|
216
|
+
def vintage_year=(vintage_year)
|
217
|
+
if !vintage_year.nil? && vintage_year > 2100
|
218
|
+
fail ArgumentError, 'invalid value for "vintage_year", must be smaller than or equal to 2100.'
|
219
|
+
end
|
220
|
+
|
221
|
+
if !vintage_year.nil? && vintage_year < 1900
|
222
|
+
fail ArgumentError, 'invalid value for "vintage_year", must be greater than or equal to 1900.'
|
223
|
+
end
|
224
|
+
|
225
|
+
@vintage_year = vintage_year
|
226
|
+
end
|
227
|
+
|
228
|
+
# Custom attribute writer method with validation
|
229
|
+
# @param [Object] vintage_start_year Value to be assigned
|
230
|
+
def vintage_start_year=(vintage_start_year)
|
231
|
+
if !vintage_start_year.nil? && vintage_start_year > 2100
|
232
|
+
fail ArgumentError, 'invalid value for "vintage_start_year", must be smaller than or equal to 2100.'
|
233
|
+
end
|
234
|
+
|
235
|
+
if !vintage_start_year.nil? && vintage_start_year < 1900
|
236
|
+
fail ArgumentError, 'invalid value for "vintage_start_year", must be greater than or equal to 1900.'
|
237
|
+
end
|
238
|
+
|
239
|
+
@vintage_start_year = vintage_start_year
|
240
|
+
end
|
241
|
+
|
242
|
+
# Custom attribute writer method with validation
|
243
|
+
# @param [Object] vintage_end_year Value to be assigned
|
244
|
+
def vintage_end_year=(vintage_end_year)
|
245
|
+
if !vintage_end_year.nil? && vintage_end_year > 2100
|
246
|
+
fail ArgumentError, 'invalid value for "vintage_end_year", must be smaller than or equal to 2100.'
|
247
|
+
end
|
248
|
+
|
249
|
+
if !vintage_end_year.nil? && vintage_end_year < 1900
|
250
|
+
fail ArgumentError, 'invalid value for "vintage_end_year", must be greater than or equal to 1900.'
|
251
|
+
end
|
252
|
+
|
253
|
+
@vintage_end_year = vintage_end_year
|
254
|
+
end
|
255
|
+
|
256
|
+
# Custom attribute writer method with validation
|
257
|
+
# @param [Object] price Value to be assigned
|
258
|
+
def price=(price)
|
259
|
+
if !price.nil? && price < 2
|
260
|
+
fail ArgumentError, 'invalid value for "price", must be greater than or equal to 2.'
|
261
|
+
end
|
262
|
+
|
263
|
+
@price = price
|
264
|
+
end
|
265
|
+
|
266
|
+
# Custom attribute writer method with validation
|
267
|
+
# @param [Object] amount Value to be assigned
|
268
|
+
def amount=(amount)
|
269
|
+
if !amount.nil? && amount > 100000000000000
|
270
|
+
fail ArgumentError, 'invalid value for "amount", must be smaller than or equal to 100000000000000.'
|
271
|
+
end
|
272
|
+
|
273
|
+
if !amount.nil? && amount < 0
|
274
|
+
fail ArgumentError, 'invalid value for "amount", must be greater than or equal to 0.'
|
275
|
+
end
|
276
|
+
|
277
|
+
@amount = amount
|
278
|
+
end
|
279
|
+
|
280
|
+
# Custom attribute writer method checking allowed values (enum).
|
281
|
+
# @param [Object] unit Object to be assigned
|
282
|
+
def unit=(unit)
|
283
|
+
validator = EnumAttributeValidator.new('String', ["g", "Wh"])
|
284
|
+
unless validator.valid?(unit)
|
285
|
+
fail ArgumentError, "invalid value for \"unit\", must be one of #{validator.allowable_values}."
|
286
|
+
end
|
287
|
+
@unit = unit
|
288
|
+
end
|
289
|
+
|
290
|
+
# Checks equality by comparing each attribute.
|
291
|
+
# @param [Object] Object to be compared
|
292
|
+
def ==(o)
|
293
|
+
return true if self.equal?(o)
|
294
|
+
self.class == o.class &&
|
295
|
+
vintage_year == o.vintage_year &&
|
296
|
+
vintage_start_year == o.vintage_start_year &&
|
297
|
+
vintage_end_year == o.vintage_end_year &&
|
298
|
+
price == o.price &&
|
299
|
+
currency == o.currency &&
|
300
|
+
amount == o.amount &&
|
301
|
+
unit == o.unit
|
302
|
+
end
|
303
|
+
|
304
|
+
# @see the `==` method
|
305
|
+
# @param [Object] Object to be compared
|
306
|
+
def eql?(o)
|
307
|
+
self == o
|
308
|
+
end
|
309
|
+
|
310
|
+
# Calculates hash code according to all attributes.
|
311
|
+
# @return [Integer] Hash code
|
312
|
+
def hash
|
313
|
+
[vintage_year, vintage_start_year, vintage_end_year, price, currency, amount, unit].hash
|
314
|
+
end
|
315
|
+
|
316
|
+
# Builds the object from hash
|
317
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
318
|
+
# @return [Object] Returns the model itself
|
319
|
+
def self.build_from_hash(attributes)
|
320
|
+
new.build_from_hash(attributes)
|
321
|
+
end
|
322
|
+
|
323
|
+
# Builds the object from hash
|
324
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
325
|
+
# @return [Object] Returns the model itself
|
326
|
+
def build_from_hash(attributes)
|
327
|
+
return nil unless attributes.is_a?(Hash)
|
328
|
+
self.class.openapi_types.each_pair do |key, type|
|
329
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
330
|
+
self.send("#{key}=", nil)
|
331
|
+
elsif type =~ /\AArray<(.*)>/i
|
332
|
+
# check to ensure the input is an array given that the attribute
|
333
|
+
# is documented as an array but the input is not
|
334
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
335
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
336
|
+
end
|
337
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
338
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
342
|
+
self
|
343
|
+
end
|
344
|
+
|
345
|
+
# Deserializes the data based on type
|
346
|
+
# @param string type Data type
|
347
|
+
# @param string value Value to be deserialized
|
348
|
+
# @return [Object] Deserialized data
|
349
|
+
def _deserialize(type, value)
|
350
|
+
case type.to_sym
|
351
|
+
when :Time
|
352
|
+
Time.parse(value)
|
353
|
+
when :Date
|
354
|
+
Date.parse(value)
|
355
|
+
when :String
|
356
|
+
value.to_s
|
357
|
+
when :Integer
|
358
|
+
value.to_i
|
359
|
+
when :Float
|
360
|
+
value.to_f
|
361
|
+
when :Boolean
|
362
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
363
|
+
true
|
364
|
+
else
|
365
|
+
false
|
366
|
+
end
|
367
|
+
when :Object
|
368
|
+
# generic object (usually a Hash), return directly
|
369
|
+
value
|
370
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
371
|
+
inner_type = Regexp.last_match[:inner_type]
|
372
|
+
value.map { |v| _deserialize(inner_type, v) }
|
373
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
374
|
+
k_type = Regexp.last_match[:k_type]
|
375
|
+
v_type = Regexp.last_match[:v_type]
|
376
|
+
{}.tap do |hash|
|
377
|
+
value.each do |k, v|
|
378
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
379
|
+
end
|
380
|
+
end
|
381
|
+
else # model
|
382
|
+
# models (e.g. Pet) or oneOf
|
383
|
+
klass = Patch.const_get(type)
|
384
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
385
|
+
end
|
386
|
+
end
|
387
|
+
|
388
|
+
# Returns the string representation of the object
|
389
|
+
# @return [String] String presentation of the object
|
390
|
+
def to_s
|
391
|
+
to_hash.to_s
|
392
|
+
end
|
393
|
+
|
394
|
+
# to_body is an alias to to_hash (backward compatibility)
|
395
|
+
# @return [Hash] Returns the object in the form of hash
|
396
|
+
def to_body
|
397
|
+
to_hash
|
398
|
+
end
|
399
|
+
|
400
|
+
# Returns the object in the form of hash
|
401
|
+
# @return [Hash] Returns the object in the form of hash
|
402
|
+
def to_hash
|
403
|
+
hash = {}
|
404
|
+
self.class.attribute_map.each_pair do |attr, param|
|
405
|
+
value = self.send(attr)
|
406
|
+
if value.nil?
|
407
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
408
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
409
|
+
end
|
410
|
+
|
411
|
+
hash[param] = _to_hash(value)
|
412
|
+
end
|
413
|
+
hash
|
414
|
+
end
|
415
|
+
|
416
|
+
# Outputs non-array value in the form of hash
|
417
|
+
# For object, use to_hash. Otherwise, just return the value
|
418
|
+
# @param [Object] value Any valid value
|
419
|
+
# @return [Hash] Returns the value in the form of hash
|
420
|
+
def _to_hash(value)
|
421
|
+
if value.is_a?(Array)
|
422
|
+
value.compact.map { |v| _to_hash(v) }
|
423
|
+
elsif value.is_a?(Hash)
|
424
|
+
{}.tap do |hash|
|
425
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
426
|
+
end
|
427
|
+
elsif value.respond_to? :to_hash
|
428
|
+
value.to_hash
|
429
|
+
else
|
430
|
+
value
|
431
|
+
end
|
432
|
+
end
|
433
|
+
end
|
434
|
+
end
|
data/lib/patch_ruby/version.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
=begin
|
2
|
-
#Patch API
|
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:
|
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.
|
14
|
+
VERSION = '2.1.1'
|
15
15
|
end
|
data/lib/patch_ruby.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
=begin
|
2
|
-
#Patch API
|
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:
|
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,9 @@ 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'
|
37
|
+
require 'patch_ruby/models/disclaimer'
|
35
38
|
require 'patch_ruby/models/error_response'
|
36
39
|
require 'patch_ruby/models/estimate'
|
37
40
|
require 'patch_ruby/models/estimate_list_response'
|
@@ -40,9 +43,10 @@ require 'patch_ruby/models/highlight'
|
|
40
43
|
require 'patch_ruby/models/inventory'
|
41
44
|
require 'patch_ruby/models/meta_index_object'
|
42
45
|
require 'patch_ruby/models/order'
|
43
|
-
require 'patch_ruby/models/order_inventory'
|
44
|
-
require 'patch_ruby/models/order_inventory_project'
|
45
46
|
require 'patch_ruby/models/order_issued_to'
|
47
|
+
require 'patch_ruby/models/order_line_item'
|
48
|
+
require 'patch_ruby/models/order_line_item_project'
|
49
|
+
require 'patch_ruby/models/order_line_item_response'
|
46
50
|
require 'patch_ruby/models/order_list_response'
|
47
51
|
require 'patch_ruby/models/order_response'
|
48
52
|
require 'patch_ruby/models/parent_technology_type'
|
@@ -55,9 +59,11 @@ require 'patch_ruby/models/sdg'
|
|
55
59
|
require 'patch_ruby/models/standard'
|
56
60
|
require 'patch_ruby/models/technology_type'
|
57
61
|
require 'patch_ruby/models/technology_type_list_response'
|
62
|
+
require 'patch_ruby/models/update_order_line_item_request'
|
58
63
|
|
59
64
|
# APIs
|
60
65
|
require 'patch_ruby/api/estimates_api'
|
66
|
+
require 'patch_ruby/api/order_line_items_api'
|
61
67
|
require 'patch_ruby/api/orders_api'
|
62
68
|
require 'patch_ruby/api/projects_api'
|
63
69
|
require 'patch_ruby/api/technology_types_api'
|
data/patch_ruby.gemspec
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
3
|
=begin
|
4
|
-
#Patch API
|
4
|
+
#Patch API V2
|
5
5
|
|
6
6
|
#The core API used to integrate with Patch's service
|
7
7
|
|
8
|
-
The version of the OpenAPI document:
|
8
|
+
The version of the OpenAPI document: 2
|
9
9
|
Contact: engineering@usepatch.com
|
10
10
|
Generated by: https://openapi-generator.tech
|
11
11
|
OpenAPI Generator version: 5.3.1
|
@@ -0,0 +1,78 @@
|
|
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 'spec_helper'
|
14
|
+
require 'json'
|
15
|
+
|
16
|
+
# Unit tests for Patch::OrderLineItemsApi
|
17
|
+
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
18
|
+
# Please update as you see appropriate
|
19
|
+
describe 'OrderLineItemsApi' do
|
20
|
+
before do
|
21
|
+
# run before each test
|
22
|
+
@api_instance = Patch::OrderLineItemsApi.new
|
23
|
+
end
|
24
|
+
|
25
|
+
after do
|
26
|
+
# run after each test
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'test an instance of OrderLineItemsApi' do
|
30
|
+
it 'should create an instance of OrderLineItemsApi' do
|
31
|
+
expect(@api_instance).to be_instance_of(Patch::OrderLineItemsApi)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# unit tests for create_order_line_item
|
36
|
+
# Creates an order line item
|
37
|
+
# Creates a line item on an order that is in the `draft` state.
|
38
|
+
# @param order_id
|
39
|
+
# @param create_order_line_item_request
|
40
|
+
# @param [Hash] opts the optional parameters
|
41
|
+
# @option opts [Integer] :patch_version
|
42
|
+
# @return [OrderLineItemResponse]
|
43
|
+
describe 'create_order_line_item test' do
|
44
|
+
it 'should work' do
|
45
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# unit tests for delete_order_line_item
|
50
|
+
# Deletes an order line item
|
51
|
+
# Deletes a line item on an order that is in the `draft` state.
|
52
|
+
# @param order_id
|
53
|
+
# @param serial_number
|
54
|
+
# @param [Hash] opts the optional parameters
|
55
|
+
# @option opts [Integer] :patch_version
|
56
|
+
# @return [DeleteOrderLineItemResponse]
|
57
|
+
describe 'delete_order_line_item test' do
|
58
|
+
it 'should work' do
|
59
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# unit tests for update_order_line_item
|
64
|
+
# Updates an order line item
|
65
|
+
# Updates a line item on an order that is in the `draft` state.
|
66
|
+
# @param order_id
|
67
|
+
# @param serial_number
|
68
|
+
# @param update_order_line_item_request
|
69
|
+
# @param [Hash] opts the optional parameters
|
70
|
+
# @option opts [Integer] :patch_version
|
71
|
+
# @return [OrderLineItemResponse]
|
72
|
+
describe 'update_order_line_item test' do
|
73
|
+
it 'should work' do
|
74
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
data/spec/api_client_spec.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
=begin
|
2
|
-
#Patch API
|
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:
|
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
|
data/spec/configuration_spec.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
=begin
|
2
|
-
#Patch API
|
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:
|
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,8 +1,10 @@
|
|
1
1
|
FactoryBot.define do
|
2
2
|
factory :create_order_request, class: Patch::CreateOrderRequest do
|
3
3
|
sequence(:project_id) { |n| n }
|
4
|
-
|
5
|
-
|
4
|
+
amount { 100 }
|
5
|
+
unit { "g" }
|
6
|
+
total_price { 100 }
|
7
|
+
currency { "USD" }
|
6
8
|
metadata { {} }
|
7
9
|
end
|
8
10
|
end
|
data/spec/factories/orders.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
FactoryBot.define do
|
2
2
|
factory :order, class: Patch::Order do
|
3
3
|
sequence(:id) { |n| n }
|
4
|
-
|
4
|
+
amount { 1_000 }
|
5
|
+
unit { "g" }
|
5
6
|
production { false }
|
6
7
|
state { "draft" }
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
price { 500 }
|
9
|
+
patch_fee { 5 }
|
10
|
+
currency { "USD" }
|
10
11
|
metadata { {} }
|
11
12
|
end
|
12
13
|
end
|
data/spec/factories/projects.rb
CHANGED
@@ -7,12 +7,9 @@ FactoryBot.define do
|
|
7
7
|
production { false }
|
8
8
|
name { "New Project" }
|
9
9
|
description { "New Descirption" }
|
10
|
-
type { "biomass" }
|
11
10
|
country { "DK" }
|
12
|
-
|
11
|
+
project_partner { "Danish Developer" }
|
13
12
|
photos { [] }
|
14
|
-
average_price_per_tonne_cents_usd { 120 }
|
15
|
-
remaining_mass_g { 1_000 }
|
16
13
|
standard { 'european_biochar_certificate' }
|
17
14
|
state { 'CO' }
|
18
15
|
latitude { 45.0 }
|
@@ -86,7 +86,7 @@ RSpec.describe 'Estimates Integration' do
|
|
86
86
|
create_order: false
|
87
87
|
)
|
88
88
|
|
89
|
-
expect(create_estimate_response.data.type).to eq '
|
89
|
+
expect(create_estimate_response.data.type).to eq 'ecommerce'
|
90
90
|
expect(create_estimate_response.data.mass_g).to be >= 10_000
|
91
91
|
end
|
92
92
|
|