Skip to content

Commit c999209

Browse files
authored
Add bitcoin estimates and registry_url (#32)
* 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
1 parent d0c1f06 commit c999209

File tree

12 files changed

+1575
-8133
lines changed

12 files changed

+1575
-8133
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
node: ['10', '12', '14']
13+
node: ['10', '12', '14', '16']
1414
name: Node ${{ matrix.node }} Test
1515
steps:
1616
- name: Check out code

.mocharc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require: '@babel/register'
2+
recursive: true

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ 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.6.0] - 2021-07-14
9+
10+
### Added
11+
12+
- Order responses return a `registry_url` field
13+
- Add support for Bitcoin estimates
14+
815
## [1.5.2] - 2021-03-30
916

1017
### Changed

README.md

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,27 +102,33 @@ Estimates allow API users to get a quote for the cost of compensating a certain
102102

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

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

112112
// Create a shipping estimate
113113
const distance_m = 9000000;
114114
// Pass in the shipping distance in meters, the transportation method, and the package mass
115115
patch.estimates.createShippingEstimate({
116-
distance_m: distance_m,
116+
distance_m,
117117
transportation_method: 'air',
118118
package_mass_g: 1000
119119
});
120120

121+
// Create a bitcoin estimate
122+
const transaction_value_btc_sats = 1000; // [Optional] Pass in the transaction value in satoshis
123+
patch.estimates.createBitcoinEstimate({
124+
transaction_value_btc_sats
125+
});
126+
121127
// Create a vehicle estimate
122128
const distance_m = 9000000;
123129
// Pass in the shipping distance in meters and the model/make/year of the vehicle
124130
patch.estimates.createVehicleEstimate({
125-
distance_m: distance_m,
131+
distance_m,
126132
make: 'Toyota',
127133
model: 'Corolla',
128134
year: 1995
@@ -184,7 +190,7 @@ Preferences are how you route your orders in Patch. If you don't have a preferen
184190
```javascript
185191
// Create a preference
186192
const projectId = 'pro_test_1234'; // Pass in the project_id for your preference
187-
patch.preferences.createPreference((project_id: projectId));
193+
patch.preferences.createPreference({ project_id: projectId });
188194

189195
// Retrieve a preference
190196
const preferenceId = 'pre_test_1234'; // Pass in the preferences's id
@@ -234,9 +240,13 @@ $ npm link @patch-technology/patch
234240
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.
235241

236242
```sh
237-
$ node
238-
> const Patch = require('@patch-technology/patch')
239-
> Patch.default(process.env.SANDBOX_API_KEY).projects.retrieveProjects().then((response) => console.log(response))
243+
SANDBOX_API_KEY=xxx node
244+
```
245+
246+
```node
247+
const Patch = require('@patch-technology/patch');
248+
const patch = Patch.default(process.env.SANDBOX_API_KEY);
249+
patch.projects.retrieveProjects().then((response) => console.log(response));
240250
```
241251

242252
### Run the specs

mocha.opts

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)