Skip to content

Commit

Permalink
Beta version
Browse files Browse the repository at this point in the history
  • Loading branch information
Waren Gonzaga committed Oct 11, 2020
1 parent 140b71a commit 447ee53
Show file tree
Hide file tree
Showing 7 changed files with 1,587 additions and 51 deletions.
9 changes: 9 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"parserOptions": {
"ecmaVersion": 2017
},

"env": {
"es6": true
}
}
73 changes: 63 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,91 @@
# BuyMeACoffee.JS [![Developed by Waren Gonzaga](https://img.shields.io/badge/Developed%20by-Waren%20Gonzaga-blue.svg?longCache=true&style=for-the-badge)](https://github.com/warengonzaga)

<!-- [![GitHub Version](https://img.shields.io/github/release/WarenGonzaga/buymeacoffee.js.svg?style=for-the-badge)](https://github.com/WarenGonzaga/buymeacoffee.js/) -->
[![GitHub Version](https://img.shields.io/github/release/WarenGonzaga/buymeacoffee.js.svg?style=for-the-badge)](https://github.com/WarenGonzaga/buymeacoffee.js/) [![Github Star](https://img.shields.io/github/stars/WarenGonzaga/buymeacoffee.js.svg?style=for-the-badge)](https://github.com/WarenGonzaga/buymeacoffee.js) [![Github Fork](https://img.shields.io/github/forks/WarenGonzaga/buymeacoffee.js.svg?style=for-the-badge)](https://github.com/WarenGonzaga/buymeacoffee.js) [![License](https://img.shields.io/github/license/WarenGonzaga/buymeacoffee.js.svg?style=for-the-badge)](https://github.com/WarenGonzaga/buymeacoffee.js)

![Powered By](https://img.shields.io/badge/Status-Development-red.svg?style=for-the-badge) [![Github Star](https://img.shields.io/github/stars/WarenGonzaga/buymeacoffee.js.svg?style=for-the-badge)](https://github.com/WarenGonzaga/buymeacoffee.js) [![Github Fork](https://img.shields.io/github/forks/WarenGonzaga/buymeacoffee.js.svg?style=for-the-badge)](https://github.com/WarenGonzaga/buymeacoffee.js) [![License](https://img.shields.io/github/license/WarenGonzaga/buymeacoffee.js.svg?style=for-the-badge)](https://github.com/WarenGonzaga/buymeacoffee.js)

A simple but powerful Node.js client for [Buy Me A Coffee](https://buymeacoff.ee/?via=WarenGonzaga) API.
A simple and lightweight but powerful Node.js client for [Buy Me A Coffee](https://buymeacoff.ee/?via=WarenGonzaga) API.

## What is Buy Me A Coffee

Buy Me a Coffee is a simple, meaningful way to fund your creative work.

Without stitching together a bunch of apps like Patreon, Mailchimp, and a donate button — you can accept support, memberships, and build a direct relationship with your fans. [Create your account here](https://buymeacoff.ee/?via=WarenGonzaga).

## Features

- Simple
- Lightweight
- Supporters Data
- Subscriptions Data
- Extras Data

(Read the [Official Docs](http://developers.buymeacoffee.com))

## Usage

...
First [get your personal access token here](http://developers.buymeacoffee.com/dashboard), then create a ``coffee.json`` file and save your personal access token inside. Example below.

```json
{
"token":"access_token_here"
}
```

After that, create your Javascript file. Example below.

```js
const access = require('./coffee.json'); // load your token
const coffee = new BMC(access.token); // add your token here

// retrieve supporters data
coffee.Supporters((data) => {
console.log(data);
});

// retrieve subscribers data
coffee.Subscriptions((data) => {
console.log(data);
});

// retrieve extras data
coffee.Extras((data) => {
console.log(data);
});
```

You can play with the data and get specific information such as supporter name. Example below.

```js
coffee.Supporters((data) => {
data = data.data[0].supporter_name;
console.log(data);
});
```

I will add more features to this API Client as soon as I have time working on it.

## Contributing

...
Contributions are welcome, create a pull request to this repo and I will review your code. Please consider to submit your pull request to the ```dev``` branch. Thank you!

## Issues

...
If you're facing a problem in using BuyMeACoffeeJS please let me know by creating an issue in this github repository. I'm happy to help you! Don't forget to provide me some screenshot or error logs of it, thank you!

## To Do

...
- Advance way to retrieve data.
- Improve development.
- Add CI to this project.

## Community

Unofficial Discord Server

[![BuyMeACoffee](https://discordapp.com/api/guilds/764424624032841748/widget.png?style=banner1)](https://discord.link/buymeacoffee)

Wanna see other projects I made? Join today!

[![Community](https://discordapp.com/api/guilds/659684980137656340/widget.png?style=banner3)](https://discord.io/warengonzaga) [![Tracker CLI](https://discordapp.com/api/guilds/694612151444439081/widget.png?style=banner3)](https://discord.io/trackercli)
[![Community](https://discordapp.com/api/guilds/659684980137656340/widget.png?style=banner2)](https://discord.io/warengonzaga) [![Tracker CLI](https://discordapp.com/api/guilds/694612151444439081/widget.png?style=banner2)](https://discord.io/trackercli)

## Donate or Support

Expand All @@ -52,4 +105,4 @@ BuyMeACoffeeJS is Developed and Maintained by **[Waren Gonzaga](https://github.c

---

:computer: Made with :heart: by Waren Gonzaga with **YHWH** :pray:
:computer: Made with :heart: and :coffee: by Waren Gonzaga with **YHWH** :pray:
15 changes: 15 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*!
* BuyMeACoffeeJS - https://github.com/WarenGonzaga/buymeacoffee.js#readme
* A simple and lightweight but powerful Node.js client for Buy Me A Coffee API
* Version: 1.0.0-beta.1
* Github: https://github.com/WarenGonzaga/buymeacoffee.js
* Licensed Under The MIT License: http://opensource.org/licenses/MIT
* Copyright (c) 2020 Waren Gonzaga
*
* Facebook: @warengonzagaofficial
* Twitter: @warengonzaga
* Github: @warengonzaga
* Website: warengonzaga.com
*/

const{get:get}=require("request"),baseURL="https://developers.buymeacoffee.com/api/v1";class BMC{constructor(s){this.access_token=s}Supporters(s){this._sendRequest("supporters",s)}Subscriptions(s){this._sendRequest("subscriptions",s)}Extras(s){this._sendRequest("extras",s)}_sendRequest(s,e){get(`${baseURL}/${s}`,{auth:{bearer:this.access_token}},(function(s,t,r){!s&200===t.statusCode&&e(JSON.parse(r))}))}}
64 changes: 59 additions & 5 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,66 @@
/**
/*!
* Buy Me A Coffee JS | Gulpfile
* By Waren Gonzaga
*/

const { series, parallel } = require('gulp');
// modules
const {
series,
src,
dest } = require('gulp'),
uglify = require('gulp-uglify-es').default,
eslint = require('gulp-eslint'),
pipeline = require('readable-stream').pipeline,
header = require('gulp-header'),
fs = require('fs');

function check(cb) {
cb();
// dev paths
const path = {
dist: "./dist",
scripts: "./src/*.js"
};

// open source label
const pkg = JSON.parse(fs.readFileSync('package.json'));
const data = {
banner: [
'/*!',
' * BuyMeACoffeeJS - <%= homepage %>',
' * <%= description %>',
' * Version: <%= version %>',
' * Github: <%= github %>',
' * Licensed Under The MIT License: http://opensource.org/licenses/MIT',
' * Copyright (c) <%= new Date().getFullYear() %> <%= author %>',
' *',
' * Facebook: @warengonzagaofficial',
' * Twitter: @warengonzaga',
' * Github: @warengonzaga',
' * Website: warengonzaga.com',
' */\n\n',
].join('\n'),
};

// lint js
function lintJS() {
return src(path.scripts)
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
}

exports.default = series(check);
// minify js
function minifyJS() {
return pipeline(
src(path.scripts),
uglify(),
dest(path.dist));
}

// add copyright label
function copyright() {
return src([path.dist+"/*.js"], {allowEmpty: true})
.pipe(header(data.banner, pkg))
.pipe(dest([path.dist]));
}

exports.default = series(lintJS, minifyJS, copyright);
Loading

0 comments on commit 447ee53

Please sign in to comment.