Mercurial > public > lazybear
comparison LazyBear/Views/Company/Networking/Company.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 | 48b3d2a410d4 |
children | c804ce7a1560 |
comparison
equal
deleted
inserted
replaced
403:48b3d2a410d4 | 404:444ec927d62f |
---|---|
4 // | 4 // |
5 // Created by Dennis Concepción Martín on 15/5/21. | 5 // Created by Dennis Concepción Martín on 15/5/21. |
6 // | 6 // |
7 | 7 |
8 import SwiftUI | 8 import SwiftUI |
9 import Bazooka | |
9 | 10 |
10 class Company: ObservableObject { | 11 class Company: ObservableObject { |
11 @Published var showChartView = false | 12 @Published var showChartView = false |
12 @Published var chartData = ChartResponse() | 13 @Published var chartData = ChartResponse() |
13 | 14 |
14 @Published var showInsidersView = false | 15 @Published var showInsidersView = false |
15 @Published var insidersData = InsidersResponse() | 16 @Published var insidersData = InsidersResponse() |
16 | 17 |
17 func request(_ url: String, _ requestType: RequestType, _ view: String) { | 18 func request(_ url: String, _ requestType: RequestType, _ view: String) { |
19 let bazooka = Bazooka() | |
18 if view == "chart" { | 20 if view == "chart" { |
19 genericRequest(url: url, model: ChartResponse.self) { response in | 21 bazooka.request(url: url, model: ChartResponse.self) { response in |
20 switch requestType { | 22 switch requestType { |
21 case .initial: | 23 case .initial: |
22 self.chartData = response | 24 self.chartData = response |
23 case .refresh: | 25 case .refresh: |
24 self.chartData.historicalPrices = response.historicalPrices | 26 self.chartData.historicalPrices = response.historicalPrices |
27 } | 29 } |
28 | 30 |
29 self.showChartView = true | 31 self.showChartView = true |
30 } | 32 } |
31 } else if view == "insider" { | 33 } else if view == "insider" { |
32 genericRequest(url: url, model: InsidersResponse.self) { response in | 34 bazooka.request(url: url, model: InsidersResponse.self) { response in |
33 self.insidersData = response | 35 self.insidersData = response |
34 } | 36 } |
35 } | 37 } |
36 } | 38 } |
37 } | 39 } |