Skip to content

Commit 0d31aea

Browse files
committed
doc: add migration guide
1 parent 2ff3554 commit 0d31aea

File tree

1 file changed

+180
-0
lines changed

1 file changed

+180
-0
lines changed

MIGRATION.md

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
2+
# Migration Guide
3+
4+
This guide helps you migrate from this SDK to new [Csharp SDK](https://github.com/apideck-libraries/sdk-csharp)
5+
6+
## Key changes
7+
8+
1. **Installation**
9+
10+
```sh
11+
# Old package
12+
dotnet add package Apideck
13+
14+
# New package
15+
dotnet add package ApideckUnifySdk
16+
```
17+
18+
2. **SDK Initialization**
19+
20+
21+
```csharp
22+
// Old SDK
23+
Configuration config = new Configuration();
24+
config.AddApiKey("Authorization", "API_KEY");
25+
config.AddApiKeyPrefix("Authorization", "Bearer");
26+
var apiInstance = new CrmApi(config);
27+
28+
// New SDK
29+
var sdk = new Apideck(
30+
apiKey: "<YOUR_BEARER_TOKEN_HERE>",
31+
consumerId: "test-consumer",
32+
appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX"
33+
);
34+
```
35+
36+
3. **Method Naming Changes**
37+
38+
```csharp
39+
// Old SDK
40+
var result = apiInstance.CompaniesAll(raw, consumerId, appId, serviceId);
41+
42+
// New SDK
43+
var req = new AccountingCompaniesListRequest() {
44+
ServiceId = "salesforce"
45+
};
46+
var result = await sdk.Accounting.Companies.ListAsync(req);
47+
```
48+
49+
50+
4. **Request/Response Structure**
51+
52+
```csharp
53+
// Old SDK
54+
var result = apiInstance.CompaniesAll();
55+
foreach (var company in result.Data) {
56+
Console.WriteLine(company.Name);
57+
}
58+
59+
// New SDK
60+
var req = new AccountingCompaniesListRequest() {
61+
ServiceId = "salesforce",
62+
Filter = new CompaniesFilter() {
63+
// Add filters here
64+
}
65+
};
66+
var result = await sdk.Accounting.Companies.ListAsync(req);
67+
68+
```
69+
70+
Every response includes httpMeta which provides access to the raw HTTP request and response:
71+
The `httpMeta` object is essential because it provides detailed information about the HTTP request and response, which can be crucial for debugging and logging purposes.
72+
73+
74+
75+
5. **Method Naming Convention Changes**
76+
77+
The new SDK uses a more consistent and intuitive naming convention. Here's how the old methods map to new ones:
78+
79+
| Old Method | New Method |
80+
|------------|------------|
81+
| CompaniesAll | Companies.ListAsync |
82+
| CompaniesAdd | Companies.CreateAsync |
83+
| CompaniesOne | Companies.GetAsync |
84+
| CompaniesUpdate | Companies.UpdateAsync |
85+
...
86+
87+
6. **Async/await support for all API calls**
88+
89+
The new SDK fully supports async/await patterns by default.
90+
91+
```csharp
92+
// Old SDK - synchronous
93+
var result = apiInstance.CompaniesAll();
94+
95+
// New SDK - async/await
96+
var result = await sdk.Accounting.Companies.ListAsync(req);
97+
```
98+
99+
The previous SDK had a [known issue](https://github.com/apideck-libraries/dotnet-sdk?tab=readme-ov-file#async-functionality-with-applied-filters) where filters didn't work correctly with async operations. This has been completely resolved in the new SDK.
100+
101+
102+
7. **Error handling**
103+
104+
```csharp
105+
// Old SDK
106+
try {
107+
var result = apiInstance.CompaniesAll(raw, consumerId, appId, serviceId);
108+
}
109+
catch (ApiException e) {
110+
Console.WriteLine("Exception when calling API: " + e.Message);
111+
Console.WriteLine("Status Code: " + e.ErrorCode);
112+
Console.WriteLine("Detail: " + e.ErrorContent);
113+
}
114+
115+
// New SDK
116+
try {
117+
var result = await sdk.Accounting.Companies.ListAsync(req);
118+
}
119+
catch (Exception ex) {
120+
if (ex is BadRequestResponse badRequest) {
121+
// Handle 400 error
122+
}
123+
else if (ex is UnauthorizedResponse unauthorized) {
124+
// Handle 401 error
125+
}
126+
else if (ex is ApideckUnifySdk.Models.Errors.APIException apiError) {
127+
// Handle other API errors
128+
}
129+
}
130+
```
131+
132+
For more information about error handling, please check our [documentation](https://github.com/apideck-libraries/sdk-csharp/tree/main?tab=readme-ov-file#error-handling)
133+
134+
135+
## Additional features in the new SDK
136+
137+
1. **Retry configuration**
138+
139+
The retry configuration allows you to specify how the SDK should handle retries for failed requests. You can configure the retry strategy, initial interval, maximum interval, exponent, and maximum elapsed time.
140+
141+
Here is an example of how to configure retries:
142+
143+
```csharp
144+
var sdk = new Apideck(
145+
retryConfig: new RetryConfig(
146+
strategy: RetryConfig.RetryStrategy.BACKOFF,
147+
backoff: new BackoffStrategy(
148+
initialIntervalMs: 1L,
149+
maxIntervalMs: 50L,
150+
maxElapsedTimeMs: 100L,
151+
exponent: 1.1
152+
),
153+
retryConnectionErrors: false
154+
),
155+
apiKey: "<YOUR_BEARER_TOKEN_HERE>",
156+
consumerId: "test-consumer",
157+
appId: "your-app-id"
158+
);
159+
```
160+
161+
For more information about retry configuration, please refer to the [Retry Configuration Documentation](https://github.com/apideck-libraries/sdk-csharp/tree/main?tab=readme-ov-file#retries).
162+
163+
164+
## Breaking Changes
165+
166+
1. Package name has changed from Apideck to ApideckUnifySdk
167+
2. All API methods now follow a consistent naming pattern and are async by default
168+
3. SDK initialization has been simplified with a unified configuration object
169+
4. More specific error types for better error handling
170+
5. Request/response models have been updated for better type safety
171+
6. All operations now use dedicated request objects for parameters
172+
173+
174+
## Need help?
175+
176+
If you encounter any issues during migration:
177+
178+
1. Checkout out our [documentation](https://github.com/apideck-libraries/sdk-csharp/tree/main?tab=readme-ov-file#apideckunifysdk)
179+
2. Open an issue on our [GitHub repository](https://github.com/apideck-libraries/sdk-csharp/issues)
180+
3. Contact our support at `[email protected]`

0 commit comments

Comments
 (0)