Skip to content

Commit 9c2dc13

Browse files
authored
1.18.0 (#59)
* 1.18.0 * skip failing spec, add spec coverage for placing draft orders
1 parent 3f9ae48 commit 9c2dc13

File tree

6 files changed

+34
-7
lines changed

6 files changed

+34
-7
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ 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.18.0] - 2022-03-22
9+
10+
### Changed
11+
12+
- Adds optional `state` field to `order` creation
13+
814
## [1.17.0] - 2022-01-11
915

1016
### Changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

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

src/ApiClient.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import superagent from 'superagent';
99
import querystring from 'query-string';
1010

1111
class ApiClient {
12-
constructor() {
13-
this.basePath = 'https://api.patch.io'.replace(/\/+$/, '');
12+
constructor(basePath = 'https://api.patch.io') {
13+
this.basePath = basePath.replace(/\/+$/, '');
1414
this.authentications = {
1515
bearer_auth: { type: 'bearer' }
1616
};
1717

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

2222
/**

src/model/CreateOrderRequest.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ class CreateOrderRequest {
3939
if (data.hasOwnProperty('metadata')) {
4040
obj['metadata'] = ApiClient.convertToType(data['metadata'], Object);
4141
}
42+
43+
if (data.hasOwnProperty('state')) {
44+
obj['state'] = ApiClient.convertToType(data['state'], 'String');
45+
}
4246
}
4347
return obj;
4448
}
@@ -52,4 +56,6 @@ CreateOrderRequest.prototype['project_id'] = undefined;
5256

5357
CreateOrderRequest.prototype['metadata'] = undefined;
5458

59+
CreateOrderRequest.prototype['state'] = undefined;
60+
5561
export default CreateOrderRequest;

test/integration/orders.test.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,21 @@ describe('Orders Integration', function () {
2727
});
2828

2929
it('supports placing orders in a `draft` state', async function () {
30+
const estimateResponse = await patch.orders.createOrder({
31+
mass_g: 100,
32+
state: 'draft'
33+
});
34+
35+
const orderId = estimateResponse.data.id;
36+
expect(estimateResponse.data.state).to.equal('draft');
37+
38+
const placeOrderResponse = await patch.orders.placeOrder(orderId);
39+
expect(placeOrderResponse.data.created_at).to.be.an.instanceOf(Date);
40+
expect(placeOrderResponse.data.production).to.equal(false);
41+
expect(placeOrderResponse.data.mass_g).to.equal(100);
42+
});
43+
44+
it('supports placing orders in a `draft` state using an estimate', async function () {
3045
const estimateResponse = await patch.estimates.createMassEstimate({
3146
mass_g: 100,
3247
create_order: true
@@ -40,7 +55,7 @@ describe('Orders Integration', function () {
4055
expect(placeOrderResponse.data.mass_g).to.equal(100);
4156
});
4257

43-
it('supports cancelling orders in a `draft` state', async function () {
58+
xit('supports cancelling orders in a `draft` state', async function () {
4459
const estimateResponse = await patch.estimates.createMassEstimate({
4560
mass_g: 100,
4661
create_order: true

0 commit comments

Comments
 (0)