@@ -43,7 +43,8 @@ class ApiClientHelper private constructor(
4343 private val credentials : ApiCredentials ,
4444 private val loggingSettings : LoggingSettings ,
4545 val httpTransport : HttpTransport ,
46- val jsonTransformer : JsonTransformer
46+ val jsonTransformer : JsonTransformer ,
47+ private val requestKind : RequestKind ? = null ,
4748) {
4849
4950 private val log = Logger .getLogger(this ::class .qualifiedName)
@@ -76,6 +77,22 @@ class ApiClientHelper private constructor(
7677 jsonTransformer = jsonTransformerProvider.build(createPolymorphicTypeList())
7778 )
7879
80+ constructor (
81+ apiServerDomain: ApiServerDomain ,
82+ credentials: ApiCredentials ,
83+ loggingSettings: LoggingSettings ,
84+ httpTransport: HttpTransport ,
85+ jsonTransformerProvider: JsonTransformerProvider ,
86+ requestKind: RequestKind ? ,
87+ ) : this (
88+ apiServerDomain = apiServerDomain,
89+ credentials = credentials,
90+ loggingSettings = loggingSettings,
91+ httpTransport = httpTransport,
92+ jsonTransformer = jsonTransformerProvider.build(createPolymorphicTypeList()),
93+ requestKind = requestKind,
94+ )
95+
7996 @PublishedApi
8097 internal fun <V > makeRequestInt (request : ApiRequest , responseParser : ResponseParser <V >, responseFieldsOverride : ResponseFields ? = null): V {
8198 val requestId = generateRequestId()
@@ -260,7 +277,12 @@ class ApiClientHelper private constructor(
260277 internal fun RequestInfo.toHttpRequest (requestId : String , responseFieldsOverride : ResponseFields ? ): HttpRequest {
261278 val uri = createApiEndpointUri(pathSegments)
262279 val params = if (responseFieldsOverride != null ) params.withResponseFieldsParam(responseFieldsOverride) else params
263- val headers = headers.withRequestId(requestId).withCredentials(credentials)
280+ val headers = headers.withRequestId(requestId)
281+ if (requestKind != null ) {
282+ headers.withRequestKind(requestKind)
283+ } else {
284+ headers.withCredentials(credentials)
285+ }
264286
265287 return when (method) {
266288 HttpMethod .GET -> HttpRequest .HttpGetRequest (
@@ -302,7 +324,12 @@ class ApiClientHelper private constructor(
302324 null ,
303325 null
304326 )
305- val encodedPath = buildBaseEndpointPath(credentials) + " /" + buildEndpointPath(pathSegments)
327+
328+ val encodedPath = if (requestKind != null ) {
329+ requestKind.buildBaseEndpointPath() + " /" + buildEndpointPath(pathSegments)
330+ } else {
331+ buildBaseEndpointPath(credentials) + " /" + buildEndpointPath(pathSegments)
332+ }
306333 return uri.toString() + encodedPath
307334 }
308335
@@ -443,6 +470,11 @@ internal fun Map<String, String>.withCredentials(credentials: ApiCredentials) =
443470 is ApiAppCredentials -> withAppCredentialsHeaders(credentials)
444471}
445472
473+ @PublishedApi
474+ internal fun Map <String , String >.withRequestKind (requestKind : RequestKind ) = toMutableMap().apply {
475+ putAll(requestKind.buildHeaders())
476+ }
477+
446478internal fun Map <String , String >.withResponseFieldsParam (responseFields : ResponseFields ): Map <String , String > {
447479 return if (responseFields.isAll()) {
448480 this - RESPONSE_FIELDS_PARAM_NAME
0 commit comments