From 016bdd86e1d994c7be4bda2b5141acc7cb0b3956 Mon Sep 17 00:00:00 2001 From: Victoria Park Date: Tue, 4 Feb 2025 08:08:00 -0800 Subject: [PATCH] update v2 migration guide for GA --- v2_MIGRATION_GUIDE.md | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/v2_MIGRATION_GUIDE.md b/v2_MIGRATION_GUIDE.md index 832db835..44c98044 100644 --- a/v2_MIGRATION_GUIDE.md +++ b/v2_MIGRATION_GUIDE.md @@ -1,6 +1,11 @@ -# Migrating Guide to 2.0.0-beta2 +# Migrating Guide to 2.0.0 -This guide helps you migrate your code from version 1.x or 2.0.0-beta1 to 2.0.0-beta2. +This guide helps you migrate your code from version 1.x or 2.0.0-beta releases to 2.0.0 GA. + +> **Note:** +> Most of the examples below show the changes introduced in **2.0.0-beta1** (new `CoreSDKError` wrapper types in **2.0.0-beta2**), which used completion signature of the form `(SomeResult?,CoreSDKError?) -> Void`. +> For **2.0.0 GA**, these methods now use `Result` in their completion blocks. +> Please see the [**What's New in 2.0.0 GA**] (#what's-new-in-200-ga) section below for updated code snippets. ## Overview Version 2.0 of the SDK transitions from delgate-based flows to completion handler-based flows. This change simplifies the integration and provides better compatibility with modern async/await patterns. @@ -297,3 +302,32 @@ func processPayment() async { } } ``` +#what's-new-in-200-ga + +### What's New in 2.0.0 GA +- If you were already in 2.0.0-beta versions, the difference in GA is that all completion blocks now return a single Result instead of two optionals. For example: +Using Completion Handlers +```swift +// 2.0.0-beta: +cardClient.approveOrder(request: cardRequest) { cardResult, error in + if let error { + // handle error + return + } + if let cardResult { + // Handle success + } +} +``` +```swift +// 2.0.0 GA: +cardClient.approveOrder(request: cardRequest) { cardResult, error in + switch result { + case .success(let cardResult): + // handle success + case .failure(let error): + // handle error + } +} +``` +- Async/await function signatures remain the same from 2.0.0 beta versions \ No newline at end of file