@epicdm/gigwage
v0.1.4
Published
Gigwage TS Client and Express Middleware for the Gigwage API
Downloads
16
Maintainers
Readme
Beta - Currently in Development
Adding convenience methods for certain endpoints, eg: listSubscriptions. Not all methods implemented yet. Please check back soon.
Installation
yarn add @epicdm/gigwage
npm install @epicdm/gigwage
See Gigwage Developer Documentation
- https://developers.gigwage.com/docs
- https://developers.gigwage.com/reference
API Client usage, see examples
import GigwageService, { Contractor, Subscription } from '../src/gigwage';
const gigwageService = new GigwageService({
config: {
apiKey: 'YOUR_API_KEY',
apiSecret: 'YOUR_API_SECRET',
apiEnvironment: 'sandbox',
},
});
/* Exposes signed axios request methods:
gigwageService.get
gigwageService.post
gigwageService.put
gigwageService.patch
gigwageService.del
*/
gigwageService.get<{ contractors: Contractor[] }>("api/v1/contractors")
.then((response) => {
const contractors = response.data.contractors;
});
gigwageService.post<{ contractor: Contractor }>("api/v1/contractors", {
contractor: {
first_name: 'John',
last_name: 'Doe',
email: '[email protected]',
}
}).then((response) => {
if (response.data.error) {
/* Axios handled error, includes validation error response:
{
"error": "Validation Failed",
"errors": [
"Email missing",
]
}
*/
}
const contractor = response.data.contractor;
});
// Reactivate Subscription
gigwageService.put<{ subscription: Subscription }>(`api/v1/subscriptions/13`)
.then((response) => {
const subscription = response.data.subscription;
});
// Delete Subscription
gigwageService.del<{ subscription: Subscription }>(`api/v1/subscriptions/13`)
.then((response) => {
const subscription = response.data.subscription;
});
Express Middleware Usage, see examples
route.post(
`/gigwage/payment`,
gigwageService.bodyParser(), // need raw and JSON body
gigwageService.validateWebhook(), // validate webhook signature
async (request, response) => {
try {
// do something with the request, its been validated
response.status(200).send(`I did it!`);
} catch (err: any) {
console.log(err);
response.status(500).send(`Webhook Error`);
return;
}
},
);
Development Getting started
Installation
Clone this repository:
git clone https://github.com/epicdigitalmedia/epic-gigwage
Open the directory and run the script line:
cd epic-gigwage
yarn # or npm i
🤝 Contributing
Contributions, issues and feature requests are welcome!Feel free to check issues page.
Show your support
Give a ⭐️ if this project helped you!
📝 License
Copyright © 2022 Epic Digital Interactive Media LLC. This project is MIT licensed.