Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better types for HttpClient #68

Merged
merged 3 commits into from
Jul 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions generated-src/app/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ export interface GetApplicationApiUsageParams {
* this endpoint.
*/
export function getApplicationApiUsage(http: HttpClient, params: GetApplicationApiUsageParams): Promise<ServerResponse<ApiUsage>> {
return get(http, `${API_BASE}ApiUsage/${params.applicationId}/`, {
end: params.end,
start: params.start
});
const strParams: Record<string, string> = {};
if (params.end !== undefined) { strParams.end = params.end; }
if (params.start !== undefined) { strParams.start = params.start; }
return get(http, `${API_BASE}ApiUsage/${params.applicationId}/`, strParams);
}

/** Get list of applications created by Bungie. */
Expand Down
46 changes: 23 additions & 23 deletions generated-src/content/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ export interface GetContentByIdParams {

/** Returns a content item referenced by id */
export function getContentById(http: HttpClient, params: GetContentByIdParams): Promise<ServerResponse<ContentItemPublicContract>> {
return get(http, `${API_BASE}GetContentById/${params.id}/${params.locale}/`, {
head: params.head
});
const strParams: Record<string, string> = {};
if (params.head !== undefined) { strParams.head = params.head.toString(); }
return get(http, `${API_BASE}GetContentById/${params.id}/${params.locale}/`, strParams);
}

export interface GetContentByTagAndTypeParams {
Expand All @@ -57,9 +57,9 @@ export interface GetContentByTagAndTypeParams {

/** Returns the newest item that matches a given tag and Content Type. */
export function getContentByTagAndType(http: HttpClient, params: GetContentByTagAndTypeParams): Promise<ServerResponse<ContentItemPublicContract>> {
return get(http, `${API_BASE}GetContentByTagAndType/${params.tag}/${params.type}/${params.locale}/`, {
head: params.head
});
const strParams: Record<string, string> = {};
if (params.head !== undefined) { strParams.head = params.head.toString(); }
return get(http, `${API_BASE}GetContentByTagAndType/${params.tag}/${params.type}/${params.locale}/`, strParams);
}

export interface SearchContentWithTextParams {
Expand All @@ -83,14 +83,14 @@ export interface SearchContentWithTextParams {
* and text search capabilities.
*/
export function searchContentWithText(http: HttpClient, params: SearchContentWithTextParams): Promise<ServerResponse<SearchResultOfContentItemPublicContract>> {
return get(http, `${API_BASE}Search/${params.locale}/`, {
ctype: params.ctype,
currentpage: params.currentpage,
head: params.head,
searchtext: params.searchtext,
source: params.source,
tag: params.tag
});
const strParams: Record<string, string> = {};
if (params.ctype !== undefined) { strParams.ctype = params.ctype; }
if (params.currentpage !== undefined) { strParams.currentpage = params.currentpage.toString(); }
if (params.head !== undefined) { strParams.head = params.head.toString(); }
if (params.searchtext !== undefined) { strParams.searchtext = params.searchtext; }
if (params.source !== undefined) { strParams.source = params.source; }
if (params.tag !== undefined) { strParams.tag = params.tag; }
return get(http, `${API_BASE}Search/${params.locale}/`, strParams);
}

export interface SearchContentByTagAndTypeParams {
Expand All @@ -107,11 +107,11 @@ export interface SearchContentByTagAndTypeParams {

/** Searches for Content Items that match the given Tag and Content Type. */
export function searchContentByTagAndType(http: HttpClient, params: SearchContentByTagAndTypeParams): Promise<ServerResponse<SearchResultOfContentItemPublicContract>> {
return get(http, `${API_BASE}SearchContentByTagAndType/${params.tag}/${params.type}/${params.locale}/`, {
currentpage: params.currentpage,
head: params.head,
itemsperpage: params.itemsperpage
});
const strParams: Record<string, string> = {};
if (params.currentpage !== undefined) { strParams.currentpage = params.currentpage.toString(); }
if (params.head !== undefined) { strParams.head = params.head.toString(); }
if (params.itemsperpage !== undefined) { strParams.itemsperpage = params.itemsperpage.toString(); }
return get(http, `${API_BASE}SearchContentByTagAndType/${params.tag}/${params.type}/${params.locale}/`, strParams);
}

export interface SearchHelpArticlesParams {
Expand All @@ -135,8 +135,8 @@ export interface RssNewsArticlesParams {

/** Returns a JSON string response that is the RSS feed for news articles. */
export function rssNewsArticles(http: HttpClient, params: RssNewsArticlesParams): Promise<ServerResponse<NewsArticleRssResponse>> {
return get(http, `${API_BASE}Rss/NewsArticles/${params.pageToken}/`, {
categoryfilter: params.categoryfilter,
includebody: params.includebody
});
const strParams: Record<string, string> = {};
if (params.categoryfilter !== undefined) { strParams.categoryfilter = params.categoryfilter; }
if (params.includebody !== undefined) { strParams.includebody = params.includebody.toString(); }
return get(http, `${API_BASE}Rss/NewsArticles/${params.pageToken}/`, strParams);
}
6 changes: 3 additions & 3 deletions generated-src/core/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export interface GetGlobalAlertsParams {
* Usually used for DOC alerts.
*/
export function getGlobalAlerts(http: HttpClient, params: GetGlobalAlertsParams): Promise<ServerResponse<GlobalAlert[]>> {
return get(http, `${API_BASE}GlobalAlerts/`, {
includestreaming: params.includestreaming
});
const strParams: Record<string, string> = {};
if (params.includestreaming !== undefined) { strParams.includestreaming = params.includestreaming.toString(); }
return get(http, `${API_BASE}GlobalAlerts/`, strParams);
}
Loading