From 4bcac8144fd438b9b93c2a9907a8581dfd899278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cihat=20Gu=CC=88ndu=CC=88z?= Date: Tue, 8 Aug 2017 20:27:53 +0200 Subject: [PATCH] Fix styling issues after feedback from @sunshinejr --- Sources/Moya/Endpoint.swift | 7 ------- Tests/TestHelpers.swift | 2 +- docs/MigrationGuides.md | 6 +++--- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/Sources/Moya/Endpoint.swift b/Sources/Moya/Endpoint.swift index 0bd170196..65b963218 100755 --- a/Sources/Moya/Endpoint.swift +++ b/Sources/Moya/Endpoint.swift @@ -74,27 +74,20 @@ extension Endpoint { switch task { case .requestPlain, .uploadFile, .uploadMultipart, .downloadDestination: return request - case .requestData(let data): request.httpBody = data return request - case let .requestParameters(parameters, parameterEncoding): return try? parameterEncoding.encode(request, with: parameters) - case let .uploadCompositeMultipart(_, urlParameters): return try? URLEncoding(destination: .queryString).encode(request, with: urlParameters) - case let .downloadParameters(parameters, parameterEncoding, _): return try? parameterEncoding.encode(request, with: parameters) - case let .requestCompositeData(bodyData: bodyData, urlParameters: urlParameters): request.httpBody = bodyData return try? URLEncoding(destination: .queryString).encode(request, with: urlParameters) - case let .requestCompositeParameters(bodyParameters: bodyParameters, bodyEncoding: bodyParameterEncoding, urlParameters: urlParameters): if bodyParameterEncoding is URLEncoding { fatalError("URLEncoding is disallowed as bodyEncoding.") } - guard let bodyfulRequest = try? bodyParameterEncoding.encode(request, with: bodyParameters) else { return nil } return try? URLEncoding(destination: .queryString).encode(bodyfulRequest, with: urlParameters) } diff --git a/Tests/TestHelpers.swift b/Tests/TestHelpers.swift index 7b57eae49..28be425b0 100644 --- a/Tests/TestHelpers.swift +++ b/Tests/TestHelpers.swift @@ -55,7 +55,7 @@ func url(_ route: TargetType) -> String { let failureEndpointClosure = { (target: GitHub) -> Endpoint in let error = NSError(domain: "com.moya.moyaerror", code: 0, userInfo: [NSLocalizedDescriptionKey: "Houston, we have a problem"]) - return Endpoint(url: url(target), sampleResponseClosure: {.networkError(error)}, method: target.method) + return Endpoint(url: url(target), sampleResponseClosure: {.networkError(error)}, method: target.method, task: target.task) } enum HTTPBin: TargetType { diff --git a/docs/MigrationGuides.md b/docs/MigrationGuides.md index e5a3f7820..ab702f8c3 100644 --- a/docs/MigrationGuides.md +++ b/docs/MigrationGuides.md @@ -6,10 +6,10 @@ Please follow the appropriate guide below when **upgrading to a new major versio ## Upgrade from 8.x to 9.x -- Move the `parameters` and `parameterEncoding` to the `task` computed property by using the case `.requestParameters(parameters:,encoding:)` -- Replace the task type `.request` with either `.requestPlain` (if you have no parameters) or `.requestParameters(parameters:,encoding:)` +- Move the `parameters` and `parameterEncoding` to the `task` computed property by using the case `.requestParameters(parameters:encoding:)` +- Replace the task type `.request` with either `.requestPlain` (if you have no parameters) or `.requestParameters(parameters:encoding:)` - There's no `parameters` and `parameterEncoding` on Endpoints any more (e.g. `addingParameters()`), use the new `task` property instead -- To send URL encoded parameters AND body parameters, you can now use the task type `.requestCompositeParameters(bodyParameters:,bodyEncoding:,urlParameters:)` +- To send URL encoded parameters AND body parameters, you can now use the task type `.requestCompositeParameters(bodyParameters:bodyEncoding:urlParameters:)` - Simplify occurrences of task type `.download(.request(destination))` to `.downloadDestination(destination)` - Simplify occurrences of task type `.upload(.file(url))` to `.uploadFile(url)` - Simplify occurrences of task type `.upload(.multipart(data))` to `.uploadMultipart(data)`