Skip to content

Commit 8e97336

Browse files
author
Rodrigo Gomez Palacio
committed
fixup! Update existing cache key usage to use OptionalHeaders
1 parent b5ed03f commit 8e97336

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

OneSignalSDK/onesignal/core/src/main/java/com/onesignal/core/internal/backend/impl/ParamsBackendService.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import com.onesignal.core.internal.backend.InfluenceParamsObject
1313
import com.onesignal.core.internal.backend.ParamsObject
1414
import com.onesignal.core.internal.http.CacheKeys
1515
import com.onesignal.core.internal.http.IHttpClient
16-
import com.onesignal.core.internal.http.impl.OptionalHeaderValues
16+
import com.onesignal.core.internal.http.impl.OptionalHeaders
1717
import com.onesignal.debug.LogLevel
1818
import com.onesignal.debug.internal.logging.Logging
1919
import org.json.JSONObject
@@ -32,9 +32,7 @@ internal class ParamsBackendService(
3232
paramsUrl += "?player_id=$subscriptionId"
3333
}
3434

35-
val headers = OptionalHeaderValues()
36-
headers.cacheKey = CacheKeys.REMOTE_PARAMS
37-
val response = _http.get(paramsUrl, headers)
35+
val response = _http.get(paramsUrl, OptionalHeaders(cacheKey = CacheKeys.REMOTE_PARAMS))
3836

3937
if (!response.isSuccess) {
4038
throw BackendException(response.statusCode, response.payload, response.retryAfterSeconds)

OneSignalSDK/onesignal/core/src/test/java/com/onesignal/core/internal/http/HttpClientTests.kt

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package com.onesignal.core.internal.http
33
import com.onesignal.common.OneSignalUtils
44
import com.onesignal.core.internal.device.impl.InstallIdService
55
import com.onesignal.core.internal.http.impl.HttpClient
6-
import com.onesignal.core.internal.http.impl.OptionalHeaderValues
6+
import com.onesignal.core.internal.http.impl.OptionalHeaders
77
import com.onesignal.core.internal.time.impl.Time
88
import com.onesignal.debug.LogLevel
99
import com.onesignal.debug.internal.logging.Logging
@@ -89,11 +89,10 @@ class HttpClientTests : FunSpec({
8989
val httpClient = mocks.httpClient
9090

9191
// When
92-
val headerValues = OptionalHeaderValues()
93-
headerValues.cacheKey = "CACHE_KEY"
94-
val response1 = httpClient.get("URL", headerValues)
92+
val headers = OptionalHeaders(cacheKey = "CACHE_KEY")
93+
val response1 = httpClient.get("URL", headers)
9594
factory.mockResponse = mockResponse2
96-
val response2 = httpClient.get("URL", headerValues)
95+
val response2 = httpClient.get("URL", headers)
9796

9897
// Then
9998
response1.statusCode shouldBe 200
@@ -126,15 +125,14 @@ class HttpClientTests : FunSpec({
126125
val httpClient = mocks.httpClient
127126

128127
// When
129-
val headerValues = OptionalHeaderValues()
130-
headerValues.cacheKey = "CACHE_KEY"
131-
val response1 = httpClient.get("URL", headerValues)
128+
val headers = OptionalHeaders(cacheKey = "CACHE_KEY")
129+
val response1 = httpClient.get("URL", headers)
132130

133131
factory.mockResponse = mockResponse2
134-
val response2 = httpClient.get("URL", headerValues)
132+
val response2 = httpClient.get("URL", headers)
135133

136134
factory.mockResponse = mockResponse3
137-
val response3 = httpClient.get("URL", headerValues)
135+
val response3 = httpClient.get("URL", headers)
138136

139137
// Then
140138
response1.statusCode shouldBe 200

0 commit comments

Comments
 (0)