Skip to content
Closed
Show file tree
Hide file tree
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
104 changes: 58 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
# Merge .NET Library
# Merge C# Library

The official Merge C# library, supporting .NET Standard, .NET Core, and .NET Framework.
[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-SDK%20generated%20by%20Fern-brightgreen)](https://github.com/fern-api/fern)
[![nuget shield](https://img.shields.io/nuget/v/Merge.Client)](https://nuget.org/packages/Merge.Client)

The Merge C# library provides convenient access to the Merge API from C#.

## Documentation

API reference documentation is available [here](https://docs.merge.dev/basics/authentication/).

## Installation

Using the .NET Core command-line interface (CLI) tools:

```sh
dotnet add package Merge.Client
nuget install Merge.Client
```

Using the NuGet Command Line Interface (CLI):
## Usage

```sh
nuget install Merge.Client
Instantiate and use the client with the following:

```csharp
using Merge.Client.Ats;
using Merge.Client;

var client = new Merge("API_KEY");
await client.Ats.Activities.CreateAsync(
new ActivityEndpointRequest { Model = new ActivityRequest(), RemoteUserId = "remote_user_id" }
);
```

## Instantiation
Expand Down Expand Up @@ -61,55 +70,68 @@ var merge = new MergeClient("YOUR_API_KEY", "YOUR_ACCOUNT_ID", new ClientOptions
```

## Exception Handling
When the API returns a non-zero status code, (4xx or 5xx response),
a subclass of MergeException will be thrown:

When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
will be thrown.

```csharp
using Merge.Client;

try {
merge.Ats.Candidates.Retrieve(...);
} catch (MergeException e) {
System.Console.WriteLine(e.Message)
System.Console.WriteLine(e.StatusCode)
var response = await client.Ats.Activities.CreateAsync(...);
} catch (MergeApiException e) {
System.Console.WriteLine(e.Body);
System.Console.WriteLine(e.StatusCode);
}
```

## Usage
## Advanced

Below are code snippets of how you can use the C# SDK.
### Retries

### Create Link Token
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
as the request is deemed retriable and the number of retry attempts has not grown larger than the configured
retry limit (default: 2).

```c#
using Merge.Client;
using Merge.Client.Ats;
A request is deemed retriable when any of the following HTTP status codes is returned:

var merge = new MergeClient("YOUR_API_KEY", "YOUR_ACCOUNT_TOKEN")
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)

merge.Ats.LinkToken.Create(new EndUserDetailsRequest{
EndUserEmailAddress = "john.smith@gmail.com",
EndUserOrganizationName = "acme",
EndUserOriginId = "1234",
})
Use the `MaxRetries` request option to configure this behavior.

```csharp
var response = await client.Ats.Activities.CreateAsync(
...,
new RequestOptions {
MaxRetries: 0 // Override MaxRetries at the request level
}
);
```

### Get Employee
### Timeouts

```c#
using Merge.Client;
using Merge.Client.Hris;
The SDK defaults to a 30 second timeout. Use the `Timeout` option to configure this behavior.

var merge = new MergeClient(
"YOUR_API_KEY", "YOUR_ACCOUNT_ID"
)
Employee employee = merge.Hris.Employees.RetrieveAsync("0958cbc6-6040-430a-848e-aafacbadf4ae",
new EmployeesRetrieveRequest{
IncludeRemoteData = true
```csharp
var response = await client.Ats.Activities.CreateAsync(
...,
new RequestOptions {
Timeout: TimeSpan.FromSeconds(3) // Override timeout to 3s
}
);
```

## Contributing

While we value open-source contributions to this SDK, this library is generated programmatically.
Additions made directly to this library would have to be moved over to our generation code,
otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
an issue first to discuss with us!

On the other hand, contributions to the README are always very welcome!
## Retries
429 Rate Limit, and >=500 Internal errors will all be
retried twice with exponential backoff. You can override this behavior
Expand All @@ -130,13 +152,3 @@ var merge = new MergeClient("...", new ClientOptions{
TimeoutInSeconds = 20 // Lower timeout
});
```

## Contributing
While we value open-source contributions to this SDK, this library
is generated programmatically. Additions made directly to this library
would have to be moved over to our generation code, otherwise they would
be overwritten upon the next generated release. Feel free to open a PR as a
proof of concept, but know that we will not be able to merge it as-is.
We suggest opening an issue first to discuss with us!

On the other hand, contributions to the README are always very welcome!
Loading