Skip to content

Commit

Permalink
Fix styling issues after feedback from @sunshinejr
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeehut authored and sunshinejr committed Aug 11, 2017
1 parent 7455af5 commit 4bcac81
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
7 changes: 0 additions & 7 deletions Sources/Moya/Endpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/TestHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func url(_ route: TargetType) -> String {

let failureEndpointClosure = { (target: GitHub) -> Endpoint<GitHub> in
let error = NSError(domain: "com.moya.moyaerror", code: 0, userInfo: [NSLocalizedDescriptionKey: "Houston, we have a problem"])
return Endpoint<GitHub>(url: url(target), sampleResponseClosure: {.networkError(error)}, method: target.method)
return Endpoint<GitHub>(url: url(target), sampleResponseClosure: {.networkError(error)}, method: target.method, task: target.task)
}

enum HTTPBin: TargetType {
Expand Down
6 changes: 3 additions & 3 deletions docs/MigrationGuides.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)`

0 comments on commit 4bcac81

Please sign in to comment.