Skip to content

Commit

Permalink
API version 2.1.0 See https://docs.patch.io/#/changelog for changes (#85
Browse files Browse the repository at this point in the history
)

* API version 2.1.0 See https://docs.patch.io/#/changelog for changes

* Update expected test results for estimates
  • Loading branch information
venalen authored Apr 4, 2023
1 parent 678cdef commit b4c8085
Show file tree
Hide file tree
Showing 14 changed files with 230 additions and 21 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ 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.1.0] - 2023-04-04

### Added

- Adds optional `vintage_start_year` and `vintage_end_year` fields to `order` creation
- Adds optional `vintage_start_year` and `vintage_end_year` fields to `order_line_item` create and update
- Adds optional `vintage_start_year` and `vintage_end_year` fields to `inventory` creation
- Adds `vintage_start_year` and `vintage_end_year` fields to `order` response
- Adds `vintage_start_year` and `vintage_end_year` fields to `order_line_item` response
- Adds optional `carrier_scac` field to `patch.estimates.createRoadShippingEstimate`
- Deprecates `createShippingEstimate` in favor of `createEcommerceEstimate`

## [1.24.2] - 2022-08-10

### Added
Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@patch-technology/patch",
"version": "2.0.1",
"version": "2.1.0",
"description": "Node.js wrapper for the Patch API",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/ApiClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ApiClient {
};

this.defaultHeaders = {
'User-Agent': 'patch-node/2.0.1',
'User-Agent': 'patch-node/2.1.0',
'Patch-Version': 2
};

Expand Down
18 changes: 18 additions & 0 deletions src/model/CreateOrderLineItemRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ class CreateOrderLineItemRequest {
);
}

if (data.hasOwnProperty('vintage_start_year')) {
obj['vintage_start_year'] = ApiClient.convertToType(
data['vintage_start_year'],
'Number'
);
}

if (data.hasOwnProperty('vintage_end_year')) {
obj['vintage_end_year'] = ApiClient.convertToType(
data['vintage_end_year'],
'Number'
);
}

if (data.hasOwnProperty('price')) {
obj['price'] = ApiClient.convertToType(data['price'], 'Number');
}
Expand All @@ -56,6 +70,10 @@ CreateOrderLineItemRequest.prototype['project_id'] = undefined;

CreateOrderLineItemRequest.prototype['vintage_year'] = undefined;

CreateOrderLineItemRequest.prototype['vintage_start_year'] = undefined;

CreateOrderLineItemRequest.prototype['vintage_end_year'] = undefined;

CreateOrderLineItemRequest.prototype['price'] = undefined;

CreateOrderLineItemRequest.prototype['currency'] = undefined;
Expand Down
18 changes: 18 additions & 0 deletions src/model/CreateOrderRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ class CreateOrderRequest {
);
}

if (data.hasOwnProperty('vintage_start_year')) {
obj['vintage_start_year'] = ApiClient.convertToType(
data['vintage_start_year'],
'Number'
);
}

if (data.hasOwnProperty('vintage_end_year')) {
obj['vintage_end_year'] = ApiClient.convertToType(
data['vintage_end_year'],
'Number'
);
}

if (data.hasOwnProperty('total_price')) {
obj['total_price'] = ApiClient.convertToType(
data['total_price'],
Expand Down Expand Up @@ -76,6 +90,10 @@ CreateOrderRequest.prototype['state'] = undefined;

CreateOrderRequest.prototype['vintage_year'] = undefined;

CreateOrderRequest.prototype['vintage_start_year'] = undefined;

CreateOrderRequest.prototype['vintage_end_year'] = undefined;

CreateOrderRequest.prototype['total_price'] = undefined;

CreateOrderRequest.prototype['currency'] = undefined;
Expand Down
9 changes: 9 additions & 0 deletions src/model/CreateRoadShippingEstimateRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ class CreateRoadShippingEstimateRequest {
);
}

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'],
Expand Down Expand Up @@ -152,6 +159,8 @@ 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;
Expand Down
43 changes: 41 additions & 2 deletions src/model/Inventory.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,40 @@
import ApiClient from '../ApiClient';

class Inventory {
constructor(vintageYear, amountAvailable, price, currency, unit) {
constructor(
vintageYear,
vintageStartYear,
vintageEndYear,
amountAvailable,
price,
currency,
unit
) {
Inventory.initialize(
this,
vintageYear,
vintageStartYear,
vintageEndYear,
amountAvailable,
price,
currency,
unit
);
}

static initialize(obj, vintageYear, amountAvailable, price, currency, unit) {
static initialize(
obj,
vintageYear,
vintageStartYear,
vintageEndYear,
amountAvailable,
price,
currency,
unit
) {
obj['vintage_year'] = vintageYear;
obj['vintage_start_year'] = vintageStartYear;
obj['vintage_end_year'] = vintageEndYear;
obj['amount_available'] = amountAvailable;
obj['price'] = price;
obj['currency'] = currency;
Expand All @@ -38,6 +59,20 @@ class Inventory {
);
}

if (data.hasOwnProperty('vintage_start_year')) {
obj['vintage_start_year'] = ApiClient.convertToType(
data['vintage_start_year'],
'Number'
);
}

if (data.hasOwnProperty('vintage_end_year')) {
obj['vintage_end_year'] = ApiClient.convertToType(
data['vintage_end_year'],
'Number'
);
}

if (data.hasOwnProperty('amount_available')) {
obj['amount_available'] = ApiClient.convertToType(
data['amount_available'],
Expand All @@ -63,6 +98,10 @@ class Inventory {

Inventory.prototype['vintage_year'] = undefined;

Inventory.prototype['vintage_start_year'] = undefined;

Inventory.prototype['vintage_end_year'] = undefined;

Inventory.prototype['amount_available'] = undefined;

Inventory.prototype['price'] = undefined;
Expand Down
45 changes: 43 additions & 2 deletions src/model/OrderLineItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,44 @@ import ApiClient from '../ApiClient';
import OrderLineItemProject from './OrderLineItemProject';

class OrderLineItem {
constructor(project, vintageYear, amount, unit, price, currency) {
constructor(
project,
vintageYear,
vintageStartYear,
vintageEndYear,
amount,
unit,
price,
currency
) {
OrderLineItem.initialize(
this,
project,
vintageYear,
vintageStartYear,
vintageEndYear,
amount,
unit,
price,
currency
);
}

static initialize(obj, project, vintageYear, amount, unit, price, currency) {
static initialize(
obj,
project,
vintageYear,
vintageStartYear,
vintageEndYear,
amount,
unit,
price,
currency
) {
obj['project'] = project;
obj['vintage_year'] = vintageYear;
obj['vintage_start_year'] = vintageStartYear;
obj['vintage_end_year'] = vintageEndYear;
obj['amount'] = amount;
obj['unit'] = unit;
obj['price'] = price;
Expand Down Expand Up @@ -52,6 +75,20 @@ class OrderLineItem {
);
}

if (data.hasOwnProperty('vintage_start_year')) {
obj['vintage_start_year'] = ApiClient.convertToType(
data['vintage_start_year'],
'Number'
);
}

if (data.hasOwnProperty('vintage_end_year')) {
obj['vintage_end_year'] = ApiClient.convertToType(
data['vintage_end_year'],
'Number'
);
}

if (data.hasOwnProperty('amount')) {
obj['amount'] = ApiClient.convertToType(data['amount'], 'Number');
}
Expand All @@ -78,6 +115,10 @@ OrderLineItem.prototype['project'] = undefined;

OrderLineItem.prototype['vintage_year'] = undefined;

OrderLineItem.prototype['vintage_start_year'] = undefined;

OrderLineItem.prototype['vintage_end_year'] = undefined;

OrderLineItem.prototype['amount'] = undefined;

OrderLineItem.prototype['unit'] = undefined;
Expand Down
18 changes: 18 additions & 0 deletions src/model/UpdateOrderLineItemRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ class UpdateOrderLineItemRequest {
);
}

if (data.hasOwnProperty('vintage_start_year')) {
obj['vintage_start_year'] = ApiClient.convertToType(
data['vintage_start_year'],
'Number'
);
}

if (data.hasOwnProperty('vintage_end_year')) {
obj['vintage_end_year'] = ApiClient.convertToType(
data['vintage_end_year'],
'Number'
);
}

if (data.hasOwnProperty('price')) {
obj['price'] = ApiClient.convertToType(data['price'], 'Number');
}
Expand All @@ -47,6 +61,10 @@ class UpdateOrderLineItemRequest {

UpdateOrderLineItemRequest.prototype['vintage_year'] = undefined;

UpdateOrderLineItemRequest.prototype['vintage_start_year'] = undefined;

UpdateOrderLineItemRequest.prototype['vintage_end_year'] = undefined;

UpdateOrderLineItemRequest.prototype['price'] = undefined;

UpdateOrderLineItemRequest.prototype['currency'] = undefined;
Expand Down
2 changes: 1 addition & 1 deletion test/integration/estimates.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('Estimates Integration', function () {
);
const estimate = createEstimateResponse.data;

expect(estimate.type).to.be.eq('shipping');
expect(estimate.type).to.be.eq('ecommerce');
expect(estimate.mass_g).to.be.above(0);
expect(estimate.production).to.be.eq(false);
expect(estimate.order).to.be.eq(null);
Expand Down
Loading

0 comments on commit b4c8085

Please sign in to comment.