Skip to content

Commit

Permalink
feat: updated bungie endpoints and typings
Browse files Browse the repository at this point in the history
  • Loading branch information
FraWolf committed Jul 2, 2023
1 parent d2c3de5 commit 28b25b8
Show file tree
Hide file tree
Showing 14 changed files with 4,651 additions and 1,894 deletions.
45 changes: 19 additions & 26 deletions src/contents/app/index.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,38 @@
import { request } from "../../adapters/http-request";
import {
formatQueryStrings,
parseAuthenticationHeaders,
} from "../../adapters/utils";
import { APIResponse } from "../../types/api";
import { Tokens } from "../../types/general";
import { ApiUsage, Application } from "../../types/interface";
import { formatQueryStrings, parseAuthenticationHeaders } from "../../adapters/utils";
import { ITokens, APIResponse, ApiUsage, Application } from "../../types";

export class App {
constructor(
private url: string,
private headers: { [key: string]: string }
) {}
constructor(private url: string, private headers: Record<string, string>) {}

/**
* Get API usage by application for time frame specified.
* Get API usage by application for time frame specified. You can go as far back as 30 days ago, and can ask for up to a 48 hour window of time in a single request. You must be authenticated with at least the ReadUserData permission to access this endpoint.
* @param applicationId ID of the application to get usage statistics.
* @param queryString The optional querystrings that can be applied.
* @param tokens The optional tokens that can be applied.
* @returns API usage by application for time frame specified
* @param end End time for query. Goes to now if not specified.
* @param start Start time for query. Goes to 24 hours ago if not specified.
* @returns Get API usage by application for time frame specified. You can go as far back as 30 days ago, and can ask for up to a 48 hour window of time in a single request. You must be authenticated with at least the ReadUserData permission to access this endpoint.
*/
GetApplicationApiUsage(
public GetApplicationApiUsage(
applicationId: number,
queryString?: { end?: string; start?: string },
tokens?: Tokens
queryString: {
end?: string;
start?: string;
} | null,
tokens: ITokens
): Promise<APIResponse<ApiUsage>> {
const requestURL = formatQueryStrings(
`${this.url}/App/ApiUsage/${applicationId}/`,
queryString
);

var requestURL = formatQueryStrings(`${this.url}/App/ApiUsage/${applicationId}/`, queryString);
const authHeaders = parseAuthenticationHeaders(this.headers, tokens);

return request(requestURL, true, "GET", authHeaders);
}

/**
* Get list of applications created by Bungie.
* @returns List of applications created by Bungie.
* @returns Get list of applications created by Bungie.
*/
GetBungieApplications(): Promise<APIResponse<Application[]>> {
const requestURL = `${this.url}/App/FirstParty/`;
public GetBungieApplications(): Promise<APIResponse<Application[]>> {
var requestURL = `${this.url}/App/FirstParty/`;

return request(requestURL, true, "GET", this.headers);
}
Expand Down
18 changes: 7 additions & 11 deletions src/contents/communitycontent/index.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
import { request } from "../../adapters/http-request";
import { APIResponse } from "../../types/api";
import { PostSearchResponse } from "../../types/interface";
import { ForumTopicsCategoryFiltersEnum, CommunityContentSortMode, APIResponse, PostSearchResponse } from "../../types";

export class CommunityContent {
constructor(
private url: string,
private headers: { [key: string]: string }
) {}
constructor(private url: string, private headers: Record<string, string>) {}

/**
* Returns community content.
* @param mediaFilter The type of media to get
* @param page Zero based page
* @param sort The sort mode.
* @returns Community content.
* @returns Returns community content.
*/
GetCommunityContent(
mediaFilter: number,
public GetCommunityContent(
mediaFilter: ForumTopicsCategoryFiltersEnum,
page: number,
sort: string
sort: CommunityContentSortMode
): Promise<APIResponse<PostSearchResponse>> {
const requestURL = `${this.url}/CommunityContent/Get/${sort}/${mediaFilter}/${page}/`;
var requestURL = `${this.url}/CommunityContent/Get/${sort}/${mediaFilter}/${page}/`;

return request(requestURL, true, "GET", this.headers);
}
Expand Down
108 changes: 55 additions & 53 deletions src/contents/content/index.ts
Original file line number Diff line number Diff line change
@@ -1,116 +1,115 @@
import { request } from "../../adapters/http-request";
import { formatQueryStrings } from "../../adapters/utils";
import { APIResponse } from "../../types/api";
import {
ContentItemPublicContract,
APIResponse,
ContentTypeDescription,
NewsArticleRssResponse,
ContentItemPublicContract,
SearchResultOfContentItemPublicContract,
} from "../../types/interface";
NewsArticleRssResponse,
} from "../../types";

export class Content {
constructor(
private url: string,
private headers: { [key: string]: string }
) {}
constructor(private url: string, private headers: Record<string, string>) {}

/**
* Gets an object describing a particular variant of content.
* @param type
* @returns An object describing a particular variant of content.
* @returns Gets an object describing a particular variant of content.
*/
GetContentType(type: string): Promise<APIResponse<ContentTypeDescription>> {
const requestURL = `${this.url}/Content/GetContentType/${type}/`;
public GetContentType(type: string): Promise<APIResponse<ContentTypeDescription>> {
var requestURL = `${this.url}/Content/GetContentType/${type}/`;

return request(requestURL, true, "GET", this.headers);
}

/**
* Returns a content item referenced by id
* @param head false
* @param id
* @param locale
* @param queryString The optional querystrings that can be applied.
* @returns A content item referenced by id
* @returns Returns a content item referenced by id
*/
GetContentById(
public GetContentById(
id: string,
locale: string,
queryString?: { head: boolean }
queryString: {
head?: boolean;
} | null
): Promise<APIResponse<ContentItemPublicContract>> {
const requestURL = formatQueryStrings(
`${this.url}/Content/GetContentById/${id}/${locale}/`,
queryString
);
var requestURL = formatQueryStrings(`${this.url}/Content/GetContentById/${id}/${locale}/`, queryString);

return request(requestURL, true, "GET", this.headers);
}

/**
* Returns the newest item that matches a given tag and Content Type.
* @param head Not used.
* @param locale
* @param tag
* @param type
* @param queryString The optional querystrings that can be applied.
* @returns The newest item that matches a given tag and Content Type.
* @returns Returns the newest item that matches a given tag and Content Type.
*/
GetContentByTagAndType(
public GetContentByTagAndType(
locale: string,
tag: string,
type: string,
queryString?: { head: boolean }
queryString: {
head?: boolean;
} | null
): Promise<APIResponse<ContentItemPublicContract>> {
const requestURL = formatQueryStrings(
`${this.url}/Content/GetContentByTagAndType/${tag}/${type}/${locale}/`,
queryString
);
var requestURL = formatQueryStrings(`${this.url}/Content/GetContentByTagAndType/${tag}/${type}/${locale}/`, queryString);

return request(requestURL, true, "GET", this.headers);
}

/**
* Gets content based on querystring information passed in.
* 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 queryString The optional querystrings that can be applied.
* @returns Content based on querystring information passed in.
* @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(
public SearchContentWithText(
locale: string,
queryString?: {
queryString: {
ctype?: string;
currentpage?: number;
head?: boolean;
searchtext?: string;
source?: string;
tag?: string;
}
} | null
): Promise<APIResponse<SearchResultOfContentItemPublicContract>> {
const requestURL = formatQueryStrings(
`${this.url}/Content/Search/${locale}/`,
queryString
);
var requestURL = formatQueryStrings(`${this.url}/Content/Search/${locale}/`, queryString);

return request(requestURL, true, "GET", this.headers);
}

/**
* 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
* @param queryString The optional querystrings that can be applied.
* @returns For Content Items that match the given Tag and Content Type.
* @returns Searches for Content Items that match the given Tag and Content Type.
*/
SearchContentByTagAndType(
public SearchContentByTagAndType(
locale: string,
tag: string,
type: string,
queryString?: {
queryString: {
currentpage?: number;
head?: boolean;
itemsperpage?: number;
}
} | null
): Promise<APIResponse<SearchResultOfContentItemPublicContract>> {
const requestURL = formatQueryStrings(
var requestURL = formatQueryStrings(
`${this.url}/Content/SearchContentByTagAndType/${tag}/${type}/${locale}/`,
queryString
);
Expand All @@ -122,26 +121,29 @@ export class Content {
* Search for Help Articles.
* @param searchtext
* @param size
* @returns Help Articles.
* @returns Search for Help Articles.
*/
SearchHelpArticles(
searchtext: string,
size: string
): Promise<APIResponse<object>> {
const requestURL = `${this.url}/Content/SearchHelpArticles/${searchtext}/${size}/`;
public SearchHelpArticles(searchtext: string, size: string): Promise<APIResponse<object>> {
var requestURL = `${this.url}/Content/SearchHelpArticles/${searchtext}/${size}/`;

return request(requestURL, true, "GET", this.headers);
}

/**
* 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 A JSON string response that is the RSS feed for news articles.
* @returns Returns a JSON string response that is the RSS feed for news articles.
*/
RssNewsArticles(
pageToken: string
public RssNewsArticles(
pageToken: string,
queryString: {
categoryfilter?: string;
includebody?: boolean;
} | null
): Promise<APIResponse<NewsArticleRssResponse>> {
const requestURL = `${this.url}/Content/Rss/NewsArticles/${pageToken}/`;
var requestURL = formatQueryStrings(`${this.url}/Content/Rss/NewsArticles/${pageToken}/`, queryString);

return request(requestURL, true, "GET", this.headers);
}
Expand Down
51 changes: 22 additions & 29 deletions src/contents/core/index.ts
Original file line number Diff line number Diff line change
@@ -1,61 +1,54 @@
import { request } from "../../adapters/http-request";
import { formatQueryStrings } from "../../adapters/utils";
import { APIResponse } from "../../types/api";
import {
CoreSettingsConfiguration,
CoreSystem,
GlobalAlert,
} from "../../types/interface";
import { APIResponse, CoreSettingsConfiguration, CoreSystem, GlobalAlert } from "../../types";

export class Core {
constructor(
private url: string,
private headers: { [key: string]: string }
) {}
constructor(private url: string, private headers: Record<string, string>) {}

/**
* List of available localization cultures
* @returns List of available localization cultures
* @returns List of available localization cultures
*/
GetAvailableLocales(): Promise<APIResponse<{ [key: string]: string }>> {
const requestURL = `${this.url}/GetAvailableLocales/`;
public GetAvailableLocales(): Promise<APIResponse<Record<string, string>>> {
var requestURL = `${this.url}/GetAvailableLocales/`;

return request(requestURL, true, "GET", this.headers);
}

/**
* Get the common settings used by the Bungie.Net environment.
* @returns The common settings used by the Bungie.Net environment.
* @returns Get the common settings used by the Bungie.Net environment.
*/
GetCommonSettings(): Promise<APIResponse<CoreSettingsConfiguration>> {
const requestURL = `${this.url}/Settings/`;
public GetCommonSettings(): Promise<APIResponse<CoreSettingsConfiguration>> {
var requestURL = `${this.url}/Settings/`;

return request(requestURL, true, "GET", this.headers);
}

/**
* Get the user-specific system overrides that should be respected alongside common systems.
* @returns The user-specific system overrides that should be respected alongside common systems.
* @returns Get the user-specific system overrides that should be respected alongside common systems.
*/
GetUserSystemOverrides(): Promise<
APIResponse<{ [key: string]: CoreSystem }>
> {
const requestURL = `${this.url}/UserSystemOverrides/`;
public GetUserSystemOverrides(): Promise<APIResponse<Record<string, CoreSystem>>> {
var requestURL = `${this.url}/UserSystemOverrides/`;

return request(requestURL, true, "GET", this.headers);
}

/**
* Gets any active global alert for display in the forum banners, help pages, etc. Usually used for DOC alerts.
* @returns Any active global alert for display in the forum banners, help pages, etc. Usually used for DOC alerts.
* @param includestreaming Determines whether Streaming Alerts are included in results
* @returns Gets any active global alert for display in the forum banners, help pages, etc. Usually used for DOC alerts.
*/
GetGlobalAlerts(queryString?: {
includestreaming: boolean;
}): Promise<APIResponse<GlobalAlert[]>> {
const requestURL = formatQueryStrings(
`${this.url}/GlobalAlerts/`,
queryString
);
public GetGlobalAlerts(
queryString: {
includestreaming?: boolean;
} | null
): Promise<APIResponse<GlobalAlert[]>> {
var requestURL = formatQueryStrings(`${this.url}/GlobalAlerts/`, queryString);

return request(requestURL, true, "GET", this.headers);
}
Expand Down
Loading

0 comments on commit 28b25b8

Please sign in to comment.