Skip to content

Commit

Permalink
Merge pull request #28 from rcaos/networking-async
Browse files Browse the repository at this point in the history
Networking Async-await
  • Loading branch information
rcaos authored Nov 4, 2024
2 parents d3d10d7 + 5a7ae56 commit 2ab75bb
Show file tree
Hide file tree
Showing 214 changed files with 2,731 additions and 3,812 deletions.
8 changes: 8 additions & 0 deletions .swiftpm/xcode/xcshareddata/xcschemes/AccountFeature.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@
BlueprintName = "AccountFeatureTests"
ReferencedContainer = "container:">
</BuildableReference>
<SkippedTests>
<Test
Identifier = "AccountViewTests">
</Test>
<Test
Identifier = "SignInViewTests">
</Test>
</SkippedTests>
</TestableReference>
</Testables>
</TestAction>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
BlueprintName = "AiringTodayFeatureTests"
ReferencedContainer = "container:">
</BuildableReference>
<SkippedTests>
<Test
Identifier = "AiringTodayViewTests">
</Test>
</SkippedTests>
</TestableReference>
</Testables>
</TestAction>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
BlueprintName = "PopularsFeatureTests"
ReferencedContainer = "container:">
</BuildableReference>
<SkippedTests>
<Test
Identifier = "PopularViewTests">
</Test>
</SkippedTests>
</TestableReference>
</Testables>
</TestAction>
Expand Down
11 changes: 11 additions & 0 deletions .swiftpm/xcode/xcshareddata/xcschemes/SearchShowsFeature.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@
BlueprintName = "SearchShowsFeatureTests"
ReferencedContainer = "container:">
</BuildableReference>
<SkippedTests>
<Test
Identifier = "ResultsSearchViewModelTests">
</Test>
<Test
Identifier = "ResultsSearchViewTests">
</Test>
<Test
Identifier = "SearchShowsOptionsViewTests">
</Test>
</SkippedTests>
</TestableReference>
</Testables>
</TestAction>
Expand Down
26 changes: 26 additions & 0 deletions .swiftpm/xcode/xcshareddata/xcschemes/ShowDetailsFeature.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,32 @@
BlueprintName = "ShowDetailsFeatureTests"
ReferencedContainer = "container:">
</BuildableReference>
<SkippedTests>
<Test
Identifier = "EpisodesListViewModelTests/test_When_Ask_For_Different_Season_And_UseCase_Doesnt_Respond_Yet_ViewModel_Should_Contains_Loading_Season_State()">
</Test>
<Test
Identifier = "EpisodesListViewModelTests/test_When_Ask_For_Different_Season_And_UseCase_Return_Error_ViewModel_Should_Contains_Loading_Season_State()">
</Test>
<Test
Identifier = "EpisodesListViewModelTests/test_When_Ask_For_Different_Season_And_UseCase_Return_OK_ViewModel_Should_Contains_Data_With_Episodes()">
</Test>
<Test
Identifier = "EpisodesListViewModelTests/test_When_Ask_For_Different_Season_And_UseCase_Return_OK_ViewModel_Should_Contains_populated()">
</Test>
<Test
Identifier = "EpisodesListViewTests">
</Test>
<Test
Identifier = "FavoriteTapsTests">
</Test>
<Test
Identifier = "TVShowDetailViewTests">
</Test>
<Test
Identifier = "WatchListTapsTests">
</Test>
</SkippedTests>
</TestableReference>
</Testables>
</TestAction>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
BlueprintName = "ShowListFeatureTests"
ReferencedContainer = "container:">
</BuildableReference>
<SkippedTests>
<Test
Identifier = "TVShowListViewTests">
</Test>
</SkippedTests>
</TestableReference>
</Testables>
</TestAction>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
//
// File.swift
//
//
// Created by Jeans Ruiz on 20/04/22.
//

Expand All @@ -14,22 +11,24 @@ import ShowListFeatureInterface
public class AccountFeatureDemoCoordinator: Coordinator {
private let window: UIWindow
private let tabBarController: UITabBarController
private let apiDataTransferService: DataTransferService
private let apiClient: ApiClient
private let imagesBaseURL: String
private let authenticateBaseURL: String
private let gravatarBaseURL: String
private var childCoordinators = [Coordinator]()

// MARK: - Life Cycle
public init(window: UIWindow,
tabBarController: UITabBarController,
apiDataTransferService: DataTransferService,
imagesBaseURL: String,
gravatarBaseURL: String,
authenticateBaseURL: String) {
public init(
window: UIWindow,
tabBarController: UITabBarController,
apiClient: ApiClient,
imagesBaseURL: String,
gravatarBaseURL: String,
authenticateBaseURL: String
) {
self.window = window
self.tabBarController = tabBarController
self.apiDataTransferService = apiDataTransferService
self.apiClient = apiClient
self.imagesBaseURL = imagesBaseURL
self.gravatarBaseURL = gravatarBaseURL
self.authenticateBaseURL = authenticateBaseURL
Expand All @@ -51,14 +50,15 @@ public class AccountFeatureDemoCoordinator: Coordinator {
}

private func buildAccountCoordinator(in navigation: UINavigationController) {
let dependencies = AccountFeature.ModuleDependencies(apiDataTransferService: apiDataTransferService,
imagesBaseURL: imagesBaseURL,
authenticateBaseURL: authenticateBaseURL,
gravatarBaseURL: gravatarBaseURL,
requestTokenRepository: FakeRequestTokenRepository(),
accessTokenRepository: FakeAccessTokenRepository(),
userLoggedRepository: FakeLoggedUserRepository(),
showListBuilder: self
let dependencies = AccountFeature.ModuleDependencies(
apiClient: apiClient,
imagesBaseURL: imagesBaseURL,
authenticateBaseURL: authenticateBaseURL,
gravatarBaseURL: gravatarBaseURL,
requestTokenRepository: FakeRequestTokenRepository(),
accessTokenRepository: FakeAccessTokenRepository(),
userLoggedRepository: FakeLoggedUserRepository(),
showListBuilder: self
)
let module = AccountFeature.Module(dependencies: dependencies)
let coordinator = module.buildAccountCoordinator(in: navigation)
Expand Down Expand Up @@ -99,7 +99,7 @@ final class FakeRequestTokenRepository: RequestTokenRepositoryProtocol {
}
}

final class FakeAccessTokenRepository: AccessTokenRepositoryProtocol{
final class FakeAccessTokenRepository: AccessTokenRepositoryProtocol {
private var privateToken: String = "6b007b57648a1e65096290fe9a6239c9a66fc8c0"

func saveAccessToken(_ token: String) {
Expand Down
39 changes: 17 additions & 22 deletions App/Demos/AccountDemo/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
//
// AppDelegate.swift
// AccountDemo
//
// Created by Jeans Ruiz on 20/04/22.
//

import UIKit
import AccountFeatureDemo
import Networking
import NetworkingInterface

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
Expand All @@ -17,35 +14,33 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)

let appConfigurations = buildAppConfigurations()
let apiDataTransferService = buildDataTransferService(appConfigurations: appConfigurations)
coordinator = AccountFeatureDemoCoordinator(window: window!,
tabBarController: UITabBarController(),
apiDataTransferService: apiDataTransferService,
imagesBaseURL: appConfigurations.imagesBaseURL,
gravatarBaseURL: appConfigurations.gravatarBaseURL,
authenticateBaseURL: appConfigurations.authenticateBaseURL)
coordinator = AccountFeatureDemoCoordinator(
window: window!,
tabBarController: UITabBarController(),
apiClient: buildApiClient(appConfigurations: appConfigurations),
imagesBaseURL: appConfigurations.imagesBaseURL,
gravatarBaseURL: appConfigurations.gravatarBaseURL,
authenticateBaseURL: appConfigurations.authenticateBaseURL
)
coordinator?.start()
return true
}
}

func buildDataTransferService(appConfigurations: AppConfigurations) -> DefaultDataTransferService {
let queryParameters = [
"api_key": appConfigurations.apiKey,
"language": NSLocale.preferredLanguages.first ?? "en"
]

let configuration = ApiDataNetworkConfig(
private func buildApiClient(appConfigurations: AppConfigurations) -> ApiClient {
let config = NetworkConfig(
baseURL: appConfigurations.apiBaseURL,
headers: [
"Content-Type": "application/json; charset=utf-8"
],
queryParameters: queryParameters
queryParameters: [
"api_key": appConfigurations.apiKey,
"language": NSLocale.preferredLanguages.first ?? "en"
]
)
let networkService = DefaultNetworkService(config: configuration)
return DefaultDataTransferService(with: networkService)
return ApiClient.live(networkConfig: config)
}

struct AppConfigurations {
Expand Down
33 changes: 14 additions & 19 deletions App/Demos/AiringTodayDemo/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
//
// AppDelegate.swift
// AiringTodayDemo
//
// Created by Jeans Ruiz on 20/04/22.
//

import UIKit
import AiringTodayFeatureDemo
import Networking
import NetworkingInterface

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
Expand All @@ -19,31 +16,29 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
window = UIWindow(frame: UIScreen.main.bounds)

let appConfigurations = buildAppConfigurations()
let apiDataTransferService = buildDataTransferService(appConfigurations: appConfigurations)
coordinator = TodayDemoCoordinator(window: window!,
tabBarController: UITabBarController(),
apiDataTransferService: apiDataTransferService,
imagesBaseURL: appConfigurations.imagesBaseURL)
coordinator = TodayDemoCoordinator(
window: window!,
tabBarController: UITabBarController(),
apiClient: buildApiClient(appConfigurations: appConfigurations),
imagesBaseURL: appConfigurations.imagesBaseURL
)
coordinator?.start()
return true
}
}

func buildDataTransferService(appConfigurations: AppConfigurations) -> DefaultDataTransferService {
let queryParameters = [
"api_key": appConfigurations.apiKey,
"language": NSLocale.preferredLanguages.first ?? "en"
]

let configuration = ApiDataNetworkConfig(
private func buildApiClient(appConfigurations: AppConfigurations) -> ApiClient {
let config = NetworkConfig(
baseURL: appConfigurations.apiBaseURL,
headers: [
"Content-Type": "application/json; charset=utf-8"
],
queryParameters: queryParameters
queryParameters: [
"api_key": appConfigurations.apiKey,
"language": NSLocale.preferredLanguages.first ?? "en"
]
)
let networkService = DefaultNetworkService(config: configuration)
return DefaultDataTransferService(with: networkService)
return ApiClient.live(networkConfig: config)
}

struct AppConfigurations {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
//
// File.swift
//
//
// Created by Jeans Ruiz on 20/04/22.
//

Expand All @@ -14,18 +11,19 @@ import ShowDetailsFeatureInterface
public class TodayDemoCoordinator: Coordinator {
private let window: UIWindow
private let tabBarController: UITabBarController
private let apiDataTransferService: DataTransferService
private let apiClient: ApiClient
private let imagesBaseURL: String
private var childCoordinators = [Coordinator]()

// MARK: - Life Cycle
public init(window: UIWindow,
tabBarController: UITabBarController,
apiDataTransferService: DataTransferService,
imagesBaseURL: String) {
public init(
window: UIWindow,
tabBarController: UITabBarController,
apiClient: ApiClient,
imagesBaseURL: String
) {
self.window = window
self.tabBarController = tabBarController
self.apiDataTransferService = apiDataTransferService
self.apiClient = apiClient
self.imagesBaseURL = imagesBaseURL
}

Expand All @@ -45,9 +43,11 @@ public class TodayDemoCoordinator: Coordinator {
}

private func buildTodayScene(in navigation: UINavigationController) {
let dependencies = AiringTodayFeature.ModuleDependencies(apiDataTransferService: apiDataTransferService,
imagesBaseURL: imagesBaseURL,
showDetailsBuilder: self)
let dependencies = AiringTodayFeature.ModuleDependencies(
apiClient: apiClient,
imagesBaseURL: imagesBaseURL,
showDetailsBuilder: self
)
let module = AiringTodayFeature.Module(dependencies: dependencies)
let coordinator = module.buildAiringTodayCoordinator(in: navigation)
coordinator.start()
Expand Down
Loading

0 comments on commit 2ab75bb

Please sign in to comment.