Skip to content

Chamada da api de login #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

JulianeGF
Copy link

@JulianeGF JulianeGF commented Apr 12, 2022

  • Cria chamada para a API de Login de forma nativa.


public final class LoginAPIClient {

func pegaloginmodel(completion: @escaping(LoginModel?, Error?) -> ()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alinhar com Douglas e Bruno para encapsular o endpoint num plist e obter de um Manager o resultado

@JulianeGF JulianeGF marked this pull request as ready for review April 14, 2022 13:07
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Criar URL em uma propriedade local, usando guard let, caso de falha pode usar assertionFailure("mensagem sobre erro")

guard let urlLogin = URL(...) else { assertionFail... }

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tentei seguir o mesmo padrao de outras chamadas

completion(.success((data, response)))
}

assertionFailure("Failure")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remover assertionFailure desta linha

public struct LoginModel: Decodable {
let success: Bool

enum CodingKeys: String, CodingKey {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"

@@ -9,6 +9,8 @@ import UIKit

class PropertyListViewController: UIViewController {

let loginAPI = LoginAPIClient()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Utilizar a chamada do login na cena do Login, que ja subiu na master.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Não encontrei a cena do Login.

@JulianeGF JulianeGF changed the title inicia implementacao da chamada api de login - WIP Chamada da api de login Apr 26, 2022
} else if let data = data, let response = response {
completion(.success((data, response)))
func fetchProperties(completion: @escaping (Result<LoginModel, ErrorRequest>) -> Void) {
let urlString = ManagerGetURL.getLoginURL()
Copy link
Contributor

@andrevinic andrevinic Apr 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Injetar no init do LoginAPIClient a propriedade ManagerGetURL

@@ -1,16 +1,32 @@
import Foundation

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Utilizar Account ViewModel para integrar o LoginAPIClient
Renomear AccountViewModel para LoginViewModel
Criar Factory da funcionalidade, olhar exemplo na master, ja temos a Factory la.

@@ -1,16 +1,32 @@
import Foundation

protocol LoginAPIClientProtocol: AnyObject {
func fetchProperties(completion: @escaping (Result<[Property], ErrorRequest>) -> Void)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Integrar a chama do APIClient na ViewModel
E esse dado na ViewModel integrado com a ViewController correspondente.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants