Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/epic-digital-im/epic-gigwage

Gigwage API Client and Express Middleware
https://github.com/epic-digital-im/epic-gigwage

api gigwage nodejs typescript

Last synced: about 1 month ago
JSON representation

Gigwage API Client and Express Middleware

Awesome Lists containing this project

README

        


:package: epic-gigwage
Epic Digital Interactive Media LLC

:package: @epicdm/gigwage


TypeScript Gigwage Client API and Express Middleware




Issues


GitHub pull requests


GitHub Downloads


GitHub Total Downloads


GitHub release





Report Bug
Request Feature

Typescript Gigwage Client w/ Express Middelware for validating incoming webhooks 🚀

# Beta - Currently in Development
Adding convenience methods for certain endpoints, eg: listSubscriptions. Not all methods implemented yet. Please check back soon.

# Installation
```bash
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](https://github.com/epicdigitalmedia/epic-gigwage/tree/main/demo)

```javascript
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](https://github.com/epicdigitalmedia/epic-gigwage/tree/main/demo)

```javascript
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:
```bash
git clone https://github.com/epicdigitalmedia/epic-gigwage
```
### Open the directory and run the script line:

```bash
cd epic-gigwage
```
```bash
yarn # or npm i
```

## 🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check [issues page](issues).

## Show your support

Give a ⭐️ if this project helped you!

[![codecov](https://codecov.io/gh/epicdigitalmedia/epic-gigwage/branch/main/graph/badge.svg?token=Q9fr548J0D)](https://codecov.io/gh/epicdigitalmedia/epic-gigwage)

## 📝 License

Copyright © 2022 [Epic Digital Interactive Media LLC](https://github.com/epicdigitalmedia).

This project is [MIT](LICENSE) licensed.