Skip to content

Commit

Permalink
Correct history for issued_to + fix changelog for Estimates (#73)
Browse files Browse the repository at this point in the history
* Round 2

* Bump version and fix changelog

* Remove unused model

* Revert

* update test

* Fix

* Tweak

* Consolidate
  • Loading branch information
pcothenet authored Jul 29, 2022
1 parent 9de03b4 commit e895ca2
Show file tree
Hide file tree
Showing 11 changed files with 2,180 additions and 2,202 deletions.
14 changes: 9 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Adds `patch.estimates.create_air_shipping_estimate` method
- Adds `patch.estimates.create_rail_shipping_estimate` method
- Adds `patch.estimates.create_road_shipping_estimate` method
- Adds `patch.estimates.create_sea_shipping_estimate` method
- Adds `patch.estimates.createAirShippingEstimate` method
- Adds `patch.estimates.createRailShippingEstimate` method
- Adds `patch.estimates.createRoadShippingEstimate` method
- Adds `patch.estimates.createSeaShippingEstimate` method

### Breaking

- Renames the `issuedTo` parameter for `orders` to `issued_to`.

## [1.23.0] - 2022-06-03

### Added

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

## [1.22.0] - 2022-05-16

Expand Down
4 changes: 2 additions & 2 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": "1.24.0",
"version": "1.24.1",
"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/1.24.0'
'User-Agent': 'patch-node/1.24.1'
};

/**
Expand Down
8 changes: 3 additions & 5 deletions src/model/CreateOrderRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import ApiClient from '../ApiClient';
import V1OrdersIssuedTo from './V1OrdersIssuedTo';
import OrderIssuedTo from './OrderIssuedTo';

class CreateOrderRequest {
constructor() {
Expand Down Expand Up @@ -71,10 +71,8 @@ class CreateOrderRequest {
obj['unit'] = ApiClient.convertToType(data['unit'], 'String');
}

if (data.hasOwnProperty('issuedTo')) {
obj['issued_to'] = V1OrdersIssuedTo.constructFromObject(
data['issuedTo']
);
if (data.hasOwnProperty('issued_to')) {
obj['issued_to'] = OrderIssuedTo.constructFromObject(data['issued_to']);
}
}
return obj;
Expand Down
4 changes: 2 additions & 2 deletions src/model/Order.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import ApiClient from '../ApiClient';
import Allocation from './Allocation';
import IssuedTo from './IssuedTo';
import OrderInventory from './OrderInventory';
import OrderIssuedTo from './OrderIssuedTo';

class Order {
constructor(
Expand Down Expand Up @@ -167,7 +167,7 @@ class Order {
}

if (data.hasOwnProperty('issued_to')) {
obj['issued_to'] = IssuedTo.constructFromObject(data['issued_to']);
obj['issued_to'] = OrderIssuedTo.constructFromObject(data['issued_to']);
}
}
return obj;
Expand Down
12 changes: 6 additions & 6 deletions src/model/IssuedTo.js → src/model/OrderIssuedTo.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@

import ApiClient from '../ApiClient';

class IssuedTo {
class OrderIssuedTo {
constructor() {
IssuedTo.initialize(this);
OrderIssuedTo.initialize(this);
}

static initialize(obj) {}

static constructFromObject(data, obj) {
if (data) {
obj = obj || new IssuedTo();
obj = obj || new OrderIssuedTo();

if (data.hasOwnProperty('name')) {
obj['name'] = ApiClient.convertToType(data['name'], 'String');
Expand All @@ -30,8 +30,8 @@ class IssuedTo {
}
}

IssuedTo.prototype['name'] = undefined;
OrderIssuedTo.prototype['name'] = undefined;

IssuedTo.prototype['email'] = undefined;
OrderIssuedTo.prototype['email'] = undefined;

export default IssuedTo;
export default OrderIssuedTo;
8 changes: 3 additions & 5 deletions src/model/PlaceOrderRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import ApiClient from '../ApiClient';
import V1OrdersIssuedTo from './V1OrdersIssuedTo';
import OrderIssuedTo from './OrderIssuedTo';

class PlaceOrderRequest {
constructor() {
Expand All @@ -19,10 +19,8 @@ class PlaceOrderRequest {
if (data) {
obj = obj || new PlaceOrderRequest();

if (data.hasOwnProperty('issuedTo')) {
obj['issued_to'] = V1OrdersIssuedTo.constructFromObject(
data['issuedTo']
);
if (data.hasOwnProperty('issued_to')) {
obj['issued_to'] = OrderIssuedTo.constructFromObject(data['issued_to']);
}
}
return obj;
Expand Down
37 changes: 0 additions & 37 deletions src/model/V1OrdersIssuedTo.js

This file was deleted.

8 changes: 4 additions & 4 deletions test/integration/orders.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ describe('Orders Integration', function () {
expect(data.price_cents_usd + data.patch_fee_cents_usd).to.eq(100);
});

it('supports creating an order with issuedTo', async function () {
it('supports creating an order with issued_to', async function () {
const issuedTo = { email: 'issuee@companyc.com', name: 'Bob Dylan' };
const { data } = await patch.orders.createOrder({
total_price_cents_usd: 100,
issuedTo: issuedTo
issued_to: issuedTo
});

expect(data.price_cents_usd + data.patch_fee_cents_usd).to.eq(100);
Expand All @@ -53,7 +53,7 @@ describe('Orders Integration', function () {
expect(placeOrderResponse.data.mass_g).to.equal(100);
});

it('supports placing orders in a `draft` state with issuedTo', async function () {
it('supports placing orders in a `draft` state with issued_to', async function () {
const estimateResponse = await patch.estimates.createMassEstimate({
mass_g: 100,
create_order: true
Expand All @@ -64,7 +64,7 @@ describe('Orders Integration', function () {
const issuedTo = { email: 'issuee@companyc.com', name: 'Bob Dylan' };

const placeOrderResponse = await patch.orders.placeOrder(orderId, {
issuedTo: issuedTo
issued_to: issuedTo
});
expect(placeOrderResponse.data.created_at).to.be.an.instanceOf(Date);
expect(placeOrderResponse.data.production).to.equal(false);
Expand Down
Loading

0 comments on commit e895ca2

Please sign in to comment.