habitat-client-node
v0.4.14
Published
An axios-powered client wrapper for the Habitat API
Downloads
14
Readme
habitat-client-node
An axios-powered client wrapper for the Habitat API
Habitat Node wrapper
Getting Started
npm i habitat-client-node
or for meteor folks...
meteor npm install habitat-client-node
Prerequisites
You'll need an API Key - contact us at [email protected] to get started!
Initialize connection
- Initialize client and login
const client = new Habitat({
baseUrl: "https://sandbox.tryhabitat.com",
apiKey: "YOUR_API_KEY"
});
//Returns a session token if it wasn't passed into constructor
client.login({
email: "[email protected]",
password: "password"
})
.then((token) => {
//set token in localStorage, etc...
});
Send an order to dispatch
client.create({
sellerId: sellerId,
thirdParty: false,
deliveryAddress: address,
deliveryInstructions: instructions,
customer: { phone, name },
DaaSType: type
})
Transaction lifecycle methods
- Call transaction lifecycle methods, super easy and all return a promise.
//accept an order (Admin / Vendor)
client.accept(orderId).then((order) => {
//what would be helpful to return here?
})
//assign a runner (Admin / Vendor)
client.assign(orderId, {
runnerId: runnerId
}).then((order) => {
//what would be helpful to return here?
})
//pickup an order (Admin / Runner)
client.pickup(orderId).then((order) => {
//what would be helpful to return here?
})
//dropoff an order (Admin / Runner)
client.dropoff(orderId, {
tip: 4.20,
receiptUrl: https://placekitten.com/50/50
}).then((order) => {
//what would be helpful to return here?
})
Built With
- Axios - Promise-based HTTP client
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Versioning
We use SemVer for versioning.
Authors
- Mike Paszkiewicz - Initial work - MikeP
License
This project is licensed under the MIT License - see the LICENSE.md file for details