Skip to content

Instantly share code, notes, and snippets.

@kristijanPetr
Created July 24, 2018 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kristijanPetr/1f016ea2e1ccca12ae110081dc3d52fa to your computer and use it in GitHub Desktop.
Save kristijanPetr/1f016ea2e1ccca12ae110081dc3d52fa to your computer and use it in GitHub Desktop.
desc
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