diff --git a/.fernignore b/.fernignore
index 82ea2627..cc92f21b 100644
--- a/.fernignore
+++ b/.fernignore
@@ -3,4 +3,8 @@
README.md
# Workflows
-.github/
\ No newline at end of file
+.github/
+
+# Version Twekas
+src/Merge.Client/Merge.Client.csproj
+src/Merge.Client/Merge.cs
diff --git a/README.md b/README.md
index 64f509c9..818af610 100644
--- a/README.md
+++ b/README.md
@@ -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"
)
```
@@ -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
@@ -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
})
@@ -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)
@@ -83,18 +83,14 @@ 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 =
})
```
@@ -102,13 +98,12 @@ merge.ATS.LinkToken.Create(new EndUserDetailsRequest{
```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
}
@@ -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
@@ -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
diff --git a/src/Merge.Client.Test/TestClient.cs b/src/Merge.Client.Test/TestClient.cs
index cf6f7940..db3abedc 100644
--- a/src/Merge.Client.Test/TestClient.cs
+++ b/src/Merge.Client.Test/TestClient.cs
@@ -1,5 +1,3 @@
namespace Merge.Client.Test;
-public class TestClient
-{
-}
+public class TestClient { }
diff --git a/src/Merge.Client.sln b/src/Merge.Client.sln
index 4d405db2..11f58625 100644
--- a/src/Merge.Client.sln
+++ b/src/Merge.Client.sln
@@ -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
@@ -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
diff --git a/src/Merge.Client/Accounting/AccountDetails/AccountDetailsClient.cs b/src/Merge.Client/Accounting/AccountDetails/AccountDetailsClient.cs
index 7696cc42..501aa8be 100644
--- a/src/Merge.Client/Accounting/AccountDetails/AccountDetailsClient.cs
+++ b/src/Merge.Client/Accounting/AccountDetails/AccountDetailsClient.cs
@@ -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;
+ }
+
+ ///
+ /// Get details for a linked account.
+ ///
+ public async Task 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(responseBody);
+ }
+ throw new Exception();
}
}
diff --git a/src/Merge.Client/Accounting/AccountToken/AccountTokenClient.cs b/src/Merge.Client/Accounting/AccountToken/AccountTokenClient.cs
index d8dd5964..08c1b483 100644
--- a/src/Merge.Client/Accounting/AccountToken/AccountTokenClient.cs
+++ b/src/Merge.Client/Accounting/AccountToken/AccountTokenClient.cs
@@ -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;
+ }
+
+ ///
+ /// Returns the account token for the end user with the provided public token.
+ ///
+ public async Task 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(responseBody);
+ }
+ throw new Exception();
}
}
diff --git a/src/Merge.Client/Accounting/AccountingClient.cs b/src/Merge.Client/Accounting/AccountingClient.cs
new file mode 100644
index 00000000..c8d6edb4
--- /dev/null
+++ b/src/Merge.Client/Accounting/AccountingClient.cs
@@ -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; }
+}
diff --git a/src/Merge.Client/Accounting/AccountingPeriods/AccountingPeriodsClient.cs b/src/Merge.Client/Accounting/AccountingPeriods/AccountingPeriodsClient.cs
index 07e334f1..2f4e6091 100644
--- a/src/Merge.Client/Accounting/AccountingPeriods/AccountingPeriodsClient.cs
+++ b/src/Merge.Client/Accounting/AccountingPeriods/AccountingPeriodsClient.cs
@@ -1,9 +1,82 @@
+using System.Text.Json;
+using Merge.Client;
+using Merge.Client.Accounting;
+
namespace Merge.Client.Accounting;
public class AccountingPeriodsClient
{
- public async void List(){
+ private RawClient _client;
+
+ public AccountingPeriodsClient(RawClient client)
+ {
+ _client = client;
}
- public async void Retrieve(){
+
+ ///
+ /// Returns a list of `AccountingPeriod` objects.
+ ///
+ public async Task ListAsync(AccountingPeriodsListRequest request)
+ {
+ var _query = new Dictionary() { };
+ if (request.Cursor != null)
+ {
+ _query["cursor"] = request.Cursor;
+ }
+ if (request.IncludeDeletedData != null)
+ {
+ _query["include_deleted_data"] = request.IncludeDeletedData;
+ }
+ if (request.IncludeRemoteData != null)
+ {
+ _query["include_remote_data"] = request.IncludeRemoteData;
+ }
+ if (request.PageSize != null)
+ {
+ _query["page_size"] = request.PageSize;
+ }
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Get,
+ Path = "/accounting/v1/accounting-periods",
+ Query = _query
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
+ }
+
+ ///
+ /// Returns an `AccountingPeriod` object with the given `id`.
+ ///
+ public async Task RetrieveAsync(
+ string id,
+ AccountingPeriodsRetrieveRequest request
+ )
+ {
+ var _query = new Dictionary() { };
+ if (request.IncludeRemoteData != null)
+ {
+ _query["include_remote_data"] = request.IncludeRemoteData;
+ }
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Get,
+ Path = $"/accounting/v1/accounting-periods/{id}",
+ Query = _query
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
}
}
diff --git a/src/Merge.Client/Accounting/AccountingPeriods/requests/AccountingPeriodsListRequest.cs b/src/Merge.Client/Accounting/AccountingPeriods/requests/AccountingPeriodsListRequest.cs
new file mode 100644
index 00000000..3b4f5920
--- /dev/null
+++ b/src/Merge.Client/Accounting/AccountingPeriods/requests/AccountingPeriodsListRequest.cs
@@ -0,0 +1,24 @@
+namespace Merge.Client.Accounting;
+
+public class AccountingPeriodsListRequest
+{
+ ///
+ /// The pagination cursor value.
+ ///
+ public string? Cursor { get; init; }
+
+ ///
+ /// Whether to include data that was marked as deleted by third party webhooks.
+ ///
+ public bool? IncludeDeletedData { get; init; }
+
+ ///
+ /// Whether to include the original data Merge fetched from the third-party to produce these models.
+ ///
+ public bool? IncludeRemoteData { get; init; }
+
+ ///
+ /// Number of results to return per page.
+ ///
+ public int? PageSize { get; init; }
+}
diff --git a/src/Merge.Client/Accounting/AccountingPeriods/requests/AccountingPeriodsRetrieveRequest.cs b/src/Merge.Client/Accounting/AccountingPeriods/requests/AccountingPeriodsRetrieveRequest.cs
new file mode 100644
index 00000000..d7fa2717
--- /dev/null
+++ b/src/Merge.Client/Accounting/AccountingPeriods/requests/AccountingPeriodsRetrieveRequest.cs
@@ -0,0 +1,9 @@
+namespace Merge.Client.Accounting;
+
+public class AccountingPeriodsRetrieveRequest
+{
+ ///
+ /// Whether to include the original data Merge fetched from the third-party to produce these models.
+ ///
+ public bool? IncludeRemoteData { get; init; }
+}
diff --git a/src/Merge.Client/Accounting/Accounts/AccountsClient.cs b/src/Merge.Client/Accounting/Accounts/AccountsClient.cs
index 57ab8dcc..430ec428 100644
--- a/src/Merge.Client/Accounting/Accounts/AccountsClient.cs
+++ b/src/Merge.Client/Accounting/Accounts/AccountsClient.cs
@@ -1,13 +1,177 @@
+using System.Text.Json;
+using Merge.Client;
+using Merge.Client.Accounting;
+
namespace Merge.Client.Accounting;
public class AccountsClient
{
- public async void List(){
+ private RawClient _client;
+
+ public AccountsClient(RawClient client)
+ {
+ _client = client;
}
- public async void Create(){
+
+ ///
+ /// Returns a list of `Account` objects.
+ ///
+ public async Task ListAsync(AccountsListRequest request)
+ {
+ var _query = new Dictionary() { };
+ if (request.CompanyId != null)
+ {
+ _query["company_id"] = request.CompanyId;
+ }
+ if (request.CreatedAfter != null)
+ {
+ _query["created_after"] = request.CreatedAfter;
+ }
+ if (request.CreatedBefore != null)
+ {
+ _query["created_before"] = request.CreatedBefore;
+ }
+ if (request.Cursor != null)
+ {
+ _query["cursor"] = request.Cursor;
+ }
+ if (request.Expand != null)
+ {
+ _query["expand"] = request.Expand;
+ }
+ if (request.IncludeDeletedData != null)
+ {
+ _query["include_deleted_data"] = request.IncludeDeletedData;
+ }
+ if (request.IncludeRemoteData != null)
+ {
+ _query["include_remote_data"] = request.IncludeRemoteData;
+ }
+ if (request.ModifiedAfter != null)
+ {
+ _query["modified_after"] = request.ModifiedAfter;
+ }
+ if (request.ModifiedBefore != null)
+ {
+ _query["modified_before"] = request.ModifiedBefore;
+ }
+ if (request.PageSize != null)
+ {
+ _query["page_size"] = request.PageSize;
+ }
+ if (request.RemoteFields != null)
+ {
+ _query["remote_fields"] = request.RemoteFields;
+ }
+ if (request.RemoteId != null)
+ {
+ _query["remote_id"] = request.RemoteId;
+ }
+ if (request.ShowEnumOrigins != null)
+ {
+ _query["show_enum_origins"] = request.ShowEnumOrigins;
+ }
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Get,
+ Path = "/accounting/v1/accounts",
+ Query = _query
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
}
- public async void Retrieve(){
+
+ ///
+ /// Creates an `Account` object with the given values.
+ ///
+ public async Task CreateAsync(AccountEndpointRequest request)
+ {
+ var _query = new Dictionary() { };
+ if (request.IsDebugMode != null)
+ {
+ _query["is_debug_mode"] = request.IsDebugMode;
+ }
+ if (request.RunAsync != null)
+ {
+ _query["run_async"] = request.RunAsync;
+ }
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Post,
+ Path = "/accounting/v1/accounts",
+ Query = _query
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
}
- public async void MetaPostRetrieve(){
+
+ ///
+ /// Returns an `Account` object with the given `id`.
+ ///
+ public async Task RetrieveAsync(string id, AccountsRetrieveRequest request)
+ {
+ var _query = new Dictionary() { };
+ if (request.Expand != null)
+ {
+ _query["expand"] = request.Expand;
+ }
+ if (request.IncludeRemoteData != null)
+ {
+ _query["include_remote_data"] = request.IncludeRemoteData;
+ }
+ if (request.RemoteFields != null)
+ {
+ _query["remote_fields"] = request.RemoteFields;
+ }
+ if (request.ShowEnumOrigins != null)
+ {
+ _query["show_enum_origins"] = request.ShowEnumOrigins;
+ }
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Get,
+ Path = $"/accounting/v1/accounts/{id}",
+ Query = _query
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
+ }
+
+ ///
+ /// Returns metadata for `Account` POSTs.
+ ///
+ public async Task MetaPostRetrieveAsync()
+ {
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Get,
+ Path = "/accounting/v1/accounts/meta/post"
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
}
}
diff --git a/src/Merge.Client/Accounting/Accounts/requests/AccountEndpointRequest.cs b/src/Merge.Client/Accounting/Accounts/requests/AccountEndpointRequest.cs
new file mode 100644
index 00000000..82d5f979
--- /dev/null
+++ b/src/Merge.Client/Accounting/Accounts/requests/AccountEndpointRequest.cs
@@ -0,0 +1,18 @@
+using Merge.Client.Accounting;
+
+namespace Merge.Client.Accounting;
+
+public class AccountEndpointRequest
+{
+ ///
+ /// Whether to include debug fields (such as log file links) in the response.
+ ///
+ public bool? IsDebugMode { get; init; }
+
+ ///
+ /// Whether or not third-party updates should be run asynchronously.
+ ///
+ public bool? RunAsync { get; init; }
+
+ public AccountRequest Model { get; init; }
+}
diff --git a/src/Merge.Client/Accounting/Accounts/requests/AccountsListRequest.cs b/src/Merge.Client/Accounting/Accounts/requests/AccountsListRequest.cs
new file mode 100644
index 00000000..640a5ccb
--- /dev/null
+++ b/src/Merge.Client/Accounting/Accounts/requests/AccountsListRequest.cs
@@ -0,0 +1,71 @@
+using Merge.Client.Accounting;
+
+namespace Merge.Client.Accounting;
+
+public class AccountsListRequest
+{
+ ///
+ /// If provided, will only return accounts for this company.
+ ///
+ public string? CompanyId { get; init; }
+
+ ///
+ /// If provided, will only return objects created after this datetime.
+ ///
+ public DateTime? CreatedAfter { get; init; }
+
+ ///
+ /// If provided, will only return objects created before this datetime.
+ ///
+ public DateTime? CreatedBefore { get; init; }
+
+ ///
+ /// The pagination cursor value.
+ ///
+ public string? Cursor { get; init; }
+
+ ///
+ /// Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces.
+ ///
+ public string? Expand { get; init; }
+
+ ///
+ /// Whether to include data that was marked as deleted by third party webhooks.
+ ///
+ public bool? IncludeDeletedData { get; init; }
+
+ ///
+ /// Whether to include the original data Merge fetched from the third-party to produce these models.
+ ///
+ public bool? IncludeRemoteData { get; init; }
+
+ ///
+ /// If provided, only objects synced by Merge after this date time will be returned.
+ ///
+ public DateTime? ModifiedAfter { get; init; }
+
+ ///
+ /// If provided, only objects synced by Merge before this date time will be returned.
+ ///
+ public DateTime? ModifiedBefore { get; init; }
+
+ ///
+ /// Number of results to return per page.
+ ///
+ public int? PageSize { get; init; }
+
+ ///
+ /// Deprecated. Use show_enum_origins.
+ ///
+ public AccountsListRequestRemoteFields? RemoteFields { get; init; }
+
+ ///
+ /// The API provider's ID for the given object.
+ ///
+ public string? RemoteId { get; init; }
+
+ ///
+ /// A comma separated list of enum field names for which you'd like the original values to be returned, instead of Merge's normalized enum values. [Learn more](https://help.merge.dev/en/articles/8950958-show_enum_origins-query-parameter)
+ ///
+ public AccountsListRequestShowEnumOrigins? ShowEnumOrigins { get; init; }
+}
diff --git a/src/Merge.Client/Accounting/Accounts/requests/AccountsRetrieveRequest.cs b/src/Merge.Client/Accounting/Accounts/requests/AccountsRetrieveRequest.cs
new file mode 100644
index 00000000..8a824f69
--- /dev/null
+++ b/src/Merge.Client/Accounting/Accounts/requests/AccountsRetrieveRequest.cs
@@ -0,0 +1,26 @@
+using Merge.Client.Accounting;
+
+namespace Merge.Client.Accounting;
+
+public class AccountsRetrieveRequest
+{
+ ///
+ /// Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces.
+ ///
+ public string? Expand { get; init; }
+
+ ///
+ /// Whether to include the original data Merge fetched from the third-party to produce these models.
+ ///
+ public bool? IncludeRemoteData { get; init; }
+
+ ///
+ /// Deprecated. Use show_enum_origins.
+ ///
+ public AccountsRetrieveRequestRemoteFields? RemoteFields { get; init; }
+
+ ///
+ /// A comma separated list of enum field names for which you'd like the original values to be returned, instead of Merge's normalized enum values. [Learn more](https://help.merge.dev/en/articles/8950958-show_enum_origins-query-parameter)
+ ///
+ public AccountsRetrieveRequestShowEnumOrigins? ShowEnumOrigins { get; init; }
+}
diff --git a/src/Merge.Client/Accounting/Addresses/AddressesClient.cs b/src/Merge.Client/Accounting/Addresses/AddressesClient.cs
index 168add06..bb6eaa6d 100644
--- a/src/Merge.Client/Accounting/Addresses/AddressesClient.cs
+++ b/src/Merge.Client/Accounting/Addresses/AddressesClient.cs
@@ -1,7 +1,49 @@
+using System.Text.Json;
+using Merge.Client;
+using Merge.Client.Accounting;
+
namespace Merge.Client.Accounting;
public class AddressesClient
{
- public async void Retrieve(){
+ private RawClient _client;
+
+ public AddressesClient(RawClient client)
+ {
+ _client = client;
+ }
+
+ ///
+ /// Returns an `Address` object with the given `id`.
+ ///
+ public async Task RetrieveAsync(string id, AddressesRetrieveRequest request)
+ {
+ var _query = new Dictionary() { };
+ if (request.IncludeRemoteData != null)
+ {
+ _query["include_remote_data"] = request.IncludeRemoteData;
+ }
+ if (request.RemoteFields != null)
+ {
+ _query["remote_fields"] = request.RemoteFields;
+ }
+ if (request.ShowEnumOrigins != null)
+ {
+ _query["show_enum_origins"] = request.ShowEnumOrigins;
+ }
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Get,
+ Path = $"/accounting/v1/addresses/{id}",
+ Query = _query
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
}
}
diff --git a/src/Merge.Client/Accounting/Addresses/requests/AddressesRetrieveRequest.cs b/src/Merge.Client/Accounting/Addresses/requests/AddressesRetrieveRequest.cs
new file mode 100644
index 00000000..aa658aa7
--- /dev/null
+++ b/src/Merge.Client/Accounting/Addresses/requests/AddressesRetrieveRequest.cs
@@ -0,0 +1,19 @@
+namespace Merge.Client.Accounting;
+
+public class AddressesRetrieveRequest
+{
+ ///
+ /// Whether to include the original data Merge fetched from the third-party to produce these models.
+ ///
+ public bool? IncludeRemoteData { get; init; }
+
+ ///
+ /// Deprecated. Use show_enum_origins.
+ ///
+ public string? RemoteFields { get; init; }
+
+ ///
+ /// A comma separated list of enum field names for which you'd like the original values to be returned, instead of Merge's normalized enum values. [Learn more](https://help.merge.dev/en/articles/8950958-show_enum_origins-query-parameter)
+ ///
+ public string? ShowEnumOrigins { get; init; }
+}
diff --git a/src/Merge.Client/Accounting/AsyncPassthrough/AsyncPassthroughClient.cs b/src/Merge.Client/Accounting/AsyncPassthrough/AsyncPassthroughClient.cs
index d9bee9cb..99365a3d 100644
--- a/src/Merge.Client/Accounting/AsyncPassthrough/AsyncPassthroughClient.cs
+++ b/src/Merge.Client/Accounting/AsyncPassthrough/AsyncPassthroughClient.cs
@@ -1,9 +1,56 @@
+using System.Text.Json;
+using Merge.Client;
+using Merge.Client.Accounting;
+
namespace Merge.Client.Accounting;
public class AsyncPassthroughClient
{
- public async void Create(){
+ private RawClient _client;
+
+ public AsyncPassthroughClient(RawClient client)
+ {
+ _client = client;
}
- public async void Retrieve(){
+
+ ///
+ /// Asynchronously pull data from an endpoint not currently supported by Merge.
+ ///
+ public async Task CreateAsync(DataPassthroughRequest request)
+ {
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Post,
+ Path = "/accounting/v1/async-passthrough",
+ Body = request
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
+ }
+
+ ///
+ /// Retrieves data from earlier async-passthrough POST request
+ ///
+ public async Task RetrieveAsync(string asyncPassthroughReceiptId)
+ {
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Get,
+ Path = $"/accounting/v1/async-passthrough/{asyncPassthroughReceiptId}"
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
}
}
diff --git a/src/Merge.Client/Accounting/Attachments/AttachmentsClient.cs b/src/Merge.Client/Accounting/Attachments/AttachmentsClient.cs
index f855ba17..780e1590 100644
--- a/src/Merge.Client/Accounting/Attachments/AttachmentsClient.cs
+++ b/src/Merge.Client/Accounting/Attachments/AttachmentsClient.cs
@@ -1,13 +1,158 @@
+using System.Text.Json;
+using Merge.Client;
+using Merge.Client.Accounting;
+
namespace Merge.Client.Accounting;
public class AttachmentsClient
{
- public async void List(){
+ private RawClient _client;
+
+ public AttachmentsClient(RawClient client)
+ {
+ _client = client;
}
- public async void Create(){
+
+ ///
+ /// Returns a list of `AccountingAttachment` objects.
+ ///
+ public async Task ListAsync(AttachmentsListRequest request)
+ {
+ var _query = new Dictionary() { };
+ if (request.CompanyId != null)
+ {
+ _query["company_id"] = request.CompanyId;
+ }
+ if (request.CreatedAfter != null)
+ {
+ _query["created_after"] = request.CreatedAfter;
+ }
+ if (request.CreatedBefore != null)
+ {
+ _query["created_before"] = request.CreatedBefore;
+ }
+ if (request.Cursor != null)
+ {
+ _query["cursor"] = request.Cursor;
+ }
+ if (request.IncludeDeletedData != null)
+ {
+ _query["include_deleted_data"] = request.IncludeDeletedData;
+ }
+ if (request.IncludeRemoteData != null)
+ {
+ _query["include_remote_data"] = request.IncludeRemoteData;
+ }
+ if (request.ModifiedAfter != null)
+ {
+ _query["modified_after"] = request.ModifiedAfter;
+ }
+ if (request.ModifiedBefore != null)
+ {
+ _query["modified_before"] = request.ModifiedBefore;
+ }
+ if (request.PageSize != null)
+ {
+ _query["page_size"] = request.PageSize;
+ }
+ if (request.RemoteId != null)
+ {
+ _query["remote_id"] = request.RemoteId;
+ }
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Get,
+ Path = "/accounting/v1/attachments",
+ Query = _query
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
}
- public async void Retrieve(){
+
+ ///
+ /// Creates an `AccountingAttachment` object with the given values.
+ ///
+ public async Task CreateAsync(
+ AccountingAttachmentEndpointRequest request
+ )
+ {
+ var _query = new Dictionary() { };
+ if (request.IsDebugMode != null)
+ {
+ _query["is_debug_mode"] = request.IsDebugMode;
+ }
+ if (request.RunAsync != null)
+ {
+ _query["run_async"] = request.RunAsync;
+ }
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Post,
+ Path = "/accounting/v1/attachments",
+ Query = _query
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
}
- public async void MetaPostRetrieve(){
+
+ ///
+ /// Returns an `AccountingAttachment` object with the given `id`.
+ ///
+ public async Task RetrieveAsync(
+ string id,
+ AttachmentsRetrieveRequest request
+ )
+ {
+ var _query = new Dictionary() { };
+ if (request.IncludeRemoteData != null)
+ {
+ _query["include_remote_data"] = request.IncludeRemoteData;
+ }
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Get,
+ Path = $"/accounting/v1/attachments/{id}",
+ Query = _query
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
+ }
+
+ ///
+ /// Returns metadata for `AccountingAttachment` POSTs.
+ ///
+ public async Task MetaPostRetrieveAsync()
+ {
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Get,
+ Path = "/accounting/v1/attachments/meta/post"
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
}
}
diff --git a/src/Merge.Client/Accounting/Attachments/requests/AccountingAttachmentEndpointRequest.cs b/src/Merge.Client/Accounting/Attachments/requests/AccountingAttachmentEndpointRequest.cs
new file mode 100644
index 00000000..944f4f65
--- /dev/null
+++ b/src/Merge.Client/Accounting/Attachments/requests/AccountingAttachmentEndpointRequest.cs
@@ -0,0 +1,18 @@
+using Merge.Client.Accounting;
+
+namespace Merge.Client.Accounting;
+
+public class AccountingAttachmentEndpointRequest
+{
+ ///
+ /// Whether to include debug fields (such as log file links) in the response.
+ ///
+ public bool? IsDebugMode { get; init; }
+
+ ///
+ /// Whether or not third-party updates should be run asynchronously.
+ ///
+ public bool? RunAsync { get; init; }
+
+ public AccountingAttachmentRequest Model { get; init; }
+}
diff --git a/src/Merge.Client/Accounting/Attachments/requests/AttachmentsListRequest.cs b/src/Merge.Client/Accounting/Attachments/requests/AttachmentsListRequest.cs
new file mode 100644
index 00000000..4b558a6c
--- /dev/null
+++ b/src/Merge.Client/Accounting/Attachments/requests/AttachmentsListRequest.cs
@@ -0,0 +1,54 @@
+namespace Merge.Client.Accounting;
+
+public class AttachmentsListRequest
+{
+ ///
+ /// If provided, will only return accounting attachments for this company.
+ ///
+ public string? CompanyId { get; init; }
+
+ ///
+ /// If provided, will only return objects created after this datetime.
+ ///
+ public DateTime? CreatedAfter { get; init; }
+
+ ///
+ /// If provided, will only return objects created before this datetime.
+ ///
+ public DateTime? CreatedBefore { get; init; }
+
+ ///
+ /// The pagination cursor value.
+ ///
+ public string? Cursor { get; init; }
+
+ ///
+ /// Whether to include data that was marked as deleted by third party webhooks.
+ ///
+ public bool? IncludeDeletedData { get; init; }
+
+ ///
+ /// Whether to include the original data Merge fetched from the third-party to produce these models.
+ ///
+ public bool? IncludeRemoteData { get; init; }
+
+ ///
+ /// If provided, only objects synced by Merge after this date time will be returned.
+ ///
+ public DateTime? ModifiedAfter { get; init; }
+
+ ///
+ /// If provided, only objects synced by Merge before this date time will be returned.
+ ///
+ public DateTime? ModifiedBefore { get; init; }
+
+ ///
+ /// Number of results to return per page.
+ ///
+ public int? PageSize { get; init; }
+
+ ///
+ /// The API provider's ID for the given object.
+ ///
+ public string? RemoteId { get; init; }
+}
diff --git a/src/Merge.Client/Accounting/Attachments/requests/AttachmentsRetrieveRequest.cs b/src/Merge.Client/Accounting/Attachments/requests/AttachmentsRetrieveRequest.cs
new file mode 100644
index 00000000..a5a4700a
--- /dev/null
+++ b/src/Merge.Client/Accounting/Attachments/requests/AttachmentsRetrieveRequest.cs
@@ -0,0 +1,9 @@
+namespace Merge.Client.Accounting;
+
+public class AttachmentsRetrieveRequest
+{
+ ///
+ /// Whether to include the original data Merge fetched from the third-party to produce these models.
+ ///
+ public bool? IncludeRemoteData { get; init; }
+}
diff --git a/src/Merge.Client/Accounting/AuditTrail/AuditTrailClient.cs b/src/Merge.Client/Accounting/AuditTrail/AuditTrailClient.cs
index cf4cce27..b528797a 100644
--- a/src/Merge.Client/Accounting/AuditTrail/AuditTrailClient.cs
+++ b/src/Merge.Client/Accounting/AuditTrail/AuditTrailClient.cs
@@ -1,7 +1,61 @@
+using System.Text.Json;
+using Merge.Client;
+using Merge.Client.Accounting;
+
namespace Merge.Client.Accounting;
public class AuditTrailClient
{
- public async void List(){
+ private RawClient _client;
+
+ public AuditTrailClient(RawClient client)
+ {
+ _client = client;
+ }
+
+ ///
+ /// Gets a list of audit trail events.
+ ///
+ public async Task ListAsync(AuditTrailListRequest request)
+ {
+ var _query = new Dictionary() { };
+ if (request.Cursor != null)
+ {
+ _query["cursor"] = request.Cursor;
+ }
+ if (request.EndDate != null)
+ {
+ _query["end_date"] = request.EndDate;
+ }
+ if (request.EventType != null)
+ {
+ _query["event_type"] = request.EventType;
+ }
+ if (request.PageSize != null)
+ {
+ _query["page_size"] = request.PageSize;
+ }
+ if (request.StartDate != null)
+ {
+ _query["start_date"] = request.StartDate;
+ }
+ if (request.UserEmail != null)
+ {
+ _query["user_email"] = request.UserEmail;
+ }
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Get,
+ Path = "/accounting/v1/audit-trail",
+ Query = _query
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
}
}
diff --git a/src/Merge.Client/Accounting/AuditTrail/requests/AuditTrailListRequest.cs b/src/Merge.Client/Accounting/AuditTrail/requests/AuditTrailListRequest.cs
new file mode 100644
index 00000000..38b939ad
--- /dev/null
+++ b/src/Merge.Client/Accounting/AuditTrail/requests/AuditTrailListRequest.cs
@@ -0,0 +1,34 @@
+namespace Merge.Client.Accounting;
+
+public class AuditTrailListRequest
+{
+ ///
+ /// The pagination cursor value.
+ ///
+ public string? Cursor { get; init; }
+
+ ///
+ /// If included, will only include audit trail events that occurred before this time
+ ///
+ public string? EndDate { get; init; }
+
+ ///
+ /// If included, will only include events with the given event type. Possible values include: `CREATED_REMOTE_PRODUCTION_API_KEY`, `DELETED_REMOTE_PRODUCTION_API_KEY`, `CREATED_TEST_API_KEY`, `DELETED_TEST_API_KEY`, `REGENERATED_PRODUCTION_API_KEY`, `INVITED_USER`, `TWO_FACTOR_AUTH_ENABLED`, `TWO_FACTOR_AUTH_DISABLED`, `DELETED_LINKED_ACCOUNT`, `CREATED_DESTINATION`, `DELETED_DESTINATION`, `CHANGED_DESTINATION`, `CHANGED_SCOPES`, `CHANGED_PERSONAL_INFORMATION`, `CHANGED_ORGANIZATION_SETTINGS`, `ENABLED_INTEGRATION`, `DISABLED_INTEGRATION`, `ENABLED_CATEGORY`, `DISABLED_CATEGORY`, `CHANGED_PASSWORD`, `RESET_PASSWORD`, `ENABLED_REDACT_UNMAPPED_DATA_FOR_ORGANIZATION`, `ENABLED_REDACT_UNMAPPED_DATA_FOR_LINKED_ACCOUNT`, `DISABLED_REDACT_UNMAPPED_DATA_FOR_ORGANIZATION`, `DISABLED_REDACT_UNMAPPED_DATA_FOR_LINKED_ACCOUNT`, `CREATED_INTEGRATION_WIDE_FIELD_MAPPING`, `CREATED_LINKED_ACCOUNT_FIELD_MAPPING`, `CHANGED_INTEGRATION_WIDE_FIELD_MAPPING`, `CHANGED_LINKED_ACCOUNT_FIELD_MAPPING`, `DELETED_INTEGRATION_WIDE_FIELD_MAPPING`, `DELETED_LINKED_ACCOUNT_FIELD_MAPPING`, `FORCED_LINKED_ACCOUNT_RESYNC`, `MUTED_ISSUE`, `GENERATED_MAGIC_LINK`
+ ///
+ public string? EventType { get; init; }
+
+ ///
+ /// Number of results to return per page.
+ ///
+ public int? PageSize { get; init; }
+
+ ///
+ /// If included, will only include audit trail events that occurred after this time
+ ///
+ public string? StartDate { get; init; }
+
+ ///
+ /// If provided, this will return events associated with the specified user email. Please note that the email address reflects the user's email at the time of the event, and may not be their current email.
+ ///
+ public string? UserEmail { get; init; }
+}
diff --git a/src/Merge.Client/Accounting/AvailableActions/AvailableActionsClient.cs b/src/Merge.Client/Accounting/AvailableActions/AvailableActionsClient.cs
index 8e27017c..df90e5e4 100644
--- a/src/Merge.Client/Accounting/AvailableActions/AvailableActionsClient.cs
+++ b/src/Merge.Client/Accounting/AvailableActions/AvailableActionsClient.cs
@@ -1,7 +1,35 @@
+using System.Text.Json;
+using Merge.Client;
+using Merge.Client.Accounting;
+
namespace Merge.Client.Accounting;
public class AvailableActionsClient
{
- public async void Retrieve(){
+ private RawClient _client;
+
+ public AvailableActionsClient(RawClient client)
+ {
+ _client = client;
+ }
+
+ ///
+ /// Returns a list of models and actions available for an account.
+ ///
+ public async Task RetrieveAsync()
+ {
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Get,
+ Path = "/accounting/v1/available-actions"
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
}
}
diff --git a/src/Merge.Client/Accounting/BalanceSheets/BalanceSheetsClient.cs b/src/Merge.Client/Accounting/BalanceSheets/BalanceSheetsClient.cs
index 6d5e4cb1..0a1f25ae 100644
--- a/src/Merge.Client/Accounting/BalanceSheets/BalanceSheetsClient.cs
+++ b/src/Merge.Client/Accounting/BalanceSheets/BalanceSheetsClient.cs
@@ -1,9 +1,111 @@
+using System.Text.Json;
+using Merge.Client;
+using Merge.Client.Accounting;
+
namespace Merge.Client.Accounting;
public class BalanceSheetsClient
{
- public async void List(){
+ private RawClient _client;
+
+ public BalanceSheetsClient(RawClient client)
+ {
+ _client = client;
}
- public async void Retrieve(){
+
+ ///
+ /// Returns a list of `BalanceSheet` objects.
+ ///
+ public async Task ListAsync(BalanceSheetsListRequest request)
+ {
+ var _query = new Dictionary() { };
+ if (request.CompanyId != null)
+ {
+ _query["company_id"] = request.CompanyId;
+ }
+ if (request.CreatedAfter != null)
+ {
+ _query["created_after"] = request.CreatedAfter;
+ }
+ if (request.CreatedBefore != null)
+ {
+ _query["created_before"] = request.CreatedBefore;
+ }
+ if (request.Cursor != null)
+ {
+ _query["cursor"] = request.Cursor;
+ }
+ if (request.Expand != null)
+ {
+ _query["expand"] = request.Expand;
+ }
+ if (request.IncludeDeletedData != null)
+ {
+ _query["include_deleted_data"] = request.IncludeDeletedData;
+ }
+ if (request.IncludeRemoteData != null)
+ {
+ _query["include_remote_data"] = request.IncludeRemoteData;
+ }
+ if (request.ModifiedAfter != null)
+ {
+ _query["modified_after"] = request.ModifiedAfter;
+ }
+ if (request.ModifiedBefore != null)
+ {
+ _query["modified_before"] = request.ModifiedBefore;
+ }
+ if (request.PageSize != null)
+ {
+ _query["page_size"] = request.PageSize;
+ }
+ if (request.RemoteId != null)
+ {
+ _query["remote_id"] = request.RemoteId;
+ }
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Get,
+ Path = "/accounting/v1/balance-sheets",
+ Query = _query
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
+ }
+
+ ///
+ /// Returns a `BalanceSheet` object with the given `id`.
+ ///
+ public async Task RetrieveAsync(string id, BalanceSheetsRetrieveRequest request)
+ {
+ var _query = new Dictionary() { };
+ if (request.Expand != null)
+ {
+ _query["expand"] = request.Expand;
+ }
+ if (request.IncludeRemoteData != null)
+ {
+ _query["include_remote_data"] = request.IncludeRemoteData;
+ }
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Get,
+ Path = $"/accounting/v1/balance-sheets/{id}",
+ Query = _query
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
}
}
diff --git a/src/Merge.Client/Accounting/BalanceSheets/requests/BalanceSheetsListRequest.cs b/src/Merge.Client/Accounting/BalanceSheets/requests/BalanceSheetsListRequest.cs
new file mode 100644
index 00000000..8e4ca474
--- /dev/null
+++ b/src/Merge.Client/Accounting/BalanceSheets/requests/BalanceSheetsListRequest.cs
@@ -0,0 +1,59 @@
+namespace Merge.Client.Accounting;
+
+public class BalanceSheetsListRequest
+{
+ ///
+ /// If provided, will only return balance sheets for this company.
+ ///
+ public string? CompanyId { get; init; }
+
+ ///
+ /// If provided, will only return objects created after this datetime.
+ ///
+ public DateTime? CreatedAfter { get; init; }
+
+ ///
+ /// If provided, will only return objects created before this datetime.
+ ///
+ public DateTime? CreatedBefore { get; init; }
+
+ ///
+ /// The pagination cursor value.
+ ///
+ public string? Cursor { get; init; }
+
+ ///
+ /// Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces.
+ ///
+ public string? Expand { get; init; }
+
+ ///
+ /// Whether to include data that was marked as deleted by third party webhooks.
+ ///
+ public bool? IncludeDeletedData { get; init; }
+
+ ///
+ /// Whether to include the original data Merge fetched from the third-party to produce these models.
+ ///
+ public bool? IncludeRemoteData { get; init; }
+
+ ///
+ /// If provided, only objects synced by Merge after this date time will be returned.
+ ///
+ public DateTime? ModifiedAfter { get; init; }
+
+ ///
+ /// If provided, only objects synced by Merge before this date time will be returned.
+ ///
+ public DateTime? ModifiedBefore { get; init; }
+
+ ///
+ /// Number of results to return per page.
+ ///
+ public int? PageSize { get; init; }
+
+ ///
+ /// The API provider's ID for the given object.
+ ///
+ public string? RemoteId { get; init; }
+}
diff --git a/src/Merge.Client/Accounting/BalanceSheets/requests/BalanceSheetsRetrieveRequest.cs b/src/Merge.Client/Accounting/BalanceSheets/requests/BalanceSheetsRetrieveRequest.cs
new file mode 100644
index 00000000..9d7aa257
--- /dev/null
+++ b/src/Merge.Client/Accounting/BalanceSheets/requests/BalanceSheetsRetrieveRequest.cs
@@ -0,0 +1,14 @@
+namespace Merge.Client.Accounting;
+
+public class BalanceSheetsRetrieveRequest
+{
+ ///
+ /// Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces.
+ ///
+ public string? Expand { get; init; }
+
+ ///
+ /// Whether to include the original data Merge fetched from the third-party to produce these models.
+ ///
+ public bool? IncludeRemoteData { get; init; }
+}
diff --git a/src/Merge.Client/Accounting/CashFlowStatements/CashFlowStatementsClient.cs b/src/Merge.Client/Accounting/CashFlowStatements/CashFlowStatementsClient.cs
index e4f21edc..ed32ae96 100644
--- a/src/Merge.Client/Accounting/CashFlowStatements/CashFlowStatementsClient.cs
+++ b/src/Merge.Client/Accounting/CashFlowStatements/CashFlowStatementsClient.cs
@@ -1,9 +1,116 @@
+using System.Text.Json;
+using Merge.Client;
+using Merge.Client.Accounting;
+
namespace Merge.Client.Accounting;
public class CashFlowStatementsClient
{
- public async void List(){
+ private RawClient _client;
+
+ public CashFlowStatementsClient(RawClient client)
+ {
+ _client = client;
}
- public async void Retrieve(){
+
+ ///
+ /// Returns a list of `CashFlowStatement` objects.
+ ///
+ public async Task ListAsync(
+ CashFlowStatementsListRequest request
+ )
+ {
+ var _query = new Dictionary() { };
+ if (request.CompanyId != null)
+ {
+ _query["company_id"] = request.CompanyId;
+ }
+ if (request.CreatedAfter != null)
+ {
+ _query["created_after"] = request.CreatedAfter;
+ }
+ if (request.CreatedBefore != null)
+ {
+ _query["created_before"] = request.CreatedBefore;
+ }
+ if (request.Cursor != null)
+ {
+ _query["cursor"] = request.Cursor;
+ }
+ if (request.Expand != null)
+ {
+ _query["expand"] = request.Expand;
+ }
+ if (request.IncludeDeletedData != null)
+ {
+ _query["include_deleted_data"] = request.IncludeDeletedData;
+ }
+ if (request.IncludeRemoteData != null)
+ {
+ _query["include_remote_data"] = request.IncludeRemoteData;
+ }
+ if (request.ModifiedAfter != null)
+ {
+ _query["modified_after"] = request.ModifiedAfter;
+ }
+ if (request.ModifiedBefore != null)
+ {
+ _query["modified_before"] = request.ModifiedBefore;
+ }
+ if (request.PageSize != null)
+ {
+ _query["page_size"] = request.PageSize;
+ }
+ if (request.RemoteId != null)
+ {
+ _query["remote_id"] = request.RemoteId;
+ }
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Get,
+ Path = "/accounting/v1/cash-flow-statements",
+ Query = _query
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
+ }
+
+ ///
+ /// Returns a `CashFlowStatement` object with the given `id`.
+ ///
+ public async Task RetrieveAsync(
+ string id,
+ CashFlowStatementsRetrieveRequest request
+ )
+ {
+ var _query = new Dictionary() { };
+ if (request.Expand != null)
+ {
+ _query["expand"] = request.Expand;
+ }
+ if (request.IncludeRemoteData != null)
+ {
+ _query["include_remote_data"] = request.IncludeRemoteData;
+ }
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Get,
+ Path = $"/accounting/v1/cash-flow-statements/{id}",
+ Query = _query
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
}
}
diff --git a/src/Merge.Client/Accounting/CashFlowStatements/requests/CashFlowStatementsListRequest.cs b/src/Merge.Client/Accounting/CashFlowStatements/requests/CashFlowStatementsListRequest.cs
new file mode 100644
index 00000000..c9115777
--- /dev/null
+++ b/src/Merge.Client/Accounting/CashFlowStatements/requests/CashFlowStatementsListRequest.cs
@@ -0,0 +1,59 @@
+namespace Merge.Client.Accounting;
+
+public class CashFlowStatementsListRequest
+{
+ ///
+ /// If provided, will only return cash flow statements for this company.
+ ///
+ public string? CompanyId { get; init; }
+
+ ///
+ /// If provided, will only return objects created after this datetime.
+ ///
+ public DateTime? CreatedAfter { get; init; }
+
+ ///
+ /// If provided, will only return objects created before this datetime.
+ ///
+ public DateTime? CreatedBefore { get; init; }
+
+ ///
+ /// The pagination cursor value.
+ ///
+ public string? Cursor { get; init; }
+
+ ///
+ /// Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces.
+ ///
+ public string? Expand { get; init; }
+
+ ///
+ /// Whether to include data that was marked as deleted by third party webhooks.
+ ///
+ public bool? IncludeDeletedData { get; init; }
+
+ ///
+ /// Whether to include the original data Merge fetched from the third-party to produce these models.
+ ///
+ public bool? IncludeRemoteData { get; init; }
+
+ ///
+ /// If provided, only objects synced by Merge after this date time will be returned.
+ ///
+ public DateTime? ModifiedAfter { get; init; }
+
+ ///
+ /// If provided, only objects synced by Merge before this date time will be returned.
+ ///
+ public DateTime? ModifiedBefore { get; init; }
+
+ ///
+ /// Number of results to return per page.
+ ///
+ public int? PageSize { get; init; }
+
+ ///
+ /// The API provider's ID for the given object.
+ ///
+ public string? RemoteId { get; init; }
+}
diff --git a/src/Merge.Client/Accounting/CashFlowStatements/requests/CashFlowStatementsRetrieveRequest.cs b/src/Merge.Client/Accounting/CashFlowStatements/requests/CashFlowStatementsRetrieveRequest.cs
new file mode 100644
index 00000000..4ee951a7
--- /dev/null
+++ b/src/Merge.Client/Accounting/CashFlowStatements/requests/CashFlowStatementsRetrieveRequest.cs
@@ -0,0 +1,14 @@
+namespace Merge.Client.Accounting;
+
+public class CashFlowStatementsRetrieveRequest
+{
+ ///
+ /// Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces.
+ ///
+ public string? Expand { get; init; }
+
+ ///
+ /// Whether to include the original data Merge fetched from the third-party to produce these models.
+ ///
+ public bool? IncludeRemoteData { get; init; }
+}
diff --git a/src/Merge.Client/Accounting/CompanyInfo/CompanyInfoClient.cs b/src/Merge.Client/Accounting/CompanyInfo/CompanyInfoClient.cs
index e0e4f338..ca14d55c 100644
--- a/src/Merge.Client/Accounting/CompanyInfo/CompanyInfoClient.cs
+++ b/src/Merge.Client/Accounting/CompanyInfo/CompanyInfoClient.cs
@@ -1,9 +1,107 @@
+using System.Text.Json;
+using Merge.Client;
+using Merge.Client.Accounting;
+
namespace Merge.Client.Accounting;
public class CompanyInfoClient
{
- public async void List(){
+ private RawClient _client;
+
+ public CompanyInfoClient(RawClient client)
+ {
+ _client = client;
}
- public async void Retrieve(){
+
+ ///
+ /// Returns a list of `CompanyInfo` objects.
+ ///
+ public async Task ListAsync(CompanyInfoListRequest request)
+ {
+ var _query = new Dictionary() { };
+ if (request.CreatedAfter != null)
+ {
+ _query["created_after"] = request.CreatedAfter;
+ }
+ if (request.CreatedBefore != null)
+ {
+ _query["created_before"] = request.CreatedBefore;
+ }
+ if (request.Cursor != null)
+ {
+ _query["cursor"] = request.Cursor;
+ }
+ if (request.Expand != null)
+ {
+ _query["expand"] = request.Expand;
+ }
+ if (request.IncludeDeletedData != null)
+ {
+ _query["include_deleted_data"] = request.IncludeDeletedData;
+ }
+ if (request.IncludeRemoteData != null)
+ {
+ _query["include_remote_data"] = request.IncludeRemoteData;
+ }
+ if (request.ModifiedAfter != null)
+ {
+ _query["modified_after"] = request.ModifiedAfter;
+ }
+ if (request.ModifiedBefore != null)
+ {
+ _query["modified_before"] = request.ModifiedBefore;
+ }
+ if (request.PageSize != null)
+ {
+ _query["page_size"] = request.PageSize;
+ }
+ if (request.RemoteId != null)
+ {
+ _query["remote_id"] = request.RemoteId;
+ }
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Get,
+ Path = "/accounting/v1/company-info",
+ Query = _query
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
+ }
+
+ ///
+ /// Returns a `CompanyInfo` object with the given `id`.
+ ///
+ public async Task RetrieveAsync(string id, CompanyInfoRetrieveRequest request)
+ {
+ var _query = new Dictionary() { };
+ if (request.Expand != null)
+ {
+ _query["expand"] = request.Expand;
+ }
+ if (request.IncludeRemoteData != null)
+ {
+ _query["include_remote_data"] = request.IncludeRemoteData;
+ }
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Get,
+ Path = $"/accounting/v1/company-info/{id}",
+ Query = _query
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
}
}
diff --git a/src/Merge.Client/Accounting/CompanyInfo/requests/CompanyInfoListRequest.cs b/src/Merge.Client/Accounting/CompanyInfo/requests/CompanyInfoListRequest.cs
new file mode 100644
index 00000000..cc37bb4a
--- /dev/null
+++ b/src/Merge.Client/Accounting/CompanyInfo/requests/CompanyInfoListRequest.cs
@@ -0,0 +1,56 @@
+using Merge.Client.Accounting;
+
+namespace Merge.Client.Accounting;
+
+public class CompanyInfoListRequest
+{
+ ///
+ /// If provided, will only return objects created after this datetime.
+ ///
+ public DateTime? CreatedAfter { get; init; }
+
+ ///
+ /// If provided, will only return objects created before this datetime.
+ ///
+ public DateTime? CreatedBefore { get; init; }
+
+ ///
+ /// The pagination cursor value.
+ ///
+ public string? Cursor { get; init; }
+
+ ///
+ /// Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces.
+ ///
+ public CompanyInfoListRequestExpand? Expand { get; init; }
+
+ ///
+ /// Whether to include data that was marked as deleted by third party webhooks.
+ ///
+ public bool? IncludeDeletedData { get; init; }
+
+ ///
+ /// Whether to include the original data Merge fetched from the third-party to produce these models.
+ ///
+ public bool? IncludeRemoteData { get; init; }
+
+ ///
+ /// If provided, only objects synced by Merge after this date time will be returned.
+ ///
+ public DateTime? ModifiedAfter { get; init; }
+
+ ///
+ /// If provided, only objects synced by Merge before this date time will be returned.
+ ///
+ public DateTime? ModifiedBefore { get; init; }
+
+ ///
+ /// Number of results to return per page.
+ ///
+ public int? PageSize { get; init; }
+
+ ///
+ /// The API provider's ID for the given object.
+ ///
+ public string? RemoteId { get; init; }
+}
diff --git a/src/Merge.Client/Accounting/CompanyInfo/requests/CompanyInfoRetrieveRequest.cs b/src/Merge.Client/Accounting/CompanyInfo/requests/CompanyInfoRetrieveRequest.cs
new file mode 100644
index 00000000..ff12566f
--- /dev/null
+++ b/src/Merge.Client/Accounting/CompanyInfo/requests/CompanyInfoRetrieveRequest.cs
@@ -0,0 +1,16 @@
+using Merge.Client.Accounting;
+
+namespace Merge.Client.Accounting;
+
+public class CompanyInfoRetrieveRequest
+{
+ ///
+ /// Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces.
+ ///
+ public CompanyInfoRetrieveRequestExpand? Expand { get; init; }
+
+ ///
+ /// Whether to include the original data Merge fetched from the third-party to produce these models.
+ ///
+ public bool? IncludeRemoteData { get; init; }
+}
diff --git a/src/Merge.Client/Accounting/Contacts/ContactsClient.cs b/src/Merge.Client/Accounting/Contacts/ContactsClient.cs
index f2e5c618..a8ace8aa 100644
--- a/src/Merge.Client/Accounting/Contacts/ContactsClient.cs
+++ b/src/Merge.Client/Accounting/Contacts/ContactsClient.cs
@@ -1,13 +1,185 @@
+using System.Text.Json;
+using Merge.Client;
+using Merge.Client.Accounting;
+
namespace Merge.Client.Accounting;
public class ContactsClient
{
- public async void List(){
+ private RawClient _client;
+
+ public ContactsClient(RawClient client)
+ {
+ _client = client;
}
- public async void Create(){
+
+ ///
+ /// Returns a list of `Contact` objects.
+ ///
+ public async Task ListAsync(ContactsListRequest request)
+ {
+ var _query = new Dictionary() { };
+ if (request.CompanyId != null)
+ {
+ _query["company_id"] = request.CompanyId;
+ }
+ if (request.CreatedAfter != null)
+ {
+ _query["created_after"] = request.CreatedAfter;
+ }
+ if (request.CreatedBefore != null)
+ {
+ _query["created_before"] = request.CreatedBefore;
+ }
+ if (request.Cursor != null)
+ {
+ _query["cursor"] = request.Cursor;
+ }
+ if (request.Expand != null)
+ {
+ _query["expand"] = request.Expand;
+ }
+ if (request.IncludeDeletedData != null)
+ {
+ _query["include_deleted_data"] = request.IncludeDeletedData;
+ }
+ if (request.IncludeRemoteData != null)
+ {
+ _query["include_remote_data"] = request.IncludeRemoteData;
+ }
+ if (request.IsCustomer != null)
+ {
+ _query["is_customer"] = request.IsCustomer;
+ }
+ if (request.IsSupplier != null)
+ {
+ _query["is_supplier"] = request.IsSupplier;
+ }
+ if (request.ModifiedAfter != null)
+ {
+ _query["modified_after"] = request.ModifiedAfter;
+ }
+ if (request.ModifiedBefore != null)
+ {
+ _query["modified_before"] = request.ModifiedBefore;
+ }
+ if (request.PageSize != null)
+ {
+ _query["page_size"] = request.PageSize;
+ }
+ if (request.RemoteFields != null)
+ {
+ _query["remote_fields"] = request.RemoteFields;
+ }
+ if (request.RemoteId != null)
+ {
+ _query["remote_id"] = request.RemoteId;
+ }
+ if (request.ShowEnumOrigins != null)
+ {
+ _query["show_enum_origins"] = request.ShowEnumOrigins;
+ }
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Get,
+ Path = "/accounting/v1/contacts",
+ Query = _query
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
}
- public async void Retrieve(){
+
+ ///
+ /// Creates a `Contact` object with the given values.
+ ///
+ public async Task CreateAsync(ContactEndpointRequest request)
+ {
+ var _query = new Dictionary() { };
+ if (request.IsDebugMode != null)
+ {
+ _query["is_debug_mode"] = request.IsDebugMode;
+ }
+ if (request.RunAsync != null)
+ {
+ _query["run_async"] = request.RunAsync;
+ }
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Post,
+ Path = "/accounting/v1/contacts",
+ Query = _query
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
}
- public async void MetaPostRetrieve(){
+
+ ///
+ /// Returns a `Contact` object with the given `id`.
+ ///
+ public async Task RetrieveAsync(string id, ContactsRetrieveRequest request)
+ {
+ var _query = new Dictionary() { };
+ if (request.Expand != null)
+ {
+ _query["expand"] = request.Expand;
+ }
+ if (request.IncludeRemoteData != null)
+ {
+ _query["include_remote_data"] = request.IncludeRemoteData;
+ }
+ if (request.RemoteFields != null)
+ {
+ _query["remote_fields"] = request.RemoteFields;
+ }
+ if (request.ShowEnumOrigins != null)
+ {
+ _query["show_enum_origins"] = request.ShowEnumOrigins;
+ }
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Get,
+ Path = $"/accounting/v1/contacts/{id}",
+ Query = _query
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
+ }
+
+ ///
+ /// Returns metadata for `Contact` POSTs.
+ ///
+ public async Task MetaPostRetrieveAsync()
+ {
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Get,
+ Path = "/accounting/v1/contacts/meta/post"
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
}
}
diff --git a/src/Merge.Client/Accounting/Contacts/requests/ContactEndpointRequest.cs b/src/Merge.Client/Accounting/Contacts/requests/ContactEndpointRequest.cs
new file mode 100644
index 00000000..c8d7c895
--- /dev/null
+++ b/src/Merge.Client/Accounting/Contacts/requests/ContactEndpointRequest.cs
@@ -0,0 +1,18 @@
+using Merge.Client.Accounting;
+
+namespace Merge.Client.Accounting;
+
+public class ContactEndpointRequest
+{
+ ///
+ /// Whether to include debug fields (such as log file links) in the response.
+ ///
+ public bool? IsDebugMode { get; init; }
+
+ ///
+ /// Whether or not third-party updates should be run asynchronously.
+ ///
+ public bool? RunAsync { get; init; }
+
+ public ContactRequest Model { get; init; }
+}
diff --git a/src/Merge.Client/Accounting/Contacts/requests/ContactsListRequest.cs b/src/Merge.Client/Accounting/Contacts/requests/ContactsListRequest.cs
new file mode 100644
index 00000000..ca57067f
--- /dev/null
+++ b/src/Merge.Client/Accounting/Contacts/requests/ContactsListRequest.cs
@@ -0,0 +1,81 @@
+using Merge.Client.Accounting;
+
+namespace Merge.Client.Accounting;
+
+public class ContactsListRequest
+{
+ ///
+ /// If provided, will only return contacts for this company.
+ ///
+ public string? CompanyId { get; init; }
+
+ ///
+ /// If provided, will only return objects created after this datetime.
+ ///
+ public DateTime? CreatedAfter { get; init; }
+
+ ///
+ /// If provided, will only return objects created before this datetime.
+ ///
+ public DateTime? CreatedBefore { get; init; }
+
+ ///
+ /// The pagination cursor value.
+ ///
+ public string? Cursor { get; init; }
+
+ ///
+ /// Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces.
+ ///
+ public ContactsListRequestExpand? Expand { get; init; }
+
+ ///
+ /// Whether to include data that was marked as deleted by third party webhooks.
+ ///
+ public bool? IncludeDeletedData { get; init; }
+
+ ///
+ /// Whether to include the original data Merge fetched from the third-party to produce these models.
+ ///
+ public bool? IncludeRemoteData { get; init; }
+
+ ///
+ /// If provided, will only return Contacts that are denoted as customers.
+ ///
+ public string? IsCustomer { get; init; }
+
+ ///
+ /// If provided, will only return Contacts that are denoted as suppliers.
+ ///
+ public string? IsSupplier { get; init; }
+
+ ///
+ /// If provided, only objects synced by Merge after this date time will be returned.
+ ///
+ public DateTime? ModifiedAfter { get; init; }
+
+ ///
+ /// If provided, only objects synced by Merge before this date time will be returned.
+ ///
+ public DateTime? ModifiedBefore { get; init; }
+
+ ///
+ /// Number of results to return per page.
+ ///
+ public int? PageSize { get; init; }
+
+ ///
+ /// Deprecated. Use show_enum_origins.
+ ///
+ public string? RemoteFields { get; init; }
+
+ ///
+ /// The API provider's ID for the given object.
+ ///
+ public string? RemoteId { get; init; }
+
+ ///
+ /// A comma separated list of enum field names for which you'd like the original values to be returned, instead of Merge's normalized enum values. [Learn more](https://help.merge.dev/en/articles/8950958-show_enum_origins-query-parameter)
+ ///
+ public string? ShowEnumOrigins { get; init; }
+}
diff --git a/src/Merge.Client/Accounting/Contacts/requests/ContactsRetrieveRequest.cs b/src/Merge.Client/Accounting/Contacts/requests/ContactsRetrieveRequest.cs
new file mode 100644
index 00000000..f14a90a6
--- /dev/null
+++ b/src/Merge.Client/Accounting/Contacts/requests/ContactsRetrieveRequest.cs
@@ -0,0 +1,26 @@
+using Merge.Client.Accounting;
+
+namespace Merge.Client.Accounting;
+
+public class ContactsRetrieveRequest
+{
+ ///
+ /// Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces.
+ ///
+ public ContactsRetrieveRequestExpand? Expand { get; init; }
+
+ ///
+ /// Whether to include the original data Merge fetched from the third-party to produce these models.
+ ///
+ public bool? IncludeRemoteData { get; init; }
+
+ ///
+ /// Deprecated. Use show_enum_origins.
+ ///
+ public string? RemoteFields { get; init; }
+
+ ///
+ /// A comma separated list of enum field names for which you'd like the original values to be returned, instead of Merge's normalized enum values. [Learn more](https://help.merge.dev/en/articles/8950958-show_enum_origins-query-parameter)
+ ///
+ public string? ShowEnumOrigins { get; init; }
+}
diff --git a/src/Merge.Client/Accounting/CreditNotes/CreditNotesClient.cs b/src/Merge.Client/Accounting/CreditNotes/CreditNotesClient.cs
index 98eab5dc..6d88eda9 100644
--- a/src/Merge.Client/Accounting/CreditNotes/CreditNotesClient.cs
+++ b/src/Merge.Client/Accounting/CreditNotes/CreditNotesClient.cs
@@ -1,9 +1,135 @@
+using System.Text.Json;
+using Merge.Client;
+using Merge.Client.Accounting;
+
namespace Merge.Client.Accounting;
public class CreditNotesClient
{
- public async void List(){
+ private RawClient _client;
+
+ public CreditNotesClient(RawClient client)
+ {
+ _client = client;
}
- public async void Retrieve(){
+
+ ///
+ /// Returns a list of `CreditNote` objects.
+ ///
+ public async Task ListAsync(CreditNotesListRequest request)
+ {
+ var _query = new Dictionary() { };
+ if (request.CompanyId != null)
+ {
+ _query["company_id"] = request.CompanyId;
+ }
+ if (request.CreatedAfter != null)
+ {
+ _query["created_after"] = request.CreatedAfter;
+ }
+ if (request.CreatedBefore != null)
+ {
+ _query["created_before"] = request.CreatedBefore;
+ }
+ if (request.Cursor != null)
+ {
+ _query["cursor"] = request.Cursor;
+ }
+ if (request.Expand != null)
+ {
+ _query["expand"] = request.Expand;
+ }
+ if (request.IncludeDeletedData != null)
+ {
+ _query["include_deleted_data"] = request.IncludeDeletedData;
+ }
+ if (request.IncludeRemoteData != null)
+ {
+ _query["include_remote_data"] = request.IncludeRemoteData;
+ }
+ if (request.ModifiedAfter != null)
+ {
+ _query["modified_after"] = request.ModifiedAfter;
+ }
+ if (request.ModifiedBefore != null)
+ {
+ _query["modified_before"] = request.ModifiedBefore;
+ }
+ if (request.PageSize != null)
+ {
+ _query["page_size"] = request.PageSize;
+ }
+ if (request.RemoteFields != null)
+ {
+ _query["remote_fields"] = request.RemoteFields;
+ }
+ if (request.RemoteId != null)
+ {
+ _query["remote_id"] = request.RemoteId;
+ }
+ if (request.ShowEnumOrigins != null)
+ {
+ _query["show_enum_origins"] = request.ShowEnumOrigins;
+ }
+ if (request.TransactionDateAfter != null)
+ {
+ _query["transaction_date_after"] = request.TransactionDateAfter;
+ }
+ if (request.TransactionDateBefore != null)
+ {
+ _query["transaction_date_before"] = request.TransactionDateBefore;
+ }
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Get,
+ Path = "/accounting/v1/credit-notes",
+ Query = _query
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
+ }
+
+ ///
+ /// Returns a `CreditNote` object with the given `id`.
+ ///
+ public async Task RetrieveAsync(string id, CreditNotesRetrieveRequest request)
+ {
+ var _query = new Dictionary() { };
+ if (request.Expand != null)
+ {
+ _query["expand"] = request.Expand;
+ }
+ if (request.IncludeRemoteData != null)
+ {
+ _query["include_remote_data"] = request.IncludeRemoteData;
+ }
+ if (request.RemoteFields != null)
+ {
+ _query["remote_fields"] = request.RemoteFields;
+ }
+ if (request.ShowEnumOrigins != null)
+ {
+ _query["show_enum_origins"] = request.ShowEnumOrigins;
+ }
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Get,
+ Path = $"/accounting/v1/credit-notes/{id}",
+ Query = _query
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
}
}
diff --git a/src/Merge.Client/Accounting/CreditNotes/Types/CreditNotesListRequestExpand.cs b/src/Merge.Client/Accounting/CreditNotes/Types/CreditNotesListRequestExpand.cs
index 5e95626e..fe5e26e1 100644
--- a/src/Merge.Client/Accounting/CreditNotes/Types/CreditNotesListRequestExpand.cs
+++ b/src/Merge.Client/Accounting/CreditNotes/Types/CreditNotesListRequestExpand.cs
@@ -64,19 +64,25 @@ public enum CreditNotesListRequestExpand
[EnumMember(Value = "applied_payments,line_items,tracking_categories,company")]
AppliedPaymentsLineItemsTrackingCategoriesCompany,
- [EnumMember(Value = "applied_payments,line_items,tracking_categories,company,accounting_period")]
+ [EnumMember(
+ Value = "applied_payments,line_items,tracking_categories,company,accounting_period"
+ )]
AppliedPaymentsLineItemsTrackingCategoriesCompanyAccountingPeriod,
[EnumMember(Value = "applied_payments,line_items,tracking_categories,contact")]
AppliedPaymentsLineItemsTrackingCategoriesContact,
- [EnumMember(Value = "applied_payments,line_items,tracking_categories,contact,accounting_period")]
+ [EnumMember(
+ Value = "applied_payments,line_items,tracking_categories,contact,accounting_period"
+ )]
AppliedPaymentsLineItemsTrackingCategoriesContactAccountingPeriod,
[EnumMember(Value = "applied_payments,line_items,tracking_categories,contact,company")]
AppliedPaymentsLineItemsTrackingCategoriesContactCompany,
- [EnumMember(Value = "applied_payments,line_items,tracking_categories,contact,company,accounting_period")]
+ [EnumMember(
+ Value = "applied_payments,line_items,tracking_categories,contact,company,accounting_period"
+ )]
AppliedPaymentsLineItemsTrackingCategoriesContactCompanyAccountingPeriod,
[EnumMember(Value = "applied_payments,tracking_categories")]
@@ -226,25 +232,33 @@ public enum CreditNotesListRequestExpand
[EnumMember(Value = "payments,applied_payments,line_items,tracking_categories")]
PaymentsAppliedPaymentsLineItemsTrackingCategories,
- [EnumMember(Value = "payments,applied_payments,line_items,tracking_categories,accounting_period")]
+ [EnumMember(
+ Value = "payments,applied_payments,line_items,tracking_categories,accounting_period"
+ )]
PaymentsAppliedPaymentsLineItemsTrackingCategoriesAccountingPeriod,
[EnumMember(Value = "payments,applied_payments,line_items,tracking_categories,company")]
PaymentsAppliedPaymentsLineItemsTrackingCategoriesCompany,
- [EnumMember(Value = "payments,applied_payments,line_items,tracking_categories,company,accounting_period")]
+ [EnumMember(
+ Value = "payments,applied_payments,line_items,tracking_categories,company,accounting_period"
+ )]
PaymentsAppliedPaymentsLineItemsTrackingCategoriesCompanyAccountingPeriod,
[EnumMember(Value = "payments,applied_payments,line_items,tracking_categories,contact")]
PaymentsAppliedPaymentsLineItemsTrackingCategoriesContact,
- [EnumMember(Value = "payments,applied_payments,line_items,tracking_categories,contact,accounting_period")]
+ [EnumMember(
+ Value = "payments,applied_payments,line_items,tracking_categories,contact,accounting_period"
+ )]
PaymentsAppliedPaymentsLineItemsTrackingCategoriesContactAccountingPeriod,
[EnumMember(Value = "payments,applied_payments,line_items,tracking_categories,contact,company")]
PaymentsAppliedPaymentsLineItemsTrackingCategoriesContactCompany,
- [EnumMember(Value = "payments,applied_payments,line_items,tracking_categories,contact,company,accounting_period")]
+ [EnumMember(
+ Value = "payments,applied_payments,line_items,tracking_categories,contact,company,accounting_period"
+ )]
PaymentsAppliedPaymentsLineItemsTrackingCategoriesContactCompanyAccountingPeriod,
[EnumMember(Value = "payments,applied_payments,tracking_categories")]
@@ -268,7 +282,9 @@ public enum CreditNotesListRequestExpand
[EnumMember(Value = "payments,applied_payments,tracking_categories,contact,company")]
PaymentsAppliedPaymentsTrackingCategoriesContactCompany,
- [EnumMember(Value = "payments,applied_payments,tracking_categories,contact,company,accounting_period")]
+ [EnumMember(
+ Value = "payments,applied_payments,tracking_categories,contact,company,accounting_period"
+ )]
PaymentsAppliedPaymentsTrackingCategoriesContactCompanyAccountingPeriod,
[EnumMember(Value = "payments,company")]
@@ -334,7 +350,9 @@ public enum CreditNotesListRequestExpand
[EnumMember(Value = "payments,line_items,tracking_categories,contact,company")]
PaymentsLineItemsTrackingCategoriesContactCompany,
- [EnumMember(Value = "payments,line_items,tracking_categories,contact,company,accounting_period")]
+ [EnumMember(
+ Value = "payments,line_items,tracking_categories,contact,company,accounting_period"
+ )]
PaymentsLineItemsTrackingCategoriesContactCompanyAccountingPeriod,
[EnumMember(Value = "payments,tracking_categories")]
diff --git a/src/Merge.Client/Accounting/CreditNotes/Types/CreditNotesRetrieveRequestExpand.cs b/src/Merge.Client/Accounting/CreditNotes/Types/CreditNotesRetrieveRequestExpand.cs
index 0e111a83..ad73f8d0 100644
--- a/src/Merge.Client/Accounting/CreditNotes/Types/CreditNotesRetrieveRequestExpand.cs
+++ b/src/Merge.Client/Accounting/CreditNotes/Types/CreditNotesRetrieveRequestExpand.cs
@@ -64,19 +64,25 @@ public enum CreditNotesRetrieveRequestExpand
[EnumMember(Value = "applied_payments,line_items,tracking_categories,company")]
AppliedPaymentsLineItemsTrackingCategoriesCompany,
- [EnumMember(Value = "applied_payments,line_items,tracking_categories,company,accounting_period")]
+ [EnumMember(
+ Value = "applied_payments,line_items,tracking_categories,company,accounting_period"
+ )]
AppliedPaymentsLineItemsTrackingCategoriesCompanyAccountingPeriod,
[EnumMember(Value = "applied_payments,line_items,tracking_categories,contact")]
AppliedPaymentsLineItemsTrackingCategoriesContact,
- [EnumMember(Value = "applied_payments,line_items,tracking_categories,contact,accounting_period")]
+ [EnumMember(
+ Value = "applied_payments,line_items,tracking_categories,contact,accounting_period"
+ )]
AppliedPaymentsLineItemsTrackingCategoriesContactAccountingPeriod,
[EnumMember(Value = "applied_payments,line_items,tracking_categories,contact,company")]
AppliedPaymentsLineItemsTrackingCategoriesContactCompany,
- [EnumMember(Value = "applied_payments,line_items,tracking_categories,contact,company,accounting_period")]
+ [EnumMember(
+ Value = "applied_payments,line_items,tracking_categories,contact,company,accounting_period"
+ )]
AppliedPaymentsLineItemsTrackingCategoriesContactCompanyAccountingPeriod,
[EnumMember(Value = "applied_payments,tracking_categories")]
@@ -226,25 +232,33 @@ public enum CreditNotesRetrieveRequestExpand
[EnumMember(Value = "payments,applied_payments,line_items,tracking_categories")]
PaymentsAppliedPaymentsLineItemsTrackingCategories,
- [EnumMember(Value = "payments,applied_payments,line_items,tracking_categories,accounting_period")]
+ [EnumMember(
+ Value = "payments,applied_payments,line_items,tracking_categories,accounting_period"
+ )]
PaymentsAppliedPaymentsLineItemsTrackingCategoriesAccountingPeriod,
[EnumMember(Value = "payments,applied_payments,line_items,tracking_categories,company")]
PaymentsAppliedPaymentsLineItemsTrackingCategoriesCompany,
- [EnumMember(Value = "payments,applied_payments,line_items,tracking_categories,company,accounting_period")]
+ [EnumMember(
+ Value = "payments,applied_payments,line_items,tracking_categories,company,accounting_period"
+ )]
PaymentsAppliedPaymentsLineItemsTrackingCategoriesCompanyAccountingPeriod,
[EnumMember(Value = "payments,applied_payments,line_items,tracking_categories,contact")]
PaymentsAppliedPaymentsLineItemsTrackingCategoriesContact,
- [EnumMember(Value = "payments,applied_payments,line_items,tracking_categories,contact,accounting_period")]
+ [EnumMember(
+ Value = "payments,applied_payments,line_items,tracking_categories,contact,accounting_period"
+ )]
PaymentsAppliedPaymentsLineItemsTrackingCategoriesContactAccountingPeriod,
[EnumMember(Value = "payments,applied_payments,line_items,tracking_categories,contact,company")]
PaymentsAppliedPaymentsLineItemsTrackingCategoriesContactCompany,
- [EnumMember(Value = "payments,applied_payments,line_items,tracking_categories,contact,company,accounting_period")]
+ [EnumMember(
+ Value = "payments,applied_payments,line_items,tracking_categories,contact,company,accounting_period"
+ )]
PaymentsAppliedPaymentsLineItemsTrackingCategoriesContactCompanyAccountingPeriod,
[EnumMember(Value = "payments,applied_payments,tracking_categories")]
@@ -268,7 +282,9 @@ public enum CreditNotesRetrieveRequestExpand
[EnumMember(Value = "payments,applied_payments,tracking_categories,contact,company")]
PaymentsAppliedPaymentsTrackingCategoriesContactCompany,
- [EnumMember(Value = "payments,applied_payments,tracking_categories,contact,company,accounting_period")]
+ [EnumMember(
+ Value = "payments,applied_payments,tracking_categories,contact,company,accounting_period"
+ )]
PaymentsAppliedPaymentsTrackingCategoriesContactCompanyAccountingPeriod,
[EnumMember(Value = "payments,company")]
@@ -334,7 +350,9 @@ public enum CreditNotesRetrieveRequestExpand
[EnumMember(Value = "payments,line_items,tracking_categories,contact,company")]
PaymentsLineItemsTrackingCategoriesContactCompany,
- [EnumMember(Value = "payments,line_items,tracking_categories,contact,company,accounting_period")]
+ [EnumMember(
+ Value = "payments,line_items,tracking_categories,contact,company,accounting_period"
+ )]
PaymentsLineItemsTrackingCategoriesContactCompanyAccountingPeriod,
[EnumMember(Value = "payments,tracking_categories")]
diff --git a/src/Merge.Client/Accounting/CreditNotes/requests/CreditNotesListRequest.cs b/src/Merge.Client/Accounting/CreditNotes/requests/CreditNotesListRequest.cs
new file mode 100644
index 00000000..ce88c2ca
--- /dev/null
+++ b/src/Merge.Client/Accounting/CreditNotes/requests/CreditNotesListRequest.cs
@@ -0,0 +1,81 @@
+using Merge.Client.Accounting;
+
+namespace Merge.Client.Accounting;
+
+public class CreditNotesListRequest
+{
+ ///
+ /// If provided, will only return credit notes for this company.
+ ///
+ public string? CompanyId { get; init; }
+
+ ///
+ /// If provided, will only return objects created after this datetime.
+ ///
+ public DateTime? CreatedAfter { get; init; }
+
+ ///
+ /// If provided, will only return objects created before this datetime.
+ ///
+ public DateTime? CreatedBefore { get; init; }
+
+ ///
+ /// The pagination cursor value.
+ ///
+ public string? Cursor { get; init; }
+
+ ///
+ /// Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces.
+ ///
+ public CreditNotesListRequestExpand? Expand { get; init; }
+
+ ///
+ /// Whether to include data that was marked as deleted by third party webhooks.
+ ///
+ public bool? IncludeDeletedData { get; init; }
+
+ ///
+ /// Whether to include the original data Merge fetched from the third-party to produce these models.
+ ///
+ public bool? IncludeRemoteData { get; init; }
+
+ ///
+ /// If provided, only objects synced by Merge after this date time will be returned.
+ ///
+ public DateTime? ModifiedAfter { get; init; }
+
+ ///
+ /// If provided, only objects synced by Merge before this date time will be returned.
+ ///
+ public DateTime? ModifiedBefore { get; init; }
+
+ ///
+ /// Number of results to return per page.
+ ///
+ public int? PageSize { get; init; }
+
+ ///
+ /// Deprecated. Use show_enum_origins.
+ ///
+ public CreditNotesListRequestRemoteFields? RemoteFields { get; init; }
+
+ ///
+ /// The API provider's ID for the given object.
+ ///
+ public string? RemoteId { get; init; }
+
+ ///
+ /// A comma separated list of enum field names for which you'd like the original values to be returned, instead of Merge's normalized enum values. [Learn more](https://help.merge.dev/en/articles/8950958-show_enum_origins-query-parameter)
+ ///
+ public CreditNotesListRequestShowEnumOrigins? ShowEnumOrigins { get; init; }
+
+ ///
+ /// If provided, will only return objects created after this datetime.
+ ///
+ public DateTime? TransactionDateAfter { get; init; }
+
+ ///
+ /// If provided, will only return objects created before this datetime.
+ ///
+ public DateTime? TransactionDateBefore { get; init; }
+}
diff --git a/src/Merge.Client/Accounting/CreditNotes/requests/CreditNotesRetrieveRequest.cs b/src/Merge.Client/Accounting/CreditNotes/requests/CreditNotesRetrieveRequest.cs
new file mode 100644
index 00000000..5b7f6236
--- /dev/null
+++ b/src/Merge.Client/Accounting/CreditNotes/requests/CreditNotesRetrieveRequest.cs
@@ -0,0 +1,26 @@
+using Merge.Client.Accounting;
+
+namespace Merge.Client.Accounting;
+
+public class CreditNotesRetrieveRequest
+{
+ ///
+ /// Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces.
+ ///
+ public CreditNotesRetrieveRequestExpand? Expand { get; init; }
+
+ ///
+ /// Whether to include the original data Merge fetched from the third-party to produce these models.
+ ///
+ public bool? IncludeRemoteData { get; init; }
+
+ ///
+ /// Deprecated. Use show_enum_origins.
+ ///
+ public CreditNotesRetrieveRequestRemoteFields? RemoteFields { get; init; }
+
+ ///
+ /// A comma separated list of enum field names for which you'd like the original values to be returned, instead of Merge's normalized enum values. [Learn more](https://help.merge.dev/en/articles/8950958-show_enum_origins-query-parameter)
+ ///
+ public CreditNotesRetrieveRequestShowEnumOrigins? ShowEnumOrigins { get; init; }
+}
diff --git a/src/Merge.Client/Accounting/DeleteAccount/DeleteAccountClient.cs b/src/Merge.Client/Accounting/DeleteAccount/DeleteAccountClient.cs
index b3ff6614..cc7391e2 100644
--- a/src/Merge.Client/Accounting/DeleteAccount/DeleteAccountClient.cs
+++ b/src/Merge.Client/Accounting/DeleteAccount/DeleteAccountClient.cs
@@ -1,7 +1,27 @@
+using Merge.Client;
+
namespace Merge.Client.Accounting;
public class DeleteAccountClient
{
- public async void Delete(){
+ private RawClient _client;
+
+ public DeleteAccountClient(RawClient client)
+ {
+ _client = client;
+ }
+
+ ///
+ /// Delete a linked account.
+ ///
+ public async void DeleteAsync()
+ {
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Post,
+ Path = "/accounting/v1/delete-account"
+ }
+ );
}
}
diff --git a/src/Merge.Client/Accounting/Expenses/ExpensesClient.cs b/src/Merge.Client/Accounting/Expenses/ExpensesClient.cs
index a08b5dcd..341fad8a 100644
--- a/src/Merge.Client/Accounting/Expenses/ExpensesClient.cs
+++ b/src/Merge.Client/Accounting/Expenses/ExpensesClient.cs
@@ -1,13 +1,169 @@
+using System.Text.Json;
+using Merge.Client;
+using Merge.Client.Accounting;
+
namespace Merge.Client.Accounting;
public class ExpensesClient
{
- public async void List(){
+ private RawClient _client;
+
+ public ExpensesClient(RawClient client)
+ {
+ _client = client;
}
- public async void Create(){
+
+ ///
+ /// Returns a list of `Expense` objects.
+ ///
+ public async Task ListAsync(ExpensesListRequest request)
+ {
+ var _query = new Dictionary() { };
+ if (request.CompanyId != null)
+ {
+ _query["company_id"] = request.CompanyId;
+ }
+ if (request.CreatedAfter != null)
+ {
+ _query["created_after"] = request.CreatedAfter;
+ }
+ if (request.CreatedBefore != null)
+ {
+ _query["created_before"] = request.CreatedBefore;
+ }
+ if (request.Cursor != null)
+ {
+ _query["cursor"] = request.Cursor;
+ }
+ if (request.Expand != null)
+ {
+ _query["expand"] = request.Expand;
+ }
+ if (request.IncludeDeletedData != null)
+ {
+ _query["include_deleted_data"] = request.IncludeDeletedData;
+ }
+ if (request.IncludeRemoteData != null)
+ {
+ _query["include_remote_data"] = request.IncludeRemoteData;
+ }
+ if (request.ModifiedAfter != null)
+ {
+ _query["modified_after"] = request.ModifiedAfter;
+ }
+ if (request.ModifiedBefore != null)
+ {
+ _query["modified_before"] = request.ModifiedBefore;
+ }
+ if (request.PageSize != null)
+ {
+ _query["page_size"] = request.PageSize;
+ }
+ if (request.RemoteId != null)
+ {
+ _query["remote_id"] = request.RemoteId;
+ }
+ if (request.TransactionDateAfter != null)
+ {
+ _query["transaction_date_after"] = request.TransactionDateAfter;
+ }
+ if (request.TransactionDateBefore != null)
+ {
+ _query["transaction_date_before"] = request.TransactionDateBefore;
+ }
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Get,
+ Path = "/accounting/v1/expenses",
+ Query = _query
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
}
- public async void Retrieve(){
+
+ ///
+ /// Creates an `Expense` object with the given values.
+ ///
+ public async Task CreateAsync(ExpenseEndpointRequest request)
+ {
+ var _query = new Dictionary() { };
+ if (request.IsDebugMode != null)
+ {
+ _query["is_debug_mode"] = request.IsDebugMode;
+ }
+ if (request.RunAsync != null)
+ {
+ _query["run_async"] = request.RunAsync;
+ }
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Post,
+ Path = "/accounting/v1/expenses",
+ Query = _query
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
}
- public async void MetaPostRetrieve(){
+
+ ///
+ /// Returns an `Expense` object with the given `id`.
+ ///
+ public async Task RetrieveAsync(string id, ExpensesRetrieveRequest request)
+ {
+ var _query = new Dictionary() { };
+ if (request.Expand != null)
+ {
+ _query["expand"] = request.Expand;
+ }
+ if (request.IncludeRemoteData != null)
+ {
+ _query["include_remote_data"] = request.IncludeRemoteData;
+ }
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Get,
+ Path = $"/accounting/v1/expenses/{id}",
+ Query = _query
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
+ }
+
+ ///
+ /// Returns metadata for `Expense` POSTs.
+ ///
+ public async Task MetaPostRetrieveAsync()
+ {
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Get,
+ Path = "/accounting/v1/expenses/meta/post"
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
}
}
diff --git a/src/Merge.Client/Accounting/Expenses/requests/ExpenseEndpointRequest.cs b/src/Merge.Client/Accounting/Expenses/requests/ExpenseEndpointRequest.cs
new file mode 100644
index 00000000..494f866b
--- /dev/null
+++ b/src/Merge.Client/Accounting/Expenses/requests/ExpenseEndpointRequest.cs
@@ -0,0 +1,18 @@
+using Merge.Client.Accounting;
+
+namespace Merge.Client.Accounting;
+
+public class ExpenseEndpointRequest
+{
+ ///
+ /// Whether to include debug fields (such as log file links) in the response.
+ ///
+ public bool? IsDebugMode { get; init; }
+
+ ///
+ /// Whether or not third-party updates should be run asynchronously.
+ ///
+ public bool? RunAsync { get; init; }
+
+ public ExpenseRequest Model { get; init; }
+}
diff --git a/src/Merge.Client/Accounting/Expenses/requests/ExpensesListRequest.cs b/src/Merge.Client/Accounting/Expenses/requests/ExpensesListRequest.cs
new file mode 100644
index 00000000..b28ccb0b
--- /dev/null
+++ b/src/Merge.Client/Accounting/Expenses/requests/ExpensesListRequest.cs
@@ -0,0 +1,71 @@
+using Merge.Client.Accounting;
+
+namespace Merge.Client.Accounting;
+
+public class ExpensesListRequest
+{
+ ///
+ /// If provided, will only return expenses for this company.
+ ///
+ public string? CompanyId { get; init; }
+
+ ///
+ /// If provided, will only return objects created after this datetime.
+ ///
+ public DateTime? CreatedAfter { get; init; }
+
+ ///
+ /// If provided, will only return objects created before this datetime.
+ ///
+ public DateTime? CreatedBefore { get; init; }
+
+ ///
+ /// The pagination cursor value.
+ ///
+ public string? Cursor { get; init; }
+
+ ///
+ /// Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces.
+ ///
+ public ExpensesListRequestExpand? Expand { get; init; }
+
+ ///
+ /// Whether to include data that was marked as deleted by third party webhooks.
+ ///
+ public bool? IncludeDeletedData { get; init; }
+
+ ///
+ /// Whether to include the original data Merge fetched from the third-party to produce these models.
+ ///
+ public bool? IncludeRemoteData { get; init; }
+
+ ///
+ /// If provided, only objects synced by Merge after this date time will be returned.
+ ///
+ public DateTime? ModifiedAfter { get; init; }
+
+ ///
+ /// If provided, only objects synced by Merge before this date time will be returned.
+ ///
+ public DateTime? ModifiedBefore { get; init; }
+
+ ///
+ /// Number of results to return per page.
+ ///
+ public int? PageSize { get; init; }
+
+ ///
+ /// The API provider's ID for the given object.
+ ///
+ public string? RemoteId { get; init; }
+
+ ///
+ /// If provided, will only return objects created after this datetime.
+ ///
+ public DateTime? TransactionDateAfter { get; init; }
+
+ ///
+ /// If provided, will only return objects created before this datetime.
+ ///
+ public DateTime? TransactionDateBefore { get; init; }
+}
diff --git a/src/Merge.Client/Accounting/Expenses/requests/ExpensesRetrieveRequest.cs b/src/Merge.Client/Accounting/Expenses/requests/ExpensesRetrieveRequest.cs
new file mode 100644
index 00000000..834fa35a
--- /dev/null
+++ b/src/Merge.Client/Accounting/Expenses/requests/ExpensesRetrieveRequest.cs
@@ -0,0 +1,16 @@
+using Merge.Client.Accounting;
+
+namespace Merge.Client.Accounting;
+
+public class ExpensesRetrieveRequest
+{
+ ///
+ /// Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces.
+ ///
+ public ExpensesRetrieveRequestExpand? Expand { get; init; }
+
+ ///
+ /// Whether to include the original data Merge fetched from the third-party to produce these models.
+ ///
+ public bool? IncludeRemoteData { get; init; }
+}
diff --git a/src/Merge.Client/Accounting/FieldMapping/FieldMappingClient.cs b/src/Merge.Client/Accounting/FieldMapping/FieldMappingClient.cs
new file mode 100644
index 00000000..6f0e2b81
--- /dev/null
+++ b/src/Merge.Client/Accounting/FieldMapping/FieldMappingClient.cs
@@ -0,0 +1,154 @@
+using System.Text.Json;
+using Merge.Client;
+using Merge.Client.Accounting;
+
+namespace Merge.Client.Accounting;
+
+public class FieldMappingClient
+{
+ private RawClient _client;
+
+ public FieldMappingClient(RawClient client)
+ {
+ _client = client;
+ }
+
+ ///
+ /// Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. [Learn more](https://docs.merge.dev/supplemental-data/field-mappings/overview/).
+ ///
+ public async Task FieldMappingsRetrieveAsync()
+ {
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Get,
+ Path = "/accounting/v1/field-mappings"
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
+ }
+
+ ///
+ /// Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync **ALL** data from start.
+ ///
+ public async Task FieldMappingsCreateAsync(
+ CreateFieldMappingRequest request
+ )
+ {
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Post,
+ Path = "/accounting/v1/field-mappings",
+ Body = request
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
+ }
+
+ ///
+ /// Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync **ALL** data from start.
+ ///
+ public async Task FieldMappingsDestroyAsync(string fieldMappingId)
+ {
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Delete,
+ Path = $"/accounting/v1/field-mappings/{fieldMappingId}"
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
+ }
+
+ ///
+ /// Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync **ALL** data from start.
+ ///
+ public async Task FieldMappingsPartialUpdateAsync(
+ string fieldMappingId,
+ PatchedEditFieldMappingRequest request
+ )
+ {
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Patch,
+ Path = $"/accounting/v1/field-mappings/{fieldMappingId}",
+ Body = request
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
+ }
+
+ ///
+ /// Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. [Learn more](https://docs.merge.dev/supplemental-data/field-mappings/overview/).
+ ///
+ public async Task RemoteFieldsRetrieveAsync(
+ RemoteFieldsRetrieveRequest request
+ )
+ {
+ var _query = new Dictionary() { };
+ if (request.CommonModels != null)
+ {
+ _query["common_models"] = request.CommonModels;
+ }
+ if (request.IncludeExampleValues != null)
+ {
+ _query["include_example_values"] = request.IncludeExampleValues;
+ }
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Get,
+ Path = "/accounting/v1/remote-fields",
+ Query = _query
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
+ }
+
+ ///
+ /// Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. [Learn more](https://docs.merge.dev/supplemental-data/field-mappings/target-fields/).
+ ///
+ public async Task TargetFieldsRetrieveAsync()
+ {
+ var response = await _client.MakeRequestAsync(
+ new RawClient.ApiRequest
+ {
+ Method = HttpMethod.Get,
+ Path = "/accounting/v1/target-fields"
+ }
+ );
+ string responseBody = await response.Raw.Content.ReadAsStringAsync();
+ if (response.StatusCode >= 200 && response.StatusCode < 400)
+ {
+ return JsonSerializer.Deserialize(responseBody);
+ }
+ throw new Exception();
+ }
+}
diff --git a/src/Merge.Client/Accounting/FieldMapping/requests/CreateFieldMappingRequest.cs b/src/Merge.Client/Accounting/FieldMapping/requests/CreateFieldMappingRequest.cs
new file mode 100644
index 00000000..77cc57eb
--- /dev/null
+++ b/src/Merge.Client/Accounting/FieldMapping/requests/CreateFieldMappingRequest.cs
@@ -0,0 +1,34 @@
+namespace Merge.Client.Accounting;
+
+public class CreateFieldMappingRequest
+{
+ ///
+ /// The name of the target field you want this remote field to map to.
+ ///
+ public string TargetFieldName { get; init; }
+
+ ///
+ /// The description of the target field you want this remote field to map to.
+ ///
+ public string TargetFieldDescription { get; init; }
+
+ ///
+ /// The field traversal path of the remote field listed when you hit the GET /remote-fields endpoint.
+ ///
+ public List