@twurple/api-call
Advanced tools
Comparing version 5.1.0-pre.5 to 5.1.0-pre.6
@@ -11,5 +11,8 @@ /// <reference lib="dom" /> | ||
* You need to obtain one using one of the [Twitch OAuth flows](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/). | ||
* @param authorizationType The type of Authorization header to send. | ||
* | ||
* Defaults to "Bearer" for Helix and "OAuth" for everything else. | ||
* @param fetchOptions Additional options to be passed to the `fetch` function. | ||
*/ | ||
export declare function callTwitchApiRaw(options: TwitchApiCallOptions, clientId?: string, accessToken?: string, fetchOptions?: TwitchApiCallFetchOptions): Promise<Response>; | ||
export declare function callTwitchApiRaw(options: TwitchApiCallOptions, clientId?: string, accessToken?: string, authorizationType?: string, fetchOptions?: TwitchApiCallFetchOptions): Promise<Response>; | ||
/** | ||
@@ -23,5 +26,8 @@ * Makes a call to the Twitch API using given credentials. | ||
* You need to obtain one using one of the [Twitch OAuth flows](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/). | ||
* @param authorizationType The type of Authorization header to send. | ||
* | ||
* Defaults to "Bearer" for Helix and "OAuth" for everything else. | ||
* @param fetchOptions Additional options to be passed to the `fetch` function. | ||
*/ | ||
export declare function callTwitchApi<T = unknown>(options: TwitchApiCallOptions, clientId?: string, accessToken?: string, fetchOptions?: TwitchApiCallFetchOptions): Promise<T>; | ||
export declare function callTwitchApi<T = unknown>(options: TwitchApiCallOptions, clientId?: string, accessToken?: string, authorizationType?: string, fetchOptions?: TwitchApiCallFetchOptions): Promise<T>; | ||
//# sourceMappingURL=apiCall.d.ts.map |
@@ -18,5 +18,8 @@ "use strict"; | ||
* You need to obtain one using one of the [Twitch OAuth flows](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/). | ||
* @param authorizationType The type of Authorization header to send. | ||
* | ||
* Defaults to "Bearer" for Helix and "OAuth" for everything else. | ||
* @param fetchOptions Additional options to be passed to the `fetch` function. | ||
*/ | ||
async function callTwitchApiRaw(options, clientId, accessToken, fetchOptions = {}) { | ||
async function callTwitchApiRaw(options, clientId, accessToken, authorizationType, fetchOptions = {}) { | ||
var _a, _b; | ||
@@ -36,3 +39,3 @@ const type = (_a = options.type) !== null && _a !== void 0 ? _a : 'helix'; | ||
if (accessToken) { | ||
headers.append('Authorization', `${type === 'helix' ? 'Bearer' : 'OAuth'} ${accessToken}`); | ||
headers.append('Authorization', `${type === 'helix' ? authorizationType !== null && authorizationType !== void 0 ? authorizationType : 'Bearer' : 'OAuth'} ${accessToken}`); | ||
} | ||
@@ -56,7 +59,10 @@ const requestOptions = { | ||
* You need to obtain one using one of the [Twitch OAuth flows](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/). | ||
* @param authorizationType The type of Authorization header to send. | ||
* | ||
* Defaults to "Bearer" for Helix and "OAuth" for everything else. | ||
* @param fetchOptions Additional options to be passed to the `fetch` function. | ||
*/ | ||
async function callTwitchApi(options, clientId, accessToken, fetchOptions = {}) { | ||
async function callTwitchApi(options, clientId, accessToken, authorizationType, fetchOptions = {}) { | ||
var _a; | ||
const response = await callTwitchApiRaw(options, clientId, accessToken, fetchOptions); | ||
const response = await callTwitchApiRaw(options, clientId, accessToken, authorizationType, fetchOptions); | ||
if (!response.ok) { | ||
@@ -63,0 +69,0 @@ const isJson = response.headers.get('Content-Type') === 'application/json'; |
{ | ||
"name": "@twurple/api-call", | ||
"version": "5.1.0-pre.5", | ||
"version": "5.1.0-pre.6", | ||
"publishConfig": { | ||
@@ -35,3 +35,3 @@ "access": "public" | ||
"@d-fischer/qs": "^7.0.2", | ||
"@twurple/common": "^5.1.0-pre.5", | ||
"@twurple/common": "^5.1.0-pre.6", | ||
"@types/node-fetch": "^2.5.7", | ||
@@ -51,3 +51,3 @@ "tslib": "^2.0.3" | ||
}, | ||
"gitHead": "c7f7a391b8db7d199cf9a33ed7ef421ce1ebd4f3" | ||
"gitHead": "c0029f41cee8750ff5ef5094cfc168df1c336af4" | ||
} |
Sorry, the diff of this file is not supported yet
18889
368
Updated@twurple/common@^5.1.0-pre.6