Skip to content

Commit

Permalink
Add bitcoin estimates and registry_url (#32)
Browse files Browse the repository at this point in the history
* Update SDK

* Fix existing spec

* Re-add +1

* Add node 16

* Make package compatible with node 10

* Add test for bitcoin estimates

* Shorten timeout

* Bump version

* Clarify testing instructions

* Make tests less flaky
  • Loading branch information
pcothenet authored Jul 13, 2021
1 parent d0c1f06 commit c999209
Show file tree
Hide file tree
Showing 12 changed files with 1,575 additions and 8,133 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: ['10', '12', '14']
node: ['10', '12', '14', '16']
name: Node ${{ matrix.node }} Test
steps:
- name: Check out code
Expand Down
2 changes: 2 additions & 0 deletions .mocharc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require: '@babel/register'
recursive: true
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ 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.6.0] - 2021-07-14

### Added

- Order responses return a `registry_url` field
- Add support for Bitcoin estimates

## [1.5.2] - 2021-03-30

### Changed
Expand Down
28 changes: 19 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,27 +102,33 @@ Estimates allow API users to get a quote for the cost of compensating a certain

```javascript
// Create a mass estimate
const mass = 1000000; // Pass in the mass in grams (i.e. 1 metric tonne)
patch.estimates.createMassEstimate({ mass_g: mass });
const mass_g = 1000000; // Pass in the mass in grams (i.e. 1 metric tonne)
patch.estimates.createMassEstimate({ mass_g });

// Create a flight estimate
const distance_m = 9000000; // Pass in the distance traveled in meters
patch.estimates.createFlightEstimate({ distance_m: distance_m });
patch.estimates.createFlightEstimate({ distance_m });

// Create a shipping estimate
const distance_m = 9000000;
// Pass in the shipping distance in meters, the transportation method, and the package mass
patch.estimates.createShippingEstimate({
distance_m: distance_m,
distance_m,
transportation_method: 'air',
package_mass_g: 1000
});

// Create a bitcoin estimate
const transaction_value_btc_sats = 1000; // [Optional] Pass in the transaction value in satoshis
patch.estimates.createBitcoinEstimate({
transaction_value_btc_sats
});

// Create a vehicle estimate
const distance_m = 9000000;
// Pass in the shipping distance in meters and the model/make/year of the vehicle
patch.estimates.createVehicleEstimate({
distance_m: distance_m,
distance_m,
make: 'Toyota',
model: 'Corolla',
year: 1995
Expand Down Expand Up @@ -184,7 +190,7 @@ Preferences are how you route your orders in Patch. If you don't have a preferen
```javascript
// Create a preference
const projectId = 'pro_test_1234'; // Pass in the project_id for your preference
patch.preferences.createPreference((project_id: projectId));
patch.preferences.createPreference({ project_id: projectId });

// Retrieve a preference
const preferenceId = 'pre_test_1234'; // Pass in the preferences's id
Expand Down Expand Up @@ -234,9 +240,13 @@ $ npm link @patch-technology/patch
This will create a `node_modules` directory in your test repository which will symlink to your locally built package. To test out the package, open a node REPL and import the package and run some queries.

```sh
$ node
> const Patch = require('@patch-technology/patch')
> Patch.default(process.env.SANDBOX_API_KEY).projects.retrieveProjects().then((response) => console.log(response))
SANDBOX_API_KEY=xxx node
```

```node
const Patch = require('@patch-technology/patch');
const patch = Patch.default(process.env.SANDBOX_API_KEY);
patch.projects.retrieveProjects().then((response) => console.log(response));
```

### Run the specs
Expand Down
1 change: 0 additions & 1 deletion mocha.opts

This file was deleted.

Loading

0 comments on commit c999209

Please sign in to comment.