patch_ruby 2.0.0 → 2.3.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 +19 -0
- data/Gemfile.lock +13 -13
- data/lib/patch_ruby/api/estimates_api.rb +1 -226
- data/lib/patch_ruby/api/order_line_items_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 +1 -1
- data/lib/patch_ruby/api_client.rb +1 -1
- data/lib/patch_ruby/models/create_mass_estimate_request.rb +5 -5
- data/lib/patch_ruby/models/create_order_line_item_request.rb +81 -13
- data/lib/patch_ruby/models/create_order_request.rb +81 -13
- data/lib/patch_ruby/models/create_road_shipping_estimate_request.rb +11 -1
- data/lib/patch_ruby/models/{create_ethereum_estimate_request.rb → disclaimer.rb} +54 -53
- data/lib/patch_ruby/models/estimate.rb +1 -1
- data/lib/patch_ruby/models/inventory.rb +31 -1
- data/lib/patch_ruby/models/order.rb +6 -6
- data/lib/patch_ruby/models/order_line_item.rb +31 -1
- data/lib/patch_ruby/models/project.rb +61 -5
- data/lib/patch_ruby/models/update_order_line_item_request.rb +81 -13
- data/lib/patch_ruby/version.rb +1 -1
- data/lib/patch_ruby.rb +1 -3
- data/patch_ruby.gemspec +1 -1
- data/spec/integration/estimates_spec.rb +0 -65
- data/spec/integration/orders_spec.rb +36 -0
- data/spec/integration/projects_spec.rb +17 -3
- data/spec/models/create_order_request_spec.rb +1 -1
- metadata +27 -29
- data/lib/patch_ruby/models/create_shipping_estimate_request.rb +0 -373
- data/lib/patch_ruby/models/create_vehicle_estimate_request.rb +0 -328
@@ -36,6 +36,9 @@ module Patch
|
|
36
36
|
# The state where this project is located.
|
37
37
|
attr_accessor :state
|
38
38
|
|
39
|
+
# The issuance type of the project. One of: ex-ante, ex-post.
|
40
|
+
attr_accessor :issuance_type
|
41
|
+
|
39
42
|
# The latitude at which this project is located.
|
40
43
|
attr_accessor :latitude
|
41
44
|
|
@@ -62,12 +65,37 @@ module Patch
|
|
62
65
|
|
63
66
|
attr_accessor :technology_type
|
64
67
|
|
65
|
-
# An array of objects containing the highlight's slug, title, and a URL for the corresponding icon. A highlight's title is a short string that spotlights a characteristic about the project.
|
68
|
+
# DEPRECATED. An array of objects containing the highlight's slug, title, and a URL for the corresponding icon. A highlight's title is a short string that spotlights a characteristic about the project. Highlights are deprecated and not populated for recent projects.
|
66
69
|
attr_accessor :highlights
|
67
70
|
|
68
71
|
# An array of objects containing available inventory for a project. Available inventory is grouped by a project's vintage year and returns amount and pricing available for a given vintage year.
|
69
72
|
attr_accessor :inventory
|
70
73
|
|
74
|
+
# An array of objects containing disclaimers about the project. Information, warnings, and critical concerns may be present.
|
75
|
+
attr_accessor :disclaimers
|
76
|
+
|
77
|
+
class EnumAttributeValidator
|
78
|
+
attr_reader :datatype
|
79
|
+
attr_reader :allowable_values
|
80
|
+
|
81
|
+
def initialize(datatype, allowable_values)
|
82
|
+
@allowable_values = allowable_values.map do |value|
|
83
|
+
case datatype.to_s
|
84
|
+
when /Integer/i
|
85
|
+
value.to_i
|
86
|
+
when /Float/i
|
87
|
+
value.to_f
|
88
|
+
else
|
89
|
+
value
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def valid?(value)
|
95
|
+
!value || allowable_values.include?(value)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
71
99
|
# Attribute mapping from ruby-style variable name to JSON key.
|
72
100
|
def self.attribute_map
|
73
101
|
{
|
@@ -78,6 +106,7 @@ module Patch
|
|
78
106
|
:'mechanism' => :'mechanism',
|
79
107
|
:'country' => :'country',
|
80
108
|
:'state' => :'state',
|
109
|
+
:'issuance_type' => :'issuance_type',
|
81
110
|
:'latitude' => :'latitude',
|
82
111
|
:'longitude' => :'longitude',
|
83
112
|
:'project_partner' => :'project_partner',
|
@@ -88,7 +117,8 @@ module Patch
|
|
88
117
|
:'tagline' => :'tagline',
|
89
118
|
:'technology_type' => :'technology_type',
|
90
119
|
:'highlights' => :'highlights',
|
91
|
-
:'inventory' => :'inventory'
|
120
|
+
:'inventory' => :'inventory',
|
121
|
+
:'disclaimers' => :'disclaimers'
|
92
122
|
}
|
93
123
|
end
|
94
124
|
|
@@ -107,6 +137,7 @@ module Patch
|
|
107
137
|
:'mechanism' => :'String',
|
108
138
|
:'country' => :'String',
|
109
139
|
:'state' => :'String',
|
140
|
+
:'issuance_type' => :'String',
|
110
141
|
:'latitude' => :'Float',
|
111
142
|
:'longitude' => :'Float',
|
112
143
|
:'project_partner' => :'String',
|
@@ -117,7 +148,8 @@ module Patch
|
|
117
148
|
:'tagline' => :'String',
|
118
149
|
:'technology_type' => :'TechnologyType',
|
119
150
|
:'highlights' => :'Array<Highlight>',
|
120
|
-
:'inventory' => :'Array<Inventory>'
|
151
|
+
:'inventory' => :'Array<Inventory>',
|
152
|
+
:'disclaimers' => :'Array<Disclaimer>'
|
121
153
|
}
|
122
154
|
end
|
123
155
|
|
@@ -188,6 +220,10 @@ module Patch
|
|
188
220
|
self.state = attributes[:'state']
|
189
221
|
end
|
190
222
|
|
223
|
+
if attributes.key?(:'issuance_type')
|
224
|
+
self.issuance_type = attributes[:'issuance_type']
|
225
|
+
end
|
226
|
+
|
191
227
|
if attributes.key?(:'latitude')
|
192
228
|
self.latitude = attributes[:'latitude']
|
193
229
|
end
|
@@ -242,6 +278,12 @@ module Patch
|
|
242
278
|
self.inventory = value
|
243
279
|
end
|
244
280
|
end
|
281
|
+
|
282
|
+
if attributes.key?(:'disclaimers')
|
283
|
+
if (value = attributes[:'disclaimers']).is_a?(Array)
|
284
|
+
self.disclaimers = value
|
285
|
+
end
|
286
|
+
end
|
245
287
|
end
|
246
288
|
|
247
289
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -295,6 +337,8 @@ module Patch
|
|
295
337
|
return false if @name.nil?
|
296
338
|
return false if @description.nil?
|
297
339
|
return false if @country.nil?
|
340
|
+
issuance_type_validator = EnumAttributeValidator.new('String', ["ex-ante", "ex-post"])
|
341
|
+
return false unless issuance_type_validator.valid?(@issuance_type)
|
298
342
|
return false if @project_partner.nil?
|
299
343
|
return false if @technology_type.nil?
|
300
344
|
return false if @highlights.nil?
|
@@ -302,6 +346,16 @@ module Patch
|
|
302
346
|
true
|
303
347
|
end
|
304
348
|
|
349
|
+
# Custom attribute writer method checking allowed values (enum).
|
350
|
+
# @param [Object] issuance_type Object to be assigned
|
351
|
+
def issuance_type=(issuance_type)
|
352
|
+
validator = EnumAttributeValidator.new('String', ["ex-ante", "ex-post"])
|
353
|
+
unless validator.valid?(issuance_type)
|
354
|
+
fail ArgumentError, "invalid value for \"issuance_type\", must be one of #{validator.allowable_values}."
|
355
|
+
end
|
356
|
+
@issuance_type = issuance_type
|
357
|
+
end
|
358
|
+
|
305
359
|
# Checks equality by comparing each attribute.
|
306
360
|
# @param [Object] Object to be compared
|
307
361
|
def ==(o)
|
@@ -314,6 +368,7 @@ module Patch
|
|
314
368
|
mechanism == o.mechanism &&
|
315
369
|
country == o.country &&
|
316
370
|
state == o.state &&
|
371
|
+
issuance_type == o.issuance_type &&
|
317
372
|
latitude == o.latitude &&
|
318
373
|
longitude == o.longitude &&
|
319
374
|
project_partner == o.project_partner &&
|
@@ -324,7 +379,8 @@ module Patch
|
|
324
379
|
tagline == o.tagline &&
|
325
380
|
technology_type == o.technology_type &&
|
326
381
|
highlights == o.highlights &&
|
327
|
-
inventory == o.inventory
|
382
|
+
inventory == o.inventory &&
|
383
|
+
disclaimers == o.disclaimers
|
328
384
|
end
|
329
385
|
|
330
386
|
# @see the `==` method
|
@@ -336,7 +392,7 @@ module Patch
|
|
336
392
|
# Calculates hash code according to all attributes.
|
337
393
|
# @return [Integer] Hash code
|
338
394
|
def hash
|
339
|
-
[id, production, name, description, mechanism, country, state, latitude, longitude, project_partner, photos, verifier, standard, sdgs, tagline, technology_type, highlights, inventory].hash
|
395
|
+
[id, production, name, description, mechanism, country, state, issuance_type, latitude, longitude, project_partner, photos, verifier, standard, sdgs, tagline, technology_type, highlights, inventory, disclaimers].hash
|
340
396
|
end
|
341
397
|
|
342
398
|
# Builds the object from hash
|
@@ -17,6 +17,10 @@ module Patch
|
|
17
17
|
class UpdateOrderLineItemRequest
|
18
18
|
attr_accessor :vintage_year
|
19
19
|
|
20
|
+
attr_accessor :vintage_start_year
|
21
|
+
|
22
|
+
attr_accessor :vintage_end_year
|
23
|
+
|
20
24
|
attr_accessor :price
|
21
25
|
|
22
26
|
attr_accessor :currency
|
@@ -51,6 +55,8 @@ module Patch
|
|
51
55
|
def self.attribute_map
|
52
56
|
{
|
53
57
|
:'vintage_year' => :'vintage_year',
|
58
|
+
:'vintage_start_year' => :'vintage_start_year',
|
59
|
+
:'vintage_end_year' => :'vintage_end_year',
|
54
60
|
:'price' => :'price',
|
55
61
|
:'currency' => :'currency',
|
56
62
|
:'amount' => :'amount',
|
@@ -67,6 +73,8 @@ module Patch
|
|
67
73
|
def self.openapi_types
|
68
74
|
{
|
69
75
|
:'vintage_year' => :'Integer',
|
76
|
+
:'vintage_start_year' => :'Integer',
|
77
|
+
:'vintage_end_year' => :'Integer',
|
70
78
|
:'price' => :'Integer',
|
71
79
|
:'currency' => :'String',
|
72
80
|
:'amount' => :'Integer',
|
@@ -78,6 +86,8 @@ module Patch
|
|
78
86
|
def self.openapi_nullable
|
79
87
|
Set.new([
|
80
88
|
:'vintage_year',
|
89
|
+
:'vintage_start_year',
|
90
|
+
:'vintage_end_year',
|
81
91
|
:'price',
|
82
92
|
:'currency',
|
83
93
|
:'amount',
|
@@ -116,6 +126,14 @@ module Patch
|
|
116
126
|
self.vintage_year = attributes[:'vintage_year']
|
117
127
|
end
|
118
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
|
+
|
119
137
|
if attributes.key?(:'price')
|
120
138
|
self.price = attributes[:'price']
|
121
139
|
end
|
@@ -137,20 +155,36 @@ module Patch
|
|
137
155
|
# @return Array for valid properties with the reasons
|
138
156
|
def list_invalid_properties
|
139
157
|
invalid_properties = Array.new
|
140
|
-
if !@vintage_year.nil? && @vintage_year >
|
141
|
-
invalid_properties.push('invalid value for "vintage_year", must be smaller than or equal to
|
158
|
+
if !@vintage_year.nil? && @vintage_year > 2225
|
159
|
+
invalid_properties.push('invalid value for "vintage_year", must be smaller than or equal to 2225.')
|
142
160
|
end
|
143
161
|
|
144
162
|
if !@vintage_year.nil? && @vintage_year < 1900
|
145
163
|
invalid_properties.push('invalid value for "vintage_year", must be greater than or equal to 1900.')
|
146
164
|
end
|
147
165
|
|
166
|
+
if !@vintage_start_year.nil? && @vintage_start_year > 2225
|
167
|
+
invalid_properties.push('invalid value for "vintage_start_year", must be smaller than or equal to 2225.')
|
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 > 2225
|
175
|
+
invalid_properties.push('invalid value for "vintage_end_year", must be smaller than or equal to 2225.')
|
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
|
+
|
148
182
|
if !@price.nil? && @price < 2
|
149
183
|
invalid_properties.push('invalid value for "price", must be greater than or equal to 2.')
|
150
184
|
end
|
151
185
|
|
152
|
-
if !@amount.nil? && @amount >
|
153
|
-
invalid_properties.push('invalid value for "amount", must be smaller than or equal to
|
186
|
+
if !@amount.nil? && @amount > 100000000000000
|
187
|
+
invalid_properties.push('invalid value for "amount", must be smaller than or equal to 100000000000000.')
|
154
188
|
end
|
155
189
|
|
156
190
|
if !@amount.nil? && @amount < 0
|
@@ -163,12 +197,16 @@ module Patch
|
|
163
197
|
# Check to see if the all the properties in the model are valid
|
164
198
|
# @return true if the model is valid
|
165
199
|
def valid?
|
166
|
-
return false if !@vintage_year.nil? && @vintage_year >
|
200
|
+
return false if !@vintage_year.nil? && @vintage_year > 2225
|
167
201
|
return false if !@vintage_year.nil? && @vintage_year < 1900
|
202
|
+
return false if !@vintage_start_year.nil? && @vintage_start_year > 2225
|
203
|
+
return false if !@vintage_start_year.nil? && @vintage_start_year < 1900
|
204
|
+
return false if !@vintage_end_year.nil? && @vintage_end_year > 2225
|
205
|
+
return false if !@vintage_end_year.nil? && @vintage_end_year < 1900
|
168
206
|
return false if !@price.nil? && @price < 2
|
169
|
-
return false if !@amount.nil? && @amount >
|
207
|
+
return false if !@amount.nil? && @amount > 100000000000000
|
170
208
|
return false if !@amount.nil? && @amount < 0
|
171
|
-
unit_validator = EnumAttributeValidator.new('String', ["g"
|
209
|
+
unit_validator = EnumAttributeValidator.new('String', ["g"])
|
172
210
|
return false unless unit_validator.valid?(@unit)
|
173
211
|
true
|
174
212
|
end
|
@@ -176,8 +214,8 @@ module Patch
|
|
176
214
|
# Custom attribute writer method with validation
|
177
215
|
# @param [Object] vintage_year Value to be assigned
|
178
216
|
def vintage_year=(vintage_year)
|
179
|
-
if !vintage_year.nil? && vintage_year >
|
180
|
-
fail ArgumentError, 'invalid value for "vintage_year", must be smaller than or equal to
|
217
|
+
if !vintage_year.nil? && vintage_year > 2225
|
218
|
+
fail ArgumentError, 'invalid value for "vintage_year", must be smaller than or equal to 2225.'
|
181
219
|
end
|
182
220
|
|
183
221
|
if !vintage_year.nil? && vintage_year < 1900
|
@@ -187,6 +225,34 @@ module Patch
|
|
187
225
|
@vintage_year = vintage_year
|
188
226
|
end
|
189
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 > 2225
|
232
|
+
fail ArgumentError, 'invalid value for "vintage_start_year", must be smaller than or equal to 2225.'
|
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 > 2225
|
246
|
+
fail ArgumentError, 'invalid value for "vintage_end_year", must be smaller than or equal to 2225.'
|
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
|
+
|
190
256
|
# Custom attribute writer method with validation
|
191
257
|
# @param [Object] price Value to be assigned
|
192
258
|
def price=(price)
|
@@ -200,8 +266,8 @@ module Patch
|
|
200
266
|
# Custom attribute writer method with validation
|
201
267
|
# @param [Object] amount Value to be assigned
|
202
268
|
def amount=(amount)
|
203
|
-
if !amount.nil? && amount >
|
204
|
-
fail ArgumentError, 'invalid value for "amount", must be smaller than or equal to
|
269
|
+
if !amount.nil? && amount > 100000000000000
|
270
|
+
fail ArgumentError, 'invalid value for "amount", must be smaller than or equal to 100000000000000.'
|
205
271
|
end
|
206
272
|
|
207
273
|
if !amount.nil? && amount < 0
|
@@ -214,7 +280,7 @@ module Patch
|
|
214
280
|
# Custom attribute writer method checking allowed values (enum).
|
215
281
|
# @param [Object] unit Object to be assigned
|
216
282
|
def unit=(unit)
|
217
|
-
validator = EnumAttributeValidator.new('String', ["g"
|
283
|
+
validator = EnumAttributeValidator.new('String', ["g"])
|
218
284
|
unless validator.valid?(unit)
|
219
285
|
fail ArgumentError, "invalid value for \"unit\", must be one of #{validator.allowable_values}."
|
220
286
|
end
|
@@ -227,6 +293,8 @@ module Patch
|
|
227
293
|
return true if self.equal?(o)
|
228
294
|
self.class == o.class &&
|
229
295
|
vintage_year == o.vintage_year &&
|
296
|
+
vintage_start_year == o.vintage_start_year &&
|
297
|
+
vintage_end_year == o.vintage_end_year &&
|
230
298
|
price == o.price &&
|
231
299
|
currency == o.currency &&
|
232
300
|
amount == o.amount &&
|
@@ -242,7 +310,7 @@ module Patch
|
|
242
310
|
# Calculates hash code according to all attributes.
|
243
311
|
# @return [Integer] Hash code
|
244
312
|
def hash
|
245
|
-
[vintage_year, price, currency, amount, unit].hash
|
313
|
+
[vintage_year, vintage_start_year, vintage_end_year, price, currency, amount, unit].hash
|
246
314
|
end
|
247
315
|
|
248
316
|
# Builds the object from hash
|
data/lib/patch_ruby/version.rb
CHANGED
data/lib/patch_ruby.rb
CHANGED
@@ -20,7 +20,6 @@ require 'patch_ruby/configuration'
|
|
20
20
|
require 'patch_ruby/models/create_air_shipping_estimate_request'
|
21
21
|
require 'patch_ruby/models/create_bitcoin_estimate_request'
|
22
22
|
require 'patch_ruby/models/create_ecommerce_estimate_request'
|
23
|
-
require 'patch_ruby/models/create_ethereum_estimate_request'
|
24
23
|
require 'patch_ruby/models/create_flight_estimate_request'
|
25
24
|
require 'patch_ruby/models/create_hotel_estimate_request'
|
26
25
|
require 'patch_ruby/models/create_mass_estimate_request'
|
@@ -29,11 +28,10 @@ require 'patch_ruby/models/create_order_request'
|
|
29
28
|
require 'patch_ruby/models/create_rail_shipping_estimate_request'
|
30
29
|
require 'patch_ruby/models/create_road_shipping_estimate_request'
|
31
30
|
require 'patch_ruby/models/create_sea_shipping_estimate_request'
|
32
|
-
require 'patch_ruby/models/create_shipping_estimate_request'
|
33
31
|
require 'patch_ruby/models/create_success_response'
|
34
|
-
require 'patch_ruby/models/create_vehicle_estimate_request'
|
35
32
|
require 'patch_ruby/models/delete_order_line_item_response'
|
36
33
|
require 'patch_ruby/models/delete_order_response'
|
34
|
+
require 'patch_ruby/models/disclaimer'
|
37
35
|
require 'patch_ruby/models/error_response'
|
38
36
|
require 'patch_ruby/models/estimate'
|
39
37
|
require 'patch_ruby/models/estimate_list_response'
|
data/patch_ruby.gemspec
CHANGED
@@ -45,51 +45,6 @@ RSpec.describe 'Estimates Integration' do
|
|
45
45
|
expect(flight_estimate_longer.data.mass_g).to be > 2 * flight_estimate.data.mass_g
|
46
46
|
end
|
47
47
|
|
48
|
-
it 'supports creating vehicle estimates' do
|
49
|
-
distance_m = 10_000
|
50
|
-
make = "Toyota"
|
51
|
-
model = "Corolla"
|
52
|
-
year = 2000
|
53
|
-
|
54
|
-
vehicle_estimate = Patch::Estimate.create_vehicle_estimate(
|
55
|
-
distance_m: distance_m,
|
56
|
-
make: make,
|
57
|
-
model: model,
|
58
|
-
year: year,
|
59
|
-
create_order: true
|
60
|
-
)
|
61
|
-
|
62
|
-
expect(vehicle_estimate.data.type).to eq 'vehicle'
|
63
|
-
expect(vehicle_estimate.data.mass_g).to be >= 1_000
|
64
|
-
expect(vehicle_estimate.data.order.amount).to be >= 1_000
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'supports creating vehicle estimates with partial information' do
|
68
|
-
distance_m = 10_000
|
69
|
-
|
70
|
-
vehicle_estimate = Patch::Estimate.create_vehicle_estimate(
|
71
|
-
distance_m: distance_m,
|
72
|
-
create_order: false
|
73
|
-
)
|
74
|
-
|
75
|
-
expect(vehicle_estimate.data.type).to eq 'vehicle'
|
76
|
-
expect(vehicle_estimate.data.mass_g).to eq 2_132
|
77
|
-
end
|
78
|
-
|
79
|
-
it 'supports creating shipping estimates' do
|
80
|
-
distance_m = 100_000_000
|
81
|
-
package_mass_g = 10_000
|
82
|
-
create_estimate_response = Patch::Estimate.create_shipping_estimate(
|
83
|
-
distance_m: distance_m,
|
84
|
-
package_mass_g: package_mass_g,
|
85
|
-
transportation_method: 'rail',
|
86
|
-
create_order: false
|
87
|
-
)
|
88
|
-
|
89
|
-
expect(create_estimate_response.data.type).to eq 'shipping'
|
90
|
-
expect(create_estimate_response.data.mass_g).to be >= 10_000
|
91
|
-
end
|
92
|
-
|
93
48
|
it 'supports creating bitcoin estimates with partial information' do
|
94
49
|
bitcoin_estimate = Patch::Estimate.create_bitcoin_estimate()
|
95
50
|
|
@@ -136,26 +91,6 @@ RSpec.describe 'Estimates Integration' do
|
|
136
91
|
expect(bitcoin_estimate_1.data.mass_g).to be < bitcoin_estimate_2.data.mass_g
|
137
92
|
end
|
138
93
|
|
139
|
-
it 'supports creating ethereum estimates with a gas amount' do
|
140
|
-
ethereum_estimate = Patch::Estimate.create_ethereum_estimate(
|
141
|
-
gas_used: 100
|
142
|
-
)
|
143
|
-
|
144
|
-
ethereum_estimate_2 = Patch::Estimate.create_ethereum_estimate(
|
145
|
-
gas_used: 1000
|
146
|
-
)
|
147
|
-
|
148
|
-
expect(ethereum_estimate.data.type).to eq 'ethereum'
|
149
|
-
expect(ethereum_estimate.data.mass_g).to be < ethereum_estimate_2.data.mass_g
|
150
|
-
end
|
151
|
-
|
152
|
-
it 'supports creating ethereum estimates with partial information' do
|
153
|
-
ethereum_estimate = Patch::Estimate.create_ethereum_estimate({ create_order: false })
|
154
|
-
|
155
|
-
expect(ethereum_estimate.data.type).to eq 'ethereum'
|
156
|
-
expect(ethereum_estimate.data.mass_g).to be >= 2_000
|
157
|
-
end
|
158
|
-
|
159
94
|
it 'supports creating hotel estimates' do
|
160
95
|
create_estimate_response = Patch::Estimate.create_hotel_estimate(
|
161
96
|
country_code: "US",
|
@@ -134,6 +134,16 @@ RSpec.describe 'Orders Integration' do
|
|
134
134
|
expect(create_order_response.data.unit).to eq("g")
|
135
135
|
end
|
136
136
|
|
137
|
+
it 'supports create with a vintage start year and vintage end year' do
|
138
|
+
create_order_response =
|
139
|
+
Patch::Order.create_order(amount: 100, unit: "g", vintage_start_year: 2022, vintage_end_year: 2023)
|
140
|
+
|
141
|
+
expect(create_order_response.success).to eq true
|
142
|
+
expect(create_order_response.data.id).not_to be_nil
|
143
|
+
expect(create_order_response.data.amount).to eq(100)
|
144
|
+
expect(create_order_response.data.unit).to eq("g")
|
145
|
+
end
|
146
|
+
|
137
147
|
it 'supports create with an amount and unit' do
|
138
148
|
create_order_response =
|
139
149
|
Patch::Order.create_order(amount: 100, unit: "g")
|
@@ -209,6 +219,32 @@ RSpec.describe 'Orders Integration' do
|
|
209
219
|
expect(delete_line_item_response.success).to eq(true)
|
210
220
|
expect(delete_line_item_response.data).to eq(line_item_id)
|
211
221
|
|
222
|
+
# Add line item via vintage_start_year and vintage_end_year
|
223
|
+
create_order_line_item_response = Patch::OrderLineItem
|
224
|
+
.create_order_line_item(order_id, { project_id: project_id, amount: 300000, unit: "g", vintage_start_year: 2023, vintage_end_year: 2025 })
|
225
|
+
|
226
|
+
expect(create_order_line_item_response.success).to eq(true)
|
227
|
+
expect(create_order_line_item_response.data.id).not_to be_nil
|
228
|
+
expect(create_order_line_item_response.data.amount).to eq(300000)
|
229
|
+
expect(create_order_line_item_response.data.vintage_start_year).to eq(2023)
|
230
|
+
expect(create_order_line_item_response.data.vintage_end_year).to eq(2025)
|
231
|
+
expect(create_order_line_item_response.data.price).to be >= 0
|
232
|
+
|
233
|
+
# Fetch order and check line item matches
|
234
|
+
retrieve_order_response = Patch::Order.retrieve_order(order_id)
|
235
|
+
expect(retrieve_order_response.data.id).to eq order_id
|
236
|
+
expect(retrieve_order_response.data.line_items.length).to eq(1)
|
237
|
+
expect(retrieve_order_response.data.line_items[0].id).to eq(line_item_id)
|
238
|
+
expect(retrieve_order_response.data.line_items[0].amount).to eq(300000)
|
239
|
+
expect(retrieve_order_response.data.line_items[0].vintage_start_year).to eq(2023)
|
240
|
+
expect(retrieve_order_response.data.line_items[0].vintage_end_year).to eq(2025)
|
241
|
+
|
242
|
+
# Delete line item
|
243
|
+
line_item_id = create_order_line_item_response.data.id
|
244
|
+
delete_line_item_response = Patch::OrderLineItem.delete_order_line_item(order_id, line_item_id)
|
245
|
+
expect(delete_line_item_response.success).to eq(true)
|
246
|
+
expect(delete_line_item_response.data).to eq(line_item_id)
|
247
|
+
|
212
248
|
# Fetch order and see it has no line items
|
213
249
|
retrieve_order_response = Patch::Order.retrieve_order(order_id)
|
214
250
|
expect(retrieve_order_response.data.id).to eq order_id
|
@@ -65,19 +65,33 @@ RSpec.describe 'Projects Integration' do
|
|
65
65
|
expect(inventory).to be_an_instance_of(Array)
|
66
66
|
expect(inventory[0]).to be_an_instance_of(Patch::Inventory)
|
67
67
|
expect(inventory[0].vintage_year).to be_an_instance_of(Integer)
|
68
|
+
expect(inventory[0].vintage_start_year).to be_an_instance_of(Integer)
|
69
|
+
expect(inventory[0].vintage_end_year).to be_an_instance_of(Integer)
|
68
70
|
expect(inventory[0].amount_available).to be_an_instance_of(Integer)
|
69
71
|
expect(inventory[0].price).to be_an_instance_of(Integer)
|
70
72
|
expect(inventory[0].currency).to be_an_instance_of(String)
|
71
73
|
expect(inventory[0].unit).to be_an_instance_of(String)
|
74
|
+
|
75
|
+
issuance_type = project.issuance_type
|
76
|
+
expect(issuance_type).to be_an_instance_of(String)
|
77
|
+
|
78
|
+
disclaimers = project.disclaimers
|
79
|
+
expect(disclaimers).to be_an_instance_of(Array)
|
80
|
+
expect(disclaimers[0]).to be_an_instance_of(Patch::Disclaimer)
|
81
|
+
expect(disclaimers[0].body).to be_an_instance_of(String)
|
82
|
+
expect(disclaimers[0].header).to be_an_instance_of(String)
|
83
|
+
expect(disclaimers[0].severity).to be_an_instance_of(String)
|
84
|
+
expect(disclaimers[0].link_text).to be_an_instance_of(String)
|
85
|
+
expect(disclaimers[0].link_destination).to be_an_instance_of(String)
|
72
86
|
end
|
73
87
|
|
74
88
|
it 'retrieves projects in the requested language' do
|
75
89
|
projects_response = Patch::Project.retrieve_projects(accept_language: 'fr')
|
76
90
|
|
77
|
-
expect(projects_response.data.
|
91
|
+
expect(projects_response.data.last.name).to include 'Démo' # French
|
78
92
|
|
79
|
-
project_id = projects_response.data.
|
93
|
+
project_id = projects_response.data.last.id
|
80
94
|
project_response = Patch::Project.retrieve_project(project_id, accept_language: 'fr')
|
81
|
-
expect(project_response.data.name).to include 'Démo' #
|
95
|
+
expect(project_response.data.name).to include 'Démo' # French
|
82
96
|
end
|
83
97
|
end
|
@@ -38,7 +38,7 @@ describe 'CreateOrderRequest' do
|
|
38
38
|
metadata: @instance.metadata
|
39
39
|
} }
|
40
40
|
let(:nullable_properties) do
|
41
|
-
Set.new(%i[project_id metadata state vintage_year total_price currency amount unit])
|
41
|
+
Set.new(%i[project_id metadata state vintage_year vintage_start_year vintage_end_year total_price currency amount unit])
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|