From d37a1e0af77dc98bfedf7be31ded6a3ed901aee4 Mon Sep 17 00:00:00 2001 From: Shayokh144 Date: Thu, 1 Dec 2022 17:30:09 +0700 Subject: [PATCH] [324] [Chore] Remove RequestConfiguration and use Maya MultiTarget --- .../NetworkAPI/Core/NetworkAPIProtocol.swift | 8 +++---- .../Core/RequestConfiguration.swift | 21 ------------------- .../Sources/Data/NetworkAPI/NetworkAPI.swift | 6 +++--- 3 files changed, 7 insertions(+), 28 deletions(-) delete mode 100644 {PROJECT_NAME}/Sources/Data/NetworkAPI/Core/RequestConfiguration.swift diff --git a/{PROJECT_NAME}/Sources/Data/NetworkAPI/Core/NetworkAPIProtocol.swift b/{PROJECT_NAME}/Sources/Data/NetworkAPI/Core/NetworkAPIProtocol.swift index cae242e4..c57e118a 100644 --- a/{PROJECT_NAME}/Sources/Data/NetworkAPI/Core/NetworkAPIProtocol.swift +++ b/{PROJECT_NAME}/Sources/Data/NetworkAPI/Core/NetworkAPIProtocol.swift @@ -7,15 +7,15 @@ import RxSwift protocol NetworkAPIProtocol { - func performRequest(_ configuration: RequestConfiguration, for type: T.Type) -> Single + func performRequest(_ configuration: TargetType, for type: T.Type) -> Single } extension NetworkAPIProtocol { func request( - provider: MoyaProvider, - configuration: RequestConfiguration + provider: MoyaProvider, + configuration: TargetType ) -> Single { - provider.rx.request(configuration) + provider.rx.request(MultiTarget(configuration)) .map(T.self) } } diff --git a/{PROJECT_NAME}/Sources/Data/NetworkAPI/Core/RequestConfiguration.swift b/{PROJECT_NAME}/Sources/Data/NetworkAPI/Core/RequestConfiguration.swift deleted file mode 100644 index 49a01809..00000000 --- a/{PROJECT_NAME}/Sources/Data/NetworkAPI/Core/RequestConfiguration.swift +++ /dev/null @@ -1,21 +0,0 @@ -// -// RequestConfiguration.swift -// - -import Foundation -import Moya - -enum RequestConfiguration {} - -extension RequestConfiguration: TargetType { - - var baseURL: URL { URL(string: "https://base_url")! } - - var path: String { "" } - - var method: Moya.Method { .get } - - var task: Moya.Task { .requestPlain } - - var headers: [String: String]? { nil } -} diff --git a/{PROJECT_NAME}/Sources/Data/NetworkAPI/NetworkAPI.swift b/{PROJECT_NAME}/Sources/Data/NetworkAPI/NetworkAPI.swift index 0adb5a36..26471429 100644 --- a/{PROJECT_NAME}/Sources/Data/NetworkAPI/NetworkAPI.swift +++ b/{PROJECT_NAME}/Sources/Data/NetworkAPI/NetworkAPI.swift @@ -8,13 +8,13 @@ import RxSwift final class NetworkAPI: NetworkAPIProtocol { - private let provider: MoyaProvider + private let provider: MoyaProvider - init(provider: MoyaProvider = MoyaProvider()) { + init(provider: MoyaProvider = MoyaProvider()) { self.provider = provider } - func performRequest(_ configuration: RequestConfiguration, for type: T.Type) -> Single { + func performRequest(_ configuration: TargetType, for type: T.Type) -> Single { request(provider: provider, configuration: configuration) } }