glitch-javascript-sdk
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -8,2 +8,4 @@ import { Config } from "./config"; | ||
import { Waitlists } from "./api"; | ||
import Requests from "./util/Requests"; | ||
import Parser from "./util/Parser"; | ||
declare class Glitch { | ||
@@ -21,3 +23,7 @@ static config: { | ||
}; | ||
static util: { | ||
Requests: typeof Requests; | ||
Parser: typeof Parser; | ||
}; | ||
} | ||
export default Glitch; |
@@ -1132,2 +1132,61 @@ import { AxiosPromise } from 'axios'; | ||
interface Route { | ||
url: string; | ||
method: string; | ||
} | ||
declare class Requests { | ||
config: Config; | ||
private static baseUrl; | ||
private static authToken; | ||
constructor(config: Config); | ||
/** | ||
* Sets the base url of the API. | ||
* | ||
* @param url The url to of the API. | ||
*/ | ||
static setBaseUrl(url: string): void; | ||
/** | ||
* Sets the JSON Web token | ||
* | ||
* @param token | ||
*/ | ||
static setAuthToken(token: string): void; | ||
private static request; | ||
/** | ||
* Calls a GET request to the url endpoint. | ||
* | ||
* @param url | ||
* @returns | ||
*/ | ||
static get<T>(url: string): AxiosPromise<Response<T>>; | ||
static post<T>(url: string, data: any): AxiosPromise<Response<T>>; | ||
static put<T>(url: string, data: any): AxiosPromise<Response<T>>; | ||
static delete<T>(url: string): AxiosPromise<Response<T>>; | ||
static uploadFile<T>(url: string, filename: string, file: File, data?: any): AxiosPromise<Response<T>>; | ||
static uploadBlob<T>(url: string, filename: string, blob: Blob, data?: any): AxiosPromise<Response<T>>; | ||
/** | ||
* The Route class contains the method and url, thereforce items can be | ||
* automatically routed depending on the configuration. | ||
* | ||
* @param route | ||
* @param data | ||
* @returns | ||
*/ | ||
static processRoute<T>(route: Route, data?: object, routeReplace?: { | ||
[key: string]: any; | ||
}): AxiosPromise<Response<T>>; | ||
} | ||
declare class Parser { | ||
/** | ||
* To be used inside a catch close, this function will parse out any JSON in a error response from the api. | ||
* | ||
* @param error The Error object from the catch clause | ||
* | ||
* @returns Either returns a JSON object or false. | ||
*/ | ||
static parseJSONFromError(error: Error): object | boolean; | ||
} | ||
declare class Glitch { | ||
@@ -1145,4 +1204,8 @@ static config: { | ||
}; | ||
static util: { | ||
Requests: typeof Requests; | ||
Parser: typeof Parser; | ||
}; | ||
} | ||
export { Glitch as default }; |
{ | ||
"name": "glitch-javascript-sdk", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Javascrip SDK for GLitch", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js", |
@@ -13,2 +13,5 @@ | ||
import Requests from "./util/Requests"; | ||
import Parser from "./util/Parser"; | ||
class Glitch { | ||
@@ -29,5 +32,10 @@ | ||
public static util = { | ||
Requests : Requests, | ||
Parser : Parser | ||
} | ||
} | ||
export default Glitch; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1912533
52
50020