diff --git a/Examples/Communication/Routers/CityRoute.swift b/Examples/Communication/Routers/CityRoute.swift index ce7d879c..0c82c697 100644 --- a/Examples/Communication/Routers/CityRoute.swift +++ b/Examples/Communication/Routers/CityRoute.swift @@ -33,23 +33,23 @@ enum CityRoute: RouteProtocol { switch self { case .cities: return RouteConfiguration(method: .get, - path: .path(["cities"]), - mockFilePath: + path: .path(["cities"]), + mockFilePath: .path(["Cities", "cities.json"])) case .city(let id): return RouteConfiguration(method: .get, - path: .path(["city", String(id)]), - mockFilePath: + path: .path(["city", String(id)]), + mockFilePath: .path(["Cities", "Details", String(format: "%i.json", id)])) case .thumb(let city): return RouteConfiguration(method: .get, - path: .path([city.thumb ?? ""]), - mockFilePath: + path: .path([city.thumb ?? ""]), + mockFilePath: .path(["Cities", "Thumbs", String(format: "%i.jpg", city.cityID)])) case .image(let city): return RouteConfiguration(method: .get, - path: .path([city.image ?? ""]), - mockFilePath: + path: .path([city.image ?? ""]), + mockFilePath: .path(["Cities", "Images", String(format: "%i.jpg", city.cityID)])) case .pinning(let configuration): return RouteConfiguration( diff --git a/README.md b/README.md index 25702feb..48dfde22 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@

- +

A zero-dependency networking solution for building modern and secure iOS, watchOS, macOS and tvOS applications. @@ -20,29 +20,28 @@

-🚀 TermiNetwork was tested in a production environment with a heavy load of asynchronous requests and tens of thousands of unique clients per day.

-
-

-

-This is a low resolution diagram of TermiNetwork that shows how its componets are connected to each other.

-
+🚀 TermiNetwork has been tested in a production environment with a heavy load of asynchronous requests and tens of thousands of unique clients per day. +

+ +This is a high level diagram of TermiNetwork showing how its componets are connected to each other. +

## Features -➡️  Multi-environment setup
-➡️  Model deserialization with Codables
-➡️  Choose the response type you want: Codable, UIImage, Data or String
-➡️  UIKit/SwiftUI helpers for downloading remote images
-➡️  Organize your Requests with Routers
-➡️  Reachability
-➡️  Transformers: convert REST models to DOMAIN models
-➡️  Error Handling
-➡️  Interceptors
-➡️  Mock Responses
-➡️  Certificate Pinning
-➡️  Flexible Configuration
-➡️  Middleware
-➡️  File/Data Upload/Download
-➡️  Pretty printed debug information +▫️ Multi-environment setup
+▫️ Model deserialization with Codables
+▫️ Decode response in the appropriate response type: Codable, UIImage, Data or String
+▫️ UIKit/SwiftUI helpers for downloading remote images
+▫️ Group your Requests in Routers
+▫️ Reachability support
+▫️ Transformers: convert models from one type to another easily
+▫️ Error Handling
+▫️ Interceptors
+▫️ Mock Responses
+▫️ Certificate Pinning
+▫️ Flexible Configuration
+▫️ Middleware
+▫️ File/Data Upload/Download
+▫️ Pretty printed debug information ### Table of contents - [Installation](#installation) diff --git a/Source/Extensions/Request+ResponseTypes.swift b/Source/Extensions/Request+ResponseTypes.swift index 8c135d9f..b69b3a53 100644 --- a/Source/Extensions/Request+ResponseTypes.swift +++ b/Source/Extensions/Request+ResponseTypes.swift @@ -24,7 +24,7 @@ extension Request { func makeResponseFailureHandler(responseHandler: @escaping (TNError) -> Void) -> (TNError, Data?, URLResponse?) -> Void { - return { error, data, urlResponse in + return { error, data, _ in self.handleDataTaskCompleted(with: data, error: error, onFailureCallback: { responseHandler(error) }) @@ -71,7 +71,7 @@ extension Request { func makeDecodableResponseFailureHandler(decodableType: T.Type, responseHandler: @escaping (T?, TNError) -> Void) -> (TNError, Data?, URLResponse?) -> Void { - return { error, data, urlResponse in + return { error, data, _ in // Check to see if there is already a deserialization error from success if case .cannotDeserialize = error { responseHandler(nil, error) diff --git a/Source/MultipartFormDataStream.swift b/Source/MultipartFormDataStream.swift index a0815630..23017968 100644 --- a/Source/MultipartFormDataStream.swift +++ b/Source/MultipartFormDataStream.swift @@ -221,7 +221,7 @@ internal class MultipartFormDataStream: NSObject, StreamDelegate { data.withUnsafeBytes { buffer in var maxLength = 0 - if case .stream(_, _) = currentBodyPart { + if case .stream = currentBodyPart { currentOffset = 0 maxLength = count < Constants.bufferSize ? count : Constants.bufferSize } else { diff --git a/Source/Reachability.swift b/Source/Reachability.swift index 7c3ed6e8..2fa427aa 100644 --- a/Source/Reachability.swift +++ b/Source/Reachability.swift @@ -113,7 +113,7 @@ open class Reachability { .passRetained(self) .toOpaque() - let callback: SCNetworkReachabilityCallBack = { (reachability, flags, info) in + let callback: SCNetworkReachabilityCallBack = { (_, flags, info) in guard let info = info else { return } Unmanaged.fromOpaque(info) diff --git a/Source/Request.swift b/Source/Request.swift index cfba7f89..11327be1 100644 --- a/Source/Request.swift +++ b/Source/Request.swift @@ -393,7 +393,7 @@ public final class Request: Operation { dataTask = SessionTaskFactory.makeDownloadTask(with: self, filePath: filePath, progressUpdate: progressUpdate, - completionHandler: { data, urlResponse in + completionHandler: { _, urlResponse in self.successCompletionHandler?(Data(), urlResponse) }, onFailure: { error, data in self.failureCompletionHandler?(error, data, self.urlResponse) diff --git a/TermiNetwork.xcodeproj/project.pbxproj b/TermiNetwork.xcodeproj/project.pbxproj index 8a5cdb10..61637f3e 100644 --- a/TermiNetwork.xcodeproj/project.pbxproj +++ b/TermiNetwork.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 23B36A0D277BB6D100A270B7 /* CryptoSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 23B36A0C277BB6D100A270B7 /* CryptoSwift */; }; F309C0ED25A512AB00D10877 /* Request+ResponseTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = F309C0EC25A512AB00D10877 /* Request+ResponseTypes.swift */; }; F30A298A258787320046C8E6 /* MiscRoute.swift in Sources */ = {isa = PBXBuildFile; fileRef = F30A2989258787320046C8E6 /* MiscRoute.swift */; }; F30A298E2587881D0046C8E6 /* RSEncryptedModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F30A298D258788180046C8E6 /* RSEncryptedModel.swift */; }; @@ -49,8 +50,6 @@ F32BB57B25A8ADCE00E6E096 /* StatusCodeTransformer.swift in Sources */ = {isa = PBXBuildFile; fileRef = F32BB57A25A8ADCE00E6E096 /* StatusCodeTransformer.swift */; }; F32C3D13243E499E004497BC /* TestPinning.swift in Sources */ = {isa = PBXBuildFile; fileRef = F32C3D12243E499E004497BC /* TestPinning.swift */; }; F3309DB4258AA05700BB018D /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F3309DB3258AA05700BB018D /* Launch Screen.storyboard */; }; - F3309DBF258ABF1200BB018D /* CryptoSwift in Frameworks */ = {isa = PBXBuildFile; productRef = F3309DBE258ABF1200BB018D /* CryptoSwift */; }; - F3309DE7258AC45800BB018D /* CryptoSwift in Frameworks */ = {isa = PBXBuildFile; productRef = F3309DE6258AC45800BB018D /* CryptoSwift */; }; F3319E9C246AD71C00D94AFE /* MultipartFormDataPartType.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3319E9B246AD71C00D94AFE /* MultipartFormDataPartType.swift */; }; F333429A25792E9D0087BDBA /* ErrorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F333429925792E9D0087BDBA /* ErrorModel.swift */; }; F3354D7825C737F600E02BC3 /* TestReachability.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3354D7725C737F600E02BC3 /* TestReachability.swift */; }; @@ -168,6 +167,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 23B36A07277BB5B800A270B7 /* CryptoKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CryptoKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.2.sdk/System/Library/Frameworks/CryptoKit.framework; sourceTree = DEVELOPER_DIR; }; F309C0EC25A512AB00D10877 /* Request+ResponseTypes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Request+ResponseTypes.swift"; sourceTree = ""; }; F30A2986258783B40046C8E6 /* CryptoMiddleware.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CryptoMiddleware.swift; sourceTree = ""; }; F30A2989258787320046C8E6 /* MiscRoute.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MiscRoute.swift; sourceTree = ""; }; @@ -305,6 +305,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 23B36A0D277BB6D100A270B7 /* CryptoSwift in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -313,7 +314,6 @@ buildActionMask = 2147483647; files = ( F3196837243D01E1008725CE /* TermiNetwork.framework in Frameworks */, - F3309DBF258ABF1200BB018D /* CryptoSwift in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -322,7 +322,6 @@ buildActionMask = 2147483647; files = ( F3D16EC82575299900F7B523 /* TermiNetwork.framework in Frameworks */, - F3309DE7258AC45800BB018D /* CryptoSwift in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -771,6 +770,7 @@ F3D16EC72575299900F7B523 /* Frameworks */ = { isa = PBXGroup; children = ( + 23B36A07277BB5B800A270B7 /* CryptoKit.framework */, F39474D725C8A1730084CB25 /* SystemConfiguration.framework */, ); name = Frameworks; @@ -815,6 +815,7 @@ ); name = TermiNetwork; packageProductDependencies = ( + 23B36A0C277BB6D100A270B7 /* CryptoSwift */, ); productName = TermiNetwork; productReference = F319682D243D01E1008725CE /* TermiNetwork.framework */; @@ -836,7 +837,6 @@ ); name = TermiNetworkTests; packageProductDependencies = ( - F3309DBE258ABF1200BB018D /* CryptoSwift */, ); productName = TermiNetworkTests; productReference = F3196836243D01E1008725CE /* TermiNetworkTests.xctest */; @@ -858,7 +858,6 @@ ); name = "TermiNetworkExamples (iOS)"; packageProductDependencies = ( - F3309DE6258AC45800BB018D /* CryptoSwift */, ); productName = "TermiNetworkExamples (iOS)"; productReference = F3556080257527C40047D46D /* TermiNetworkExamples.app */; @@ -897,7 +896,7 @@ ); mainGroup = F3196823243D01E1008725CE; packageReferences = ( - F3309DBD258ABF1200BB018D /* XCRemoteSwiftPackageReference "CryptoSwift" */, + 23B36A0B277BB6D100A270B7 /* XCRemoteSwiftPackageReference "CryptoSwift" */, ); productRefGroup = F319682E243D01E1008725CE /* Products */; projectDirPath = ""; @@ -959,7 +958,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if which swiftlint >/dev/null; then\n swiftlint --path \"$PROJECT_DIR/Source\" --config \"$PROJECT_DIR/.swiftlint.yml\"\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n"; + shellScript = "export PATH=\"/opt/homebrew/bin/:$PATH\"\nif which swiftlint >/dev/null; then\n swiftlint --path \"$PROJECT_DIR/Source\" --config \"$PROJECT_DIR/.swiftlint.yml\"\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n"; }; F3196885243D0904008725CE /* ShellScript */ = { isa = PBXShellScriptBuildPhase; @@ -1443,25 +1442,20 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ - F3309DBD258ABF1200BB018D /* XCRemoteSwiftPackageReference "CryptoSwift" */ = { + 23B36A0B277BB6D100A270B7 /* XCRemoteSwiftPackageReference "CryptoSwift" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/krzyzanowskim/CryptoSwift"; requirement = { kind = upToNextMajorVersion; - minimumVersion = 1.3.8; + minimumVersion = 1.0.0; }; }; /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ - F3309DBE258ABF1200BB018D /* CryptoSwift */ = { + 23B36A0C277BB6D100A270B7 /* CryptoSwift */ = { isa = XCSwiftPackageProductDependency; - package = F3309DBD258ABF1200BB018D /* XCRemoteSwiftPackageReference "CryptoSwift" */; - productName = CryptoSwift; - }; - F3309DE6258AC45800BB018D /* CryptoSwift */ = { - isa = XCSwiftPackageProductDependency; - package = F3309DBD258ABF1200BB018D /* XCRemoteSwiftPackageReference "CryptoSwift" */; + package = 23B36A0B277BB6D100A270B7 /* XCRemoteSwiftPackageReference "CryptoSwift" */; productName = CryptoSwift; }; /* End XCSwiftPackageProductDependency section */ diff --git a/TermiNetworkLogo.svg b/TermiNetworkLogo.svg index 3374560d..dbd452b4 100644 --- a/TermiNetworkLogo.svg +++ b/TermiNetworkLogo.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/Tests/herokuapp.com.cer b/Tests/herokuapp.com.cer index 063eb69a..cc97c4d5 100644 Binary files a/Tests/herokuapp.com.cer and b/Tests/herokuapp.com.cer differ