2018-06-11 19:03:43 -07:00
|
|
|
import { flow } from "lodash";
|
2018-07-03 15:47:15 -04:00
|
|
|
import unsentRequest from "netlify-cms-lib-util/unsentRequest";
|
|
|
|
import { then } from "netlify-cms-lib-util/promise";
|
2018-06-11 19:03:43 -07:00
|
|
|
import GitlabAPI from "Backends/gitlab/API";
|
|
|
|
|
|
|
|
export default class API extends GitlabAPI {
|
|
|
|
constructor(config) {
|
|
|
|
super(config);
|
|
|
|
this.tokenPromise = config.tokenPromise;
|
|
|
|
this.commitAuthor = config.commitAuthor;
|
|
|
|
this.repoURL = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
authenticateRequest = async req => unsentRequest.withHeaders({
|
|
|
|
Authorization: `Bearer ${ await this.tokenPromise() }`,
|
|
|
|
}, req);
|
|
|
|
|
|
|
|
request = async req => flow([
|
|
|
|
this.buildRequest,
|
|
|
|
this.authenticateRequest,
|
|
|
|
then(unsentRequest.performRequest),
|
|
|
|
])(req);
|
|
|
|
|
|
|
|
hasWriteAccess = () => Promise.resolve(true)
|
|
|
|
}
|