Skip to content

Commit

Permalink
1.18.0 (#59)
Browse files Browse the repository at this point in the history
* 1.18.0

* skip failing spec, add spec coverage for placing draft orders
  • Loading branch information
rmody3 authored Mar 22, 2022
1 parent 3f9ae48 commit 9c2dc13
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ 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).

## [1.18.0] - 2022-03-22

### Changed

- Adds optional `state` field to `order` creation

## [1.17.0] - 2022-01-11

### Changed
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.17.1",
"version": "1.18.0",
"description": "Node.js wrapper for the Patch API",
"license": "MIT",
"repository": {
Expand Down
6 changes: 3 additions & 3 deletions src/ApiClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import superagent from 'superagent';
import querystring from 'query-string';

class ApiClient {
constructor() {
this.basePath = 'https://api.patch.io'.replace(/\/+$/, '');
constructor(basePath = 'https://api.patch.io') {
this.basePath = basePath.replace(/\/+$/, '');
this.authentications = {
bearer_auth: { type: 'bearer' }
};

this.defaultHeaders = {
'User-Agent': 'patch-node/1.17.1'
'User-Agent': 'patch-node/1.18.0'
};

/**
Expand Down
6 changes: 6 additions & 0 deletions src/model/CreateOrderRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ class CreateOrderRequest {
if (data.hasOwnProperty('metadata')) {
obj['metadata'] = ApiClient.convertToType(data['metadata'], Object);
}

if (data.hasOwnProperty('state')) {
obj['state'] = ApiClient.convertToType(data['state'], 'String');
}
}
return obj;
}
Expand All @@ -52,4 +56,6 @@ CreateOrderRequest.prototype['project_id'] = undefined;

CreateOrderRequest.prototype['metadata'] = undefined;

CreateOrderRequest.prototype['state'] = undefined;

export default CreateOrderRequest;
17 changes: 16 additions & 1 deletion test/integration/orders.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ describe('Orders Integration', function () {
});

it('supports placing orders in a `draft` state', async function () {
const estimateResponse = await patch.orders.createOrder({
mass_g: 100,
state: 'draft'
});

const orderId = estimateResponse.data.id;
expect(estimateResponse.data.state).to.equal('draft');

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.mass_g).to.equal(100);
});

it('supports placing orders in a `draft` state using an estimate', async function () {
const estimateResponse = await patch.estimates.createMassEstimate({
mass_g: 100,
create_order: true
Expand All @@ -40,7 +55,7 @@ describe('Orders Integration', function () {
expect(placeOrderResponse.data.mass_g).to.equal(100);
});

it('supports cancelling orders in a `draft` state', async function () {
xit('supports cancelling orders in a `draft` state', async function () {
const estimateResponse = await patch.estimates.createMassEstimate({
mass_g: 100,
create_order: true
Expand Down

0 comments on commit 9c2dc13

Please sign in to comment.