Skip to content

Commit

Permalink
rename checkout not available
Browse files Browse the repository at this point in the history
  • Loading branch information
cianbuckley committed Oct 6, 2023
1 parent 20b0f2a commit e64eb3a
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ extension MyViewController: ShopifyCheckoutDelegate {

/// Issued when checkout is no longer available and will no longer be available with the checkout url supplied.
/// This may happen when the user has paused on checkout for a long period (hours) and then attempted to proceed again with the same checkout url
/// In event of checkoutNotAvailable, a new checkout url will need to be generated
case checkoutNotAvailable(message: String)
/// In event of checkoutUnavailable, a new checkout url will need to be generated
case checkoutUnavailable(message: String)
}

func checkoutDidClickLink(url: URL) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ extension CartViewController: CheckoutDelegate {
func checkoutDidFail(error: ShopifyCheckout.CheckoutError) {
switch error {
case .sdkError(let underlying): print(#function, underlying)
case .checkoutNotAvailable(let message): forceCloseCheckout(message)
case .checkoutUnavailable(let message): forceCloseCheckout(message)
case .serverError(let message): forceCloseCheckout(message)
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/ShopifyCheckout/CheckoutBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ extension CheckoutBridge {
enum WebEvent: Decodable {
case checkoutComplete
case checkoutCanceled
case checkoutNotAvailable
case checkoutUnavailable
case unsupported(String)

enum CodingKeys: String, CodingKey {
Expand All @@ -75,7 +75,7 @@ extension CheckoutBridge {
case "close":
self = .checkoutCanceled
case "error":
self = .checkoutNotAvailable
self = .checkoutUnavailable
default:
self = .unsupported(name)
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/ShopifyCheckout/CheckoutError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ public enum CheckoutError: Swift.Error {

/// Issued when checkout is no longer available and will no longer be available with the checkout url supplied.
/// This may happen when the user has paused on checkout for a long period (hours) and then attempted to proceed again with the same checkout url
/// In event of checkoutNotAvailable, a new checkout url will need to be generated
case checkoutNotAvailable(message: String)
/// In event of checkoutUnavailable, a new checkout url will need to be generated
case checkoutUnavailable(message: String)
}
6 changes: 3 additions & 3 deletions Sources/ShopifyCheckout/CheckoutView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ extension CheckoutView: WKScriptMessageHandler {
case .checkoutComplete:
CheckoutView.cache = nil
viewDelegate?.checkoutViewDidCompleteCheckout()
case .checkoutNotAvailable:
case .checkoutUnavailable:
CheckoutView.cache = nil
viewDelegate?.checkoutViewDidFailWithError(error: .checkoutNotAvailable(message: "Checkout not available."))
viewDelegate?.checkoutViewDidFailWithError(error: .checkoutUnavailable(message: "Checkout unavailable."))
default:
()
}
Expand Down Expand Up @@ -149,7 +149,7 @@ extension CheckoutView: WKNavigationDelegate {
}
}()

viewDelegate?.checkoutViewDidFailWithError(error: .checkoutNotAvailable(message: message))
viewDelegate?.checkoutViewDidFailWithError(error: .checkoutUnavailable(message: message))
return .cancel
}

Expand Down
6 changes: 3 additions & 3 deletions Tests/ShopifyCheckoutTests/CheckoutBridgeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class CheckoutBridgeTests: XCTestCase {
}
}

func testDecodeSupportsCheckoutNotAvailableEvent() throws {
func testDecodeSupportsCheckoutUnavailableEvent() throws {
let mock = WKScriptMessageMock(body: """
{
"name": "error"
Expand All @@ -107,8 +107,8 @@ class CheckoutBridgeTests: XCTestCase {

let result = try CheckoutBridge.decode(mock)

guard case CheckoutBridge.WebEvent.checkoutNotAvailable = result else {
return XCTFail("expected CheckoutScriptMessage.checkoutNotAvailable, got \(result)")
guard case CheckoutBridge.WebEvent.checkoutUnavailable = result else {
return XCTFail("expected CheckoutScriptMessage.checkoutUnavailable, got \(result)")
}
}
}

0 comments on commit e64eb3a

Please sign in to comment.