diff --git a/app/api/CircleCI.js b/app/api/CircleCI.js index 51ad6a5..24caa46 100644 --- a/app/api/CircleCI.js +++ b/app/api/CircleCI.js @@ -1,9 +1,16 @@ import endpoints from './endpoints'; import request from './request'; +import token from './token'; -export function checkToken(token) { +export function checkToken(possibleToken) { const url = endpoints.get('USER_INFO'); - return request(url, 'GET', {}, token).then(function (response) { + return request(url, 'GET', {}, possibleToken).then(function (response) { return response.ok; }); } + +export function getProjects() { + const CIToken = token.get(); + const url = endpoints.get('ALL_PROJECTS'); + return request(url, 'GET', {}, CIToken); +} diff --git a/app/api/endpoints.js b/app/api/endpoints.js index eec93f4..25f4399 100644 --- a/app/api/endpoints.js +++ b/app/api/endpoints.js @@ -4,5 +4,6 @@ import UrlAssembler from 'url-assembler'; const URL_BASE = UrlAssembler('https://circleci.com/api/v1'); export default Map({ - USER_INFO: URL_BASE.segment('/me') + USER_INFO: URL_BASE.segment('/me'), + ALL_PROJECTS: URL_BASE.segment('/projects') });