diff --git a/emarsys-firebase/src/androidTest/java/com/emarsys/fake/FakeFirebaseDependencyContainer.kt b/emarsys-firebase/src/androidTest/java/com/emarsys/fake/FakeFirebaseDependencyContainer.kt index 5f2e076c..f1ca76b9 100644 --- a/emarsys-firebase/src/androidTest/java/com/emarsys/fake/FakeFirebaseDependencyContainer.kt +++ b/emarsys-firebase/src/androidTest/java/com/emarsys/fake/FakeFirebaseDependencyContainer.kt @@ -56,7 +56,6 @@ import com.emarsys.mobileengage.push.NotificationInformationListenerProvider import com.emarsys.mobileengage.push.PushInternal import com.emarsys.mobileengage.push.PushTokenProvider import com.emarsys.mobileengage.push.SilentNotificationInformationListenerProvider -import com.emarsys.mobileengage.request.CoreCompletionHandlerRefreshTokenProxyProvider import com.emarsys.mobileengage.request.MobileEngageRequestModelFactory import com.emarsys.mobileengage.responsehandler.MobileEngageTokenResponseHandler import com.emarsys.mobileengage.service.mapper.RemoteMessageMapperFactory @@ -121,7 +120,6 @@ class FakeFirebaseDependencyContainer( override val appLifecycleObserver: AppLifecycleObserver = mock(), override val requestModelHelper: RequestModelHelper = mock(), override val sessionIdHolder: SessionIdHolder = mock(), - override val coreCompletionHandlerRefreshTokenProxyProvider: CoreCompletionHandlerRefreshTokenProxyProvider = mock(), override val mobileEngageRequestModelFactory: MobileEngageRequestModelFactory = mock(), override val mobileEngageSession: MobileEngageSession = mock(), override val activityLifecycleWatchdog: ActivityLifecycleWatchdog = mock(), diff --git a/emarsys-huawei/src/androidTest/java/com/emarsys/fake/FakeHuaweiDependencyContainer.kt b/emarsys-huawei/src/androidTest/java/com/emarsys/fake/FakeHuaweiDependencyContainer.kt index 24f0774f..72a443c9 100644 --- a/emarsys-huawei/src/androidTest/java/com/emarsys/fake/FakeHuaweiDependencyContainer.kt +++ b/emarsys-huawei/src/androidTest/java/com/emarsys/fake/FakeHuaweiDependencyContainer.kt @@ -56,7 +56,6 @@ import com.emarsys.mobileengage.push.NotificationInformationListenerProvider import com.emarsys.mobileengage.push.PushInternal import com.emarsys.mobileengage.push.PushTokenProvider import com.emarsys.mobileengage.push.SilentNotificationInformationListenerProvider -import com.emarsys.mobileengage.request.CoreCompletionHandlerRefreshTokenProxyProvider import com.emarsys.mobileengage.request.MobileEngageRequestModelFactory import com.emarsys.mobileengage.responsehandler.MobileEngageTokenResponseHandler import com.emarsys.mobileengage.service.mapper.RemoteMessageMapperFactory @@ -121,7 +120,6 @@ class FakeHuaweiDependencyContainer( override val appLifecycleObserver: AppLifecycleObserver = mock(), override val requestModelHelper: RequestModelHelper = mock(), override val sessionIdHolder: SessionIdHolder = mock(), - override val coreCompletionHandlerRefreshTokenProxyProvider: CoreCompletionHandlerRefreshTokenProxyProvider = mock(), override val mobileEngageRequestModelFactory: MobileEngageRequestModelFactory = mock(), override val mobileEngageSession: MobileEngageSession = mock(), override val activityLifecycleWatchdog: ActivityLifecycleWatchdog = mock(), diff --git a/emarsys-sdk/src/androidTest/java/com/emarsys/di/FakeDependencyContainer.kt b/emarsys-sdk/src/androidTest/java/com/emarsys/di/FakeDependencyContainer.kt index f6bb7f66..4edbea94 100644 --- a/emarsys-sdk/src/androidTest/java/com/emarsys/di/FakeDependencyContainer.kt +++ b/emarsys-sdk/src/androidTest/java/com/emarsys/di/FakeDependencyContainer.kt @@ -64,7 +64,7 @@ import com.emarsys.mobileengage.push.NotificationInformationListenerProvider import com.emarsys.mobileengage.push.PushInternal import com.emarsys.mobileengage.push.PushTokenProvider import com.emarsys.mobileengage.push.SilentNotificationInformationListenerProvider -import com.emarsys.mobileengage.request.CoreCompletionHandlerRefreshTokenProxyProvider +import com.emarsys.request.CoreCompletionHandlerRefreshTokenProxyProvider import com.emarsys.mobileengage.request.MobileEngageRequestModelFactory import com.emarsys.mobileengage.responsehandler.MobileEngageTokenResponseHandler import com.emarsys.mobileengage.service.mapper.RemoteMessageMapperFactory diff --git a/emarsys-sdk/src/main/java/com/emarsys/di/DefaultEmarsysComponent.kt b/emarsys-sdk/src/main/java/com/emarsys/di/DefaultEmarsysComponent.kt index 5b46a1e6..f21ebdb8 100644 --- a/emarsys-sdk/src/main/java/com/emarsys/di/DefaultEmarsysComponent.kt +++ b/emarsys-sdk/src/main/java/com/emarsys/di/DefaultEmarsysComponent.kt @@ -147,7 +147,7 @@ import com.emarsys.mobileengage.push.NotificationInformationListenerProvider import com.emarsys.mobileengage.push.PushInternal import com.emarsys.mobileengage.push.PushTokenProvider import com.emarsys.mobileengage.push.SilentNotificationInformationListenerProvider -import com.emarsys.mobileengage.request.CoreCompletionHandlerRefreshTokenProxyProvider +import com.emarsys.request.CoreCompletionHandlerRefreshTokenProxyProvider import com.emarsys.mobileengage.request.MobileEngageRequestModelFactory import com.emarsys.mobileengage.request.mapper.ContactTokenHeaderMapper import com.emarsys.mobileengage.request.mapper.DefaultRequestHeaderMapper diff --git a/emarsys-sdk/src/main/java/com/emarsys/di/EmarsysComponent.kt b/emarsys-sdk/src/main/java/com/emarsys/di/EmarsysComponent.kt index 6e1d868f..146c07dc 100644 --- a/emarsys-sdk/src/main/java/com/emarsys/di/EmarsysComponent.kt +++ b/emarsys-sdk/src/main/java/com/emarsys/di/EmarsysComponent.kt @@ -16,6 +16,7 @@ import com.emarsys.predict.PredictApi import com.emarsys.predict.PredictRestrictedApi import com.emarsys.predict.di.PredictComponent import com.emarsys.push.PushApi +import com.emarsys.request.CoreCompletionHandlerRefreshTokenProxyProvider fun emarsys() = EmarsysComponent.instance ?: throw IllegalStateException("DependencyContainer has to be setup first!") @@ -92,4 +93,6 @@ interface EmarsysComponent : MobileEngageComponent, PredictComponent { val loggingEventService: EventServiceApi val isGooglePlayServiceAvailable: Boolean + + val coreCompletionHandlerRefreshTokenProxyProvider: CoreCompletionHandlerRefreshTokenProxyProvider } diff --git a/emarsys/src/androidTest/java/com/emarsys/fake/FakeEmarsysDependencyContainer.kt b/emarsys/src/androidTest/java/com/emarsys/fake/FakeEmarsysDependencyContainer.kt index c5d066a7..592d6d17 100644 --- a/emarsys/src/androidTest/java/com/emarsys/fake/FakeEmarsysDependencyContainer.kt +++ b/emarsys/src/androidTest/java/com/emarsys/fake/FakeEmarsysDependencyContainer.kt @@ -57,7 +57,6 @@ import com.emarsys.mobileengage.push.NotificationInformationListenerProvider import com.emarsys.mobileengage.push.PushInternal import com.emarsys.mobileengage.push.PushTokenProvider import com.emarsys.mobileengage.push.SilentNotificationInformationListenerProvider -import com.emarsys.mobileengage.request.CoreCompletionHandlerRefreshTokenProxyProvider import com.emarsys.mobileengage.request.MobileEngageRequestModelFactory import com.emarsys.mobileengage.responsehandler.MobileEngageTokenResponseHandler import com.emarsys.mobileengage.service.mapper.RemoteMessageMapperFactory @@ -122,7 +121,6 @@ class FakeEmarsysDependencyContainer( override val appLifecycleObserver: AppLifecycleObserver = mock(), override val requestModelHelper: RequestModelHelper = mock(), override val sessionIdHolder: SessionIdHolder = mock(), - override val coreCompletionHandlerRefreshTokenProxyProvider: CoreCompletionHandlerRefreshTokenProxyProvider = mock(), override val mobileEngageRequestModelFactory: MobileEngageRequestModelFactory = mock(), override val mobileEngageSession: MobileEngageSession = mock(), override val activityLifecycleWatchdog: ActivityLifecycleWatchdog = mock(), diff --git a/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/request/CoreCompletionHandlerRefreshTokenProxyProviderTest.kt b/emarsys/src/androidTest/java/com/emarsys/request/CoreCompletionHandlerRefreshTokenProxyProviderTest.kt similarity index 90% rename from mobile-engage/src/androidTest/java/com/emarsys/mobileengage/request/CoreCompletionHandlerRefreshTokenProxyProviderTest.kt rename to emarsys/src/androidTest/java/com/emarsys/request/CoreCompletionHandlerRefreshTokenProxyProviderTest.kt index a1999a76..f04cc530 100644 --- a/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/request/CoreCompletionHandlerRefreshTokenProxyProviderTest.kt +++ b/emarsys/src/androidTest/java/com/emarsys/request/CoreCompletionHandlerRefreshTokenProxyProviderTest.kt @@ -1,4 +1,4 @@ -package com.emarsys.mobileengage.request +package com.emarsys.request import com.emarsys.core.CoreCompletionHandler @@ -8,6 +8,7 @@ import com.emarsys.core.request.factory.CoreCompletionHandlerMiddlewareProvider import com.emarsys.core.storage.StringStorage import com.emarsys.core.worker.CoreCompletionHandlerMiddleware import com.emarsys.core.worker.Worker +import com.emarsys.mobileengage.request.MobileEngageRequestModelFactory import com.emarsys.mobileengage.responsehandler.MobileEngageTokenResponseHandler import com.emarsys.mobileengage.util.RequestModelHelper import com.emarsys.testUtil.AnnotationSpec @@ -53,7 +54,7 @@ class CoreCompletionHandlerRefreshTokenProxyProviderTest : AnnotationSpec() { mockRequestModelFactory = mock() coreCompletionHandlerRefreshTokenProxyProvider = - CoreCompletionHandlerRefreshTokenProxyProvider( + com.emarsys.request.CoreCompletionHandlerRefreshTokenProxyProvider( mockCoreCompletionHandlerMiddlewareProvider, mockRestClient, mockContactTokenStorage, @@ -74,7 +75,7 @@ class CoreCompletionHandlerRefreshTokenProxyProviderTest : AnnotationSpec() { mockCoreCompletionHandler ) ).thenReturn(mockCoreCompletionHandlerMiddleware) - val expectedProxy = CoreCompletionHandlerRefreshTokenProxy( + val expectedProxy = com.emarsys.request.CoreCompletionHandlerRefreshTokenProxy( mockCoreCompletionHandlerMiddleware, mockRestClient, mockContactTokenStorage, @@ -100,7 +101,7 @@ class CoreCompletionHandlerRefreshTokenProxyProviderTest : AnnotationSpec() { val result = coreCompletionHandlerRefreshTokenProxyProvider.provideProxy(null, null) - result.javaClass shouldBe CoreCompletionHandlerRefreshTokenProxy::class.java + result.javaClass shouldBe com.emarsys.request.CoreCompletionHandlerRefreshTokenProxy::class.java } @Test @@ -118,6 +119,6 @@ class CoreCompletionHandlerRefreshTokenProxyProviderTest : AnnotationSpec() { mockCoreCompletionHandler ) - result.javaClass shouldBe CoreCompletionHandlerRefreshTokenProxy::class.java + result.javaClass shouldBe com.emarsys.request.CoreCompletionHandlerRefreshTokenProxy::class.java } } \ No newline at end of file diff --git a/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/request/CoreCompletionHandlerRefreshTokenProxyTest.kt b/emarsys/src/androidTest/java/com/emarsys/request/CoreCompletionHandlerRefreshTokenProxyTest.kt similarity index 98% rename from mobile-engage/src/androidTest/java/com/emarsys/mobileengage/request/CoreCompletionHandlerRefreshTokenProxyTest.kt rename to emarsys/src/androidTest/java/com/emarsys/request/CoreCompletionHandlerRefreshTokenProxyTest.kt index b379c905..34ea88d4 100644 --- a/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/request/CoreCompletionHandlerRefreshTokenProxyTest.kt +++ b/emarsys/src/androidTest/java/com/emarsys/request/CoreCompletionHandlerRefreshTokenProxyTest.kt @@ -1,4 +1,4 @@ -package com.emarsys.mobileengage.request +package com.emarsys.request import com.emarsys.core.CoreCompletionHandler @@ -7,6 +7,7 @@ import com.emarsys.core.request.model.RequestMethod import com.emarsys.core.request.model.RequestModel import com.emarsys.core.response.ResponseModel import com.emarsys.core.storage.Storage +import com.emarsys.mobileengage.request.MobileEngageRequestModelFactory import com.emarsys.mobileengage.responsehandler.MobileEngageTokenResponseHandler import com.emarsys.mobileengage.util.RequestModelHelper import com.emarsys.testUtil.AnnotationSpec diff --git a/mobile-engage/src/main/java/com/emarsys/mobileengage/request/CoreCompletionHandlerRefreshTokenProxy.kt b/emarsys/src/main/java/com/emarsys/request/CoreCompletionHandlerRefreshTokenProxy.kt similarity index 96% rename from mobile-engage/src/main/java/com/emarsys/mobileengage/request/CoreCompletionHandlerRefreshTokenProxy.kt rename to emarsys/src/main/java/com/emarsys/request/CoreCompletionHandlerRefreshTokenProxy.kt index 8ef63fc0..f2136867 100644 --- a/mobile-engage/src/main/java/com/emarsys/mobileengage/request/CoreCompletionHandlerRefreshTokenProxy.kt +++ b/emarsys/src/main/java/com/emarsys/request/CoreCompletionHandlerRefreshTokenProxy.kt @@ -1,10 +1,11 @@ -package com.emarsys.mobileengage.request +package com.emarsys.request import com.emarsys.core.CoreCompletionHandler import com.emarsys.core.request.RestClient import com.emarsys.core.request.model.RequestModel import com.emarsys.core.response.ResponseModel import com.emarsys.core.storage.Storage +import com.emarsys.mobileengage.request.MobileEngageRequestModelFactory import com.emarsys.mobileengage.responsehandler.MobileEngageTokenResponseHandler import com.emarsys.mobileengage.util.RequestModelHelper @@ -43,7 +44,8 @@ class CoreCompletionHandlerRefreshTokenProxy( reset() coreCompletionHandler.onError(id, response!!.copy(statusCode = 418)) } else if (responseModel.statusCode == 401 - && requestModelHelper.isMobileEngageRequest(responseModel.requestModel)) { + && requestModelHelper.isMobileEngageRequest(responseModel.requestModel) + ) { pushTokenStorage.remove() originalResponseModel = responseModel val refreshTokenRequestModel = requestModelFactory.createRefreshContactTokenRequest() diff --git a/mobile-engage/src/main/java/com/emarsys/mobileengage/request/CoreCompletionHandlerRefreshTokenProxyProvider.kt b/emarsys/src/main/java/com/emarsys/request/CoreCompletionHandlerRefreshTokenProxyProvider.kt similarity index 94% rename from mobile-engage/src/main/java/com/emarsys/mobileengage/request/CoreCompletionHandlerRefreshTokenProxyProvider.kt rename to emarsys/src/main/java/com/emarsys/request/CoreCompletionHandlerRefreshTokenProxyProvider.kt index 9f2064a1..34c939bf 100644 --- a/mobile-engage/src/main/java/com/emarsys/mobileengage/request/CoreCompletionHandlerRefreshTokenProxyProvider.kt +++ b/emarsys/src/main/java/com/emarsys/request/CoreCompletionHandlerRefreshTokenProxyProvider.kt @@ -1,4 +1,4 @@ -package com.emarsys.mobileengage.request +package com.emarsys.request import com.emarsys.core.CoreCompletionHandler import com.emarsys.core.Mockable @@ -7,6 +7,7 @@ import com.emarsys.core.request.factory.CompletionHandlerProxyProvider import com.emarsys.core.request.factory.CoreCompletionHandlerMiddlewareProvider import com.emarsys.core.storage.Storage import com.emarsys.core.worker.Worker +import com.emarsys.mobileengage.request.MobileEngageRequestModelFactory import com.emarsys.mobileengage.responsehandler.MobileEngageTokenResponseHandler import com.emarsys.mobileengage.util.RequestModelHelper diff --git a/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/fake/FakeMobileEngageDependencyContainer.kt b/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/fake/FakeMobileEngageDependencyContainer.kt index 27b498eb..27da3022 100644 --- a/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/fake/FakeMobileEngageDependencyContainer.kt +++ b/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/fake/FakeMobileEngageDependencyContainer.kt @@ -56,7 +56,6 @@ import com.emarsys.mobileengage.push.NotificationInformationListenerProvider import com.emarsys.mobileengage.push.PushInternal import com.emarsys.mobileengage.push.PushTokenProvider import com.emarsys.mobileengage.push.SilentNotificationInformationListenerProvider -import com.emarsys.mobileengage.request.CoreCompletionHandlerRefreshTokenProxyProvider import com.emarsys.mobileengage.request.MobileEngageRequestModelFactory import com.emarsys.mobileengage.responsehandler.MobileEngageTokenResponseHandler import com.emarsys.mobileengage.service.mapper.RemoteMessageMapperFactory @@ -121,7 +120,6 @@ class FakeMobileEngageDependencyContainer( override val appLifecycleObserver: AppLifecycleObserver = mock(), override val requestModelHelper: RequestModelHelper = mock(), override val sessionIdHolder: SessionIdHolder = mock(), - override val coreCompletionHandlerRefreshTokenProxyProvider: CoreCompletionHandlerRefreshTokenProxyProvider = mock(), override val mobileEngageRequestModelFactory: MobileEngageRequestModelFactory = mock(), override val mobileEngageSession: MobileEngageSession = mock(), override val activityLifecycleWatchdog: ActivityLifecycleWatchdog = mock(), diff --git a/mobile-engage/src/main/java/com/emarsys/mobileengage/di/MobileEngageComponent.kt b/mobile-engage/src/main/java/com/emarsys/mobileengage/di/MobileEngageComponent.kt index 3ec2feb2..39e2a629 100644 --- a/mobile-engage/src/main/java/com/emarsys/mobileengage/di/MobileEngageComponent.kt +++ b/mobile-engage/src/main/java/com/emarsys/mobileengage/di/MobileEngageComponent.kt @@ -33,7 +33,6 @@ import com.emarsys.mobileengage.push.NotificationInformationListenerProvider import com.emarsys.mobileengage.push.PushInternal import com.emarsys.mobileengage.push.PushTokenProvider import com.emarsys.mobileengage.push.SilentNotificationInformationListenerProvider -import com.emarsys.mobileengage.request.CoreCompletionHandlerRefreshTokenProxyProvider import com.emarsys.mobileengage.request.MobileEngageRequestModelFactory import com.emarsys.mobileengage.responsehandler.MobileEngageTokenResponseHandler import com.emarsys.mobileengage.service.mapper.RemoteMessageMapperFactory @@ -184,8 +183,6 @@ interface MobileEngageComponent : CoreComponent { val sessionIdHolder: SessionIdHolder - val coreCompletionHandlerRefreshTokenProxyProvider: CoreCompletionHandlerRefreshTokenProxyProvider - val mobileEngageRequestModelFactory: MobileEngageRequestModelFactory val mobileEngageSession: MobileEngageSession