quria
Version:
A user-friendly Destiny 2 API Wrapper written with TypeScript and approved by -Axis Minds- Oryx.
103 lines (102 loc) • 5.13 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Content = void 0;
const adapters_1 = require("../../adapters");
class Content {
url;
headers;
constructor(url, headers) {
this.url = url;
this.headers = headers;
}
/**
* Gets an object describing a particular variant of content.
* @param type
* @returns Gets an object describing a particular variant of content.
*/
GetContentType(type, tokens) {
const requestURL = `${this.url}/Content/GetContentType/${type}/`;
const authHeaders = (0, adapters_1.parseAuthenticationHeaders)(this.headers, tokens);
return adapters_1.Controller.request(requestURL, true, "GET", authHeaders);
}
/**
* Returns a content item referenced by id
* @param head false
* @param id
* @param locale
* @returns Returns a content item referenced by id
*/
GetContentById(id, locale, queryString, tokens) {
const requestURL = (0, adapters_1.formatQueryStrings)(`${this.url}/Content/GetContentById/${id}/${locale}/`, queryString);
const authHeaders = (0, adapters_1.parseAuthenticationHeaders)(this.headers, tokens);
return adapters_1.Controller.request(requestURL, true, "GET", authHeaders);
}
/**
* Returns the newest item that matches a given tag and Content Type.
* @param head Not used.
* @param locale
* @param tag
* @param type
* @returns Returns the newest item that matches a given tag and Content Type.
*/
GetContentByTagAndType(locale, tag, type, queryString, tokens) {
const requestURL = (0, adapters_1.formatQueryStrings)(`${this.url}/Content/GetContentByTagAndType/${tag}/${type}/${locale}/`, queryString);
const authHeaders = (0, adapters_1.parseAuthenticationHeaders)(this.headers, tokens);
return adapters_1.Controller.request(requestURL, true, "GET", authHeaders);
}
/**
* Gets content based on querystring information passed in. Provides basic search and text search capabilities.
* @param ctype Content type tag: Help, News, etc. Supply multiple ctypes separated by space.
* @param currentpage Page number for the search results, starting with page 1.
* @param head Not used.
* @param locale
* @param searchtext Word or phrase for the search.
* @param source For analytics, hint at the part of the app that triggered the search. Optional.
* @param tag Tag used on the content to be searched.
* @returns Gets content based on querystring information passed in. Provides basic search and text search capabilities.
*/
SearchContentWithText(locale, queryString, tokens) {
const requestURL = (0, adapters_1.formatQueryStrings)(`${this.url}/Content/Search/${locale}/`, queryString);
const authHeaders = (0, adapters_1.parseAuthenticationHeaders)(this.headers, tokens);
return adapters_1.Controller.request(requestURL, true, "GET", authHeaders);
}
/**
* Searches for Content Items that match the given Tag and Content Type.
* @param currentpage Page number for the search results starting with page 1.
* @param head Not used.
* @param itemsperpage Not used.
* @param locale
* @param tag
* @param type
* @returns Searches for Content Items that match the given Tag and Content Type.
*/
SearchContentByTagAndType(locale, tag, type, queryString, tokens) {
const requestURL = (0, adapters_1.formatQueryStrings)(`${this.url}/Content/SearchContentByTagAndType/${tag}/${type}/${locale}/`, queryString);
const authHeaders = (0, adapters_1.parseAuthenticationHeaders)(this.headers, tokens);
return adapters_1.Controller.request(requestURL, true, "GET", authHeaders);
}
/**
* Search for Help Articles.
* @param searchtext
* @param size
* @returns Search for Help Articles.
*/
SearchHelpArticles(searchtext, size, tokens) {
const requestURL = `${this.url}/Content/SearchHelpArticles/${searchtext}/${size}/`;
const authHeaders = (0, adapters_1.parseAuthenticationHeaders)(this.headers, tokens);
return adapters_1.Controller.request(requestURL, true, "GET", authHeaders);
}
/**
* Returns a JSON string response that is the RSS feed for news articles.
* @param categoryfilter Optionally filter response to only include news items in a certain category.
* @param includebody Optionally include full content body for each news item.
* @param pageToken Zero-based pagination token for paging through result sets.
* @returns Returns a JSON string response that is the RSS feed for news articles.
*/
RssNewsArticles(pageToken, queryString, tokens) {
const requestURL = (0, adapters_1.formatQueryStrings)(`${this.url}/Content/Rss/NewsArticles/${pageToken}/`, queryString);
const authHeaders = (0, adapters_1.parseAuthenticationHeaders)(this.headers, tokens);
return adapters_1.Controller.request(requestURL, true, "GET", authHeaders);
}
}
exports.Content = Content;