Skip to content

Commit 3ee740e

Browse files
committed
- doc update
1 parent c5a4f7b commit 3ee740e

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ By default you can perform a single request which returns a simple JSON response
5757

5858
```swift
5959
let testServerApi = API(withBaseUrl: "http://jsonplaceholder.typicode.com")
60-
testServerApi.get("/posts") { (error, data) in
60+
testServerApi.get("/posts") { (status, data) in
6161
//This data will be SwiftyJSON's Optional JSON type by default (data: JSON?)
6262
}
6363
```
@@ -104,7 +104,7 @@ extension ExampleResponse: JSONCodable {}
104104
After implementing the response object, you have to set the type of the expected response data in the completion's parameter list like this.
105105

106106
```swift
107-
testServerApi.get("/posts") { (error, data: [ExampleResponse]?) in
107+
testServerApi.get("/posts") { (status, data: [ExampleResponse]?) in
108108
//This a swift array now, filled with ExampleResponse instances
109109
}
110110
```
@@ -116,7 +116,7 @@ In this case an array was expected as response, but simple types will work as we
116116
Querying is simple like this:
117117

118118
```swift
119-
testServerApi.get("/posts", query: ["userId" : "1"]) { (error, object: [ExampleResponse]?) in
119+
testServerApi.get("/posts", query: ["userId" : "1"]) { (status, object: [ExampleResponse]?) in
120120
//...
121121
}
122122
```
@@ -128,7 +128,7 @@ Values in the query parameter dictionary must implement the `Queryable` protocol
128128
### Simple body
129129

130130
```swift
131-
testServerApi.post("/posts", data: ["body": "something","id": 1, "title": "Some title", "userId": 9]) { (error, object) in
131+
testServerApi.post("/posts", data: ["body": "something","id": 1, "title": "Some title", "userId": 9]) { (status, object) in
132132
//...
133133
}
134134
```
@@ -184,7 +184,7 @@ To upload, just pass a `ValidRequestData` to the approptiate function's data par
184184
```swift
185185
var uploadData = ExampleData(body: "body", id: 1, title: "title", userId: 2)
186186

187-
testServerApi.post("/posts", data: uploadData) { (error, object) in
187+
testServerApi.post("/posts", data: uploadData) { (status, object) in
188188
//...
189189
}
190190
```
@@ -207,7 +207,7 @@ var parameters: [String: String] {
207207
}
208208

209209
// ...
210-
oldServerApi.post("/post.php", query: ["dir": "gujci_test"], data: uploadData.formValue){ (error, response) in
210+
oldServerApi.post("/post.php", query: ["dir": "gujci_test"], data: uploadData.formValue){ (status, response) in
211211
// ... do something
212212
}
213213
```
@@ -226,7 +226,7 @@ As an optional extension `RESTAPIImage` adds a util implementation for `Multipa
226226

227227
````swift
228228
let uploadData = JPGUploadMultipartFormData(image: image, fileName: "image", uploadName: "upfile")
229-
api.post("/me/profile_picture", data: uploadData) { (err, resp) in
229+
api.post("/me/profile_picture", data: uploadData) { (status, resp) in
230230
//...
231231
}
232232
````
@@ -288,7 +288,7 @@ To log server sent errrors turn on `APIErrorLoggingEnabled`.
288288
- [x] Document the authentication
289289
- [x] Carthage support
290290
- [x] CocoaPods support
291-
- [x] expand error types to almost full
291+
- [x] expand status types to almost full
292292
- [x] make JSON and [JSON] comform to JSONParseable to reduce redundant code (Solved by adding ValidResponseData & Conditional Conformance)
293293
- [ ] Add more unit tests
294294
- [x] Travis

RESTAPI/APIImplementation.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,7 @@ internal extension API {
6565
print("\(request.url?.absoluteString ?? "Unknown URL") \(err) with no description")
6666
}
6767
}
68-
if let validData = data {
69-
completion(ResponseStatus(with: response), validData)
70-
}
71-
else {
72-
completion(ResponseStatus(with: response), nil)
73-
}
68+
completion(ResponseStatus(with: response), data)
7469

7570
}) .resume()
7671
}

0 commit comments

Comments
 (0)