From eddfb49be51fb25c62bf927c33a8e3bd1ace0fdb Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 5 May 2016 14:18:21 +0100 Subject: [PATCH] Remove old api files --- app/api/CircleCI.js | 39 --------------------------------------- app/api/request.js | 16 ---------------- app/api/token.js | 13 ------------- 3 files changed, 68 deletions(-) delete mode 100644 app/api/CircleCI.js delete mode 100644 app/api/request.js delete mode 100644 app/api/token.js diff --git a/app/api/CircleCI.js b/app/api/CircleCI.js deleted file mode 100644 index cd427c5..0000000 --- a/app/api/CircleCI.js +++ /dev/null @@ -1,39 +0,0 @@ -import endpoints from '../settings/endpoints'; -import request from './request'; -import token from './token'; - -function JSONify(response) { - return response.json(); -} - -const [GET] = ['GET']; - -export function checkToken(possibleToken) { - const url = endpoints.get('USER_INFO'); - return request(url, GET, {}, possibleToken).then(function (response) { - return response.ok; - }); -} - -export async function getUserDetails() { - const CIToken = await token.get(); - const url = endpoints.get('USER_INFO'); - return await request(url, GET, {}, CIToken).then(JSONify); -} - -export async function getProjects() { - const CIToken = await token.get(); - const url = endpoints.get('ALL_PROJECTS'); - return await request(url, GET, {}, CIToken).then(JSONify); -} - -export async function getProjectRecentBuilds(user, repo, limit = 1, offset = 0) { - const CIToken = await token.get(); - const url = endpoints.get('PROJECT_RECENTS').param({ user, repo }).query({ limit, offset }); - return await request( - url, - GET, - {}, - CIToken) - .then(JSONify); -} diff --git a/app/api/request.js b/app/api/request.js deleted file mode 100644 index 6c3c7ae..0000000 --- a/app/api/request.js +++ /dev/null @@ -1,16 +0,0 @@ -import token from './token'; - -export default function request(url, method, data = {}, CIToken) { - CIToken = CIToken || token.get(); - const fullURL = url.query({ 'circle-token': CIToken }).toString(); - let fetchParams = { - method, - headers: { - 'Accept': 'application/json', - }, - }; - if (method !== 'GET' && method !== 'HEAD') { - fetchParams.body = JSON.stringify(data); - } - return fetch(fullURL, fetchParams); -} diff --git a/app/api/token.js b/app/api/token.js deleted file mode 100644 index d33594e..0000000 --- a/app/api/token.js +++ /dev/null @@ -1,13 +0,0 @@ -import { AsyncStorage } from 'react-native'; - -const STORAGE_KEY = 'CIRCLE_TOKEN'; - -async function get() { - return await AsyncStorage.getItem(STORAGE_KEY); -} - -async function set(token) { - return await AsyncStorage.setItem(STORAGE_KEY, token); -} - -export default { get, set};