changeset 414:b93172662988

Implement networking KeyStats
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Wed, 09 Jun 2021 10:57:25 +0200
parents 2984d8946342
children 34f9e408b861
files LazyBear.xcodeproj/project.pbxproj LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate LazyBear/Global Models/KeyStatsModel.swift LazyBear/Views/Company/Networking/ChartResponse.swift LazyBear/Views/Company/Networking/Company.swift
diffstat 5 files changed, 45 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/LazyBear.xcodeproj/project.pbxproj	Wed Jun 09 10:23:52 2021 +0200
+++ b/LazyBear.xcodeproj/project.pbxproj	Wed Jun 09 10:57:25 2021 +0200
@@ -69,6 +69,7 @@
 		95A7C066261639E0003E2EC1 /* SearchView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95A7C065261639DF003E2EC1 /* SearchView.swift */; };
 		95A7C0742616409D003E2EC1 /* ParseJSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95A7C0732616409D003E2EC1 /* ParseJSON.swift */; };
 		95AD4A2D26078C1400498079 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95AD4A2C26078C1400498079 /* ContentView.swift */; };
+		95BB05B22670B8C3005A2029 /* KeyStatsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95BB05B12670B8C3005A2029 /* KeyStatsModel.swift */; };
 		95BD2FAE26341BD1008B6752 /* TextfieldAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95BD2FAD26341BD1008B6752 /* TextfieldAlert.swift */; };
 		95BD2FB326341D36008B6752 /* BlurBackground.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95BD2FB226341D36008B6752 /* BlurBackground.swift */; };
 		95C8C0E0262A369F0082D1D9 /* ProfileResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95C8C0DF262A369F0082D1D9 /* ProfileResponse.swift */; };
@@ -172,6 +173,7 @@
 		95A7C065261639DF003E2EC1 /* SearchView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchView.swift; sourceTree = "<group>"; };
 		95A7C0732616409D003E2EC1 /* ParseJSON.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParseJSON.swift; sourceTree = "<group>"; };
 		95AD4A2C26078C1400498079 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
+		95BB05B12670B8C3005A2029 /* KeyStatsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyStatsModel.swift; sourceTree = "<group>"; };
 		95BD2FAD26341BD1008B6752 /* TextfieldAlert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextfieldAlert.swift; sourceTree = "<group>"; };
 		95BD2FB226341D36008B6752 /* BlurBackground.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlurBackground.swift; sourceTree = "<group>"; };
 		95C8C0DF262A369F0082D1D9 /* ProfileResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileResponse.swift; sourceTree = "<group>"; };
@@ -315,6 +317,7 @@
 				9594F03F2651355B00CFA8D4 /* HistoricalPricesModel.swift */,
 				95602703265ABB990046F97E /* InsiderRosterModel.swift */,
 				95CCFB55266E7A0F00C384A1 /* InsiderTransactionModel.swift */,
+				95BB05B12670B8C3005A2029 /* KeyStatsModel.swift */,
 			);
 			path = "Global Models";
 			sourceTree = "<group>";
@@ -712,6 +715,7 @@
 				95721DA6262761E700EC527B /* CurrencyRow.swift in Sources */,
 				95CCFB58266E7F4F00C384A1 /* InsiderList.swift in Sources */,
 				9562404C263C766D00C6C511 /* WatchlistCreator.swift in Sources */,
+				95BB05B22670B8C3005A2029 /* KeyStatsModel.swift in Sources */,
 				95672B8F25DDA54700DCBE4A /* LazyBearApp.swift in Sources */,
 				95A7C066261639E0003E2EC1 /* SearchView.swift in Sources */,
 				9550444C26111FED000E0BCB /* StockItem.swift in Sources */,
Binary file LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LazyBear/Global Models/KeyStatsModel.swift	Wed Jun 09 10:57:25 2021 +0200
@@ -0,0 +1,37 @@
+//
+//  KeyStatsModel.swift
+//  LazyBear
+//
+//  Created by Dennis Concepción Martín on 9/6/21.
+//
+
+import SwiftUI
+
+struct KeyStatsModel: Codable {
+    var avg10Volume, avg30Volume: Int?
+    var beta: Double?
+    var companyName: String?
+    var day200MovingAvg, day30ChangePercent, day50MovingAvg, day5ChangePercent: Double?
+    var dividendYield: Double?
+    var employees: Int?
+    var exDividendDate: String?
+    var float, marketcap: Int?
+    var maxChangePercent, month1ChangePercent, month3ChangePercent, month6ChangePercent: Double?
+    var nextDividendDate, nextEarningsDate: String?
+    var peRatio: Double?
+    var sharesOutstanding: Int?
+    var ttmDividendRate, ttmEPS, week52Change, week52High: Double?
+    var week52HighSplitAdjustOnly, week52Low: Double?
+    var week52LowSplitAdjustOnly: Double?
+    var year1ChangePercent, year2ChangePercent, year5ChangePercent, ytdChangePercent: Double?
+
+    enum CodingKeys: String, CodingKey {
+        case avg10Volume, avg30Volume, beta, companyName, day200MovingAvg, day30ChangePercent, day50MovingAvg, day5ChangePercent, dividendYield, employees, exDividendDate, float, marketcap, maxChangePercent, month1ChangePercent, month3ChangePercent, month6ChangePercent, nextDividendDate, nextEarningsDate, peRatio, sharesOutstanding, ttmDividendRate, ttmEPS
+        case week52Change = "week52change"
+        case week52High = "week52high"
+        case week52HighSplitAdjustOnly = "week52highSplitAdjustOnly"
+        case week52Low = "week52low"
+        case week52LowSplitAdjustOnly = "week52lowSplitAdjustOnly"
+        case year1ChangePercent, year2ChangePercent, year5ChangePercent, ytdChangePercent
+    }
+}
--- a/LazyBear/Views/Company/Networking/ChartResponse.swift	Wed Jun 09 10:23:52 2021 +0200
+++ b/LazyBear/Views/Company/Networking/ChartResponse.swift	Wed Jun 09 10:57:25 2021 +0200
@@ -11,10 +11,13 @@
     var historicalPrices: [HistoricalPricesModel]?
     var quote: [String: QuoteModel]?
     var latestNews: [LatestNewsModel]?
+    var keyStats: KeyStatsModel?
     
     private enum CodingKeys : String, CodingKey {
         case historicalPrices = "historical_prices"
         case quote
         case latestNews = "latest_news"
+        case keyStats = "key_stats"
     }
 }
+
--- a/LazyBear/Views/Company/Networking/Company.swift	Wed Jun 09 10:23:52 2021 +0200
+++ b/LazyBear/Views/Company/Networking/Company.swift	Wed Jun 09 10:57:25 2021 +0200
@@ -22,6 +22,7 @@
                 switch requestType {
                 case .initial:
                     self.chartData = response
+                    print(response)
                 case .refresh:
                     self.chartData.historicalPrices = response.historicalPrices
                 case .streaming: