Skip to content

Add new flights parameters #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/health_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: ['10','12','14','16']
node: ['10', '12', '14', '16']
max-parallel: 1
name: Node ${{ matrix.node }} Test
steps:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
name: Create GitHub deployment
id: deployment
with:
token: "${{ github.token }}"
token: '${{ github.token }}'
target_url: ${{ env.TARGET_URL }}
environment: production

Expand Down Expand Up @@ -45,16 +45,16 @@ jobs:
if: success()
uses: chrnorm/deployment-status@releases/v1
with:
token: "${{ github.token }}"
token: '${{ github.token }}'
target_url: ${{ env.TARGET_URL }}
state: "success"
state: 'success'
deployment_id: ${{ steps.deployment.outputs.deployment_id }}

- name: Update deployment status (failure)
if: failure()
uses: chrnorm/deployment-status@releases/v1
with:
token: "${{ github.token }}"
token: '${{ github.token }}'
target_url: ${{ env.TARGET_URL }}
state: "failure"
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
state: 'failure'
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
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.11.0] - 2021-09-07

### Added

- Adds support for airports, aircracts, cabin class and passenger count in flight estimates

## [1.10.0] - 2021-08-27

### Added
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.10.2",
"version": "1.11.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/1.10.2'
'User-Agent': 'patch-node/1.11.0'
};

/**
Expand Down
53 changes: 48 additions & 5 deletions src/model/CreateFlightEstimateRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
import ApiClient from '../ApiClient';

class CreateFlightEstimateRequest {
constructor(distanceM) {
CreateFlightEstimateRequest.initialize(this, distanceM);
constructor() {
CreateFlightEstimateRequest.initialize(this);
}

static initialize(obj, distanceM) {
obj['distance_m'] = distanceM;
}
static initialize(obj) {}

static constructFromObject(data, obj) {
if (data) {
Expand All @@ -27,6 +25,41 @@ class CreateFlightEstimateRequest {
);
}

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

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

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

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

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

if (data.hasOwnProperty('project_id')) {
obj['project_id'] = ApiClient.convertToType(
data['project_id'],
Expand All @@ -47,6 +80,16 @@ class CreateFlightEstimateRequest {

CreateFlightEstimateRequest.prototype['distance_m'] = undefined;

CreateFlightEstimateRequest.prototype['origin_airport'] = undefined;

CreateFlightEstimateRequest.prototype['destination_airport'] = undefined;

CreateFlightEstimateRequest.prototype['aircraft_code'] = undefined;

CreateFlightEstimateRequest.prototype['cabin_class'] = undefined;

CreateFlightEstimateRequest.prototype['passenger_count'] = undefined;

CreateFlightEstimateRequest.prototype['project_id'] = undefined;

CreateFlightEstimateRequest.prototype['create_order'] = undefined;
Expand Down
18 changes: 15 additions & 3 deletions test/integration/estimates.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ describe('Estimates Integration', function () {
expect(retrieveEstimatesResponse.data.length).to.be.above(0);
});

it('supports creating flight estimates with an order', async function () {
it('supports creating flight estimates with distance', async function () {
const createEstimateResponse = await patch.estimates.createFlightEstimate({
distance_m: 1000,
create_order: true
distance_m: 1000
});
const estimate = createEstimateResponse.data;

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

it('supports creating flight estimates with airports', async function () {
const { data: estimate1 } = await patch.estimates.createFlightEstimate({
origin_airport: 'SFO',
destination_airport: 'LAX'
});
const { data: estimate2 } = await patch.estimates.createFlightEstimate({
origin_airport: 'SFO',
destination_airport: 'JFK'
});

expect(estimate2.mass_g).to.be.greaterThan(estimate1.mass_g);
});

it('supports creating shipping estimates without an order', async function () {
const createEstimateResponse = await patch.estimates.createShippingEstimate(
{
Expand Down