nycJSorg/angular-presentation

View on GitHub
apps/codelab/src/app/admin/feedback/github.service.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';

@Injectable({
  providedIn: 'root'
})
export class GithubService {
  repo = 'codelab-fun/codelab';

  constructor(private http: HttpClient) {}

  createIssue(issueData, accessToken) {
    const headers = { Authorization: 'token ' + accessToken };
    const options = { headers };
    return this.http.post(
      `https://api.github.com/repos/${this.repo}/issues`,
      issueData,
      options
    );
  }

  closeIssue(changes, issueId, accessToken) {
    const headers = { Authorization: 'token ' + accessToken };
    const options = { headers };
    return this.http.patch(
      `https://api.github.com/repos/${this.repo}/issues/${issueId}`,
      changes,
      options
    );
  }
}