This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface Repository { | |
| suspend fun getRedditPosts(): ResultWrapper<String> | |
| } | |
| class RepositoryImpl(private val service: RedditService, | |
| private val dispatcher: CoroutineDispatcher = Dispatchers.IO) : Repository { | |
| override suspend fun getRedditPosts(): ResultWrapper<RedditPosts> { | |
| return safeApiCall(dispatcher) { service.getRedditPosts().toRedditPosts() } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun fetchData() { | |
| viewModelScope.launch { | |
| val redditResponse = repository.getRedditPosts() | |
| when (redditResponse) { | |
| is NetworkError -> showNetworkError() | |
| is GenericError-> showGenericError(redditResponse) | |
| is Success -> showSuccess(redditResponse.value) | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class NetworkHelperTest { | |
| private val dispatcher = TestCoroutineDispatcher() | |
| @Test | |
| fun `when lambda returns successfully then it should emit the result as success`() { | |
| runBlockingTest { | |
| val lambdaResult = true | |
| val result = safeApiCall(dispatcher) { lambdaResult } | |
| assertEquals(ResultWrapper.Success(lambdaResult), result) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| project.flavors.each { flavor, config -> | |
| project.dependencies.add("${flavor}Compile", project(config.entryModule)) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data class ErrorResponse( | |
| val error_description: String, // this is the translated error shown to the user directly from the API | |
| val causes: Map<String, String> = emptyMap() //this is for errors on specific field on a form | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Credentials { | |
| final String givenName; | |
| final String familyName; | |
| Credentials(this.givenName, this.familyName); | |
| } | |
| void main() { | |
| final credentials1 = Credentials('Doug', 'blabla'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// This interceptor is simplified because is doesn't contemplate | |
| /// a refresh token, which you should take care of. | |
| /// I haven't tested this code, but I believe it should work. | |
| /// If you have some feedback, please leave a comment and I'll review it :) Thanks. | |
| class AuthInterceptor extends InterceptorsWrapper { | |
| final Dio loggedDio; | |
| final Dio tokenDio; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'dart:async'; | |
| void main() { | |
| escutarDeepLinks().listen((e) { | |
| print(e); | |
| }, onError: (error) { | |
| print('deu erro vei. $error'); | |
| }); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| git_url("[email protected]:<yourcompany>/<repo>.git") | |
| storage_mode("git") | |
| type("development") # The default type, can be: appstore, adhoc, enterprise or development |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # These keys must be filled in order to fetch the certificates | |
| # Git basic authorization for match encoded in base64 | |
| # This is only needed if the user is not authenticated using ssh on git or if you're running on CI/CD server. | |
| # MATCH_GIT_BASIC_AUTHORIZATION= | |
| # Password used to encrypt/decrypt certificates | |
| MATCH_PASSWORD= | |
| # (Optional) Your local machine password, such as the one you use to login. |