-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from emanuelgalvao/feat/version2
feat: version 2.0.0
- Loading branch information
Showing
22 changed files
with
479 additions
and
313 deletions.
There are no files selected for viewing
This file contains 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 file contains 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 file contains 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
11 changes: 0 additions & 11 deletions
11
buscacep/src/main/java/com/emanuelgalvao/buscacep/callback/CepCallback.kt
This file was deleted.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
buscacep/src/main/java/com/emanuelgalvao/buscacep/callback/CepResponse.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.emanuelgalvao.buscacep.callback | ||
|
||
import com.emanuelgalvao.buscacep.model.CepData | ||
|
||
sealed interface CepResponse { | ||
class Error(val message: String): CepResponse | ||
class Success(val data: CepData): CepResponse | ||
} |
This file contains 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
9 changes: 6 additions & 3 deletions
9
buscacep/src/main/java/com/emanuelgalvao/buscacep/data/CepRepository.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
package com.emanuelgalvao.buscacep.data | ||
|
||
import com.emanuelgalvao.buscacep.callback.CepCallback | ||
import com.emanuelgalvao.buscacep.callback.CepResponse | ||
import com.emanuelgalvao.buscacep.model.CepData | ||
|
||
internal interface CepRepository { | ||
interface CepRepository { | ||
|
||
suspend fun searchCep(cep: String): CepCallback | ||
suspend fun getCepData(cep: String): CepResponse | ||
|
||
suspend fun getCepDataOrNull(cep: String): CepData? | ||
} |
11 changes: 8 additions & 3 deletions
11
buscacep/src/main/java/com/emanuelgalvao/buscacep/manager/CepManager.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
package com.emanuelgalvao.buscacep.manager | ||
|
||
import com.emanuelgalvao.buscacep.callback.CepCallback | ||
import com.emanuelgalvao.buscacep.callback.CepResponse | ||
import com.emanuelgalvao.buscacep.data.CepRepository | ||
import com.emanuelgalvao.buscacep.model.CepData | ||
|
||
internal class CepManager(private val cepRepository: CepRepository) { | ||
|
||
suspend fun getCepData(cep: String): CepCallback { | ||
return cepRepository.searchCep(cep) | ||
suspend fun getCepData(cep: String): CepResponse { | ||
return cepRepository.getCepData(cep) | ||
} | ||
|
||
suspend fun getCepDataOrNull(cep: String): CepData? { | ||
return cepRepository.getCepDataOrNull(cep) | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
buscacep/src/main/java/com/emanuelgalvao/buscacep/model/CepApiResponse.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.emanuelgalvao.buscacep.model | ||
|
||
data class CepApiResponse( | ||
val bairro: String, | ||
val cep: String, | ||
val complemento: String, | ||
val ddd: String, | ||
val gia: String, | ||
val ibge: String, | ||
val localidade: String, | ||
val logradouro: String, | ||
val siafi: String, | ||
val uf: String, | ||
val erro: Boolean | ||
) |
14 changes: 14 additions & 0 deletions
14
buscacep/src/main/java/com/emanuelgalvao/buscacep/model/CepData.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.emanuelgalvao.buscacep.model | ||
|
||
data class CepData( | ||
val bairro: String, | ||
val cep: String, | ||
val complemento: String, | ||
val ddd: String, | ||
val gia: String, | ||
val ibge: String, | ||
val localidade: String, | ||
val logradouro: String, | ||
val siafi: String, | ||
val uf: String | ||
) |
12 changes: 0 additions & 12 deletions
12
buscacep/src/main/java/com/emanuelgalvao/buscacep/model/CepModel.kt
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
buscacep/src/main/java/com/emanuelgalvao/buscacep/model/CepResponse.kt
This file was deleted.
Oops, something went wrong.
10 changes: 2 additions & 8 deletions
10
buscacep/src/main/java/com/emanuelgalvao/buscacep/network/ApiServices.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,5 @@ | ||
package com.emanuelgalvao.buscacep.network | ||
|
||
|
||
internal class ApiServices { | ||
|
||
companion object { | ||
|
||
val cepService: CepService = RetrofitClient.getClient().create(CepService::class.java) | ||
|
||
} | ||
internal object ApiServices { | ||
val cepService: CepService = RetrofitClient.getClient().create(CepService::class.java) | ||
} |
6 changes: 3 additions & 3 deletions
6
buscacep/src/main/java/com/emanuelgalvao/buscacep/network/CepService.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
package com.emanuelgalvao.buscacep.network | ||
|
||
import com.emanuelgalvao.buscacep.model.CepResponse | ||
import com.emanuelgalvao.buscacep.model.CepApiResponse | ||
import retrofit2.Response | ||
import retrofit2.http.GET | ||
import retrofit2.http.Path | ||
|
||
internal interface CepService { | ||
interface CepService { | ||
|
||
@GET("{cep}/json/") | ||
suspend fun searchCep(@Path(value = "cep") cep: String) : Response<CepResponse> | ||
suspend fun searchCep(@Path(value = "cep") cep: String) : Response<CepApiResponse> | ||
} |
This file contains 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
Oops, something went wrong.