Skip to content

Commit 016bdd8

Browse files
committed
update v2 migration guide for GA
1 parent 768e971 commit 016bdd8

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

v2_MIGRATION_GUIDE.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
# Migrating Guide to 2.0.0-beta2
1+
# Migrating Guide to 2.0.0
22

3-
This guide helps you migrate your code from version 1.x or 2.0.0-beta1 to 2.0.0-beta2.
3+
This guide helps you migrate your code from version 1.x or 2.0.0-beta releases to 2.0.0 GA.
4+
5+
> **Note:**
6+
> 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`.
7+
> For **2.0.0 GA**, these methods now use `Result<SomeResult, CoreSDKError>` in their completion blocks.
8+
> Please see the [**What's New in 2.0.0 GA**] (#what's-new-in-200-ga) section below for updated code snippets.
49
510
## Overview
611
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 {
297302
}
298303
}
299304
```
305+
#what's-new-in-200-ga
306+
307+
### What's New in 2.0.0 GA
308+
- 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:
309+
Using Completion Handlers
310+
```swift
311+
// 2.0.0-beta:
312+
cardClient.approveOrder(request: cardRequest) { cardResult, error in
313+
if let error {
314+
// handle error
315+
return
316+
}
317+
if let cardResult {
318+
// Handle success
319+
}
320+
}
321+
```
322+
```swift
323+
// 2.0.0 GA:
324+
cardClient.approveOrder(request: cardRequest) { cardResult, error in
325+
switch result {
326+
case .success(let cardResult):
327+
// handle success
328+
case .failure(let error):
329+
// handle error
330+
}
331+
}
332+
```
333+
- Async/await function signatures remain the same from 2.0.0 beta versions

0 commit comments

Comments
 (0)