changeset 450:4b8031e696e8

Change Bazooka to Alamofire Alamofire is compatible with WatchOS and MacOS
author Dennis Concepción Martín <dennisconcepcionmartin@gmail.com>
date Sat, 26 Jun 2021 16:36:53 +0200
parents 4255f94d0767
children bb130738b816
files LazyBear.xcodeproj/project.pbxproj LazyBear.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate LazyBear/Views/Company/Networking/Company.swift LazyBear/Views/Home/Networking/Home.swift LazyBear/Views/Profile/Helpers/WatchlistCreatorList.swift LazyBear/Views/Profile/Networking/Profile.swift LazyBear/Views/Search/Networking/Search.swift
diffstat 8 files changed, 69 insertions(+), 64 deletions(-) [+]
line wrap: on
line diff
--- a/LazyBear.xcodeproj/project.pbxproj	Wed Jun 23 13:03:00 2021 +0200
+++ b/LazyBear.xcodeproj/project.pbxproj	Sat Jun 26 16:36:53 2021 +0200
@@ -78,7 +78,6 @@
 		9576BFED26810713002BCAC6 /* InsiderRosterList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9576BFEC26810713002BCAC6 /* InsiderRosterList.swift */; };
 		9576BFEF26810719002BCAC6 /* InsiderRosterRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9576BFEE26810719002BCAC6 /* InsiderRosterRow.swift */; };
 		958A735225E0170900FD7ECA /* CloudKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 958A735125E0170900FD7ECA /* CloudKit.framework */; };
-		9594331326691789004A0339 /* Bazooka in Frameworks */ = {isa = PBXBuildFile; productRef = 9594331226691789004A0339 /* Bazooka */; };
 		9594F0402651355B00CFA8D4 /* HistoricalPricesModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9594F03F2651355B00CFA8D4 /* HistoricalPricesModel.swift */; };
 		9595DC342682849E00DC8104 /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9595DC332682849E00DC8104 /* HomeView.swift */; };
 		9595DC36268284B100DC8104 /* CompanyRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9595DC35268284B100DC8104 /* CompanyRow.swift */; };
@@ -100,6 +99,7 @@
 		95BB05B22670B8C3005A2029 /* KeyStatsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95BB05B12670B8C3005A2029 /* KeyStatsModel.swift */; };
 		95BC1C642683326C00F94373 /* KeyStatsRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95BC1C632683326C00F94373 /* KeyStatsRow.swift */; };
 		95BC1C66268336A200F94373 /* UnwrapAnyOptional.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95BC1C65268336A200F94373 /* UnwrapAnyOptional.swift */; };
+		95BEA1A626876DE100BF18AB /* Alamofire in Frameworks */ = {isa = PBXBuildFile; productRef = 95BEA1A526876DE100BF18AB /* Alamofire */; };
 		95C22F3F26776F010014C98A /* CompanyModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95C22F3E26776F010014C98A /* CompanyModel.swift */; };
 		95C8C0E0262A369F0082D1D9 /* ProfileResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95C8C0DF262A369F0082D1D9 /* ProfileResponse.swift */; };
 		95CCFB56266E7A0F00C384A1 /* InsiderTransactionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95CCFB55266E7A0F00C384A1 /* InsiderTransactionModel.swift */; };
@@ -344,8 +344,8 @@
 			buildActionMask = 2147483647;
 			files = (
 				958A735225E0170900FD7ECA /* CloudKit.framework in Frameworks */,
+				95BEA1A626876DE100BF18AB /* Alamofire in Frameworks */,
 				950B6F3F267643640029E447 /* StoreKit.framework in Frameworks */,
-				9594331326691789004A0339 /* Bazooka in Frameworks */,
 				9547482A26822F0700D6A966 /* StockCharts in Frameworks */,
 				95A4B933263E9F810056F036 /* Introspect in Frameworks */,
 				950B6F3D267643460029E447 /* Purchases in Frameworks */,
@@ -868,9 +868,9 @@
 			packageProductDependencies = (
 				954D7EC1260BE70C00A13C50 /* SwiftlySearch */,
 				95A4B932263E9F810056F036 /* Introspect */,
-				9594331226691789004A0339 /* Bazooka */,
 				950B6F3C267643460029E447 /* Purchases */,
 				9547482926822F0700D6A966 /* StockCharts */,
+				95BEA1A526876DE100BF18AB /* Alamofire */,
 			);
 			productName = LazyBear;
 			productReference = 95672B8B25DDA54700DCBE4A /* LazyBear.app */;
@@ -924,9 +924,9 @@
 			packageReferences = (
 				954D7EC0260BE70C00A13C50 /* XCRemoteSwiftPackageReference "SwiftlySearch" */,
 				95A4B931263E9F810056F036 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */,
-				9594331126691789004A0339 /* XCRemoteSwiftPackageReference "Bazooka" */,
 				950B6F3B267643460029E447 /* XCRemoteSwiftPackageReference "purchases-ios" */,
 				9547482826822F0700D6A966 /* XCRemoteSwiftPackageReference "StockCharts" */,
+				95BEA1A426876DE100BF18AB /* XCRemoteSwiftPackageReference "Alamofire" */,
 			);
 			productRefGroup = 95672B8C25DDA54700DCBE4A /* Products */;
 			projectDirPath = "";
@@ -1703,14 +1703,6 @@
 				minimumVersion = 1.2.4;
 			};
 		};
-		9594331126691789004A0339 /* XCRemoteSwiftPackageReference "Bazooka" */ = {
-			isa = XCRemoteSwiftPackageReference;
-			repositoryURL = "https://github.com/denniscm190/Bazooka.git";
-			requirement = {
-				kind = upToNextMajorVersion;
-				minimumVersion = 1.0.0;
-			};
-		};
 		95A4B931263E9F810056F036 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */ = {
 			isa = XCRemoteSwiftPackageReference;
 			repositoryURL = "https://github.com/siteline/SwiftUI-Introspect.git";
@@ -1719,6 +1711,14 @@
 				minimumVersion = 0.1.3;
 			};
 		};
+		95BEA1A426876DE100BF18AB /* XCRemoteSwiftPackageReference "Alamofire" */ = {
+			isa = XCRemoteSwiftPackageReference;
+			repositoryURL = "https://github.com/Alamofire/Alamofire.git";
+			requirement = {
+				kind = upToNextMajorVersion;
+				minimumVersion = 5.4.3;
+			};
+		};
 /* End XCRemoteSwiftPackageReference section */
 
 /* Begin XCSwiftPackageProductDependency section */
@@ -1737,16 +1737,16 @@
 			package = 954D7EC0260BE70C00A13C50 /* XCRemoteSwiftPackageReference "SwiftlySearch" */;
 			productName = SwiftlySearch;
 		};
-		9594331226691789004A0339 /* Bazooka */ = {
-			isa = XCSwiftPackageProductDependency;
-			package = 9594331126691789004A0339 /* XCRemoteSwiftPackageReference "Bazooka" */;
-			productName = Bazooka;
-		};
 		95A4B932263E9F810056F036 /* Introspect */ = {
 			isa = XCSwiftPackageProductDependency;
 			package = 95A4B931263E9F810056F036 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */;
 			productName = Introspect;
 		};
+		95BEA1A526876DE100BF18AB /* Alamofire */ = {
+			isa = XCSwiftPackageProductDependency;
+			package = 95BEA1A426876DE100BF18AB /* XCRemoteSwiftPackageReference "Alamofire" */;
+			productName = Alamofire;
+		};
 /* End XCSwiftPackageProductDependency section */
 
 /* Begin XCVersionGroup section */
--- a/LazyBear.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved	Wed Jun 23 13:03:00 2021 +0200
+++ b/LazyBear.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved	Sat Jun 26 16:36:53 2021 +0200
@@ -2,12 +2,12 @@
   "object": {
     "pins": [
       {
-        "package": "Bazooka",
-        "repositoryURL": "https://github.com/denniscm190/Bazooka.git",
+        "package": "Alamofire",
+        "repositoryURL": "https://github.com/Alamofire/Alamofire.git",
         "state": {
           "branch": null,
-          "revision": "4ac8be52a434c25d46d2486b66ba33f53ffdddb6",
-          "version": "1.0.0"
+          "revision": "f96b619bcb2383b43d898402283924b80e2c4bae",
+          "version": "5.4.3"
         }
       },
       {
Binary file LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- a/LazyBear/Views/Company/Networking/Company.swift	Wed Jun 23 13:03:00 2021 +0200
+++ b/LazyBear/Views/Company/Networking/Company.swift	Sat Jun 26 16:36:53 2021 +0200
@@ -6,7 +6,7 @@
 //
 
 import SwiftUI
-import Bazooka
+import Alamofire
 
 class Company: ObservableObject {
     @Published var showView = false
@@ -15,19 +15,20 @@
     
     func request(_ url: String, _ requestType: RequestType) {
         if requestType == .refresh { self.showChart = false }
-        let bazooka = Bazooka()
-        bazooka.request(url: url, model: CompanyResponse.self) { response in
-            switch requestType {
-            case .initial:
-                self.data = response
-            case .streaming:
-                self.data.quote = response.quote
-            case .refresh:
-                self.data.historicalPrices = response.historicalPrices
+        AF.request(url).responseDecodable(of: CompanyResponse.self) { response in
+            if let value = response.value {
+                switch requestType {
+                case .initial:
+                    self.data = value
+                case .streaming:
+                    self.data.quote = value.quote
+                case .refresh:
+                    self.data.historicalPrices = value.historicalPrices
+                }
+                
+                self.showView = true
+                self.showChart = true
             }
-            
-            self.showView = true
-            self.showChart = true
         }
     }
 }
--- a/LazyBear/Views/Home/Networking/Home.swift	Wed Jun 23 13:03:00 2021 +0200
+++ b/LazyBear/Views/Home/Networking/Home.swift	Sat Jun 26 16:36:53 2021 +0200
@@ -6,24 +6,25 @@
 //
 
 import SwiftUI
-import Bazooka
+import Alamofire
 
 class Home: ObservableObject {
     @Published var showView = false
     @Published var data = HomeResponse()
     
     func request(_ url: String, _ requestType: RequestType) {
-        let bazooka = Bazooka()
-        bazooka.request(url: url, model: HomeResponse.self) { response in
-            switch requestType {
-            case .initial:
-                self.data = response
-            default:
-                self.data.lists = response.lists
-                self.data.sectorPerformance = response.sectorPerformance
+        AF.request(url).responseDecodable(of: HomeResponse.self) { response in
+            if let value = response.value {
+                switch requestType {
+                case .initial:
+                    self.data = value
+                default:
+                    self.data.lists = value.lists
+                    self.data.sectorPerformance = value.sectorPerformance
+                }
+                
+                self.showView = true
             }
-            
-            self.showView = true
         }
     }
 }
--- a/LazyBear/Views/Profile/Helpers/WatchlistCreatorList.swift	Wed Jun 23 13:03:00 2021 +0200
+++ b/LazyBear/Views/Profile/Helpers/WatchlistCreatorList.swift	Sat Jun 26 16:36:53 2021 +0200
@@ -6,7 +6,7 @@
 //
 
 import SwiftUI
-import Bazooka
+import Alamofire
 
 struct WatchlistCreatorList: View {
     @ObservedObject var watchlistCreatorClass: WatchlistCreatorClass
@@ -45,9 +45,10 @@
      Get companies from the API that matches the searched text
      */
     private func request(_ url: String) {
-        let bazooka = Bazooka()
-        bazooka.request(url: url, model: [SearchResponse].self) { response in
-            self.companies = response
+        AF.request(url).responseDecodable(of: [SearchResponse].self) { response in
+            if let value = response.value {
+                self.companies = value
+            }
         }
     }
     
--- a/LazyBear/Views/Profile/Networking/Profile.swift	Wed Jun 23 13:03:00 2021 +0200
+++ b/LazyBear/Views/Profile/Networking/Profile.swift	Sat Jun 26 16:36:53 2021 +0200
@@ -6,23 +6,24 @@
 //
 
 import SwiftUI
-import Bazooka
+import Alamofire
 
 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 = response
+        AF.request(url).responseDecodable(of: ProfileResponse.self) { response in
+            if let value = response.value {
+                switch requestType {
+                case .initial:
+                    self.data = value
+                default:
+                    self.data = value
+                }
+
+                self.showView = true
             }
-            
-            self.showView = true
         }
     }
 }
--- a/LazyBear/Views/Search/Networking/Search.swift	Wed Jun 23 13:03:00 2021 +0200
+++ b/LazyBear/Views/Search/Networking/Search.swift	Sat Jun 26 16:36:53 2021 +0200
@@ -6,17 +6,18 @@
 //
 
 import SwiftUI
-import Bazooka
+import Alamofire
 
 class Search: ObservableObject {
     @Published var data = [SearchResponse()]
     @Published var showSearchList = false
     
     func request(_ url: String) {
-        let bazooka = Bazooka()
-        bazooka.request(url: url, model: [SearchResponse].self) { response in
-            self.data = response
-            self.showSearchList = true
+        AF.request(url).responseDecodable(of: [SearchResponse].self) { response in
+            if let value = response.value {
+                self.data = value
+                self.showSearchList = true
+            }
         }
     }
 }