view LazyBear/Views/Profile/Networking/Profile.swift @ 404:444ec927d62f

Install Bazooka package
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Thu, 03 Jun 2021 16:05:01 +0200
parents f843c6382529
children 4effac4733b0
line wrap: on
line source

//
//  Profile.swift
//  LazyBear
//
//  Created by Dennis Concepción Martín on 7/5/21.
//

import SwiftUI
import Bazooka

class Profile: ObservableObject {
    @Published var showView = false
    @Published var data = ProfileResponse()
    
    func request(_ url: String, _ requestType: RequestType) {
        let bazooka = Bazooka()
        bazooka.request(url: url, model: ProfileResponse.self) { response in
            switch requestType {
            case .initial:
                self.data = response
            default:
                self.data.quotes = response.quotes
            }
            
            self.showView = true
        }
    }
}