Guest User

Untitled

a guest
Mar 24th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. /* eslint-disable no-underscore-dangle */
  2. const Assert = require('assert');
  3. const GitHubApi = require('github');
  4.  
  5. function WriteClient(options) {
  6. Assert.ok(options, 'WriteClient options required');
  7. Assert.ok(options.organization, 'WriteClient organization required');
  8. Assert.ok(options.repository, 'WriteClient repository required');
  9. Assert.ok(options.token, 'WriteClient token required');
  10.  
  11. this.defaultVariables = {
  12. owner: options.organization,
  13. repo: options.repository
  14. };
  15.  
  16. this._client = new GitHubApi();
  17.  
  18. this._client.authenticate({
  19. type: 'token',
  20. token: options.token
  21. });
  22.  
  23. this.createIssue = params =>
  24. new Promise((resolve, reject) => {
  25. this._client.issues.create(Object.assign({}, this.defaultVariables, params), (err, res) => {
  26. if (err) return reject(err);
  27. return resolve(res.data);
  28. });
  29. });
  30. }
  31.  
  32. module.exports = WriteClient;
Add Comment
Please, Sign In to add comment