Skip to content

Commit 27d3662

Browse files
authored
Add new flights parameters (#41)
* Update for flights * Update changelog
1 parent 858501b commit 27d3662

File tree

8 files changed

+80
-19
lines changed

8 files changed

+80
-19
lines changed

.github/workflows/health_check.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
node: ['10','12','14','16']
11+
node: ['10', '12', '14', '16']
1212
max-parallel: 1
1313
name: Node ${{ matrix.node }} Test
1414
steps:

.github/workflows/publish.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
name: Create GitHub deployment
1717
id: deployment
1818
with:
19-
token: "${{ github.token }}"
19+
token: '${{ github.token }}'
2020
target_url: ${{ env.TARGET_URL }}
2121
environment: production
2222

@@ -45,16 +45,16 @@ jobs:
4545
if: success()
4646
uses: chrnorm/deployment-status@releases/v1
4747
with:
48-
token: "${{ github.token }}"
48+
token: '${{ github.token }}'
4949
target_url: ${{ env.TARGET_URL }}
50-
state: "success"
50+
state: 'success'
5151
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
5252

5353
- name: Update deployment status (failure)
5454
if: failure()
5555
uses: chrnorm/deployment-status@releases/v1
5656
with:
57-
token: "${{ github.token }}"
57+
token: '${{ github.token }}'
5858
target_url: ${{ env.TARGET_URL }}
59-
state: "failure"
60-
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
59+
state: 'failure'
60+
deployment_id: ${{ steps.deployment.outputs.deployment_id }}

CHANGELOG.md

+6
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.11.0] - 2021-09-07
9+
10+
### Added
11+
12+
- Adds support for airports, aircracts, cabin class and passenger count in flight estimates
13+
814
## [1.10.0] - 2021-08-27
915

1016
### Added

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

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

src/ApiClient.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ApiClient {
1616
};
1717

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

2222
/**

src/model/CreateFlightEstimateRequest.js

+48-5
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@
88
import ApiClient from '../ApiClient';
99

1010
class CreateFlightEstimateRequest {
11-
constructor(distanceM) {
12-
CreateFlightEstimateRequest.initialize(this, distanceM);
11+
constructor() {
12+
CreateFlightEstimateRequest.initialize(this);
1313
}
1414

15-
static initialize(obj, distanceM) {
16-
obj['distance_m'] = distanceM;
17-
}
15+
static initialize(obj) {}
1816

1917
static constructFromObject(data, obj) {
2018
if (data) {
@@ -27,6 +25,41 @@ class CreateFlightEstimateRequest {
2725
);
2826
}
2927

28+
if (data.hasOwnProperty('origin_airport')) {
29+
obj['origin_airport'] = ApiClient.convertToType(
30+
data['origin_airport'],
31+
'String'
32+
);
33+
}
34+
35+
if (data.hasOwnProperty('destination_airport')) {
36+
obj['destination_airport'] = ApiClient.convertToType(
37+
data['destination_airport'],
38+
'String'
39+
);
40+
}
41+
42+
if (data.hasOwnProperty('aircraft_code')) {
43+
obj['aircraft_code'] = ApiClient.convertToType(
44+
data['aircraft_code'],
45+
'String'
46+
);
47+
}
48+
49+
if (data.hasOwnProperty('cabin_class')) {
50+
obj['cabin_class'] = ApiClient.convertToType(
51+
data['cabin_class'],
52+
'String'
53+
);
54+
}
55+
56+
if (data.hasOwnProperty('passenger_count')) {
57+
obj['passenger_count'] = ApiClient.convertToType(
58+
data['passenger_count'],
59+
'Number'
60+
);
61+
}
62+
3063
if (data.hasOwnProperty('project_id')) {
3164
obj['project_id'] = ApiClient.convertToType(
3265
data['project_id'],
@@ -47,6 +80,16 @@ class CreateFlightEstimateRequest {
4780

4881
CreateFlightEstimateRequest.prototype['distance_m'] = undefined;
4982

83+
CreateFlightEstimateRequest.prototype['origin_airport'] = undefined;
84+
85+
CreateFlightEstimateRequest.prototype['destination_airport'] = undefined;
86+
87+
CreateFlightEstimateRequest.prototype['aircraft_code'] = undefined;
88+
89+
CreateFlightEstimateRequest.prototype['cabin_class'] = undefined;
90+
91+
CreateFlightEstimateRequest.prototype['passenger_count'] = undefined;
92+
5093
CreateFlightEstimateRequest.prototype['project_id'] = undefined;
5194

5295
CreateFlightEstimateRequest.prototype['create_order'] = undefined;

test/integration/estimates.test.js

+15-3
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ describe('Estimates Integration', function () {
2121
expect(retrieveEstimatesResponse.data.length).to.be.above(0);
2222
});
2323

24-
it('supports creating flight estimates with an order', async function () {
24+
it('supports creating flight estimates with distance', async function () {
2525
const createEstimateResponse = await patch.estimates.createFlightEstimate({
26-
distance_m: 1000,
27-
create_order: true
26+
distance_m: 1000
2827
});
2928
const estimate = createEstimateResponse.data;
3029

@@ -34,6 +33,19 @@ describe('Estimates Integration', function () {
3433
expect(estimate.order.state).to.be.eq('draft');
3534
});
3635

36+
it('supports creating flight estimates with airports', async function () {
37+
const { data: estimate1 } = await patch.estimates.createFlightEstimate({
38+
origin_airport: 'SFO',
39+
destination_airport: 'LAX'
40+
});
41+
const { data: estimate2 } = await patch.estimates.createFlightEstimate({
42+
origin_airport: 'SFO',
43+
destination_airport: 'JFK'
44+
});
45+
46+
expect(estimate2.mass_g).to.be.greaterThan(estimate1.mass_g);
47+
});
48+
3749
it('supports creating shipping estimates without an order', async function () {
3850
const createEstimateResponse = await patch.estimates.createShippingEstimate(
3951
{

0 commit comments

Comments
 (0)