patch_ruby 2.0.0 → 2.1.1
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 +9 -10
- data/lib/patch_ruby/api_client.rb +1 -1
- data/lib/patch_ruby/configuration.rb +1 -2
- data/lib/patch_ruby/models/create_mass_estimate_request.rb +5 -5
- data/lib/patch_ruby/models/create_order_line_item_request.rb +74 -6
- data/lib/patch_ruby/models/create_order_request.rb +74 -6
- data/lib/patch_ruby/models/create_road_shipping_estimate_request.rb +11 -1
- data/lib/patch_ruby/models/disclaimer.rb +282 -0
- 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 +60 -4
- data/lib/patch_ruby/models/update_order_line_item_request.rb +74 -6
- data/lib/patch_ruby/version.rb +1 -1
- data/lib/patch_ruby.rb +1 -0
- data/spec/integration/estimates_spec.rb +1 -1
- 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 +26 -25
@@ -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
|
@@ -145,12 +163,28 @@ module Patch
|
|
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 > 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
|
+
|
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
|
@@ -165,8 +199,12 @@ module Patch
|
|
165
199
|
def valid?
|
166
200
|
return false if !@vintage_year.nil? && @vintage_year > 2100
|
167
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
|
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
209
|
unit_validator = EnumAttributeValidator.new('String', ["g", "Wh"])
|
172
210
|
return false unless unit_validator.valid?(@unit)
|
@@ -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 > 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
|
+
|
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
|
@@ -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
@@ -34,6 +34,7 @@ require 'patch_ruby/models/create_success_response'
|
|
34
34
|
require 'patch_ruby/models/create_vehicle_estimate_request'
|
35
35
|
require 'patch_ruby/models/delete_order_line_item_response'
|
36
36
|
require 'patch_ruby/models/delete_order_response'
|
37
|
+
require 'patch_ruby/models/disclaimer'
|
37
38
|
require 'patch_ruby/models/error_response'
|
38
39
|
require 'patch_ruby/models/estimate'
|
39
40
|
require 'patch_ruby/models/estimate_list_response'
|
@@ -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
|
|
@@ -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
|
|
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: 2.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patch Technology
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- lib/patch_ruby/models/create_vehicle_estimate_request.rb
|
119
119
|
- lib/patch_ruby/models/delete_order_line_item_response.rb
|
120
120
|
- lib/patch_ruby/models/delete_order_response.rb
|
121
|
+
- lib/patch_ruby/models/disclaimer.rb
|
121
122
|
- lib/patch_ruby/models/error_response.rb
|
122
123
|
- lib/patch_ruby/models/estimate.rb
|
123
124
|
- lib/patch_ruby/models/estimate_list_response.rb
|
@@ -213,47 +214,47 @@ signing_key:
|
|
213
214
|
specification_version: 4
|
214
215
|
summary: Ruby wrapper for the Patch API
|
215
216
|
test_files:
|
216
|
-
- spec/api/technology_types_api_spec.rb
|
217
|
-
- spec/api/order_line_items_api_spec.rb
|
218
|
-
- spec/api/orders_api_spec.rb
|
219
217
|
- spec/api/projects_api_spec.rb
|
220
218
|
- spec/api/estimates_api_spec.rb
|
219
|
+
- spec/api/orders_api_spec.rb
|
220
|
+
- spec/api/order_line_items_api_spec.rb
|
221
|
+
- spec/api/technology_types_api_spec.rb
|
221
222
|
- spec/api_client_spec.rb
|
222
223
|
- spec/configuration_spec.rb
|
223
224
|
- spec/constants.rb
|
224
|
-
- spec/factories/
|
225
|
-
- spec/factories/estimate_responses.rb
|
226
|
-
- spec/factories/sdgs.rb
|
225
|
+
- spec/factories/meta_index_objects.rb
|
227
226
|
- spec/factories/estimate_list_responses.rb
|
228
|
-
- spec/factories/order_list_responses.rb
|
229
|
-
- spec/factories/project_responses.rb
|
230
|
-
- spec/factories/projects.rb
|
231
|
-
- spec/factories/project_list_responses.rb
|
232
|
-
- spec/factories/orders.rb
|
233
|
-
- spec/factories/estimates.rb
|
234
|
-
- spec/factories/create_order_requests.rb
|
235
227
|
- spec/factories/create_mass_estimate_requests.rb
|
236
|
-
- spec/factories/
|
228
|
+
- spec/factories/projects.rb
|
229
|
+
- spec/factories/order_list_responses.rb
|
237
230
|
- spec/factories/technology_type.rb
|
231
|
+
- spec/factories/estimates.rb
|
238
232
|
- spec/factories/error_responses.rb
|
233
|
+
- spec/factories/parent_technology_type.rb
|
234
|
+
- spec/factories/project_responses.rb
|
235
|
+
- spec/factories/create_order_requests.rb
|
236
|
+
- spec/factories/orders.rb
|
237
|
+
- spec/factories/sdgs.rb
|
239
238
|
- spec/factories/order_responses.rb
|
240
|
-
- spec/
|
241
|
-
- spec/
|
239
|
+
- spec/factories/project_list_responses.rb
|
240
|
+
- spec/factories/estimate_responses.rb
|
242
241
|
- spec/integration/projects/technology_types_spec.rb
|
243
242
|
- spec/integration/estimates_spec.rb
|
243
|
+
- spec/integration/projects_spec.rb
|
244
|
+
- spec/integration/orders_spec.rb
|
244
245
|
- spec/models/order_response_spec.rb
|
245
|
-
- spec/models/
|
246
|
-
- spec/models/
|
246
|
+
- spec/models/meta_index_object_spec.rb
|
247
|
+
- spec/models/project_spec.rb
|
248
|
+
- spec/models/create_order_request_spec.rb
|
249
|
+
- spec/models/project_response_spec.rb
|
247
250
|
- spec/models/create_mass_estimate_request_spec.rb
|
248
|
-
- spec/models/estimate_response_spec.rb
|
249
251
|
- spec/models/project_list_response_spec.rb
|
252
|
+
- spec/models/order_spec.rb
|
250
253
|
- spec/models/error_response_spec.rb
|
251
|
-
- spec/models/meta_index_object_spec.rb
|
252
|
-
- spec/models/project_response_spec.rb
|
253
|
-
- spec/models/project_spec.rb
|
254
254
|
- spec/models/estimate_spec.rb
|
255
|
+
- spec/models/order_list_response_spec.rb
|
255
256
|
- spec/models/estimate_list_response_spec.rb
|
256
|
-
- spec/models/
|
257
|
+
- spec/models/estimate_response_spec.rb
|
257
258
|
- spec/patch_ruby_spec.rb
|
258
259
|
- spec/spec_helper.rb
|
259
260
|
- spec/support/shared/generated_classes.rb
|