-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # README.md
- Loading branch information
Showing
47 changed files
with
3,074 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
NetworkingSampleApp/NetworkingSampleApp/API/Routers/SampleDownloadRouter.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// SampleDownloadRouter.swift | ||
// | ||
// | ||
// Created by Matej Molnár on 07.03.2023. | ||
// | ||
|
||
import Foundation | ||
import Networking | ||
|
||
/// Implementation of sample API router | ||
enum SampleDownloadRouter: Requestable { | ||
case download(url: URL) | ||
|
||
var baseURL: URL { | ||
switch self { | ||
case let .download(url): | ||
return url | ||
} | ||
} | ||
|
||
var path: String { | ||
switch self { | ||
case .download: | ||
return "" | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
NetworkingSampleApp/NetworkingSampleApp/API/Routers/SampleUploadRouter.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// SampleUploadRouter.swift | ||
// NetworkingSampleApp | ||
// | ||
// Created by Tony Ngo on 12.06.2023. | ||
// | ||
|
||
import Foundation | ||
import Networking | ||
|
||
enum SampleUploadRouter: Requestable { | ||
case image | ||
case file(URL) | ||
case multipart(boundary: String) | ||
|
||
var baseURL: URL { | ||
URL(string: SampleAPIConstants.uploadHost)! | ||
} | ||
|
||
var headers: [String: String]? { | ||
switch self { | ||
case .image: | ||
return ["Content-Type": "image/png"] | ||
case let .file(url): | ||
return ["Content-Type": url.mimeType] | ||
case let .multipart(boundary): | ||
return ["Content-Type": "multipart/form-data; boundary=\(boundary)"] | ||
} | ||
} | ||
|
||
var path: String { | ||
"/post" | ||
} | ||
|
||
var method: HTTPMethod { | ||
.post | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ import Foundation | |
enum SampleAPIConstants { | ||
static let userHost = "https://reqres.in/api" | ||
static let authHost = "https://nonexistentmockauth.com/api" | ||
static let uploadHost = "https://httpbin.org" | ||
static let validEmail = "[email protected]" | ||
static let validPassword = "cityslicka" | ||
static let videoUrl = "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
NetworkingSampleApp/NetworkingSampleApp/Extensions/ByteCountFormatter+Convenience.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// ByteCountFormatter+Convenience.swift | ||
// NetworkingSampleApp | ||
// | ||
// Created by Tony Ngo on 30.06.2023. | ||
// | ||
|
||
import Foundation | ||
|
||
extension ByteCountFormatter { | ||
static let megaBytesFormatter: ByteCountFormatter = { | ||
let formatter = ByteCountFormatter() | ||
formatter.allowedUnits = [.useMB] | ||
formatter.countStyle = .file | ||
return formatter | ||
}() | ||
} |
32 changes: 32 additions & 0 deletions
32
NetworkingSampleApp/NetworkingSampleApp/Extensions/DownloadAPIManager+SharedInstance.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// DownloadAPIManager+SharedInstance.swift | ||
// NetworkingSampleApp | ||
// | ||
// Created by Dominika Gajdová on 12.05.2023. | ||
// | ||
|
||
import Networking | ||
|
||
extension DownloadAPIManager { | ||
static var shared: DownloadAPIManaging = { | ||
var responseProcessors: [ResponseProcessing] = [ | ||
LoggingInterceptor.shared, | ||
StatusCodeProcessor.shared | ||
] | ||
var errorProcessors: [ErrorProcessing] = [LoggingInterceptor.shared] | ||
|
||
#if DEBUG | ||
responseProcessors.append(EndpointRequestStorageProcessor.shared) | ||
errorProcessors.append(EndpointRequestStorageProcessor.shared) | ||
#endif | ||
|
||
return DownloadAPIManager( | ||
urlSessionConfiguration: .default, | ||
requestAdapters: [ | ||
LoggingInterceptor.shared | ||
], | ||
responseProcessors: responseProcessors, | ||
errorProcessors: errorProcessors | ||
) | ||
}() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.