Created
July 24, 2018 17:59
-
-
Save kristijanPetr/027910096e273b6c312cbea778a04450 to your computer and use it in GitHub Desktop.
desc
This file contains 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