Skip to content

Commit a2aef6e

Browse files
authored
Merge pull request #68 from DestinyItemManager/better-httpclient-types
Better types for HttpClient
2 parents a395a8a + f5f9e05 commit a2aef6e

File tree

29 files changed

+512
-385
lines changed

29 files changed

+512
-385
lines changed

generated-src/app/api.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ export interface GetApplicationApiUsageParams {
3838
* this endpoint.
3939
*/
4040
export function getApplicationApiUsage(http: HttpClient, params: GetApplicationApiUsageParams): Promise<ServerResponse<ApiUsage>> {
41-
return get(http, `${API_BASE}ApiUsage/${params.applicationId}/`, {
42-
end: params.end,
43-
start: params.start
44-
});
41+
const strParams: Record<string, string> = {};
42+
if (params.end !== undefined) { strParams.end = params.end; }
43+
if (params.start !== undefined) { strParams.start = params.start; }
44+
return get(http, `${API_BASE}ApiUsage/${params.applicationId}/`, strParams);
4545
}
4646

4747
/** Get list of applications created by Bungie. */

generated-src/content/api.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ export interface GetContentByIdParams {
4242

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

5050
export interface GetContentByTagAndTypeParams {
@@ -57,9 +57,9 @@ export interface GetContentByTagAndTypeParams {
5757

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

6565
export interface SearchContentWithTextParams {
@@ -83,14 +83,14 @@ export interface SearchContentWithTextParams {
8383
* and text search capabilities.
8484
*/
8585
export function searchContentWithText(http: HttpClient, params: SearchContentWithTextParams): Promise<ServerResponse<SearchResultOfContentItemPublicContract>> {
86-
return get(http, `${API_BASE}Search/${params.locale}/`, {
87-
ctype: params.ctype,
88-
currentpage: params.currentpage,
89-
head: params.head,
90-
searchtext: params.searchtext,
91-
source: params.source,
92-
tag: params.tag
93-
});
86+
const strParams: Record<string, string> = {};
87+
if (params.ctype !== undefined) { strParams.ctype = params.ctype; }
88+
if (params.currentpage !== undefined) { strParams.currentpage = params.currentpage.toString(); }
89+
if (params.head !== undefined) { strParams.head = params.head.toString(); }
90+
if (params.searchtext !== undefined) { strParams.searchtext = params.searchtext; }
91+
if (params.source !== undefined) { strParams.source = params.source; }
92+
if (params.tag !== undefined) { strParams.tag = params.tag; }
93+
return get(http, `${API_BASE}Search/${params.locale}/`, strParams);
9494
}
9595

9696
export interface SearchContentByTagAndTypeParams {
@@ -107,11 +107,11 @@ export interface SearchContentByTagAndTypeParams {
107107

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

117117
export interface SearchHelpArticlesParams {
@@ -135,8 +135,8 @@ export interface RssNewsArticlesParams {
135135

136136
/** Returns a JSON string response that is the RSS feed for news articles. */
137137
export function rssNewsArticles(http: HttpClient, params: RssNewsArticlesParams): Promise<ServerResponse<NewsArticleRssResponse>> {
138-
return get(http, `${API_BASE}Rss/NewsArticles/${params.pageToken}/`, {
139-
categoryfilter: params.categoryfilter,
140-
includebody: params.includebody
141-
});
138+
const strParams: Record<string, string> = {};
139+
if (params.categoryfilter !== undefined) { strParams.categoryfilter = params.categoryfilter; }
140+
if (params.includebody !== undefined) { strParams.includebody = params.includebody.toString(); }
141+
return get(http, `${API_BASE}Rss/NewsArticles/${params.pageToken}/`, strParams);
142142
}

generated-src/core/api.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export interface GetGlobalAlertsParams {
5151
* Usually used for DOC alerts.
5252
*/
5353
export function getGlobalAlerts(http: HttpClient, params: GetGlobalAlertsParams): Promise<ServerResponse<GlobalAlert[]>> {
54-
return get(http, `${API_BASE}GlobalAlerts/`, {
55-
includestreaming: params.includestreaming
56-
});
54+
const strParams: Record<string, string> = {};
55+
if (params.includestreaming !== undefined) { strParams.includestreaming = params.includestreaming.toString(); }
56+
return get(http, `${API_BASE}GlobalAlerts/`, strParams);
5757
}

0 commit comments

Comments
 (0)