Skip to content
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 5 additions & 1 deletion .fernignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
README.md

# Workflows
.github/
.github/

# Version Twekas
src/Merge.Client/Merge.Client.csproj
src/Merge.Client/Merge.cs
39 changes: 14 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ of the SDK methods are awaitable!

```csharp
using Merge;
using Merge.ATS;
using Merge.Ats;

MergeClient merge = new MergeClient(
"YOUR_API_KEY", "YOUR_ACCOUNT_ID"
Merge merge = new Merge(
"YOUR_API_KEY", "YOUR_ACCOUNT_TOKEN"
)
```

Expand All @@ -41,8 +41,8 @@ using more than one Merge API category right now, the SDK provides upgrade-flexi
Each category is namespaced:

```csharp
MergeClient merge = new MergeClient(
"YOUR_API_KEY", "YOUR_ACCOUNT_ID"
Merge merge = new Merge(
"YOUR_API_KEY", "YOUR_ACCOUNT_TOKEN"
)

merge.ATS. # APIs specific to the ATS Category
Expand All @@ -54,7 +54,7 @@ merge.HRIS. # APIs specific to the HRIS Category
You can override the HttpClient by passing in `ClientOptions`.

```csharp
merge = new MergeClient("YOUR_API_KEY", "YOUR_ACCOUNT_ID", new ClientOptions{
merge = new Merge("YOUR_API_KEY", "YOUR_ACCOUNT_ID", new ClientOptions{
HttpClient = ... // Override the Http Client
BaseURL = ... // Override the Base URL
})
Expand All @@ -68,7 +68,7 @@ a subclass of MergeException will be thrown:
using Merge;

try {
merge.ATS.Candidates.Retrieve(...);
merge.Ats.Candidates.Retrieve(...);
} catch (MergeException e) {
System.Console.WriteLine(e.Message)
System.Console.WriteLine(e.StatusCode)
Expand All @@ -83,32 +83,27 @@ Below are code snippets of how you can use the C# SDK.

```c#
using Merge;
using Merge.ATS;
using Merge.Ats;

MergeClient merge = new MergeClient(
"YOUR_API_KEY",
"YOUR_ACCOUNT_ID"
)
Merge merge = new Merge("YOUR_API_KEY", "YOUR_ACCOUNT_TOKEN")

merge.ATS.LinkToken.Create(new EndUserDetailsRequest{
merge.Ats.LinkToken.Create(new EndUserDetailsRequest{
EndUserEmailAddress = "john.smith@gmail.com",
EndUserOrganizationName = "acme",
EndUserOriginId = "1234",
Categories =
})
```

### Get Employee

```c#
using Merge;
using Merge.HRIS;
using Merge.Hris;

MergeClient merge = new MergeClient(
"YOUR_API_KEY",
"YOUR_ACCOUNT_ID"
MergeClient merge = new Merge(
"YOUR_API_KEY", "YOUR_ACCOUNT_ID"
)
Employee employee = merge.HRIS.Employees.Retrieve("0958cbc6-6040-430a-848e-aafacbadf4ae",
Employee employee = merge.Hris.Employees.RetrieveAsync("0958cbc6-6040-430a-848e-aafacbadf4ae",
new EmployeesRetrieveRequest{
IncludeRemoteData = true
}
Expand All @@ -124,9 +119,6 @@ globally or per-request.
var merge = new Merge("...", new ClientOptions{
MaxRetries = 1 // Only retry once
});
merge.ATS.Candidates.Retrieve(new CandidatesRetrieveRequest{ ... }, new RequestOptions {
MaxRetries = 0 // Disable retries
});
```

## Timeouts
Expand All @@ -137,9 +129,6 @@ globally or per-request.
var merge = new Merge("...", new ClientOptions{
TimeoutInSeconds = 20 // Lower timeout
});
merge.ATS.Candidates.Retrieve(new Merge{ ... }, new RequestOptions {
TimeoutInSeconds = 90 // Raise timeout
});
```

## Contributing
Expand Down
4 changes: 1 addition & 3 deletions src/Merge.Client.Test/TestClient.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
namespace Merge.Client.Test;

public class TestClient
{
}
public class TestClient { }
20 changes: 10 additions & 10 deletions src/Merge.Client.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Merge.Client", "Merge.Client\Merge.Client.csproj", "{F270F3CE-3B9F-48B1-8313-0AC0582EA987}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Merge.Client", "Merge.Client\Merge.Client.csproj", "{19553BD2-51BE-463B-ABEE-237BADF72B8A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Merge.Client.Test", "Merge.Client.Test\Merge.Client.Test.csproj", "{7098C0CE-E054-4492-8E05-54E0F6DEFFA7}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Merge.Client.Test", "Merge.Client.Test\Merge.Client.Test.csproj", "{1B8B8673-78F7-4998-B45C-70EC71615B85}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -16,13 +16,13 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F270F3CE-3B9F-48B1-8313-0AC0582EA987}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F270F3CE-3B9F-48B1-8313-0AC0582EA987}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F270F3CE-3B9F-48B1-8313-0AC0582EA987}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F270F3CE-3B9F-48B1-8313-0AC0582EA987}.Release|Any CPU.Build.0 = Release|Any CPU
{7098C0CE-E054-4492-8E05-54E0F6DEFFA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7098C0CE-E054-4492-8E05-54E0F6DEFFA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7098C0CE-E054-4492-8E05-54E0F6DEFFA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7098C0CE-E054-4492-8E05-54E0F6DEFFA7}.Release|Any CPU.Build.0 = Release|Any CPU
{19553BD2-51BE-463B-ABEE-237BADF72B8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{19553BD2-51BE-463B-ABEE-237BADF72B8A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{19553BD2-51BE-463B-ABEE-237BADF72B8A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{19553BD2-51BE-463B-ABEE-237BADF72B8A}.Release|Any CPU.Build.0 = Release|Any CPU
{1B8B8673-78F7-4998-B45C-70EC71615B85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1B8B8673-78F7-4998-B45C-70EC71615B85}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1B8B8673-78F7-4998-B45C-70EC71615B85}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1B8B8673-78F7-4998-B45C-70EC71615B85}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -1,7 +1,35 @@
using System.Text.Json;
using Merge.Client;
using Merge.Client.Accounting;

namespace Merge.Client.Accounting;

public class AccountDetailsClient
{
public async void Retrieve(){
private RawClient _client;

public AccountDetailsClient(RawClient client)
{
_client = client;
}

/// <summary>
/// Get details for a linked account.
/// </summary>
public async Task<AccountDetails> RetrieveAsync()
{
var response = await _client.MakeRequestAsync(
new RawClient.ApiRequest
{
Method = HttpMethod.Get,
Path = "/accounting/v1/account-details"
}
);
string responseBody = await response.Raw.Content.ReadAsStringAsync();
if (response.StatusCode >= 200 && response.StatusCode < 400)
{
return JsonSerializer.Deserialize<AccountDetails>(responseBody);
}
throw new Exception();
}
}
30 changes: 29 additions & 1 deletion src/Merge.Client/Accounting/AccountToken/AccountTokenClient.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,35 @@
using System.Text.Json;
using Merge.Client;
using Merge.Client.Accounting;

namespace Merge.Client.Accounting;

public class AccountTokenClient
{
public async void Retrieve(){
private RawClient _client;

public AccountTokenClient(RawClient client)
{
_client = client;
}

/// <summary>
/// Returns the account token for the end user with the provided public token.
/// </summary>
public async Task<AccountToken> RetrieveAsync(string publicToken)
{
var response = await _client.MakeRequestAsync(
new RawClient.ApiRequest
{
Method = HttpMethod.Get,
Path = $"/accounting/v1/account-token/{publicToken}"
}
);
string responseBody = await response.Raw.Content.ReadAsStringAsync();
if (response.StatusCode >= 200 && response.StatusCode < 400)
{
return JsonSerializer.Deserialize<AccountToken>(responseBody);
}
throw new Exception();
}
}
131 changes: 131 additions & 0 deletions src/Merge.Client/Accounting/AccountingClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
using Merge.Client;
using Merge.Client.Accounting;

namespace Merge.Client.Accounting;

public class AccountingClient
{
private RawClient _client;

public AccountingClient(RawClient client)
{
_client = client;
AccountDetails = new AccountDetailsClient(_client);
AccountToken = new AccountTokenClient(_client);
AccountingPeriods = new AccountingPeriodsClient(_client);
Accounts = new AccountsClient(_client);
Addresses = new AddressesClient(_client);
AsyncPassthrough = new AsyncPassthroughClient(_client);
Attachments = new AttachmentsClient(_client);
AuditTrail = new AuditTrailClient(_client);
AvailableActions = new AvailableActionsClient(_client);
BalanceSheets = new BalanceSheetsClient(_client);
CashFlowStatements = new CashFlowStatementsClient(_client);
CompanyInfo = new CompanyInfoClient(_client);
Contacts = new ContactsClient(_client);
CreditNotes = new CreditNotesClient(_client);
Scopes = new ScopesClient(_client);
DeleteAccount = new DeleteAccountClient(_client);
Expenses = new ExpensesClient(_client);
FieldMapping = new FieldMappingClient(_client);
GenerateKey = new GenerateKeyClient(_client);
IncomeStatements = new IncomeStatementsClient(_client);
Invoices = new InvoicesClient(_client);
Issues = new IssuesClient(_client);
Items = new ItemsClient(_client);
JournalEntries = new JournalEntriesClient(_client);
LinkToken = new LinkTokenClient(_client);
LinkedAccounts = new LinkedAccountsClient(_client);
Passthrough = new PassthroughClient(_client);
Payments = new PaymentsClient(_client);
PhoneNumbers = new PhoneNumbersClient(_client);
PurchaseOrders = new PurchaseOrdersClient(_client);
RegenerateKey = new RegenerateKeyClient(_client);
SelectiveSync = new SelectiveSyncClient(_client);
SyncStatus = new SyncStatusClient(_client);
ForceResync = new ForceResyncClient(_client);
TaxRates = new TaxRatesClient(_client);
TrackingCategories = new TrackingCategoriesClient(_client);
Transactions = new TransactionsClient(_client);
VendorCredits = new VendorCreditsClient(_client);
WebhookReceivers = new WebhookReceiversClient(_client);
}

public AccountDetailsClient AccountDetails { get; }

public AccountTokenClient AccountToken { get; }

public AccountingPeriodsClient AccountingPeriods { get; }

public AccountsClient Accounts { get; }

public AddressesClient Addresses { get; }

public AsyncPassthroughClient AsyncPassthrough { get; }

public AttachmentsClient Attachments { get; }

public AuditTrailClient AuditTrail { get; }

public AvailableActionsClient AvailableActions { get; }

public BalanceSheetsClient BalanceSheets { get; }

public CashFlowStatementsClient CashFlowStatements { get; }

public CompanyInfoClient CompanyInfo { get; }

public ContactsClient Contacts { get; }

public CreditNotesClient CreditNotes { get; }

public ScopesClient Scopes { get; }

public DeleteAccountClient DeleteAccount { get; }

public ExpensesClient Expenses { get; }

public FieldMappingClient FieldMapping { get; }

public GenerateKeyClient GenerateKey { get; }

public IncomeStatementsClient IncomeStatements { get; }

public InvoicesClient Invoices { get; }

public IssuesClient Issues { get; }

public ItemsClient Items { get; }

public JournalEntriesClient JournalEntries { get; }

public LinkTokenClient LinkToken { get; }

public LinkedAccountsClient LinkedAccounts { get; }

public PassthroughClient Passthrough { get; }

public PaymentsClient Payments { get; }

public PhoneNumbersClient PhoneNumbers { get; }

public PurchaseOrdersClient PurchaseOrders { get; }

public RegenerateKeyClient RegenerateKey { get; }

public SelectiveSyncClient SelectiveSync { get; }

public SyncStatusClient SyncStatus { get; }

public ForceResyncClient ForceResync { get; }

public TaxRatesClient TaxRates { get; }

public TrackingCategoriesClient TrackingCategories { get; }

public TransactionsClient Transactions { get; }

public VendorCreditsClient VendorCredits { get; }

public WebhookReceiversClient WebhookReceivers { get; }
}
Loading