@@ -21,26 +21,27 @@ export function create{{#lambda.titlecase}}{{apiName}}{{/lambda.titlecase}}({
21
21
...options
22
22
}: CreateClientOptions{ {#hasRegionalHost} } & { region{{#fallbackToAliasHost} }?{ {/fallbackToAliasHost} }: Region }{ {/hasRegionalHost} }) {
23
23
const auth = createAuth(appIdOption, apiKeyOption, authMode);
24
+ const transporter = createTransporter({
25
+ hosts: getDefaultHosts({{#hostWithAppID} }appIdOption{ {/hostWithAppID} }{ {#hasRegionalHost} }regionOption{ {/hasRegionalHost} }),
26
+ ...options,
27
+ algoliaAgent: getAlgoliaAgent({
28
+ algoliaAgents,
29
+ client: ' {{{algoliaAgent}}}' ,
30
+ version: apiClientVersion,
31
+ } ),
32
+ baseHeaders: {
33
+ ' content-type' : ' text/plain' ,
34
+ ...auth.headers(),
35
+ ...options.baseHeaders,
36
+ } ,
37
+ baseQueryParameters: {
38
+ ...auth.queryParameters(),
39
+ ...options.baseQueryParameters,
40
+ } ,
41
+ });
24
42
25
43
return {
26
- transporter: createTransporter({
27
- hosts: getDefaultHosts({{#hostWithAppID} }appIdOption{ {/hostWithAppID} }{ {#hasRegionalHost} }regionOption{ {/hasRegionalHost} }),
28
- ...options,
29
- algoliaAgent: getAlgoliaAgent({
30
- algoliaAgents,
31
- client: ' {{{algoliaAgent}}}' ,
32
- version: apiClientVersion,
33
- } ),
34
- baseHeaders: {
35
- ' content-type' : ' text/plain' ,
36
- ...auth.headers(),
37
- ...options.baseHeaders,
38
- } ,
39
- baseQueryParameters: {
40
- ...auth.queryParameters(),
41
- ...options.baseQueryParameters,
42
- } ,
43
- }),
44
+ transporter,
44
45
45
46
/**
46
47
* The `appId` currently in use.
@@ -52,16 +53,16 @@ export function create{{#lambda.titlecase}}{{apiName}}{{/lambda.titlecase}}({
52
53
*/
53
54
clearCache(): Promise< void> {
54
55
return Promise.all([
55
- this. transporter.requestsCache.clear(),
56
- this. transporter.responsesCache.clear(),
56
+ transporter.requestsCache.clear(),
57
+ transporter.responsesCache.clear(),
57
58
]).then(() => undefined);
58
59
} ,
59
60
60
61
/**
61
62
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
62
63
*/
63
64
get _ua(): string {
64
- return this. transporter.algoliaAgent.value;
65
+ return transporter.algoliaAgent.value;
65
66
} ,
66
67
67
68
/**
@@ -71,7 +72,7 @@ export function create{{#lambda.titlecase}}{{apiName}}{{/lambda.titlecase}}({
71
72
* @param version - The version of the agent.
72
73
*/
73
74
addAlgoliaAgent(segment: string, version?: string): void {
74
- this. transporter.algoliaAgent.add({ segment, version } );
75
+ transporter.algoliaAgent.add({ segment, version } );
75
76
},
76
77
77
78
/**
@@ -82,9 +83,9 @@ export function create{{#lambda.titlecase}}{{apiName}}{{/lambda.titlecase}}({
82
83
*/
83
84
setClientApiKey({ apiKey } : { apiKey: string } ): void {
84
85
if (! authMode || authMode === ' WithinHeaders' ) {
85
- this. transporter.baseHeaders[' x-algolia-api-key' ] = apiKey;
86
+ transporter.baseHeaders[' x-algolia-api-key' ] = apiKey;
86
87
} else {
87
- this. transporter.baseQueryParameters[' x-algolia-api-key' ] = apiKey;
88
+ transporter.baseQueryParameters[' x-algolia-api-key' ] = apiKey;
88
89
}
89
90
},
90
91
@@ -156,7 +157,7 @@ export function create{{#lambda.titlecase}}{{apiName}}{{/lambda.titlecase}}({
156
157
{ {/vendorExtensions} }
157
158
};
158
159
159
- return this. transporter.request(request, requestOptions);
160
+ return transporter.request(request, requestOptions);
160
161
},
161
162
162
163
{ {/operation} }
0 commit comments