Skip to content

Commit 812da36

Browse files
committed
ECWID-161269 - made the field credentials temporarily optional
1 parent 55b0e8e commit 812da36

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

src/main/kotlin/com/ecwid/apiclient/v3/ApiClientHelper.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private val REQUEST_ID_CHARACTERS = ('a'..'z') + ('A'..'Z') + ('0'..'9')
4040

4141
class ApiClientHelper private constructor(
4242
private val apiServerDomain: ApiServerDomain,
43-
private val credentials: ApiCredentials,
43+
private val credentials: ApiCredentials?,
4444
private val loggingSettings: LoggingSettings,
4545
val httpTransport: HttpTransport,
4646
val jsonTransformer: JsonTransformer,
@@ -51,7 +51,7 @@ class ApiClientHelper private constructor(
5151

5252
constructor(
5353
apiServerDomain: ApiServerDomain,
54-
storeCredentials: ApiStoreCredentials,
54+
storeCredentials: ApiStoreCredentials?,
5555
loggingSettings: LoggingSettings,
5656
httpTransport: HttpTransport,
5757
jsonTransformerProvider: JsonTransformerProvider
@@ -65,7 +65,7 @@ class ApiClientHelper private constructor(
6565

6666
constructor(
6767
apiServerDomain: ApiServerDomain,
68-
credentials: ApiCredentials,
68+
credentials: ApiCredentials?,
6969
loggingSettings: LoggingSettings,
7070
httpTransport: HttpTransport,
7171
jsonTransformerProvider: JsonTransformerProvider
@@ -79,7 +79,7 @@ class ApiClientHelper private constructor(
7979

8080
constructor(
8181
apiServerDomain: ApiServerDomain,
82-
credentials: ApiCredentials,
82+
credentials: ApiCredentials?,
8383
loggingSettings: LoggingSettings,
8484
httpTransport: HttpTransport,
8585
jsonTransformerProvider: JsonTransformerProvider,
@@ -281,7 +281,11 @@ class ApiClientHelper private constructor(
281281
if (requestKind != null) {
282282
it.withRequestKind(requestKind)
283283
} else {
284-
it.withCredentials(credentials)
284+
if (credentials != null) {
285+
it.withCredentials(credentials)
286+
} else {
287+
it
288+
}
285289
}
286290
}
287291
return when (method) {
@@ -328,7 +332,7 @@ class ApiClientHelper private constructor(
328332
val encodedPath = if (requestKind != null) {
329333
requestKind.buildBaseEndpointPath() + "/" + buildEndpointPath(pathSegments)
330334
} else {
331-
buildBaseEndpointPath(credentials) + "/" + buildEndpointPath(pathSegments)
335+
credentials?.let { buildBaseEndpointPath(it) } + "/" + buildEndpointPath(pathSegments)
332336
}
333337
return uri.toString() + encodedPath
334338
}

0 commit comments

Comments
 (0)