Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

feat: Adds support to beagle gRPC library #1497

Merged
merged 11 commits into from
Apr 23, 2021
1 change: 0 additions & 1 deletion android/beagle/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,3 @@ task dokkaHugo(type: org.jetbrains.dokka.gradle.DokkaTask) {
dokkaHugoPlugin 'com.github.cotechde:dokka-hugo-plugin:master-SNAPSHOT'
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import kotlin.coroutines.resumeWithException
import java.net.URI

internal class BeagleApi(
private val httpClient: HttpClient? = BeagleEnvironment.beagleSdk.httpClient,
private val httpClient: HttpClient? = BeagleEnvironment.beagleSdk.httpClientFactory?.create()
?: BeagleEnvironment.beagleSdk.httpClient
) {
companion object {
const val BEAGLE_PLATFORM_HEADER_KEY = "beagle-platform"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright 2020 ZUP IT SERVICOS EM TECNOLOGIA E INOVACAO SA
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package br.com.zup.beagle.android.networking

interface HttpClientFactory {
fun create(): HttpClient
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import br.com.zup.beagle.android.logger.BeagleLogger
import br.com.zup.beagle.android.navigation.BeagleControllerReference
import br.com.zup.beagle.android.navigation.DeepLinkHandler
import br.com.zup.beagle.android.networking.HttpClient
import br.com.zup.beagle.android.networking.HttpClientFactory
import br.com.zup.beagle.android.networking.urlbuilder.UrlBuilder
import br.com.zup.beagle.android.operation.Operation
import br.com.zup.beagle.android.store.StoreHandler
Expand All @@ -47,6 +48,7 @@ interface BeagleSdk {
val deepLinkHandler: DeepLinkHandler?
val validatorHandler: ValidatorHandler?
val httpClient: HttpClient?
val httpClientFactory: HttpClientFactory?
val designSystem: DesignSystem?
val imageDownloader: BeagleImageDownloader?
val storeHandler: StoreHandler?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import br.com.zup.beagle.android.logger.BeagleLogger
import br.com.zup.beagle.android.navigation.BeagleControllerReference
import br.com.zup.beagle.android.navigation.DeepLinkHandler
import br.com.zup.beagle.android.networking.HttpClient
import br.com.zup.beagle.android.networking.HttpClientFactory
import br.com.zup.beagle.android.networking.urlbuilder.UrlBuilder
import br.com.zup.beagle.android.operation.Operation
import br.com.zup.beagle.android.setup.BeagleConfig
Expand Down Expand Up @@ -58,6 +59,8 @@ class MyBeagleSetup(override val analyticsProvider: AnalyticsProvider? = null) :

override val httpClient: HttpClient? = null

override val httpClientFactory: HttpClientFactory? = null

override val designSystem: DesignSystem? = null

override val imageDownloader: BeagleImageDownloader? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import br.com.zup.beagle.android.logger.BeagleLogger
import br.com.zup.beagle.android.navigation.BeagleControllerReference
import br.com.zup.beagle.android.navigation.DeepLinkHandler
import br.com.zup.beagle.android.networking.HttpClient
import br.com.zup.beagle.android.networking.HttpClientFactory
import br.com.zup.beagle.android.networking.urlbuilder.UrlBuilder
import br.com.zup.beagle.android.operation.Operation
import br.com.zup.beagle.android.setup.BeagleConfig
Expand Down Expand Up @@ -58,6 +59,8 @@ class MyBeagleSetup : BeagleSdk {

override val httpClient: HttpClient? = null

override val httpClientFactory: HttpClientFactory? = null

override val designSystem: DesignSystem? = null

override val imageDownloader: BeagleImageDownloader? = null
Expand Down
3 changes: 3 additions & 0 deletions android/processor-shared-code/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import br.com.zup.beagle.Dependencies
apply plugin: 'kotlin'
apply from: "./../../jacoco.gradle"

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

dependencies {
implementation Dependencies.GeneralLibraries.kotlin
implementation Dependencies.ProcessorLibraries.kotlinPoet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ val HTTP_CLIENT_HANDLER = BeagleClass(
"br.com.zup.beagle.android.networking",
"HttpClient"
)
val HTTP_CLIENT_FACTORY_HANDLER = BeagleClass(
"br.com.zup.beagle.android.networking",
"HttpClientFactory"
)
val VALIDATOR_HANDLER = BeagleClass(
"br.com.zup.beagle.android.components.form.core",
"ValidatorHandler"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ internal data class PropertySpecifications(
var deepLinkHandler: TypeElement? = null,
var formLocalActionHandler: TypeElement? = null,
var httpClient: TypeElement? = null,
var httpClientFactory: TypeElement? = null,
var designSystem: TypeElement? = null,
var defaultBeagleActivity: TypeElement? = null,
var beagleActivities: List<TypeElement>? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import br.com.zup.beagle.android.compiler.DESIGN_SYSTEM
import br.com.zup.beagle.android.compiler.ANALYTICS
import br.com.zup.beagle.android.compiler.ANALYTICS_PROVIDER
import br.com.zup.beagle.android.compiler.CONTROLLER_REFERENCE
import br.com.zup.beagle.android.compiler.HTTP_CLIENT_FACTORY_HANDLER
import br.com.zup.beagle.compiler.shared.BeagleClass
import javax.lang.model.element.TypeElement

Expand All @@ -48,6 +49,10 @@ internal object PropertyImplementationManager {
propertySpecifications?.httpClient,
HTTP_CLIENT_HANDLER
),
propertySpec(
propertySpecifications?.httpClientFactory,
HTTP_CLIENT_FACTORY_HANDLER
),
propertySpec(
propertySpecifications?.designSystem,
DESIGN_SYSTEM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import br.com.zup.beagle.android.compiler.STORE_HANDLER
import br.com.zup.beagle.android.compiler.URL_BUILDER_HANDLER
import br.com.zup.beagle.android.compiler.BEAGLE_LOGGER
import br.com.zup.beagle.android.compiler.BEAGLE_IMAGE_DOWNLOADER
import br.com.zup.beagle.android.compiler.HTTP_CLIENT_FACTORY_HANDLER
import br.com.zup.beagle.compiler.shared.implements
import javax.annotation.processing.ProcessingEnvironment
import javax.lang.model.element.TypeElement
Expand Down Expand Up @@ -56,6 +57,11 @@ internal object TypeElementImplementationManager {
val element = propertySpecifications?.httpClient
propertySpecifications?.httpClient = manage.manageTypeElement(element, HTTP_CLIENT_HANDLER.className)
}
typeElement.implements(HTTP_CLIENT_FACTORY_HANDLER, processingEnv) -> {
val element = propertySpecifications?.httpClientFactory
propertySpecifications?.httpClientFactory =
manage.manageTypeElement(element, HTTP_CLIENT_FACTORY_HANDLER.className)
}
typeElement.implements(STORE_HANDLER, processingEnv) -> {
val element = propertySpecifications?.storeHandler
propertySpecifications?.storeHandler = manage.manageTypeElement(element, STORE_HANDLER.className)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const val VALID_ANALYTICS_BEAGLE_SDK =
import br.com.zup.beagle.android.navigation.BeagleControllerReference
import br.com.zup.beagle.android.navigation.DeepLinkHandler
import br.com.zup.beagle.android.networking.HttpClient
import br.com.zup.beagle.android.networking.HttpClientFactory
import br.com.zup.beagle.android.networking.urlbuilder.UrlBuilder
import br.com.zup.beagle.android.operation.Operation
import br.com.zup.beagle.android.setup.BeagleConfig
Expand All @@ -72,6 +73,8 @@ const val VALID_ANALYTICS_BEAGLE_SDK =
public override val deepLinkHandler : DeepLinkHandler? = null

public override val httpClient : HttpClient? = null

public override val httpClientFactory : HttpClientFactory? = null

public override val designSystem : DesignSystem? = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const val VALID_ANALYTICS_PROVIDER_BEAGLE_SDK =
import br.com.zup.beagle.android.navigation.BeagleControllerReference
import br.com.zup.beagle.android.navigation.DeepLinkHandler
import br.com.zup.beagle.android.networking.HttpClient
import br.com.zup.beagle.android.networking.HttpClientFactory
import br.com.zup.beagle.android.networking.urlbuilder.UrlBuilder
import br.com.zup.beagle.android.operation.Operation
import br.com.zup.beagle.android.setup.BeagleConfig
Expand All @@ -72,6 +73,8 @@ const val VALID_ANALYTICS_PROVIDER_BEAGLE_SDK =
public override val deepLinkHandler : DeepLinkHandler? = null

public override val httpClient : HttpClient? = null

public override val httpClientFactory : HttpClientFactory? = null

public override val designSystem : DesignSystem? = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const val VALID_BEAGLE_CONFIG_IN_BEAGLE_SDK =
import br.com.zup.beagle.android.navigation.BeagleControllerReference
import br.com.zup.beagle.android.navigation.DeepLinkHandler
import br.com.zup.beagle.android.networking.HttpClient
import br.com.zup.beagle.android.networking.HttpClientFactory
import br.com.zup.beagle.android.networking.urlbuilder.UrlBuilder
import br.com.zup.beagle.android.operation.Operation
import br.com.zup.beagle.android.setup.BeagleConfig
Expand All @@ -77,6 +78,8 @@ const val VALID_BEAGLE_CONFIG_IN_BEAGLE_SDK =
public override val deepLinkHandler : DeepLinkHandler? = null

public override val httpClient : HttpClient? = null

public override val httpClientFactory : HttpClientFactory? = null

public override val designSystem : DesignSystem? = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const val COMPLETE_BEAGLE_CUSTOM_CLASS =
import br.com.zup.beagle.android.setup.DesignSystem
import br.com.zup.beagle.android.action.FormLocalActionHandler
import br.com.zup.beagle.android.networking.HttpClient
import br.com.zup.beagle.android.networking.HttpClientFactory
import br.com.zup.beagle.android.imagedownloader.BeagleImageDownloader
import br.com.zup.beagle.android.logger.BeagleLogger
import br.com.zup.beagle.annotation.RegisterOperation
Expand Down Expand Up @@ -89,6 +90,9 @@ const val COMPLETE_BEAGLE_CUSTOM_CLASS =
@BeagleComponent
class HttpClientTest: HttpClient { }

@BeagleComponent
class HttpClientFactoryTest: HttpClientFactory { }

@BeagleComponent
class ImageDownloaderTest: BeagleImageDownloader { }

Expand Down Expand Up @@ -125,6 +129,7 @@ const val BEAGLE_SETUP_COMPLETE =
import br.com.zup.beagle.android.navigation.BeagleControllerReference
import br.com.zup.beagle.android.navigation.DeepLinkHandler
import br.com.zup.beagle.android.networking.HttpClient
import br.com.zup.beagle.android.networking.HttpClientFactory
import br.com.zup.beagle.android.networking.urlbuilder.UrlBuilder
import br.com.zup.beagle.android.operation.Operation
import br.com.zup.beagle.android.setup.BeagleConfig
Expand All @@ -147,6 +152,8 @@ const val BEAGLE_SETUP_COMPLETE =
public override val deepLinkHandler: DeepLinkHandler = br.com.test.beagle.DeepLinkHandlerTest()

public override val httpClient: HttpClient = br.com.test.beagle.HttpClientTest()

public override val httpClientFactory: HttpClientFactory = br.com.test.beagle.HttpClientFactoryTest()

public override val designSystem: DesignSystem = br.com.test.beagle.DesignSystemTest()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const val VALID_DEEP_LINK_HANDLER_BEAGLE_SDK =
import br.com.zup.beagle.android.navigation.BeagleControllerReference
import br.com.zup.beagle.android.navigation.DeepLinkHandler
import br.com.zup.beagle.android.networking.HttpClient
import br.com.zup.beagle.android.networking.HttpClientFactory
import br.com.zup.beagle.android.networking.urlbuilder.UrlBuilder
import br.com.zup.beagle.android.operation.Operation
import br.com.zup.beagle.android.setup.BeagleConfig
Expand All @@ -71,6 +72,8 @@ const val VALID_DEEP_LINK_HANDLER_BEAGLE_SDK =
public override val deepLinkHandler : DeepLinkHandler = br.com.test.beagle.DeepLinkHandlerTest()

public override val httpClient : HttpClient? = null

public override val httpClientFactory : HttpClientFactory? = null

public override val designSystem : DesignSystem? = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const val VALID_DESIGN_SYSTEM_BEAGLE_SDK =
import br.com.zup.beagle.android.navigation.BeagleControllerReference
import br.com.zup.beagle.android.navigation.DeepLinkHandler
import br.com.zup.beagle.android.networking.HttpClient
import br.com.zup.beagle.android.networking.HttpClientFactory
import br.com.zup.beagle.android.networking.urlbuilder.UrlBuilder
import br.com.zup.beagle.android.operation.Operation
import br.com.zup.beagle.android.setup.BeagleConfig
Expand All @@ -72,6 +73,8 @@ const val VALID_DESIGN_SYSTEM_BEAGLE_SDK =
public override val deepLinkHandler : DeepLinkHandler? = null

public override val httpClient : HttpClient? = null

public override val httpClientFactory : HttpClientFactory? = null

public override val designSystem : DesignSystem = br.com.test.beagle.DesignSystemTest()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const val VALID_FORM_LOCAL_ACTION_HANDLER_BEAGLE_SDK =
import br.com.zup.beagle.android.navigation.BeagleControllerReference
import br.com.zup.beagle.android.navigation.DeepLinkHandler
import br.com.zup.beagle.android.networking.HttpClient
import br.com.zup.beagle.android.networking.HttpClientFactory
import br.com.zup.beagle.android.networking.urlbuilder.UrlBuilder
import br.com.zup.beagle.android.operation.Operation
import br.com.zup.beagle.android.setup.BeagleConfig
Expand All @@ -72,6 +73,8 @@ const val VALID_FORM_LOCAL_ACTION_HANDLER_BEAGLE_SDK =
public override val deepLinkHandler : DeepLinkHandler? = null

public override val httpClient : HttpClient? = null

public override val httpClientFactory : HttpClientFactory? = null

public override val designSystem : DesignSystem? = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const val VALID_HTTP_CLIENT_BEAGLE_SDK =
import br.com.zup.beagle.android.navigation.BeagleControllerReference
import br.com.zup.beagle.android.navigation.DeepLinkHandler
import br.com.zup.beagle.android.networking.HttpClient
import br.com.zup.beagle.android.networking.HttpClientFactory
import br.com.zup.beagle.android.networking.urlbuilder.UrlBuilder
import br.com.zup.beagle.android.operation.Operation
import br.com.zup.beagle.android.setup.BeagleConfig
Expand All @@ -71,6 +72,8 @@ const val VALID_HTTP_CLIENT_BEAGLE_SDK =
public override val deepLinkHandler : DeepLinkHandler? = null

public override val httpClient : HttpClient = br.com.test.beagle.HttpClientTest()

public override val httpClientFactory : HttpClientFactory? = null

public override val designSystem : DesignSystem? = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const val VALID_IMAGE_DOWNLOADER_BEAGLE_SDK =
import br.com.zup.beagle.android.navigation.BeagleControllerReference
import br.com.zup.beagle.android.navigation.DeepLinkHandler
import br.com.zup.beagle.android.networking.HttpClient
import br.com.zup.beagle.android.networking.HttpClientFactory
import br.com.zup.beagle.android.networking.urlbuilder.UrlBuilder
import br.com.zup.beagle.android.operation.Operation
import br.com.zup.beagle.android.setup.BeagleConfig
Expand All @@ -72,6 +73,8 @@ const val VALID_IMAGE_DOWNLOADER_BEAGLE_SDK =
public override val deepLinkHandler : DeepLinkHandler? = null

public override val httpClient : HttpClient? = null

public override val httpClientFactory : HttpClientFactory? = null

public override val designSystem : DesignSystem? = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const val VALID_LOGGER_BEAGLE_SDK =
import br.com.zup.beagle.android.navigation.BeagleControllerReference
import br.com.zup.beagle.android.navigation.DeepLinkHandler
import br.com.zup.beagle.android.networking.HttpClient
import br.com.zup.beagle.android.networking.HttpClientFactory
import br.com.zup.beagle.android.networking.urlbuilder.UrlBuilder
import br.com.zup.beagle.android.operation.Operation
import br.com.zup.beagle.android.setup.BeagleConfig
Expand All @@ -72,6 +73,8 @@ const val VALID_LOGGER_BEAGLE_SDK =
public override val deepLinkHandler : DeepLinkHandler? = null

public override val httpClient : HttpClient? = null

public override val httpClientFactory : HttpClientFactory? = null

public override val designSystem : DesignSystem? = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const val VALID_STORE_HANDLER_BEAGLE_SDK =
import br.com.zup.beagle.android.navigation.BeagleControllerReference
import br.com.zup.beagle.android.navigation.DeepLinkHandler
import br.com.zup.beagle.android.networking.HttpClient
import br.com.zup.beagle.android.networking.HttpClientFactory
import br.com.zup.beagle.android.networking.urlbuilder.UrlBuilder
import br.com.zup.beagle.android.operation.Operation
import br.com.zup.beagle.android.setup.BeagleConfig
Expand All @@ -72,6 +73,8 @@ const val VALID_STORE_HANDLER_BEAGLE_SDK =
public override val deepLinkHandler : DeepLinkHandler? = null

public override val httpClient : HttpClient? = null

public override val httpClientFactory : HttpClientFactory? = null

public override val designSystem : DesignSystem? = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const val VALID_URL_BUILDER_BEAGLE_SDK =
import br.com.zup.beagle.android.navigation.BeagleControllerReference
import br.com.zup.beagle.android.navigation.DeepLinkHandler
import br.com.zup.beagle.android.networking.HttpClient
import br.com.zup.beagle.android.networking.HttpClientFactory
import br.com.zup.beagle.android.networking.urlbuilder.UrlBuilder
import br.com.zup.beagle.android.operation.Operation
import br.com.zup.beagle.android.setup.BeagleConfig
Expand All @@ -72,6 +73,8 @@ const val VALID_URL_BUILDER_BEAGLE_SDK =
public override val deepLinkHandler : DeepLinkHandler? = null

public override val httpClient : HttpClient? = null

public override val httpClientFactory : HttpClientFactory? = null

public override val designSystem : DesignSystem? = null

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright 2020 ZUP IT SERVICOS EM TECNOLOGIA E INOVACAO SA
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package br.com.zup.beagle.android.networking

interface HttpClientFactory
Loading