Skip to content

Commit

Permalink
Updated some comments and README to use correct cases for Swift.Result.
Browse files Browse the repository at this point in the history
  • Loading branch information
dgallagher-venmo committed Feb 20, 2019
1 parent b586fd1 commit 25e9a43
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
22 changes: 11 additions & 11 deletions QuizTrain/Network/ObjectAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ extension ObjectAPI {
handler closures when complete. Swift inference auto-detects which
process(...) method to call.

The value passed to a Outcome.succeeded and .failed cases varies. See
The value passed to a Outcome.success and .failed cases varies. See
method comments for details.

If handle429TooManyRequestErrors is true and the API returned a 429 Too
Expand All @@ -323,8 +323,8 @@ extension ObjectAPI {
/**
Process API.RequestOutcome's to delete an object.

- Outcome.succeeded receives an API.DataResponse.
- Outcome.failed receives a RequestError.
- Outcome.success receives an API.DataResponse.
- Outcome.failure receives a RequestError.
*/
fileprivate func process(_ apiRequestOutcome: API.RequestOutcome, retryHandler: @escaping (() -> Void), completionHandler: @escaping (Outcome<API.RequestResult, RequestError>) -> Void) {

Expand Down Expand Up @@ -352,9 +352,9 @@ extension ObjectAPI {
/**
Process API.RequestOutcome's to get a single object.

- Outcome.succeeded receives an object deserialized from
- Outcome.success receives an object deserialized from
API.RequestOutcome.
- Outcome.failed receives a DataRequestError.
- Outcome.failure receives a DataRequestError.
*/
fileprivate func process<ObjectType: JSONDeserializable>(_ apiRequestOutcome: API.RequestOutcome, retryHandler: @escaping (() -> Void), completionHandler: @escaping (Outcome<ObjectType, DataRequestError>) -> Void) {

Expand Down Expand Up @@ -382,9 +382,9 @@ extension ObjectAPI {
/**
Process API.RequestOutcome's to get multiple objects.

- Outcome.succeeded receives 0+ object(s) deserialized from
- Outcome.success receives 0+ object(s) deserialized from
API.RequestOutcome.
- Outcome.failed receives a DataRequestError.
- Outcome.failure receives a DataRequestError.
*/
fileprivate func process<ObjectType: JSONDeserializable>(_ apiRequestOutcome: API.RequestOutcome, retryHandler: @escaping (() -> Void), completionHandler: @escaping (Outcome<[ObjectType], DataRequestError>) -> Void) {

Expand Down Expand Up @@ -413,9 +413,9 @@ extension ObjectAPI {
Process API.RequestOutcome's to add or update an object returning a new
added/updated object if successful.

- Outcome.succeeded receives an object deserialized from
- Outcome.success receives an object deserialized from
API.RequestOutcome.
- Outcome.failed receives an UpdateRequestError.
- Outcome.failure receives an UpdateRequestError.
*/
fileprivate func process<ObjectType: JSONDeserializable>(_ apiRequestOutcome: API.RequestOutcome, retryHandler: @escaping (() -> Void), completionHandler: @escaping (Outcome<ObjectType, UpdateRequestError>) -> Void) {

Expand Down Expand Up @@ -448,9 +448,9 @@ extension ObjectAPI {
Process API.RequestOutcome's to add or update multiple objects returning an
array of the added/updated objects if successful.

- Outcome.succeeded receives an array of objects deserialized from
- Outcome.success receives an array of objects deserialized from
API.RequestOutcome.
- Outcome.failed receives an UpdateRequestError.
- Outcome.failure receives an UpdateRequestError.
*/
fileprivate func process<ObjectType: JSONDeserializable>(_ apiRequestOutcome: API.RequestOutcome, retryHandler: @escaping (() -> Void), completionHandler: @escaping (Outcome<[ObjectType], UpdateRequestError>) -> Void) {

Expand Down
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ Below shows a limited number of examples. For all examples see [ObjectAPITests.s

objectAPI.getCases(inProjectWithId: 5) { (outcome) in
switch outcome {
case .failed(let error):
case .failure(let error):
print(error.debugDescription)
case .succeeded(let cases):
case .success(let cases):
print(cases) // Do something with cases.
}
}
Expand All @@ -46,9 +46,9 @@ Below shows a limited number of examples. For all examples see [ObjectAPITests.s

objectAPI.addCase(newCase, to: section) { (outcome) in
switch outcome {
case .failed(let error):
case .failure(let error):
print(error.debugDescription)
case .succeeded(let `case`):
case .success(let `case`):
print(`case`.title) // Do something with the newly created `case`.
}
}
Expand All @@ -61,9 +61,9 @@ Below shows a limited number of examples. For all examples see [ObjectAPITests.s

objectAPI.updateSuite(suite) { (outcome) in
switch outcome {
case .failed(let error):
case .failure(let error):
print(error.debugDescription)
case .succeeded(let updatedSuite):
case .success(let updatedSuite):
print(updatedSuite.description) // "Updated description for this suite."
print(updatedSuite.name) // "Updated name of this suite."
}
Expand All @@ -75,9 +75,9 @@ Below shows a limited number of examples. For all examples see [ObjectAPITests.s

objectAPI.deleteSection(section) { (outcome) in
switch outcome {
case .failed(let error):
case .failure(let error):
print(error.debugDescription)
case .succeeded(_): // nil on successful deletes
case .success(_): // nil on successful deletes
print("The section has been successfully deleted.")
}
}
Expand All @@ -88,9 +88,9 @@ Below shows a limited number of examples. For all examples see [ObjectAPITests.s

objectAPI.closePlan(plan) { (outcome) in
switch outcome {
case .failed(let error):
case .failure(let error):
print(error.debugDescription)
case .succeeded(let closedPlan):
case .success(let closedPlan):
print(closedPlan.isCompleted) // true
print(closedPlan.completedOn) // timestamp
}
Expand All @@ -102,9 +102,9 @@ Below shows a limited number of examples. For all examples see [ObjectAPITests.s

milestone.parent(objectAPI) { (outcome) in
switch outcome {
case .failed(let error):
case .failure(let error):
print(error.debugDescription)
case .succeeded(let optionalParent):
case .success(let optionalParent):
if let parent = optionalParent {
print("Milestone \(milestone.id) has a parent with an id of \(parent.id).")
} else {
Expand All @@ -119,9 +119,9 @@ Below shows a limited number of examples. For all examples see [ObjectAPITests.s

objectAPI.getRuns(inProjectWithId: 3, filteredBy: filters) { (outcome) in
switch outcome {
case .failed(let error):
case .failure(let error):
print(error.debugDescription)
case .succeeded(let completedRuns):
case .success(let completedRuns):
for completedRun in completedRuns {
print(completedRun.isCompleted) // true
}
Expand All @@ -136,9 +136,9 @@ Below shows a limited number of examples. For all examples see [ObjectAPITests.s

objectAPI.getPlans(in: project, filteredBy: filters) { (outcome) in
switch outcome {
case .failed(let error):
case .failure(let error):
print(error.debugDescription)
case .succeeded(let plans): // There will be 5 or less plans.
case .success(let plans): // There will be 5 or less plans.
for plan in plans {
print(plan.name)
}
Expand Down

0 comments on commit 25e9a43

Please sign in to comment.