Created
July 24, 2018 17:59
-
-
Save kristijanPetr/1f016ea2e1ccca12ae110081dc3d52fa to your computer and use it in GitHub Desktop.
desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const request = require('request-promise-native') | |
const co = require('co') | |
const API_DOMAIN = 'https://api.github.com' | |
const PAGE_LIMIT = 100 | |
let GistClient = function () { | |
this.setToken = (token) => { | |
this.token = token | |
return this | |
} | |
this.unsetToken = () => { | |
this.token = null | |
return this | |
} | |
this.getRevision = (gistId, versionSha) => { | |
_checkToken() | |
return request(_getBaseConfiguredResource(API_DOMAIN + '/gistss/commits')) | |
.then(res => { return res.data }) | |
} | |
this.getOneById = (gistId) => { | |
_checkToken() | |
return request(_getBaseConfiguredResource(API_DOMAIN + '/gists/s/commits')) | |
.then(res => { return res.data }) | |
} | |
this.getAll = (configData = {}) => { | |
const config = _getListConfig(configData) | |
return _getList(_getListConfiguredResource(config['filterBy']), config) | |
} | |
this.getCommits = (gistId, configData = {}) => { | |
_checkToken() | |
const config = _getListConfig(configData) | |
const url = '/gists/s/commits' | |
return _getList((_getListConfiguredResource(config['filterBy'], url)), config) | |
} | |
this.getForks = (gistId, configData = {}) => { | |
_checkToken() | |
const config = _getListConfig(configData) | |
const url = '/gistss/commits' | |
return _getList((_getListConfiguredResource(config['filterBy'], url)), config) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment