bungie-net-core
Version:
An easy way to interact with the Bungie.net API
95 lines (94 loc) • 3.8 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getContentById = getContentById;
exports.getContentByTagAndType = getContentByTagAndType;
exports.getContentType = getContentType;
exports.rssNewsArticles = rssNewsArticles;
exports.searchContentByTagAndType = searchContentByTagAndType;
exports.searchContentWithText = searchContentWithText;
exports.searchHelpArticles = searchHelpArticles;
async function getContentType(http, params) {
const baseUrl = `https://www.bungie.net/Platform/Content/GetContentType/${params.type}/`;
const searchParams = undefined;
return await http({
method: 'GET',
baseUrl,
searchParams,
body: undefined
});
}
async function getContentById(http, params) {
const baseUrl = `https://www.bungie.net/Platform/Content/GetContentById/${params.id}/${params.locale}/`;
const searchParams = new URLSearchParams();
if (params.head !== undefined) searchParams.append('head', params.head.toString());
return await http({
method: 'GET',
baseUrl,
searchParams,
body: undefined
});
}
async function getContentByTagAndType(http, params) {
const baseUrl = `https://www.bungie.net/Platform/Content/GetContentByTagAndType/${params.tag}/${params.type}/${params.locale}/`;
const searchParams = new URLSearchParams();
if (params.head !== undefined) searchParams.append('head', params.head.toString());
return await http({
method: 'GET',
baseUrl,
searchParams,
body: undefined
});
}
async function searchContentWithText(http, params) {
const baseUrl = `https://www.bungie.net/Platform/Content/Search/${params.locale}/`;
const searchParams = new URLSearchParams();
if (params.ctype !== undefined) searchParams.append('ctype', params.ctype.toString());
if (params.currentpage !== undefined) searchParams.append('currentpage', params.currentpage.toString());
if (params.head !== undefined) searchParams.append('head', params.head.toString());
if (params.searchtext !== undefined) searchParams.append('searchtext', params.searchtext.toString());
if (params.source !== undefined) searchParams.append('source', params.source.toString());
if (params.tag !== undefined) searchParams.append('tag', params.tag.toString());
return await http({
method: 'GET',
baseUrl,
searchParams,
body: undefined
});
}
async function searchContentByTagAndType(http, params) {
const baseUrl = `https://www.bungie.net/Platform/Content/SearchContentByTagAndType/${params.tag}/${params.type}/${params.locale}/`;
const searchParams = new URLSearchParams();
if (params.currentpage !== undefined) searchParams.append('currentpage', params.currentpage.toString());
if (params.head !== undefined) searchParams.append('head', params.head.toString());
if (params.itemsperpage !== undefined) searchParams.append('itemsperpage', params.itemsperpage.toString());
return await http({
method: 'GET',
baseUrl,
searchParams,
body: undefined
});
}
async function searchHelpArticles(http, params) {
const baseUrl = `https://www.bungie.net/Platform/Content/SearchHelpArticles/${params.searchtext}/${params.size}/`;
const searchParams = undefined;
return await http({
method: 'GET',
baseUrl,
searchParams,
body: undefined
});
}
async function rssNewsArticles(http, params) {
const baseUrl = `https://www.bungie.net/Platform/Content/Rss/NewsArticles/${params.pageToken}/`;
const searchParams = new URLSearchParams();
if (params.categoryfilter !== undefined) searchParams.append('categoryfilter', params.categoryfilter.toString());
if (params.includebody !== undefined) searchParams.append('includebody', params.includebody.toString());
return await http({
method: 'GET',
baseUrl,
searchParams,
body: undefined
});
}