From 5d8e16caf360db308b2262ff2f2a09b0d8d4c7b5 Mon Sep 17 00:00:00 2001 From: Paul Cothenet Date: Fri, 7 Nov 2025 12:30:38 -0800 Subject: [PATCH] Remove remaining estimates --- CHANGELOG.md | 7 + README.md | 53 --- package-lock.json | 4 +- package.json | 2 +- src/ApiClient.js | 2 +- src/api/EstimatesApi.js | 437 ------------------ src/index.js | 3 - src/model/CreateAirShippingEstimateRequest.js | 97 ---- src/model/CreateBitcoinEstimateRequest.js | 69 --- src/model/CreateMassEstimateRequest.js | 51 -- .../CreateRailShippingEstimateRequest.js | 123 ----- .../CreateRoadShippingEstimateRequest.js | 168 ------- src/model/CreateSeaShippingEstimateRequest.js | 154 ------ src/model/Estimate.js | 63 --- src/model/EstimateListResponse.js | 56 --- src/model/EstimateResponse.js | 48 -- test/integration/estimates.test.js | 240 ---------- test/integration/orders.test.js | 52 +-- 18 files changed, 14 insertions(+), 1615 deletions(-) delete mode 100644 src/api/EstimatesApi.js delete mode 100644 src/model/CreateAirShippingEstimateRequest.js delete mode 100644 src/model/CreateBitcoinEstimateRequest.js delete mode 100644 src/model/CreateMassEstimateRequest.js delete mode 100644 src/model/CreateRailShippingEstimateRequest.js delete mode 100644 src/model/CreateRoadShippingEstimateRequest.js delete mode 100644 src/model/CreateSeaShippingEstimateRequest.js delete mode 100644 src/model/Estimate.js delete mode 100644 src/model/EstimateListResponse.js delete mode 100644 src/model/EstimateResponse.js delete mode 100644 test/integration/estimates.test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index e83c289..24c1c0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.6.0] - 2025-11-07 + +### Removed + +- Removes `createMassEstimate` and `createBitcoinEstimate` method +- Retires all remaining estimates functionalities + ## [2.5.0] - 2025-08-19 ### Removed diff --git a/README.md b/README.md index e37d45e..2123001 100644 --- a/README.md +++ b/README.md @@ -53,12 +53,6 @@ npm install install-peers ### Orders -In Patch, orders represent a purchase of carbon offsets or negative emissions by mass. -Place orders directly if you know the amount of carbon dioxide you would like to sequester. -If you do not know how much to purchase, use an estimate. -You can also create an order with a maximum desired price, and we'll allocate enough mass to -fulfill the order for you. - [API Reference](https://docs.patch.io/#/?id=orders) #### Examples @@ -105,53 +99,6 @@ const page = 1; // Pass in which page of orders you'd like patch.orders.retrieveOrders({ page }); ``` -### Estimates - -Estimates allow API users to get a quote for the cost of compensating a certain amount of CO2. When creating an estimate, an order in the `draft` state will also be created, reserving the allocation of a project for 5 minutes. If you don't place your draft order within those 5 minutes, the order will automatically be cancelled. - -[API Reference](https://docs.patch.io/#/?id=estimates) - -#### Examples - -```javascript -// Create a mass estimate -const mass_g = 1000000; // Pass in the mass in grams (i.e. 1 metric tonne) -patch.estimates.createMassEstimate({ mass_g }); - -// Create an ecommerce estimate -const distance_m = 9000000; -// Pass in the shipping distance in meters, the transportation method, and the package mass -patch.estimates.createEcommerceEstimate({ - distance_m, - package_mass_g: 1000, - transportation_method: 'air' -}); - -// Create a bitcoin estimate -const transaction_value_btc_sats = 1000; // [Optional] Pass in the transaction value in satoshis -patch.estimates.createBitcoinEstimate({ - transaction_value_btc_sats -}); - -// Create a vehicle estimate -const distance_m = 9000000; -// Pass in the driving distance in meters and the model/make/year of the vehicle -patch.estimates.createVehicleEstimate({ - distance_m, - make: 'Toyota', - model: 'Corolla', - year: 1995 -}); - -// Retrieve an estimate -const estimateId = 'est_test_1234'; -patch.estimates.retrieveEstimate(estimate_id); - -// Retrieve a list of estimates -const page = 1; // Pass in which page of estimates you'd like -patch.estimates.retrieveEstimates({ page }); -``` - ### Projects Projects are the ways Patch takes CO2 out of the air. They can represent reforestation, enhanced weathering, direct air carbon capture, etc. When you place an order via Patch, it is allocated to a project. diff --git a/package-lock.json b/package-lock.json index 2d844ce..832dc02 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@patch-technology/patch", - "version": "2.5.0", + "version": "2.6.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@patch-technology/patch", - "version": "2.5.0", + "version": "2.6.0", "license": "MIT", "dependencies": { "query-string": "^7.0.1", diff --git a/package.json b/package.json index 36a9971..f60c8ec 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@patch-technology/patch", - "version": "2.5.0", + "version": "2.6.0", "description": "Node.js wrapper for the Patch API", "license": "MIT", "repository": { diff --git a/src/ApiClient.js b/src/ApiClient.js index 0dba068..dc963c0 100644 --- a/src/ApiClient.js +++ b/src/ApiClient.js @@ -16,7 +16,7 @@ class ApiClient { }; this.defaultHeaders = { - 'User-Agent': 'patch-node/2.5.0', + 'User-Agent': 'patch-node/2.6.0', 'Patch-Version': 2 }; diff --git a/src/api/EstimatesApi.js b/src/api/EstimatesApi.js deleted file mode 100644 index c752f5b..0000000 --- a/src/api/EstimatesApi.js +++ /dev/null @@ -1,437 +0,0 @@ -/** - * Patch API V2 - * The core API used to integrate with Patch's service - * - * Contact: engineering@usepatch.com - */ - -import ApiClient from '../ApiClient'; -import CreateAirShippingEstimateRequest from '../model/CreateAirShippingEstimateRequest'; -import CreateBitcoinEstimateRequest from '../model/CreateBitcoinEstimateRequest'; -import CreateMassEstimateRequest from '../model/CreateMassEstimateRequest'; -import CreateRailShippingEstimateRequest from '../model/CreateRailShippingEstimateRequest'; -import CreateRoadShippingEstimateRequest from '../model/CreateRoadShippingEstimateRequest'; -import CreateSeaShippingEstimateRequest from '../model/CreateSeaShippingEstimateRequest'; -import ErrorResponse from '../model/ErrorResponse'; -import EstimateListResponse from '../model/EstimateListResponse'; -import EstimateResponse from '../model/EstimateResponse'; - -export default class EstimatesApi { - constructor(apiClient) { - this.apiClient = apiClient || ApiClient.instance; - } - - createAirShippingEstimateWithHttpInfo( - createAirShippingEstimateRequest, - opts - ) { - opts = opts || {}; - - const _createAirShippingEstimateRequest = - CreateAirShippingEstimateRequest.constructFromObject( - createAirShippingEstimateRequest, - new CreateAirShippingEstimateRequest() - ); - - // verify the required parameter 'createAirShippingEstimateRequest' is set - if ( - _createAirShippingEstimateRequest === undefined || - _createAirShippingEstimateRequest === null - ) { - throw new Error( - "Missing the required parameter 'createAirShippingEstimateRequest' when calling createAirShippingEstimate" - ); - } - - let postBody = _createAirShippingEstimateRequest; - let pathParams = {}; - let queryParams = {}; - let headerParams = { - 'Patch-Version': opts['patchVersion'] - }; - let formParams = {}; - - let authNames = ['bearer_auth']; - let contentTypes = ['application/json']; - let accepts = ['application/json']; - let returnType = EstimateResponse; - - return this.apiClient.callApi( - '/v1/estimates/shipping/air', - 'POST', - pathParams, - queryParams, - headerParams, - formParams, - postBody, - authNames, - contentTypes, - accepts, - returnType - ); - } - - createAirShippingEstimate(createAirShippingEstimateRequest, opts) { - return this.createAirShippingEstimateWithHttpInfo( - createAirShippingEstimateRequest, - opts - ); - } - - createBitcoinEstimateWithHttpInfo(createBitcoinEstimateRequest, opts) { - opts = opts || {}; - - const _createBitcoinEstimateRequest = - CreateBitcoinEstimateRequest.constructFromObject( - createBitcoinEstimateRequest, - new CreateBitcoinEstimateRequest() - ); - - // verify the required parameter 'createBitcoinEstimateRequest' is set - if ( - _createBitcoinEstimateRequest === undefined || - _createBitcoinEstimateRequest === null - ) { - throw new Error( - "Missing the required parameter 'createBitcoinEstimateRequest' when calling createBitcoinEstimate" - ); - } - - let postBody = _createBitcoinEstimateRequest; - let pathParams = {}; - let queryParams = {}; - let headerParams = { - 'Patch-Version': opts['patchVersion'] - }; - let formParams = {}; - - let authNames = ['bearer_auth']; - let contentTypes = ['application/json']; - let accepts = ['application/json']; - let returnType = EstimateResponse; - - return this.apiClient.callApi( - '/v1/estimates/crypto/btc', - 'POST', - pathParams, - queryParams, - headerParams, - formParams, - postBody, - authNames, - contentTypes, - accepts, - returnType - ); - } - - createBitcoinEstimate(createBitcoinEstimateRequest, opts) { - return this.createBitcoinEstimateWithHttpInfo( - createBitcoinEstimateRequest, - opts - ); - } - - createMassEstimateWithHttpInfo(createMassEstimateRequest, opts) { - opts = opts || {}; - - const _createMassEstimateRequest = - CreateMassEstimateRequest.constructFromObject( - createMassEstimateRequest, - new CreateMassEstimateRequest() - ); - - // verify the required parameter 'createMassEstimateRequest' is set - if ( - _createMassEstimateRequest === undefined || - _createMassEstimateRequest === null - ) { - throw new Error( - "Missing the required parameter 'createMassEstimateRequest' when calling createMassEstimate" - ); - } - - let postBody = _createMassEstimateRequest; - let pathParams = {}; - let queryParams = {}; - let headerParams = { - 'Patch-Version': opts['patchVersion'] - }; - let formParams = {}; - - let authNames = ['bearer_auth']; - let contentTypes = ['application/json']; - let accepts = ['application/json']; - let returnType = EstimateResponse; - - return this.apiClient.callApi( - '/v1/estimates/mass', - 'POST', - pathParams, - queryParams, - headerParams, - formParams, - postBody, - authNames, - contentTypes, - accepts, - returnType - ); - } - - createMassEstimate(createMassEstimateRequest, opts) { - return this.createMassEstimateWithHttpInfo(createMassEstimateRequest, opts); - } - - createRailShippingEstimateWithHttpInfo( - createRailShippingEstimateRequest, - opts - ) { - opts = opts || {}; - - const _createRailShippingEstimateRequest = - CreateRailShippingEstimateRequest.constructFromObject( - createRailShippingEstimateRequest, - new CreateRailShippingEstimateRequest() - ); - - // verify the required parameter 'createRailShippingEstimateRequest' is set - if ( - _createRailShippingEstimateRequest === undefined || - _createRailShippingEstimateRequest === null - ) { - throw new Error( - "Missing the required parameter 'createRailShippingEstimateRequest' when calling createRailShippingEstimate" - ); - } - - let postBody = _createRailShippingEstimateRequest; - let pathParams = {}; - let queryParams = {}; - let headerParams = { - 'Patch-Version': opts['patchVersion'] - }; - let formParams = {}; - - let authNames = ['bearer_auth']; - let contentTypes = ['application/json']; - let accepts = ['application/json']; - let returnType = EstimateResponse; - - return this.apiClient.callApi( - '/v1/estimates/shipping/rail', - 'POST', - pathParams, - queryParams, - headerParams, - formParams, - postBody, - authNames, - contentTypes, - accepts, - returnType - ); - } - - createRailShippingEstimate(createRailShippingEstimateRequest, opts) { - return this.createRailShippingEstimateWithHttpInfo( - createRailShippingEstimateRequest, - opts - ); - } - - createRoadShippingEstimateWithHttpInfo( - createRoadShippingEstimateRequest, - opts - ) { - opts = opts || {}; - - const _createRoadShippingEstimateRequest = - CreateRoadShippingEstimateRequest.constructFromObject( - createRoadShippingEstimateRequest, - new CreateRoadShippingEstimateRequest() - ); - - // verify the required parameter 'createRoadShippingEstimateRequest' is set - if ( - _createRoadShippingEstimateRequest === undefined || - _createRoadShippingEstimateRequest === null - ) { - throw new Error( - "Missing the required parameter 'createRoadShippingEstimateRequest' when calling createRoadShippingEstimate" - ); - } - - let postBody = _createRoadShippingEstimateRequest; - let pathParams = {}; - let queryParams = {}; - let headerParams = { - 'Patch-Version': opts['patchVersion'] - }; - let formParams = {}; - - let authNames = ['bearer_auth']; - let contentTypes = ['application/json']; - let accepts = ['application/json']; - let returnType = EstimateResponse; - - return this.apiClient.callApi( - '/v1/estimates/shipping/road', - 'POST', - pathParams, - queryParams, - headerParams, - formParams, - postBody, - authNames, - contentTypes, - accepts, - returnType - ); - } - - createRoadShippingEstimate(createRoadShippingEstimateRequest, opts) { - return this.createRoadShippingEstimateWithHttpInfo( - createRoadShippingEstimateRequest, - opts - ); - } - - createSeaShippingEstimateWithHttpInfo( - createSeaShippingEstimateRequest, - opts - ) { - opts = opts || {}; - - const _createSeaShippingEstimateRequest = - CreateSeaShippingEstimateRequest.constructFromObject( - createSeaShippingEstimateRequest, - new CreateSeaShippingEstimateRequest() - ); - - // verify the required parameter 'createSeaShippingEstimateRequest' is set - if ( - _createSeaShippingEstimateRequest === undefined || - _createSeaShippingEstimateRequest === null - ) { - throw new Error( - "Missing the required parameter 'createSeaShippingEstimateRequest' when calling createSeaShippingEstimate" - ); - } - - let postBody = _createSeaShippingEstimateRequest; - let pathParams = {}; - let queryParams = {}; - let headerParams = { - 'Patch-Version': opts['patchVersion'] - }; - let formParams = {}; - - let authNames = ['bearer_auth']; - let contentTypes = ['application/json']; - let accepts = ['application/json']; - let returnType = EstimateResponse; - - return this.apiClient.callApi( - '/v1/estimates/shipping/sea', - 'POST', - pathParams, - queryParams, - headerParams, - formParams, - postBody, - authNames, - contentTypes, - accepts, - returnType - ); - } - - createSeaShippingEstimate(createSeaShippingEstimateRequest, opts) { - return this.createSeaShippingEstimateWithHttpInfo( - createSeaShippingEstimateRequest, - opts - ); - } - - retrieveEstimateWithHttpInfo(id, opts) { - opts = opts || {}; - - // verify the required parameter 'id' is set - if (id === undefined || id === null) { - throw new Error( - "Missing the required parameter 'id' when calling retrieveEstimate" - ); - } - - let postBody = null; - let pathParams = { - id: id - }; - let queryParams = {}; - let headerParams = { - 'Patch-Version': opts['patchVersion'] - }; - let formParams = {}; - - let authNames = ['bearer_auth']; - let contentTypes = []; - let accepts = ['application/json']; - let returnType = EstimateResponse; - - return this.apiClient.callApi( - '/v1/estimates/{id}', - 'GET', - pathParams, - queryParams, - headerParams, - formParams, - postBody, - authNames, - contentTypes, - accepts, - returnType - ); - } - - retrieveEstimate(id, opts) { - return this.retrieveEstimateWithHttpInfo(id, opts); - } - - retrieveEstimatesWithHttpInfo(opts) { - opts = opts || {}; - - let postBody = null; - let pathParams = {}; - let queryParams = { - page: opts['page'] - }; - let headerParams = { - 'Patch-Version': opts['patchVersion'] - }; - let formParams = {}; - - let authNames = ['bearer_auth']; - let contentTypes = []; - let accepts = ['application/json']; - let returnType = EstimateListResponse; - - return this.apiClient.callApi( - '/v1/estimates', - 'GET', - pathParams, - queryParams, - headerParams, - formParams, - postBody, - authNames, - contentTypes, - accepts, - returnType - ); - } - - retrieveEstimates(opts) { - return this.retrieveEstimatesWithHttpInfo(opts); - } -} diff --git a/src/index.js b/src/index.js index ad73b7b..a156953 100644 --- a/src/index.js +++ b/src/index.js @@ -6,7 +6,6 @@ */ import ApiClient from './ApiClient'; -import EstimatesApi from './api/EstimatesApi'; import OrderLineItemsApi from './api/OrderLineItemsApi'; import OrdersApi from './api/OrdersApi'; import ProjectsApi from './api/ProjectsApi'; @@ -18,8 +17,6 @@ export default function Patch(accessToken) { this.client = ApiClient.instance; this.client.authentications['bearer_auth'].accessToken = accessToken; - this.estimates = new EstimatesApi(this.client); - this.orderlineitems = new OrderLineItemsApi(this.client); this.orders = new OrdersApi(this.client); diff --git a/src/model/CreateAirShippingEstimateRequest.js b/src/model/CreateAirShippingEstimateRequest.js deleted file mode 100644 index 0abb1de..0000000 --- a/src/model/CreateAirShippingEstimateRequest.js +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Patch API V2 - * The core API used to integrate with Patch's service - * - * Contact: engineering@usepatch.com - */ - -import ApiClient from '../ApiClient'; - -class CreateAirShippingEstimateRequest { - constructor() { - CreateAirShippingEstimateRequest.initialize(this); - } - - static initialize(obj) {} - - static constructFromObject(data, obj) { - if (data) { - obj = obj || new CreateAirShippingEstimateRequest(); - - if (data.hasOwnProperty('destination_airport')) { - obj['destination_airport'] = ApiClient.convertToType( - data['destination_airport'], - 'String' - ); - } - - if (data.hasOwnProperty('origin_airport')) { - obj['origin_airport'] = ApiClient.convertToType( - data['origin_airport'], - 'String' - ); - } - - if (data.hasOwnProperty('aircraft_code')) { - obj['aircraft_code'] = ApiClient.convertToType( - data['aircraft_code'], - 'String' - ); - } - - if (data.hasOwnProperty('aircraft_type')) { - obj['aircraft_type'] = ApiClient.convertToType( - data['aircraft_type'], - 'String' - ); - } - - if (data.hasOwnProperty('freight_mass_g')) { - obj['freight_mass_g'] = ApiClient.convertToType( - data['freight_mass_g'], - 'Number' - ); - } - - if (data.hasOwnProperty('emissions_scope')) { - obj['emissions_scope'] = ApiClient.convertToType( - data['emissions_scope'], - 'String' - ); - } - - if (data.hasOwnProperty('project_id')) { - obj['project_id'] = ApiClient.convertToType( - data['project_id'], - 'String' - ); - } - - if (data.hasOwnProperty('create_order')) { - obj['create_order'] = ApiClient.convertToType( - data['create_order'], - 'Boolean' - ); - } - } - return obj; - } -} - -CreateAirShippingEstimateRequest.prototype['destination_airport'] = undefined; - -CreateAirShippingEstimateRequest.prototype['origin_airport'] = undefined; - -CreateAirShippingEstimateRequest.prototype['aircraft_code'] = undefined; - -CreateAirShippingEstimateRequest.prototype['aircraft_type'] = 'unknown'; - -CreateAirShippingEstimateRequest.prototype['freight_mass_g'] = undefined; - -CreateAirShippingEstimateRequest.prototype['emissions_scope'] = 'ttw'; - -CreateAirShippingEstimateRequest.prototype['project_id'] = undefined; - -CreateAirShippingEstimateRequest.prototype['create_order'] = false; - -export default CreateAirShippingEstimateRequest; diff --git a/src/model/CreateBitcoinEstimateRequest.js b/src/model/CreateBitcoinEstimateRequest.js deleted file mode 100644 index 11cc903..0000000 --- a/src/model/CreateBitcoinEstimateRequest.js +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Patch API V2 - * The core API used to integrate with Patch's service - * - * Contact: engineering@usepatch.com - */ - -import ApiClient from '../ApiClient'; - -class CreateBitcoinEstimateRequest { - constructor() { - CreateBitcoinEstimateRequest.initialize(this); - } - - static initialize(obj) {} - - static constructFromObject(data, obj) { - if (data) { - obj = obj || new CreateBitcoinEstimateRequest(); - - if (data.hasOwnProperty('timestamp')) { - obj['timestamp'] = ApiClient.convertToType(data['timestamp'], 'Date'); - } - - if (data.hasOwnProperty('transaction_value_btc_sats')) { - obj['transaction_value_btc_sats'] = ApiClient.convertToType( - data['transaction_value_btc_sats'], - 'Number' - ); - } - - if (data.hasOwnProperty('average_daily_balance_btc_sats')) { - obj['average_daily_balance_btc_sats'] = ApiClient.convertToType( - data['average_daily_balance_btc_sats'], - 'Number' - ); - } - - if (data.hasOwnProperty('project_id')) { - obj['project_id'] = ApiClient.convertToType( - data['project_id'], - 'String' - ); - } - - if (data.hasOwnProperty('create_order')) { - obj['create_order'] = ApiClient.convertToType( - data['create_order'], - 'Boolean' - ); - } - } - return obj; - } -} - -CreateBitcoinEstimateRequest.prototype['timestamp'] = undefined; - -CreateBitcoinEstimateRequest.prototype['transaction_value_btc_sats'] = - undefined; - -CreateBitcoinEstimateRequest.prototype['average_daily_balance_btc_sats'] = - undefined; - -CreateBitcoinEstimateRequest.prototype['project_id'] = undefined; - -CreateBitcoinEstimateRequest.prototype['create_order'] = false; - -export default CreateBitcoinEstimateRequest; diff --git a/src/model/CreateMassEstimateRequest.js b/src/model/CreateMassEstimateRequest.js deleted file mode 100644 index 4f1a6bd..0000000 --- a/src/model/CreateMassEstimateRequest.js +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Patch API V2 - * The core API used to integrate with Patch's service - * - * Contact: engineering@usepatch.com - */ - -import ApiClient from '../ApiClient'; - -class CreateMassEstimateRequest { - constructor(massG) { - CreateMassEstimateRequest.initialize(this, massG); - } - - static initialize(obj, massG) { - obj['mass_g'] = massG; - } - - static constructFromObject(data, obj) { - if (data) { - obj = obj || new CreateMassEstimateRequest(); - - if (data.hasOwnProperty('mass_g')) { - obj['mass_g'] = ApiClient.convertToType(data['mass_g'], 'Number'); - } - - if (data.hasOwnProperty('create_order')) { - obj['create_order'] = ApiClient.convertToType( - data['create_order'], - 'Boolean' - ); - } - - if (data.hasOwnProperty('project_id')) { - obj['project_id'] = ApiClient.convertToType( - data['project_id'], - 'String' - ); - } - } - return obj; - } -} - -CreateMassEstimateRequest.prototype['mass_g'] = undefined; - -CreateMassEstimateRequest.prototype['create_order'] = false; - -CreateMassEstimateRequest.prototype['project_id'] = undefined; - -export default CreateMassEstimateRequest; diff --git a/src/model/CreateRailShippingEstimateRequest.js b/src/model/CreateRailShippingEstimateRequest.js deleted file mode 100644 index c55c679..0000000 --- a/src/model/CreateRailShippingEstimateRequest.js +++ /dev/null @@ -1,123 +0,0 @@ -/** - * Patch API V2 - * The core API used to integrate with Patch's service - * - * Contact: engineering@usepatch.com - */ - -import ApiClient from '../ApiClient'; - -class CreateRailShippingEstimateRequest { - constructor() { - CreateRailShippingEstimateRequest.initialize(this); - } - - static initialize(obj) {} - - static constructFromObject(data, obj) { - if (data) { - obj = obj || new CreateRailShippingEstimateRequest(); - - if (data.hasOwnProperty('destination_country_code')) { - obj['destination_country_code'] = ApiClient.convertToType( - data['destination_country_code'], - 'String' - ); - } - - if (data.hasOwnProperty('destination_locode')) { - obj['destination_locode'] = ApiClient.convertToType( - data['destination_locode'], - 'String' - ); - } - - if (data.hasOwnProperty('destination_postal_code')) { - obj['destination_postal_code'] = ApiClient.convertToType( - data['destination_postal_code'], - 'String' - ); - } - - if (data.hasOwnProperty('origin_country_code')) { - obj['origin_country_code'] = ApiClient.convertToType( - data['origin_country_code'], - 'String' - ); - } - - if (data.hasOwnProperty('origin_locode')) { - obj['origin_locode'] = ApiClient.convertToType( - data['origin_locode'], - 'String' - ); - } - - if (data.hasOwnProperty('origin_postal_code')) { - obj['origin_postal_code'] = ApiClient.convertToType( - data['origin_postal_code'], - 'String' - ); - } - - if (data.hasOwnProperty('fuel_type')) { - obj['fuel_type'] = ApiClient.convertToType(data['fuel_type'], 'String'); - } - - if (data.hasOwnProperty('freight_mass_g')) { - obj['freight_mass_g'] = ApiClient.convertToType( - data['freight_mass_g'], - 'Number' - ); - } - - if (data.hasOwnProperty('emissions_scope')) { - obj['emissions_scope'] = ApiClient.convertToType( - data['emissions_scope'], - 'String' - ); - } - - if (data.hasOwnProperty('project_id')) { - obj['project_id'] = ApiClient.convertToType( - data['project_id'], - 'String' - ); - } - - if (data.hasOwnProperty('create_order')) { - obj['create_order'] = ApiClient.convertToType( - data['create_order'], - 'Boolean' - ); - } - } - return obj; - } -} - -CreateRailShippingEstimateRequest.prototype['destination_country_code'] = - undefined; - -CreateRailShippingEstimateRequest.prototype['destination_locode'] = undefined; - -CreateRailShippingEstimateRequest.prototype['destination_postal_code'] = - undefined; - -CreateRailShippingEstimateRequest.prototype['origin_country_code'] = undefined; - -CreateRailShippingEstimateRequest.prototype['origin_locode'] = undefined; - -CreateRailShippingEstimateRequest.prototype['origin_postal_code'] = undefined; - -CreateRailShippingEstimateRequest.prototype['fuel_type'] = 'default'; - -CreateRailShippingEstimateRequest.prototype['freight_mass_g'] = undefined; - -CreateRailShippingEstimateRequest.prototype['emissions_scope'] = 'ttw'; - -CreateRailShippingEstimateRequest.prototype['project_id'] = undefined; - -CreateRailShippingEstimateRequest.prototype['create_order'] = false; - -export default CreateRailShippingEstimateRequest; diff --git a/src/model/CreateRoadShippingEstimateRequest.js b/src/model/CreateRoadShippingEstimateRequest.js deleted file mode 100644 index d1afea9..0000000 --- a/src/model/CreateRoadShippingEstimateRequest.js +++ /dev/null @@ -1,168 +0,0 @@ -/** - * Patch API V2 - * The core API used to integrate with Patch's service - * - * Contact: engineering@usepatch.com - */ - -import ApiClient from '../ApiClient'; - -class CreateRoadShippingEstimateRequest { - constructor() { - CreateRoadShippingEstimateRequest.initialize(this); - } - - static initialize(obj) {} - - static constructFromObject(data, obj) { - if (data) { - obj = obj || new CreateRoadShippingEstimateRequest(); - - if (data.hasOwnProperty('destination_country_code')) { - obj['destination_country_code'] = ApiClient.convertToType( - data['destination_country_code'], - 'String' - ); - } - - if (data.hasOwnProperty('destination_locode')) { - obj['destination_locode'] = ApiClient.convertToType( - data['destination_locode'], - 'String' - ); - } - - if (data.hasOwnProperty('destination_postal_code')) { - obj['destination_postal_code'] = ApiClient.convertToType( - data['destination_postal_code'], - 'String' - ); - } - - if (data.hasOwnProperty('origin_country_code')) { - obj['origin_country_code'] = ApiClient.convertToType( - data['origin_country_code'], - 'String' - ); - } - - if (data.hasOwnProperty('origin_locode')) { - obj['origin_locode'] = ApiClient.convertToType( - data['origin_locode'], - 'String' - ); - } - - if (data.hasOwnProperty('origin_postal_code')) { - obj['origin_postal_code'] = ApiClient.convertToType( - data['origin_postal_code'], - 'String' - ); - } - - if (data.hasOwnProperty('cargo_type')) { - obj['cargo_type'] = ApiClient.convertToType( - data['cargo_type'], - 'String' - ); - } - - if (data.hasOwnProperty('container_size_code')) { - obj['container_size_code'] = ApiClient.convertToType( - data['container_size_code'], - 'String' - ); - } - - if (data.hasOwnProperty('emissions_scope')) { - obj['emissions_scope'] = ApiClient.convertToType( - data['emissions_scope'], - 'String' - ); - } - - if (data.hasOwnProperty('freight_mass_g')) { - obj['freight_mass_g'] = ApiClient.convertToType( - data['freight_mass_g'], - 'Number' - ); - } - - if (data.hasOwnProperty('fuel_type')) { - obj['fuel_type'] = ApiClient.convertToType(data['fuel_type'], 'String'); - } - - if (data.hasOwnProperty('number_of_containers')) { - obj['number_of_containers'] = ApiClient.convertToType( - data['number_of_containers'], - 'Number' - ); - } - - if (data.hasOwnProperty('truck_weight_t')) { - obj['truck_weight_t'] = ApiClient.convertToType( - data['truck_weight_t'], - 'Number' - ); - } - - if (data.hasOwnProperty('carrier_scac')) { - obj['carrier_scac'] = ApiClient.convertToType( - data['carrier_scac'], - 'String' - ); - } - - if (data.hasOwnProperty('project_id')) { - obj['project_id'] = ApiClient.convertToType( - data['project_id'], - 'String' - ); - } - - if (data.hasOwnProperty('create_order')) { - obj['create_order'] = ApiClient.convertToType( - data['create_order'], - 'Boolean' - ); - } - } - return obj; - } -} - -CreateRoadShippingEstimateRequest.prototype['destination_country_code'] = - undefined; - -CreateRoadShippingEstimateRequest.prototype['destination_locode'] = undefined; - -CreateRoadShippingEstimateRequest.prototype['destination_postal_code'] = - undefined; - -CreateRoadShippingEstimateRequest.prototype['origin_country_code'] = undefined; - -CreateRoadShippingEstimateRequest.prototype['origin_locode'] = undefined; - -CreateRoadShippingEstimateRequest.prototype['origin_postal_code'] = undefined; - -CreateRoadShippingEstimateRequest.prototype['cargo_type'] = 'average_mixed'; - -CreateRoadShippingEstimateRequest.prototype['container_size_code'] = undefined; - -CreateRoadShippingEstimateRequest.prototype['emissions_scope'] = 'ttw'; - -CreateRoadShippingEstimateRequest.prototype['freight_mass_g'] = undefined; - -CreateRoadShippingEstimateRequest.prototype['fuel_type'] = 'diesel'; - -CreateRoadShippingEstimateRequest.prototype['number_of_containers'] = undefined; - -CreateRoadShippingEstimateRequest.prototype['truck_weight_t'] = undefined; - -CreateRoadShippingEstimateRequest.prototype['carrier_scac'] = undefined; - -CreateRoadShippingEstimateRequest.prototype['project_id'] = undefined; - -CreateRoadShippingEstimateRequest.prototype['create_order'] = false; - -export default CreateRoadShippingEstimateRequest; diff --git a/src/model/CreateSeaShippingEstimateRequest.js b/src/model/CreateSeaShippingEstimateRequest.js deleted file mode 100644 index aa4fb07..0000000 --- a/src/model/CreateSeaShippingEstimateRequest.js +++ /dev/null @@ -1,154 +0,0 @@ -/** - * Patch API V2 - * The core API used to integrate with Patch's service - * - * Contact: engineering@usepatch.com - */ - -import ApiClient from '../ApiClient'; - -class CreateSeaShippingEstimateRequest { - constructor() { - CreateSeaShippingEstimateRequest.initialize(this); - } - - static initialize(obj) {} - - static constructFromObject(data, obj) { - if (data) { - obj = obj || new CreateSeaShippingEstimateRequest(); - - if (data.hasOwnProperty('destination_country_code')) { - obj['destination_country_code'] = ApiClient.convertToType( - data['destination_country_code'], - 'String' - ); - } - - if (data.hasOwnProperty('destination_locode')) { - obj['destination_locode'] = ApiClient.convertToType( - data['destination_locode'], - 'String' - ); - } - - if (data.hasOwnProperty('destination_postal_code')) { - obj['destination_postal_code'] = ApiClient.convertToType( - data['destination_postal_code'], - 'String' - ); - } - - if (data.hasOwnProperty('origin_country_code')) { - obj['origin_country_code'] = ApiClient.convertToType( - data['origin_country_code'], - 'String' - ); - } - - if (data.hasOwnProperty('origin_locode')) { - obj['origin_locode'] = ApiClient.convertToType( - data['origin_locode'], - 'String' - ); - } - - if (data.hasOwnProperty('origin_postal_code')) { - obj['origin_postal_code'] = ApiClient.convertToType( - data['origin_postal_code'], - 'String' - ); - } - - if (data.hasOwnProperty('container_size_code')) { - obj['container_size_code'] = ApiClient.convertToType( - data['container_size_code'], - 'String' - ); - } - - if (data.hasOwnProperty('emissions_scope')) { - obj['emissions_scope'] = ApiClient.convertToType( - data['emissions_scope'], - 'String' - ); - } - - if (data.hasOwnProperty('freight_mass_g')) { - obj['freight_mass_g'] = ApiClient.convertToType( - data['freight_mass_g'], - 'Number' - ); - } - - if (data.hasOwnProperty('freight_volume_cubic_m')) { - obj['freight_volume_cubic_m'] = ApiClient.convertToType( - data['freight_volume_cubic_m'], - 'Number' - ); - } - - if (data.hasOwnProperty('number_of_containers')) { - obj['number_of_containers'] = ApiClient.convertToType( - data['number_of_containers'], - 'Number' - ); - } - - if (data.hasOwnProperty('vessel_imo')) { - obj['vessel_imo'] = ApiClient.convertToType( - data['vessel_imo'], - 'Number' - ); - } - - if (data.hasOwnProperty('project_id')) { - obj['project_id'] = ApiClient.convertToType( - data['project_id'], - 'String' - ); - } - - if (data.hasOwnProperty('create_order')) { - obj['create_order'] = ApiClient.convertToType( - data['create_order'], - 'Boolean' - ); - } - } - return obj; - } -} - -CreateSeaShippingEstimateRequest.prototype['destination_country_code'] = - undefined; - -CreateSeaShippingEstimateRequest.prototype['destination_locode'] = undefined; - -CreateSeaShippingEstimateRequest.prototype['destination_postal_code'] = - undefined; - -CreateSeaShippingEstimateRequest.prototype['origin_country_code'] = undefined; - -CreateSeaShippingEstimateRequest.prototype['origin_locode'] = undefined; - -CreateSeaShippingEstimateRequest.prototype['origin_postal_code'] = undefined; - -CreateSeaShippingEstimateRequest.prototype['container_size_code'] = undefined; - -CreateSeaShippingEstimateRequest.prototype['emissions_scope'] = 'ttw'; - -CreateSeaShippingEstimateRequest.prototype['freight_mass_g'] = undefined; - -CreateSeaShippingEstimateRequest.prototype['freight_volume_cubic_m'] = - undefined; - -CreateSeaShippingEstimateRequest.prototype['number_of_containers'] = undefined; - -CreateSeaShippingEstimateRequest.prototype['vessel_imo'] = undefined; - -CreateSeaShippingEstimateRequest.prototype['project_id'] = undefined; - -CreateSeaShippingEstimateRequest.prototype['create_order'] = false; - -export default CreateSeaShippingEstimateRequest; diff --git a/src/model/Estimate.js b/src/model/Estimate.js deleted file mode 100644 index 43d7600..0000000 --- a/src/model/Estimate.js +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Patch API V2 - * The core API used to integrate with Patch's service - * - * Contact: engineering@usepatch.com - */ - -import ApiClient from '../ApiClient'; -import Order from './Order'; - -class Estimate { - constructor(id, production, type) { - Estimate.initialize(this, id, production, type); - } - - static initialize(obj, id, production, type) { - obj['id'] = id; - obj['production'] = production; - obj['type'] = type; - } - - static constructFromObject(data, obj) { - if (data) { - obj = obj || new Estimate(); - - if (data.hasOwnProperty('id')) { - obj['id'] = ApiClient.convertToType(data['id'], 'String'); - } - - if (data.hasOwnProperty('production')) { - obj['production'] = ApiClient.convertToType( - data['production'], - 'Boolean' - ); - } - - if (data.hasOwnProperty('type')) { - obj['type'] = ApiClient.convertToType(data['type'], 'String'); - } - - if (data.hasOwnProperty('mass_g')) { - obj['mass_g'] = ApiClient.convertToType(data['mass_g'], 'Number'); - } - - if (data.hasOwnProperty('order')) { - obj['order'] = ApiClient.convertToType(data['order'], Order); - } - } - return obj; - } -} - -Estimate.prototype['id'] = undefined; - -Estimate.prototype['production'] = undefined; - -Estimate.prototype['type'] = undefined; - -Estimate.prototype['mass_g'] = undefined; - -Estimate.prototype['order'] = undefined; - -export default Estimate; diff --git a/src/model/EstimateListResponse.js b/src/model/EstimateListResponse.js deleted file mode 100644 index 6c5ea26..0000000 --- a/src/model/EstimateListResponse.js +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Patch API V2 - * The core API used to integrate with Patch's service - * - * Contact: engineering@usepatch.com - */ - -import ApiClient from '../ApiClient'; -import Estimate from './Estimate'; -import MetaIndexObject from './MetaIndexObject'; - -class EstimateListResponse { - constructor(success, error, data, meta) { - EstimateListResponse.initialize(this, success, error, data, meta); - } - - static initialize(obj, success, error, data, meta) { - obj['success'] = success; - obj['error'] = error; - obj['data'] = data; - obj['meta'] = meta; - } - - static constructFromObject(data, obj) { - if (data) { - obj = obj || new EstimateListResponse(); - - if (data.hasOwnProperty('success')) { - obj['success'] = ApiClient.convertToType(data['success'], 'Boolean'); - } - - if (data.hasOwnProperty('error')) { - obj['error'] = ApiClient.convertToType(data['error'], Object); - } - - if (data.hasOwnProperty('data')) { - obj['data'] = ApiClient.convertToType(data['data'], [Estimate]); - } - - if (data.hasOwnProperty('meta')) { - obj['meta'] = MetaIndexObject.constructFromObject(data['meta']); - } - } - return obj; - } -} - -EstimateListResponse.prototype['success'] = undefined; - -EstimateListResponse.prototype['error'] = undefined; - -EstimateListResponse.prototype['data'] = undefined; - -EstimateListResponse.prototype['meta'] = undefined; - -export default EstimateListResponse; diff --git a/src/model/EstimateResponse.js b/src/model/EstimateResponse.js deleted file mode 100644 index 9f975ab..0000000 --- a/src/model/EstimateResponse.js +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Patch API V2 - * The core API used to integrate with Patch's service - * - * Contact: engineering@usepatch.com - */ - -import ApiClient from '../ApiClient'; -import Estimate from './Estimate'; - -class EstimateResponse { - constructor(success, error, data) { - EstimateResponse.initialize(this, success, error, data); - } - - static initialize(obj, success, error, data) { - obj['success'] = success; - obj['error'] = error; - obj['data'] = data; - } - - static constructFromObject(data, obj) { - if (data) { - obj = obj || new EstimateResponse(); - - if (data.hasOwnProperty('success')) { - obj['success'] = ApiClient.convertToType(data['success'], 'Boolean'); - } - - if (data.hasOwnProperty('error')) { - obj['error'] = ApiClient.convertToType(data['error'], Object); - } - - if (data.hasOwnProperty('data')) { - obj['data'] = Estimate.constructFromObject(data['data']); - } - } - return obj; - } -} - -EstimateResponse.prototype['success'] = undefined; - -EstimateResponse.prototype['error'] = undefined; - -EstimateResponse.prototype['data'] = undefined; - -export default EstimateResponse; diff --git a/test/integration/estimates.test.js b/test/integration/estimates.test.js deleted file mode 100644 index c0bdfb4..0000000 --- a/test/integration/estimates.test.js +++ /dev/null @@ -1,240 +0,0 @@ -import { expect } from 'chai'; -import Patch from '../../dist/index'; -const patch = Patch(process.env.SANDBOX_API_KEY); - -describe('Estimates Integration', function () { - it('supports create, retrieve and list', async function () { - const createEstimateResponse = await patch.estimates.createMassEstimate({ - mass_g: 100, - create_order: true - }); - const estimateId = createEstimateResponse.data.id; - - const retrieveEstimateResponse = - await patch.estimates.retrieveEstimate(estimateId); - expect(retrieveEstimateResponse.data.id).to.equal(estimateId); - expect(retrieveEstimateResponse.data.order.state).to.equal('reserved'); - - const retrieveEstimatesResponse = await patch.estimates.retrieveEstimates({ - page: 1 - }); - expect(retrieveEstimatesResponse.data.length).to.be.above(0); - }); - - it('supports creating bitcoin estimates without parameters', async function () { - const { data: estimate } = await patch.estimates.createBitcoinEstimate(); - - expect(estimate.type).to.be.eq('bitcoin'); - expect(estimate.mass_g).to.be.above(0); - expect(estimate.production).to.be.eq(false); - }); - - it('supports creating bitcoin estimates with a timestamp', async function () { - const { data: estimate1 } = await patch.estimates.createBitcoinEstimate({ - timestamp: '2021-06-01T20:31:18.403Z' - }); - const { data: estimate2 } = await patch.estimates.createBitcoinEstimate({ - timestamp: '2021-07-01T20:31:18.403Z' - }); - - expect(estimate1.mass_g).to.be.above(estimate2.mass_g); // BTC emitted less in July than in June - }); - - it('supports creating bitcoin estimates with a transaction value', async function () { - const { data: estimate1 } = await patch.estimates.createBitcoinEstimate({ - transaction_value_btc_sats: 2000 - }); - const { data: estimate2 } = await patch.estimates.createBitcoinEstimate({ - transaction_value_btc_sats: 1000 - }); - - expect(estimate1.mass_g).to.be.above(estimate2.mass_g); - }); - - it('supports creating bitcoin estimates with a daily balance', async function () { - const { data: estimate1 } = await patch.estimates.createBitcoinEstimate({ - average_daily_balance_btc_sats: 1000000 - }); - const { data: estimate2 } = await patch.estimates.createBitcoinEstimate({ - average_daily_balance_btc_sats: 10000000 - }); - - expect(estimate1.mass_g).to.be.below(estimate2.mass_g); - }); - - it('supports creating air shipping estimates from airports', async function () { - const createEstimateResponse = - await patch.estimates.createAirShippingEstimate({ - destination_airport: 'JFK', - freight_mass_g: 19_158, - origin_airport: 'ATL' - }); - const estimate = createEstimateResponse.data; - - expect(estimate.order).to.be.eq(null); - expect(estimate.mass_g).to.be.above(0); - expect(estimate.production).to.be.eq(false); - expect(estimate.type).to.be.eq('shipping_air'); - }); - - it('supports creating air shipping estimates with an order', async function () { - const createEstimateResponse = - await patch.estimates.createAirShippingEstimate({ - create_order: true, - destination_airport: 'BOS', - distance_m: 292_630, - freight_mass_g: 24_091, - origin_airport: 'MIA' - }); - const estimate = createEstimateResponse.data; - - expect(estimate.order.amount).to.be.above(0); - expect(estimate.mass_g).to.be.above(0); - expect(estimate.production).to.be.eq(false); - expect(estimate.type).to.be.eq('shipping_air'); - }); - - it('supports creating rail shipping estimates from addresses', async function () { - const createEstimateResponse = - await patch.estimates.createRailShippingEstimate({ - destination_country_code: 'US', - destination_postal_code: '90210', - freight_mass_g: 18_092, - origin_country_code: 'US', - origin_postal_code: '97209' - }); - const estimate = createEstimateResponse.data; - - expect(estimate.order).to.be.eq(null); - expect(estimate.mass_g).to.be.above(0); - expect(estimate.production).to.be.eq(false); - expect(estimate.type).to.be.eq('shipping_rail'); - }); - - it('supports creating rail shipping estimates from locodes', async function () { - const createEstimateResponse = - await patch.estimates.createRailShippingEstimate({ - destination_locode: 'USSD2', - freight_mass_g: 18_092, - origin_locode: 'USSEA' - }); - const estimate = createEstimateResponse.data; - - expect(estimate.order).to.be.eq(null); - expect(estimate.mass_g).to.be.above(0); - expect(estimate.production).to.be.eq(false); - expect(estimate.type).to.be.eq('shipping_rail'); - }); - - it('supports creating rail shipping estimates with an order', async function () { - const createEstimateResponse = - await patch.estimates.createRailShippingEstimate({ - create_order: true, - destination_locode: 'USSD2', - freight_mass_g: 19_217, - origin_locode: 'USSEA' - }); - const estimate = createEstimateResponse.data; - - expect(estimate.order.amount).to.be.above(0); - expect(estimate.mass_g).to.be.above(0); - expect(estimate.production).to.be.eq(false); - expect(estimate.type).to.be.eq('shipping_rail'); - }); - - it('supports creating road shipping estimates from addresses', async function () { - const createEstimateResponse = - await patch.estimates.createRoadShippingEstimate({ - destination_country_code: 'US', - destination_postal_code: '90210', - freight_mass_g: 19_166, - origin_country_code: 'US', - origin_postal_code: '97209' - }); - const estimate = createEstimateResponse.data; - - expect(estimate.order).to.be.eq(null); - expect(estimate.mass_g).to.be.above(0); - expect(estimate.production).to.be.eq(false); - expect(estimate.type).to.be.eq('shipping_road'); - }); - - it('supports creating road shipping estimates from locodes', async function () { - const createEstimateResponse = - await patch.estimates.createRoadShippingEstimate({ - destination_locode: 'USSD2', - freight_mass_g: 16_907, - origin_locode: 'USSEA' - }); - const estimate = createEstimateResponse.data; - - expect(estimate.order).to.be.eq(null); - expect(estimate.mass_g).to.be.above(0); - expect(estimate.production).to.be.eq(false); - expect(estimate.type).to.be.eq('shipping_road'); - }); - - it('supports creating road shipping estimates with an order', async function () { - const createEstimateResponse = - await patch.estimates.createRoadShippingEstimate({ - create_order: true, - destination_locode: 'USSD2', - freight_mass_g: 21_933, - origin_locode: 'USSEA' - }); - const estimate = createEstimateResponse.data; - - expect(estimate.order.amount).to.be.above(0); - expect(estimate.mass_g).to.be.above(0); - expect(estimate.production).to.be.eq(false); - expect(estimate.type).to.be.eq('shipping_road'); - }); - - it('supports creating sea shipping estimates from addresses', async function () { - const createEstimateResponse = - await patch.estimates.createSeaShippingEstimate({ - destination_country_code: 'US', - destination_postal_code: '90210', - freight_mass_g: 26_906, - origin_country_code: 'US', - origin_postal_code: '97209' - }); - const estimate = createEstimateResponse.data; - - expect(estimate.order).to.be.eq(null); - expect(estimate.mass_g).to.be.above(0); - expect(estimate.production).to.be.eq(false); - expect(estimate.type).to.be.eq('shipping_sea'); - }); - - it('supports creating sea shipping estimates from locodes', async function () { - const createEstimateResponse = - await patch.estimates.createSeaShippingEstimate({ - destination_locode: 'USSEA', - freight_mass_g: 17_311, - origin_locode: 'HKHKG' - }); - const estimate = createEstimateResponse.data; - - expect(estimate.order).to.be.eq(null); - expect(estimate.mass_g).to.be.above(0); - expect(estimate.production).to.be.eq(false); - expect(estimate.type).to.be.eq('shipping_sea'); - }); - - it('supports creating sea shipping estimates with an order', async function () { - const createEstimateResponse = - await patch.estimates.createSeaShippingEstimate({ - create_order: true, - destination_locode: 'USSEA', - freight_mass_g: 26_210, - origin_locode: 'HKHKG' - }); - const estimate = createEstimateResponse.data; - - expect(estimate.order.amount).to.be.above(0); - expect(estimate.mass_g).to.be.above(0); - expect(estimate.production).to.be.eq(false); - expect(estimate.type).to.be.eq('shipping_sea'); - }); -}); diff --git a/test/integration/orders.test.js b/test/integration/orders.test.js index 3cb213d..4e08f52 100644 --- a/test/integration/orders.test.js +++ b/test/integration/orders.test.js @@ -44,14 +44,14 @@ describe('Orders Integration', function () { }); it('supports placing orders in a `draft` state', async function () { - const estimateResponse = await patch.orders.createOrder({ + const draft = await patch.orders.createOrder({ amount: 100, unit: 'g', state: 'draft' }); - const orderId = estimateResponse.data.id; - expect(estimateResponse.data.state).to.equal('draft'); + const orderId = draft.data.id; + expect(draft.data.state).to.equal('draft'); const placeOrderResponse = await patch.orders.placeOrder(orderId); expect(placeOrderResponse.data.created_at).to.be.an.instanceOf(Date); @@ -59,52 +59,6 @@ describe('Orders Integration', function () { expect(placeOrderResponse.data.amount).to.equal(100); }); - it('supports placing orders in a `reserved` state with issued_to', async function () { - const estimateResponse = await patch.estimates.createMassEstimate({ - mass_g: 100, - create_order: true - }); - const orderId = estimateResponse.data.order.id; - expect(estimateResponse.data.order.state).to.equal('reserved'); - - const issuedTo = { email: 'issuee@companyc.com', name: 'Bob Dylan' }; - - const placeOrderResponse = await patch.orders.placeOrder(orderId, { - issued_to: issuedTo - }); - expect(placeOrderResponse.data.created_at).to.be.an.instanceOf(Date); - expect(placeOrderResponse.data.production).to.equal(false); - expect(placeOrderResponse.data.amount).to.equal(100); - expect(placeOrderResponse.data.issued_to.email).to.equal(issuedTo.email); - expect(placeOrderResponse.data.issued_to.name).to.equal(issuedTo.name); - }); - - it('supports placing orders in a `reserved` state using an estimate', async function () { - const estimateResponse = await patch.estimates.createMassEstimate({ - mass_g: 100, - create_order: true - }); - const orderId = estimateResponse.data.order.id; - expect(estimateResponse.data.order.state).to.equal('reserved'); - - const placeOrderResponse = await patch.orders.placeOrder(orderId); - expect(placeOrderResponse.data.created_at).to.be.an.instanceOf(Date); - expect(placeOrderResponse.data.production).to.equal(false); - expect(placeOrderResponse.data.amount).to.equal(100); - }); - - it('supports cancelling orders in a `reserved` state', async function () { - const estimateResponse = await patch.estimates.createMassEstimate({ - mass_g: 100, - create_order: true - }); - const orderId = estimateResponse.data.order.id; - expect(estimateResponse.data.order.state).to.equal('reserved'); - - const placeOrderResponse = await patch.orders.cancelOrder(orderId); - expect(placeOrderResponse.data.state).to.equal('cancelled'); - }); - it('supports creating and querying orders by metadata', async function () { const createOrderResponse = await patch.orders.createOrder({ amount: 100,