This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
Sphere/app/api/CircleCI.js

30 lines
828 B
JavaScript
Raw Normal View History

2016-02-06 12:42:19 +00:00
import endpoints from './endpoints';
import request from './request';
2016-02-21 11:59:53 +00:00
function JSONify(response) {
return response.json();
}
2016-02-23 23:12:32 +00:00
const [GET] = ['GET'];
2016-05-05 18:26:22 +01:00
export async function checkToken(possibleToken) {
2016-02-06 12:42:19 +00:00
const url = endpoints.get('USER_INFO');
2016-05-05 18:26:22 +01:00
const response = await request(url, GET, {}, possibleToken);
return response.ok;
2016-02-06 12:42:19 +00:00
}
2016-02-10 22:42:45 +00:00
2016-02-23 23:12:32 +00:00
export async function getUserDetails() {
const url = endpoints.get('USER_INFO');
2016-05-05 18:51:31 +01:00
return await request(url, GET).then(JSONify);
2016-02-23 23:12:32 +00:00
}
2016-02-21 11:59:53 +00:00
export async function getProjects() {
2016-02-10 22:42:45 +00:00
const url = endpoints.get('ALL_PROJECTS');
2016-05-05 18:51:31 +01:00
return await request(url, GET).then(JSONify);
2016-02-23 23:12:32 +00:00
}
2016-03-13 19:28:22 +00:00
export async function getProjectRecentBuilds(user, repo, limit = 1, offset = 0) {
const url = endpoints.get('PROJECT_RECENTS').param({ user, repo }).query({ limit, offset });
2016-05-05 18:51:31 +01:00
return await request(url, GET).then(JSONify);
2016-02-10 22:42:45 +00:00
}