Skip to content

Commit

Permalink
Add btc balance (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
pcothenet authored Sep 10, 2021
1 parent 6068180 commit c78ffe1
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 10 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.13.0] - 2021-09-10

### Added

- Adds ability to create Bitcoin and Ethereum estimates using the daily balance held.

## [1.12.0] - 2021-09-08

### 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.12.0",
"version": "1.13.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.12.0'
'User-Agent': 'patch-node/1.13.0'
};

/**
Expand Down
12 changes: 11 additions & 1 deletion src/model/CreateBitcoinEstimateRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ class CreateBitcoinEstimateRequest {
);
}

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

if (data.hasOwnProperty('project_id')) {
obj['project_id'] = ApiClient.convertToType(
data['project_id'],
Expand All @@ -52,8 +59,11 @@ CreateBitcoinEstimateRequest.prototype['timestamp'] = undefined;
CreateBitcoinEstimateRequest.prototype['transaction_value_btc_sats'] =
undefined;

CreateBitcoinEstimateRequest.prototype['average_daily_balance_btc_sats'] =
undefined;

CreateBitcoinEstimateRequest.prototype['project_id'] = undefined;

CreateBitcoinEstimateRequest.prototype['create_order'] = undefined;
CreateBitcoinEstimateRequest.prototype['create_order'] = false;

export default CreateBitcoinEstimateRequest;
12 changes: 11 additions & 1 deletion src/model/CreateEthereumEstimateRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ class CreateEthereumEstimateRequest {
);
}

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

if (data.hasOwnProperty('project_id')) {
obj['project_id'] = ApiClient.convertToType(
data['project_id'],
Expand All @@ -58,8 +65,11 @@ CreateEthereumEstimateRequest.prototype['gas_used'] = undefined;
CreateEthereumEstimateRequest.prototype['transaction_value_eth_gwei'] =
undefined;

CreateEthereumEstimateRequest.prototype['average_daily_balance_eth_gwei'] =
undefined;

CreateEthereumEstimateRequest.prototype['project_id'] = undefined;

CreateEthereumEstimateRequest.prototype['create_order'] = undefined;
CreateEthereumEstimateRequest.prototype['create_order'] = false;

export default CreateEthereumEstimateRequest;
2 changes: 1 addition & 1 deletion src/model/CreateFlightEstimateRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,6 @@ CreateFlightEstimateRequest.prototype['passenger_count'] = undefined;

CreateFlightEstimateRequest.prototype['project_id'] = undefined;

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

export default CreateFlightEstimateRequest;
2 changes: 1 addition & 1 deletion src/model/CreateMassEstimateRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CreateMassEstimateRequest {

CreateMassEstimateRequest.prototype['mass_g'] = undefined;

CreateMassEstimateRequest.prototype['create_order'] = undefined;
CreateMassEstimateRequest.prototype['create_order'] = false;

CreateMassEstimateRequest.prototype['project_id'] = undefined;

Expand Down
2 changes: 1 addition & 1 deletion src/model/CreateShippingEstimateRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ CreateShippingEstimateRequest.prototype['transportation_method'] = undefined;

CreateShippingEstimateRequest.prototype['project_id'] = undefined;

CreateShippingEstimateRequest.prototype['create_order'] = undefined;
CreateShippingEstimateRequest.prototype['create_order'] = false;

export default CreateShippingEstimateRequest;
2 changes: 1 addition & 1 deletion src/model/CreateVehicleEstimateRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ CreateVehicleEstimateRequest.prototype['year'] = undefined;

CreateVehicleEstimateRequest.prototype['project_id'] = undefined;

CreateVehicleEstimateRequest.prototype['create_order'] = undefined;
CreateVehicleEstimateRequest.prototype['create_order'] = false;

export default CreateVehicleEstimateRequest;
11 changes: 11 additions & 0 deletions test/integration/estimates.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,17 @@ describe('Estimates Integration', function () {
expect(estimate1.mass_g).to.be.above(estimate2.mass_g);
});

it('supports creating bitcoin estimates with a daily balance', async function () {
const { data: estimate1 } = await patch.estimates.createBitcoinEstimate({
average_daily_balance_btc_sats: 1000000
});
const { data: estimate2 } = await patch.estimates.createBitcoinEstimate({
average_daily_balance_btc_sats: 10000000
});

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

it('supports creating ethereum estimates with a gas value', async function () {
const createEstimateResponse = await patch.estimates.createEthereumEstimate(
{
Expand Down

0 comments on commit c78ffe1

Please sign in to comment.