1
- # Merge .NET Library
1
+ # Merge C# Library
2
2
3
- The official Merge C# library, supporting .NET Standard, .NET Core, and .NET Framework.
3
+ [ ![ fern shield] ( https://img.shields.io/badge/%F0%9F%8C%BF-SDK%20generated%20by%20Fern-brightgreen )] ( https://github.com/fern-api/fern )
4
+ [ ![ nuget shield] ( https://img.shields.io/nuget/v/Merge.Client )] ( https://nuget.org/packages/Merge.Client )
5
+
6
+ The Merge C# library provides convenient access to the Merge API from C#.
4
7
5
8
## Documentation
6
9
7
10
API reference documentation is available [ here] ( https://docs.merge.dev/basics/authentication/ ) .
8
11
9
12
## Installation
10
13
11
- Using the .NET Core command-line interface (CLI) tools:
12
-
13
14
``` sh
14
- dotnet add package Merge.Client
15
+ nuget install Merge.Client
15
16
```
16
17
17
- Using the NuGet Command Line Interface (CLI):
18
+ ## Usage
18
19
19
- ``` sh
20
- nuget install Merge.Client
20
+ Instantiate and use the client with the following:
21
+
22
+ ``` csharp
23
+ using Merge .Client .Ats ;
24
+ using Merge .Client ;
25
+
26
+ var client = new Merge (" API_KEY" );
27
+ await client .Ats .Activities .CreateAsync (
28
+ new ActivityEndpointRequest { Model = new ActivityRequest (), RemoteUserId = " remote_user_id" }
29
+ );
21
30
```
22
31
23
32
## Instantiation
@@ -61,55 +70,68 @@ var merge = new MergeClient("YOUR_API_KEY", "YOUR_ACCOUNT_ID", new ClientOptions
61
70
```
62
71
63
72
## Exception Handling
64
- When the API returns a non - zero status code , (4xx or 5xx response ),
65
- a subclass of MergeException will be thrown :
73
+
74
+ When the API returns a non - success status code (4xx or 5xx response ), a subclass of the following error
75
+ will be thrown .
66
76
67
77
```csharp
68
78
using Merge .Client ;
69
79
70
80
try {
71
- merge .Ats .Candidates . Retrieve (.. .);
72
- } catch (MergeException e ) {
73
- System .Console .WriteLine (e .Message )
74
- System .Console .WriteLine (e .StatusCode )
81
+ var response = await client .Ats .Activities . CreateAsync (.. .);
82
+ } catch (MergeApiException e ) {
83
+ System .Console .WriteLine (e .Body );
84
+ System .Console .WriteLine (e .StatusCode );
75
85
}
76
86
```
77
87
78
- ## Usage
88
+ ## Advanced
79
89
80
- Below are code snippets of how you can use the C# SDK.
90
+ ### Retries
81
91
82
- ### Create Link Token
92
+ The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
93
+ as the request is deemed retriable and the number of retry attempts has not grown larger than the configured
94
+ retry limit (default: 2).
83
95
84
- ``` c#
85
- using Merge .Client ;
86
- using Merge .Client .Ats ;
96
+ A request is deemed retriable when any of the following HTTP status codes is returned:
87
97
88
- var merge = new MergeClient (" YOUR_API_KEY" , " YOUR_ACCOUNT_TOKEN" )
98
+ - [ 408] ( https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408 ) (Timeout)
99
+ - [ 429] ( https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429 ) (Too Many Requests)
100
+ - [ 5XX] ( https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 ) (Internal Server Errors)
89
101
90
- merge .Ats .LinkToken .Create (new EndUserDetailsRequest {
91
- EndUserEmailAddress = " [email protected] " ,
92
- EndUserOrganizationName = " acme" ,
93
- EndUserOriginId = " 1234" ,
94
- })
102
+ Use the ` MaxRetries ` request option to configure this behavior.
103
+
104
+ ``` csharp
105
+ var response = await client .Ats .Activities .CreateAsync (
106
+ .. .,
107
+ new RequestOptions {
108
+ MaxRetries : 0 // Override MaxRetries at the request level
109
+ }
110
+ );
95
111
```
96
112
97
- ### Get Employee
113
+ ### Timeouts
98
114
99
- ```c #
100
- using Merge .Client ;
101
- using Merge .Client .Hris ;
115
+ The SDK defaults to a 30 second timeout. Use the ` Timeout ` option to configure this behavior.
102
116
103
- var merge = new MergeClient (
104
- " YOUR_API_KEY" , " YOUR_ACCOUNT_ID"
105
- )
106
- Employee employee = merge .Hris .Employees .RetrieveAsync (" 0958cbc6-6040-430a-848e-aafacbadf4ae" ,
107
- new EmployeesRetrieveRequest {
108
- IncludeRemoteData = true
117
+ ``` csharp
118
+ var response = await client .Ats .Activities .CreateAsync (
119
+ .. .,
120
+ new RequestOptions {
121
+ Timeout : TimeSpan .FromSeconds (3 ) // Override timeout to 3s
109
122
}
110
123
);
111
124
```
112
125
126
+ ## Contributing
127
+
128
+ While we value open-source contributions to this SDK, this library is generated programmatically.
129
+ Additions made directly to this library would have to be moved over to our generation code,
130
+ otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
131
+ a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
132
+ an issue first to discuss with us!
133
+
134
+ On the other hand, contributions to the README are always very welcome!
113
135
## Retries
114
136
429 Rate Limit, and >=500 Internal errors will all be
115
137
retried twice with exponential backoff. You can override this behavior
@@ -130,13 +152,3 @@ var merge = new MergeClient("...", new ClientOptions{
130
152
TimeoutInSeconds = 20 // Lower timeout
131
153
});
132
154
```
133
-
134
- ## Contributing
135
- While we value open-source contributions to this SDK, this library
136
- is generated programmatically. Additions made directly to this library
137
- would have to be moved over to our generation code, otherwise they would
138
- be overwritten upon the next generated release. Feel free to open a PR as a
139
- proof of concept, but know that we will not be able to merge it as-is.
140
- We suggest opening an issue first to discuss with us!
141
-
142
- On the other hand, contributions to the README are always very welcome!
0 commit comments