Skip to content

Commit

Permalink
Fix naming + error messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumedebavelaere committed Jun 7, 2018
1 parent 2a6b5ed commit ddcaadc
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 17 deletions.
5 changes: 1 addition & 4 deletions TradeItIosTicketSDK2/TradeItOrder.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
public typealias TradeItPlaceOrderResult = TradeItPlaceTradeResult
public typealias TradeItPreviewOrderResult = TradeItPreviewTradeResult
public typealias TradeItPlaceOrderHandlers = (_ onSuccess: @escaping (TradeItPlaceOrderResult) -> Void,
_ onVerifyUrl: @escaping (
URL,
_ complete1FA: @escaping () -> Void
) -> Void,
_ onVerifyUrl: @escaping (URL, _ completeTradeChallenge: @escaping () -> Void) -> Void,
_ onFailure: @escaping (TradeItErrorResult) -> Void) -> Void

@objc public class TradeItOrder: NSObject {
Expand Down
11 changes: 4 additions & 7 deletions TradeItIosTicketSDK2/TradeItOrderService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ internal class TradeItOrderService: NSObject {
func cancelOrder(
_ data: TradeItCancelOrderRequest,
onSuccess: @escaping () -> Void,
onVerifyUrl: @escaping (
URL,
_ complete1FA: @escaping () -> Void
) -> Void,
onVerifyUrl: @escaping (URL, _ completeCancelOrderChallenge: @escaping () -> Void) -> Void,
onFailure: @escaping (TradeItErrorResult) -> Void
) {
data.token = self.session.token
Expand All @@ -65,7 +62,7 @@ internal class TradeItOrderService: NSObject {
onVerifyUrl(
oAuthUrl,
{
self.complete1FA(completionBlock: handler)
self.completeCancelOrderChallenge(completionBlock: handler)
}
)
case _ as TradeItAllOrderStatusResult:
Expand All @@ -83,7 +80,7 @@ internal class TradeItOrderService: NSObject {
}
}

func complete1FA(completionBlock: @escaping (TradeItResult) -> Void) {
func completeCancelOrderChallenge(completionBlock: @escaping (TradeItResult) -> Void) {
let complete1FARequest = TradeItComplete1FARequest(token: self.session.token)
let request = TradeItRequestFactory.buildJsonRequest(
for: complete1FARequest,
Expand All @@ -93,7 +90,7 @@ internal class TradeItOrderService: NSObject {

self.session.connector.send(request, targetClassType: TradeItAllOrderStatusResult.self) { result in
completionBlock(
result ?? TradeItErrorResult.tradeError(withSystemMessage: "Error canceling order.")
result ?? TradeItErrorResult.error(withSystemMessage: "Error canceling order.")
)
}
}
Expand Down
9 changes: 6 additions & 3 deletions TradeItIosTicketSDK2/TradeItOrdersViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ class TradeItOrdersViewController: TradeItViewController, TradeItOrdersTableDele
activityView.hide(animated: true)
self.loadOrders()
},
onVerifyUrl: { url, complete1FA in
self.cancelOrderSecurityHandler = complete1FA
onVerifyUrl: { url, completeCancelOrderChallenge in
self.cancelOrderSecurityHandler = completeCancelOrderChallenge
let safariViewController = SFSafariViewController(url: url)
self.present(safariViewController, animated: true, completion: nil)
},
Expand Down Expand Up @@ -126,7 +126,10 @@ class TradeItOrdersViewController: TradeItViewController, TradeItOrdersTableDele
cancelOrderSecurityHandler()
} else {
return self.alertManager.showError(
TradeItErrorResult.error(withSystemMessage: "Canceling order could not be submitted please try again."),
TradeItErrorResult(
title: "Canceling order failed",
message: "Your cancel order request could not be submitted. Please try again."
),
onViewController: self
)
}
Expand Down
4 changes: 2 additions & 2 deletions TradeItIosTicketSDK2/TradeItTradePreviewViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ class TradeItTradePreviewViewController: TradeItViewController, UITableViewDeleg
activityView.hide(animated: true)
self.delegate?.orderSuccessfullyPlaced(onTradePreviewViewController: self, withPlaceOrderResult: result)
},
{ url, complete1FA in
self.tradeSecurityHandler = complete1FA
{ url, completeTradeChallenge in
self.tradeSecurityHandler = completeTradeChallenge
let safariViewController = SFSafariViewController(url: url)
self.present(safariViewController, animated: true, completion: nil)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class TradeItYahooTradePreviewViewController: TradeItYahooViewController, UITabl

self.fireViewEventNotification(view: .submitted)
},
{ url, complete1FA in
{ url, completeTradeChallenge in
activityView.hide(animated: true)
self.alertManager.showError(
TradeItErrorResult.tradeError(withSystemMessage: "completeTradeChallenge is not implemented"),
Expand Down

0 comments on commit ddcaadc

Please sign in to comment.