A JS wrapper around Pact's APIs to make it faster and easier to use in client/server JS projects.
Each async method returns a promise.
This project currently requires the use of a module build tool like browserify or webpack. The output dist
is simply babel transformed code to ES5. In future this could be a completely packaged dist.
Each resource can be access from your pact-api
instance:
import PactAPI from 'pact-api';
const pact = new PactAPI();
// pact.{RESOURCE_NAME}.{METHOD_NAME}
token
: optional token to auth requests with (defaultundefined
)version
: optional version of the API to hit (defaultv1
)base
: optinal base url used for requests (defaulthttps://api.pactcoffee.com
)
Each method returns a promise:
pact.tokens
.create({email: 'hurr', password: 'durr'})
.then(
(body) => return pact.tokens.del(),
(err) => throw new Error(error)
);
- token
create()
del()
- products
list({queryParams})
listCoffees({queryParams})
listHardwares({queryParams})
retrieve(sku)
- users
create({params})
start()
- addresses
list()
create({params})
retrieve(id)
update({params})
del(id)
- recurrables
list()
create({params})
retrieve(id)
update({params})
del(id)
- orders
list()
create({params})
retrieve(id)
update({params})
del(id)
- account
fetch()
- identities
create({params})
update({params})
- gifts
create({params})
- validate
password({password})
address({params})
voucher({params})
npm run test
- Fork
- Make changes
npm run build
- Commit changes
- Appropriate version bump:
npm version major|minor|patch
- Open a PR