Conversation
|
|
||
| public final class LoginAPIClient { | ||
|
|
||
| func pegaloginmodel(completion: @escaping(LoginModel?, Error?) -> ()) { |
There was a problem hiding this comment.
utilizar camel case no metodo
pegaLoginModel
trocar por ingles
getLoginModel
| public final class LoginAPIClient { | ||
|
|
||
| func pegaloginmodel(completion: @escaping(LoginModel?, Error?) -> ()) { | ||
| let url = URL(string: "https://raw.githubusercontent.com/devpass-tech/challenge-realestate-app/main/api/login.json")! |
There was a problem hiding this comment.
alinhar com Douglas e Bruno para encapsular o endpoint num plist e obter de um Manager o resultado
| public final class LoginAPIClient { | ||
|
|
||
| func getLoginModel(completion: @escaping (Result<(Data, URLResponse), Error>) -> Void) { | ||
| URLSession.shared.dataTask(with: URL(string: "https://raw.githubusercontent.com/devpass-tech/challenge-realestate-app/main/api/login.json")!) { data, response, error in |
There was a problem hiding this comment.
Criar URL em uma propriedade local, usando guard let, caso de falha pode usar assertionFailure("mensagem sobre erro")
guard let urlLogin = URL(...) else { assertionFail... }
There was a problem hiding this comment.
Tentei seguir o mesmo padrao de outras chamadas
| completion(.success((data, response))) | ||
| } | ||
|
|
||
| assertionFailure("Failure") |
There was a problem hiding this comment.
remover assertionFailure desta linha
| public struct LoginModel: Decodable { | ||
| let success: Bool | ||
|
|
||
| enum CodingKeys: String, CodingKey { |
There was a problem hiding this comment.
Aqui podemos remover coding keys, tem o mesmo valor da variavel.
este CodingKeys utilizamos apenas para valor diferente da raiz do da propriedade declarada.
Exemplo: let sucessO: Bool
CodingKeys... successo = "success"
|
|
||
| class PropertyListViewController: UIViewController { | ||
|
|
||
| let loginAPI = LoginAPIClient() |
There was a problem hiding this comment.
Utilizar a chamada do login na cena do Login, que ja subiu na master.
There was a problem hiding this comment.
Não encontrei a cena do Login.
7d87939 to
896e675
Compare
896e675 to
3da9877
Compare
| } else if let data = data, let response = response { | ||
| completion(.success((data, response))) | ||
| func fetchProperties(completion: @escaping (Result<LoginModel, ErrorRequest>) -> Void) { | ||
| let urlString = ManagerGetURL.getLoginURL() |
There was a problem hiding this comment.
Injetar no init do LoginAPIClient a propriedade ManagerGetURL
| @@ -1,16 +1,32 @@ | |||
| import Foundation | |||
|
|
|||
There was a problem hiding this comment.
Utilizar Account ViewModel para integrar o LoginAPIClient
Renomear AccountViewModel para LoginViewModel
Criar Factory da funcionalidade, olhar exemplo na master, ja temos a Factory la.
| import Foundation | ||
|
|
||
| protocol LoginAPIClientProtocol: AnyObject { | ||
| func fetchProperties(completion: @escaping (Result<[Property], ErrorRequest>) -> Void) |
There was a problem hiding this comment.
Integrar a chama do APIClient na ViewModel
E esse dado na ViewModel integrado com a ViewController correspondente.
Uh oh!
There was an error while loading. Please reload this page.