comparison LazyBear/Views/Company/Networking/Company.swift @ 438:7f2a24a774eb

Implement CompanyView networking
author Dennis Concepción Martín <dennisconcepcionmartin@gmail.com>
date Sun, 20 Jun 2021 13:20:19 +0200
parents
children 01fa77358b82
comparison
equal deleted inserted replaced
437:5ca468751db2 438:7f2a24a774eb
1 //
2 // Company.swift
3 // LazyBear
4 //
5 // Created by Dennis Concepción Martín on 20/6/21.
6 //
7
8 import SwiftUI
9 import Bazooka
10
11 class Company: ObservableObject {
12 @Published var showView = false
13 @Published var data = CompanyResponse()
14
15 func request(_ url: String, _ requestType: RequestType) {
16 let bazooka = Bazooka()
17 bazooka.request(url: url, model: CompanyResponse.self) { response in
18 switch requestType {
19 case .initial:
20 self.data = response
21 case .streaming:
22 self.data.quote = response.quote
23 case .refresh:
24 self.data.historicalPrices = response.historicalPrices
25 }
26
27 self.showView = true
28 }
29 }
30 }