Skip to content

Commit 9de03b4

Browse files
authored
Add patch.estimates methods for GLEC-certified shipping estimates (#72)
* Add patch.estimates methods for GLEC-certified shipping estimates * Add changelog update * Remove all changes to orders * Update constants and variable names * Remove distance_m * Lower threshold to ensure no flakes
1 parent 17989de commit 9de03b4

12 files changed

+1329
-28
lines changed

Diff for: CHANGELOG.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,20 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.24.0] - 2022-07-22
9+
10+
### Added
11+
12+
- Adds `patch.estimates.create_air_shipping_estimate` method
13+
- Adds `patch.estimates.create_rail_shipping_estimate` method
14+
- Adds `patch.estimates.create_road_shipping_estimate` method
15+
- Adds `patch.estimates.create_sea_shipping_estimate` method
16+
817
## [1.23.0] - 2022-06-03
918

1019
### Added
1120

12-
- Adds support for the `issuedTo` parameter on `orders`, to add support for creating and placing orders on behalf of another party.
21+
- Adds support for the `issued_to` parameter on `orders`, to add support for creating and placing orders on behalf of another party.
1322

1423
## [1.22.0] - 2022-05-16
1524

Diff for: README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ const totalPrice = 500; // Pass in the total price in smallest currency unit (ie
7777
const currency = 'USD';
7878
patch.orders.createOrder({ total_price: totalPrice, currency: currency });
7979

80-
// Create order with the issuedTo field (optional)
80+
// Create order with the issued_to field (optional)
8181
const amount = 1_000_000; // Pass in the amount in unit specified
8282
const unit = 'g';
83-
const issuedTo = { email: '[email protected]', name: 'Olivia Jones' };
84-
patch.orders.createOrder({ amount: amount, unit: unit, issuedTo: issuedTo });
83+
const issued_to = { email: '[email protected]', name: 'Olivia Jones' };
84+
patch.orders.createOrder({ amount: amount, unit: unit, issued_to: issued_to });
8585

8686
// Retrieve an order
8787
orderId = 'ord_test_1234'; // Pass in the order's id
@@ -91,10 +91,10 @@ patch.orders.retrieveOrder(orderId);
9191
const orderId = 'ord_test_1234'; // Pass in the order's id
9292
patch.orders.placeOrder(orderId);
9393

94-
// Place an order with the issuedTo field (optional)
94+
// Place an order with the issued_to field (optional)
9595
const orderId = 'ord_test_1234'; // Pass in the order's id
96-
const issuedTo = { email: '[email protected]', name: 'Olivia Jones' };
97-
patch.orders.placeOrder(orderId, { issuedTo: issuedTo });
96+
const issued_to = { email: '[email protected]', name: 'Olivia Jones' };
97+
patch.orders.placeOrder(orderId, { issued_to: issued_to });
9898

9999
// Cancel an order
100100
const orderId = 'ord_test_1234'; // Pass in the order's id

Diff for: package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@patch-technology/patch",
3-
"version": "1.23.0",
3+
"version": "1.24.0",
44
"description": "Node.js wrapper for the Patch API",
55
"license": "MIT",
66
"repository": {

Diff for: src/ApiClient.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ApiClient {
1616
};
1717

1818
this.defaultHeaders = {
19-
'User-Agent': 'patch-node/1.23.0'
19+
'User-Agent': 'patch-node/1.24.0'
2020
};
2121

2222
/**

Diff for: src/api/EstimatesApi.js

+200
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@
66
*/
77

88
import ApiClient from '../ApiClient';
9+
import CreateAirShippingEstimateRequest from '../model/CreateAirShippingEstimateRequest';
910
import CreateBitcoinEstimateRequest from '../model/CreateBitcoinEstimateRequest';
1011
import CreateEthereumEstimateRequest from '../model/CreateEthereumEstimateRequest';
1112
import CreateFlightEstimateRequest from '../model/CreateFlightEstimateRequest';
1213
import CreateHotelEstimateRequest from '../model/CreateHotelEstimateRequest';
1314
import CreateMassEstimateRequest from '../model/CreateMassEstimateRequest';
15+
import CreateRailShippingEstimateRequest from '../model/CreateRailShippingEstimateRequest';
16+
import CreateRoadShippingEstimateRequest from '../model/CreateRoadShippingEstimateRequest';
17+
import CreateSeaShippingEstimateRequest from '../model/CreateSeaShippingEstimateRequest';
1418
import CreateShippingEstimateRequest from '../model/CreateShippingEstimateRequest';
1519
import CreateVehicleEstimateRequest from '../model/CreateVehicleEstimateRequest';
1620
import ErrorResponse from '../model/ErrorResponse';
@@ -22,6 +26,55 @@ export default class EstimatesApi {
2226
this.apiClient = apiClient || ApiClient.instance;
2327
}
2428

29+
createAirShippingEstimateWithHttpInfo(createAirShippingEstimateRequest) {
30+
const _createAirShippingEstimateRequest =
31+
CreateAirShippingEstimateRequest.constructFromObject(
32+
createAirShippingEstimateRequest,
33+
new CreateAirShippingEstimateRequest()
34+
);
35+
let postBody = _createAirShippingEstimateRequest;
36+
37+
// verify the required parameter 'createAirShippingEstimateRequest' is set
38+
if (
39+
_createAirShippingEstimateRequest === undefined ||
40+
_createAirShippingEstimateRequest === null
41+
) {
42+
throw new Error(
43+
"Missing the required parameter 'createAirShippingEstimateRequest' when calling createAirShippingEstimate"
44+
);
45+
}
46+
47+
let pathParams = {};
48+
let queryParams = {};
49+
let headerParams = {};
50+
let formParams = {};
51+
52+
let authNames = ['bearer_auth'];
53+
let contentTypes = ['application/json'];
54+
let accepts = ['application/json'];
55+
let returnType = EstimateResponse;
56+
57+
return this.apiClient.callApi(
58+
'/v1/estimates/shipping/air',
59+
'POST',
60+
pathParams,
61+
queryParams,
62+
headerParams,
63+
formParams,
64+
postBody,
65+
authNames,
66+
contentTypes,
67+
accepts,
68+
returnType
69+
);
70+
}
71+
72+
createAirShippingEstimate(createAirShippingEstimateRequest) {
73+
return this.createAirShippingEstimateWithHttpInfo(
74+
createAirShippingEstimateRequest
75+
);
76+
}
77+
2578
createBitcoinEstimateWithHttpInfo(createBitcoinEstimateRequest) {
2679
const _createBitcoinEstimateRequest =
2780
CreateBitcoinEstimateRequest.constructFromObject(
@@ -259,6 +312,153 @@ export default class EstimatesApi {
259312
return this.createMassEstimateWithHttpInfo(createMassEstimateRequest);
260313
}
261314

315+
createRailShippingEstimateWithHttpInfo(createRailShippingEstimateRequest) {
316+
const _createRailShippingEstimateRequest =
317+
CreateRailShippingEstimateRequest.constructFromObject(
318+
createRailShippingEstimateRequest,
319+
new CreateRailShippingEstimateRequest()
320+
);
321+
let postBody = _createRailShippingEstimateRequest;
322+
323+
// verify the required parameter 'createRailShippingEstimateRequest' is set
324+
if (
325+
_createRailShippingEstimateRequest === undefined ||
326+
_createRailShippingEstimateRequest === null
327+
) {
328+
throw new Error(
329+
"Missing the required parameter 'createRailShippingEstimateRequest' when calling createRailShippingEstimate"
330+
);
331+
}
332+
333+
let pathParams = {};
334+
let queryParams = {};
335+
let headerParams = {};
336+
let formParams = {};
337+
338+
let authNames = ['bearer_auth'];
339+
let contentTypes = ['application/json'];
340+
let accepts = ['application/json'];
341+
let returnType = EstimateResponse;
342+
343+
return this.apiClient.callApi(
344+
'/v1/estimates/shipping/rail',
345+
'POST',
346+
pathParams,
347+
queryParams,
348+
headerParams,
349+
formParams,
350+
postBody,
351+
authNames,
352+
contentTypes,
353+
accepts,
354+
returnType
355+
);
356+
}
357+
358+
createRailShippingEstimate(createRailShippingEstimateRequest) {
359+
return this.createRailShippingEstimateWithHttpInfo(
360+
createRailShippingEstimateRequest
361+
);
362+
}
363+
364+
createRoadShippingEstimateWithHttpInfo(createRoadShippingEstimateRequest) {
365+
const _createRoadShippingEstimateRequest =
366+
CreateRoadShippingEstimateRequest.constructFromObject(
367+
createRoadShippingEstimateRequest,
368+
new CreateRoadShippingEstimateRequest()
369+
);
370+
let postBody = _createRoadShippingEstimateRequest;
371+
372+
// verify the required parameter 'createRoadShippingEstimateRequest' is set
373+
if (
374+
_createRoadShippingEstimateRequest === undefined ||
375+
_createRoadShippingEstimateRequest === null
376+
) {
377+
throw new Error(
378+
"Missing the required parameter 'createRoadShippingEstimateRequest' when calling createRoadShippingEstimate"
379+
);
380+
}
381+
382+
let pathParams = {};
383+
let queryParams = {};
384+
let headerParams = {};
385+
let formParams = {};
386+
387+
let authNames = ['bearer_auth'];
388+
let contentTypes = ['application/json'];
389+
let accepts = ['application/json'];
390+
let returnType = EstimateResponse;
391+
392+
return this.apiClient.callApi(
393+
'/v1/estimates/shipping/road',
394+
'POST',
395+
pathParams,
396+
queryParams,
397+
headerParams,
398+
formParams,
399+
postBody,
400+
authNames,
401+
contentTypes,
402+
accepts,
403+
returnType
404+
);
405+
}
406+
407+
createRoadShippingEstimate(createRoadShippingEstimateRequest) {
408+
return this.createRoadShippingEstimateWithHttpInfo(
409+
createRoadShippingEstimateRequest
410+
);
411+
}
412+
413+
createSeaShippingEstimateWithHttpInfo(createSeaShippingEstimateRequest) {
414+
const _createSeaShippingEstimateRequest =
415+
CreateSeaShippingEstimateRequest.constructFromObject(
416+
createSeaShippingEstimateRequest,
417+
new CreateSeaShippingEstimateRequest()
418+
);
419+
let postBody = _createSeaShippingEstimateRequest;
420+
421+
// verify the required parameter 'createSeaShippingEstimateRequest' is set
422+
if (
423+
_createSeaShippingEstimateRequest === undefined ||
424+
_createSeaShippingEstimateRequest === null
425+
) {
426+
throw new Error(
427+
"Missing the required parameter 'createSeaShippingEstimateRequest' when calling createSeaShippingEstimate"
428+
);
429+
}
430+
431+
let pathParams = {};
432+
let queryParams = {};
433+
let headerParams = {};
434+
let formParams = {};
435+
436+
let authNames = ['bearer_auth'];
437+
let contentTypes = ['application/json'];
438+
let accepts = ['application/json'];
439+
let returnType = EstimateResponse;
440+
441+
return this.apiClient.callApi(
442+
'/v1/estimates/shipping/sea',
443+
'POST',
444+
pathParams,
445+
queryParams,
446+
headerParams,
447+
formParams,
448+
postBody,
449+
authNames,
450+
contentTypes,
451+
accepts,
452+
returnType
453+
);
454+
}
455+
456+
createSeaShippingEstimate(createSeaShippingEstimateRequest) {
457+
return this.createSeaShippingEstimateWithHttpInfo(
458+
createSeaShippingEstimateRequest
459+
);
460+
}
461+
262462
createShippingEstimateWithHttpInfo(createShippingEstimateRequest) {
263463
const _createShippingEstimateRequest =
264464
CreateShippingEstimateRequest.constructFromObject(

0 commit comments

Comments
 (0)