Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update v2 Migration Guide for GA #317

Merged
merged 4 commits into from
Feb 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions v2_MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
@@ -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 to 2.x

> **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<SomeResult, CoreSDKError>` in their completion blocks.
> Please see the [What's New in 2.0.0](#whats-new-in-200) 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.
Expand Down Expand Up @@ -297,3 +302,31 @@ func processPayment() async {
}
}
```

### What's New in 2.0.0
- If you were already in 2.0.0-beta versions, the difference in 2.0.0 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