patch_ruby 1.23.0 → 1.24.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -90,7 +90,6 @@ RSpec.describe 'Estimates Integration' do
90
90
  expect(create_estimate_response.data.mass_g).to be >= 10_000
91
91
  end
92
92
 
93
-
94
93
  it 'supports creating bitcoin estimates with partial information' do
95
94
  bitcoin_estimate = Patch::Estimate.create_bitcoin_estimate()
96
95
 
@@ -171,4 +170,169 @@ RSpec.describe 'Estimates Integration' do
171
170
  expect(create_estimate_response.data.mass_g).to be >= 100_000
172
171
  expect(create_estimate_response.data.id).not_to be_nil
173
172
  end
173
+
174
+ it 'supports creating ecommerce estimates' do
175
+ distance_m = 100_000_000
176
+ package_mass_g = 10_000
177
+ create_estimate_response = Patch::Estimate.create_ecommerce_estimate(
178
+ distance_m: distance_m,
179
+ package_mass_g: package_mass_g,
180
+ transportation_method: 'rail',
181
+ create_order: false
182
+ )
183
+
184
+ expect(create_estimate_response.data.type).to eq 'ecommerce'
185
+ expect(create_estimate_response.data.mass_g).to be >= 10_000
186
+ end
187
+
188
+ context "when creating an air shipping estimate" do
189
+ it "supports creating an estimate using airports" do
190
+ air_shipping_estimate = Patch::Estimate.create_air_shipping_estimate(
191
+ aircraft_type: "cargo",
192
+ create_order: false,
193
+ destination_airport: "JFK",
194
+ freight_mass_g: 31_300,
195
+ origin_airport: "SFO"
196
+ )
197
+ expect(air_shipping_estimate.data.type).to eq('shipping_air')
198
+ expect(air_shipping_estimate.data.mass_g).to be > 0
199
+ end
200
+
201
+ it "supports creating an estimate with an order" do
202
+ air_shipping_estimate = Patch::Estimate.create_air_shipping_estimate(
203
+ aircraft_type: "cargo",
204
+ create_order: true,
205
+ destination_airport: "JFK",
206
+ freight_mass_g: 19_140,
207
+ origin_airport: "SFO"
208
+ )
209
+ expect(air_shipping_estimate.data.type).to eq('shipping_air')
210
+ expect(air_shipping_estimate.data.mass_g).to be > 0
211
+ expect(air_shipping_estimate.data.order.amount).to be > 0
212
+ end
213
+ end
214
+
215
+ context "when creating a rail shipping estimate" do
216
+ it "supports creating an estimate using locodes" do
217
+ rail_shipping_estimate = Patch::Estimate.create_rail_shipping_estimate(
218
+ create_order: false,
219
+ destination_locode: "USSEA",
220
+ emissions_scope: "wtw",
221
+ freight_mass_g: 419_060,
222
+ fuel_type: "diesel",
223
+ origin_locode: "USSD2"
224
+ )
225
+ expect(rail_shipping_estimate.data.type).to eq('shipping_rail')
226
+ expect(rail_shipping_estimate.data.mass_g).to be > 0
227
+ end
228
+
229
+ it "supports creating an estimate using postal codes" do
230
+ rail_shipping_estimate = Patch::Estimate.create_rail_shipping_estimate(
231
+ create_order: false,
232
+ destination_country_code: "US",
233
+ destination_postal_code: "97209",
234
+ emissions_scope: "wtw",
235
+ freight_mass_g: 226_000,
236
+ fuel_type: "diesel",
237
+ origin_country_code: "US",
238
+ origin_postal_code: "90210"
239
+ )
240
+ expect(rail_shipping_estimate.data.type).to eq('shipping_rail')
241
+ expect(rail_shipping_estimate.data.mass_g).to be > 0
242
+ end
243
+
244
+ it "supports creating an estimate with an order" do
245
+ rail_shipping_estimate = Patch::Estimate.create_rail_shipping_estimate(
246
+ create_order: true,
247
+ destination_locode: "USSEA",
248
+ freight_mass_g: 359_000,
249
+ origin_locode: "USSD2"
250
+ )
251
+ expect(rail_shipping_estimate.data.type).to eq('shipping_rail')
252
+ expect(rail_shipping_estimate.data.mass_g).to be > 0
253
+ expect(rail_shipping_estimate.data.order.amount).to be > 0
254
+ end
255
+ end
256
+
257
+ context "when creating a road shipping estimate" do
258
+ it "supports creating an estimate using locodes" do
259
+ road_shipping_estimate = Patch::Estimate.create_road_shipping_estimate(
260
+ create_order: false,
261
+ container_size_code: "20GP",
262
+ destination_locode: "USSEA",
263
+ emissions_scope: "wtw",
264
+ freight_mass_g: 124_870,
265
+ origin_locode: "USSD2"
266
+ )
267
+ expect(road_shipping_estimate.data.type).to eq('shipping_road')
268
+ expect(road_shipping_estimate.data.mass_g).to be > 0
269
+ end
270
+
271
+ it "supports creating an estimate using postal codes" do
272
+ road_shipping_estimate = Patch::Estimate.create_road_shipping_estimate(
273
+ create_order: false,
274
+ destination_country_code: "US",
275
+ destination_postal_code: "97209",
276
+ emissions_scope: "wtw",
277
+ freight_mass_g: 226_000,
278
+ origin_country_code: "US",
279
+ origin_postal_code: "90210"
280
+ )
281
+ expect(road_shipping_estimate.data.type).to eq('shipping_road')
282
+ expect(road_shipping_estimate.data.mass_g).to be > 0
283
+ end
284
+
285
+ it "supports creating an estimate with an order" do
286
+ road_shipping_estimate = Patch::Estimate.create_road_shipping_estimate(
287
+ create_order: true,
288
+ destination_locode: "USSEA",
289
+ freight_mass_g: 359_000,
290
+ origin_locode: "USSD2"
291
+ )
292
+ expect(road_shipping_estimate.data.type).to eq('shipping_road')
293
+ expect(road_shipping_estimate.data.mass_g).to be > 0
294
+ expect(road_shipping_estimate.data.order.amount).to be > 0
295
+ end
296
+ end
297
+
298
+ context "when creating a sea shipping estimate" do
299
+ it "supports creating an estimate using locodes" do
300
+ sea_shipping_estimate = Patch::Estimate.create_sea_shipping_estimate(
301
+ create_order: false,
302
+ container_size_code: "20GP",
303
+ destination_locode: "HKHKG",
304
+ emissions_scope: "wtw",
305
+ freight_mass_g: 124_870,
306
+ origin_locode: "FRMRS"
307
+ )
308
+ expect(sea_shipping_estimate.data.type).to eq('shipping_sea')
309
+ expect(sea_shipping_estimate.data.mass_g).to be > 0
310
+ end
311
+
312
+ it "supports creating an estimate using postal codes" do
313
+ sea_shipping_estimate = Patch::Estimate.create_sea_shipping_estimate(
314
+ create_order: false,
315
+ destination_country_code: "US",
316
+ destination_postal_code: "97209",
317
+ emissions_scope: "wtw",
318
+ freight_mass_g: 226_000,
319
+ origin_country_code: "US",
320
+ origin_postal_code: "90210"
321
+ )
322
+ expect(sea_shipping_estimate.data.type).to eq('shipping_sea')
323
+ expect(sea_shipping_estimate.data.mass_g).to be > 0
324
+ end
325
+
326
+ it "supports creating an estimate with an order" do
327
+ sea_shipping_estimate = Patch::Estimate.create_sea_shipping_estimate(
328
+ create_order: true,
329
+ destination_locode: "USSEA",
330
+ freight_mass_g: 359_000,
331
+ origin_locode: "USSD2"
332
+ )
333
+ expect(sea_shipping_estimate.data.type).to eq('shipping_sea')
334
+ expect(sea_shipping_estimate.data.mass_g).to be > 0
335
+ expect(sea_shipping_estimate.data.order.amount).to be > 0
336
+ end
337
+ end
174
338
  end
@@ -47,7 +47,7 @@ RSpec.describe 'Orders Integration' do
47
47
  Constants::BIOMASS_TEST_PROJECT_ID
48
48
  )
49
49
 
50
- issued_to = {email: 'envimpact@companyb.com', name: 'Company B'}
50
+ issued_to = { email: 'envimpact@companyb.com', name: 'Company B' }
51
51
  total_price_cents_usd = 50_00
52
52
 
53
53
  create_order_response = Patch::Order.create_order(
@@ -135,8 +135,8 @@ RSpec.describe 'Orders Integration' do
135
135
  create_estimate_to_place_response = Patch::Estimate.create_mass_estimate(mass_g: 100, create_order: true)
136
136
  order_to_place_id = create_estimate_to_place_response.data.order.id
137
137
 
138
- issued_to = {email: 'envimpact@companya.com', name: 'Company A'}
139
- place_order_response = Patch::Order.place_order(order_to_place_id, { issued_to: issued_to})
138
+ issued_to = { email: 'envimpact@companya.com', name: 'Company A' }
139
+ place_order_response = Patch::Order.place_order(order_to_place_id, issued_to: issued_to)
140
140
  expect(place_order_response.data.state).to eq 'placed'
141
141
  expect(place_order_response.data.issued_to.email).to eq(issued_to[:email])
142
142
  expect(place_order_response.data.issued_to.name).to eq(issued_to[:name])
@@ -76,10 +76,10 @@ RSpec.describe 'Projects Integration' do
76
76
  it 'retrieves projects in the requested language' do
77
77
  projects_response = Patch::Project.retrieve_projects(accept_language: 'fr')
78
78
 
79
- expect(projects_response.data.first.name).to include 'Projet' # French
79
+ expect(projects_response.data.first.name).to include 'Démo' # French
80
80
 
81
81
  project_id = projects_response.data.first.id
82
82
  project_response = Patch::Project.retrieve_project(project_id, accept_language: 'fr')
83
- expect(project_response.data.name).to include 'Projet' # Frenc
83
+ expect(project_response.data.name).to include 'Démo' # Frenc
84
84
  end
85
85
  end
@@ -31,7 +31,7 @@ describe 'CreateOrderRequest' do
31
31
  let(:instance) { @instance }
32
32
  let(:instance_hash) { { project_id: @instance.project_id, mass_g: @instance.mass_g, total_price_cents_usd: @instance.total_price_cents_usd, metadata: @instance.metadata } }
33
33
  let(:nullable_properties) do
34
- Set.new(%i[mass_g total_price_cents_usd project_id metadata state vintage_year total_price currency amount unit issued_to])
34
+ Set.new(%i[mass_g total_price_cents_usd project_id metadata state vintage_year total_price currency amount unit])
35
35
  end
36
36
  end
37
37
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: patch_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.23.0
4
+ version: 1.24.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patch Technology
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-06 00:00:00.000000000 Z
11
+ date: 2022-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -101,12 +101,17 @@ files:
101
101
  - lib/patch_ruby/api_error.rb
102
102
  - lib/patch_ruby/configuration.rb
103
103
  - lib/patch_ruby/models/allocation.rb
104
+ - lib/patch_ruby/models/create_air_shipping_estimate_request.rb
104
105
  - lib/patch_ruby/models/create_bitcoin_estimate_request.rb
106
+ - lib/patch_ruby/models/create_ecommerce_estimate_request.rb
105
107
  - lib/patch_ruby/models/create_ethereum_estimate_request.rb
106
108
  - lib/patch_ruby/models/create_flight_estimate_request.rb
107
109
  - lib/patch_ruby/models/create_hotel_estimate_request.rb
108
110
  - lib/patch_ruby/models/create_mass_estimate_request.rb
109
111
  - lib/patch_ruby/models/create_order_request.rb
112
+ - lib/patch_ruby/models/create_rail_shipping_estimate_request.rb
113
+ - lib/patch_ruby/models/create_road_shipping_estimate_request.rb
114
+ - lib/patch_ruby/models/create_sea_shipping_estimate_request.rb
110
115
  - lib/patch_ruby/models/create_shipping_estimate_request.rb
111
116
  - lib/patch_ruby/models/create_success_response.rb
112
117
  - lib/patch_ruby/models/create_vehicle_estimate_request.rb
@@ -116,11 +121,11 @@ files:
116
121
  - lib/patch_ruby/models/estimate_response.rb
117
122
  - lib/patch_ruby/models/highlight.rb
118
123
  - lib/patch_ruby/models/inventory.rb
119
- - lib/patch_ruby/models/issued_to.rb
120
124
  - lib/patch_ruby/models/meta_index_object.rb
121
125
  - lib/patch_ruby/models/order.rb
122
126
  - lib/patch_ruby/models/order_inventory.rb
123
127
  - lib/patch_ruby/models/order_inventory_project.rb
128
+ - lib/patch_ruby/models/order_issued_to.rb
124
129
  - lib/patch_ruby/models/order_list_response.rb
125
130
  - lib/patch_ruby/models/order_response.rb
126
131
  - lib/patch_ruby/models/parent_technology_type.rb
@@ -133,7 +138,6 @@ files:
133
138
  - lib/patch_ruby/models/standard.rb
134
139
  - lib/patch_ruby/models/technology_type.rb
135
140
  - lib/patch_ruby/models/technology_type_list_response.rb
136
- - lib/patch_ruby/models/v1_orders_issued_to.rb
137
141
  - lib/patch_ruby/version.rb
138
142
  - patch_ruby.gemspec
139
143
  - spec/api/estimates_api_spec.rb
@@ -205,48 +209,48 @@ signing_key:
205
209
  specification_version: 4
206
210
  summary: Ruby wrapper for the Patch API
207
211
  test_files:
208
- - spec/api/technology_types_api_spec.rb
209
- - spec/api/estimates_api_spec.rb
210
212
  - spec/api/projects_api_spec.rb
211
213
  - spec/api/orders_api_spec.rb
214
+ - spec/api/technology_types_api_spec.rb
215
+ - spec/api/estimates_api_spec.rb
212
216
  - spec/api_client_spec.rb
213
217
  - spec/configuration_spec.rb
214
218
  - spec/constants.rb
215
- - spec/factories/estimates.rb
216
- - spec/factories/project_responses.rb
217
- - spec/factories/estimate_responses.rb
218
- - spec/factories/meta_index_objects.rb
219
- - spec/factories/order_responses.rb
220
- - spec/factories/project_list_responses.rb
221
- - spec/factories/error_responses.rb
222
- - spec/factories/create_mass_estimate_requests.rb
223
219
  - spec/factories/parent_technology_type.rb
224
- - spec/factories/orders.rb
225
220
  - spec/factories/sdgs.rb
221
+ - spec/factories/project_list_responses.rb
222
+ - spec/factories/estimate_responses.rb
223
+ - spec/factories/orders.rb
224
+ - spec/factories/meta_index_objects.rb
226
225
  - spec/factories/create_order_requests.rb
226
+ - spec/factories/order_responses.rb
227
+ - spec/factories/project_responses.rb
227
228
  - spec/factories/allocations.rb
228
- - spec/factories/technology_type.rb
229
+ - spec/factories/estimates.rb
229
230
  - spec/factories/projects.rb
230
231
  - spec/factories/estimate_list_responses.rb
231
232
  - spec/factories/order_list_responses.rb
232
- - spec/integration/projects_spec.rb
233
+ - spec/factories/error_responses.rb
234
+ - spec/factories/technology_type.rb
235
+ - spec/factories/create_mass_estimate_requests.rb
233
236
  - spec/integration/projects/technology_types_spec.rb
234
237
  - spec/integration/orders_spec.rb
235
238
  - spec/integration/estimates_spec.rb
239
+ - spec/integration/projects_spec.rb
240
+ - spec/models/allocation_spec.rb
241
+ - spec/models/project_list_response_spec.rb
236
242
  - spec/models/meta_index_object_spec.rb
237
- - spec/models/estimate_spec.rb
238
- - spec/models/estimate_list_response_spec.rb
239
243
  - spec/models/estimate_response_spec.rb
240
- - spec/models/project_list_response_spec.rb
241
- - spec/models/create_order_request_spec.rb
242
- - spec/models/project_spec.rb
243
- - spec/models/allocation_spec.rb
244
- - spec/models/order_list_response_spec.rb
245
- - spec/models/error_response_spec.rb
246
- - spec/models/project_response_spec.rb
247
- - spec/models/order_spec.rb
244
+ - spec/models/estimate_list_response_spec.rb
248
245
  - spec/models/create_mass_estimate_request_spec.rb
246
+ - spec/models/project_response_spec.rb
247
+ - spec/models/error_response_spec.rb
248
+ - spec/models/estimate_spec.rb
249
+ - spec/models/order_list_response_spec.rb
249
250
  - spec/models/order_response_spec.rb
251
+ - spec/models/project_spec.rb
252
+ - spec/models/order_spec.rb
253
+ - spec/models/create_order_request_spec.rb
250
254
  - spec/patch_ruby_spec.rb
251
255
  - spec/spec_helper.rb
252
256
  - spec/support/shared/generated_classes.rb