Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,28 @@ jobs:
- name: Build Release
run: dotnet build src -c Release /p:ContinuousIntegrationBuild=true

unit-tests:
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v3

- uses: actions/checkout@master

- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.x

- name: Install tools
run: |
dotnet tool restore

- name: Run Tests
run: |
dotnet test src


publish:
needs: [compile]
Expand Down
3 changes: 2 additions & 1 deletion src/Merge.Client.Test/Merge.Client.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand All @@ -15,6 +15,7 @@
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2"/>
<PackageReference Include="NUnit.Analyzers" Version="3.6.1"/>
<PackageReference Include="coverlet.collector" Version="3.2.0"/>
<PackageReference Include="FluentAssertions.Json" Version="6.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
5 changes: 5 additions & 0 deletions src/Merge.Client.Test/TestClient.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
using NUnit.Framework;

#nullable enable

namespace Merge.Client.Test;

[TestFixture]
public class TestClient { }
20 changes: 10 additions & 10 deletions src/Merge.Client.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Merge.Client", "Merge.Client\Merge.Client.csproj", "{8D54A66D-E9D5-417E-9BE5-8FEF3F7F660F}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Merge.Client", "Merge.Client\Merge.Client.csproj", "{5940579A-1D95-4B3E-9CC6-F5D30AB2D95A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Merge.Client.Test", "Merge.Client.Test\Merge.Client.Test.csproj", "{ECDC139A-E6BD-4FDD-9966-4F7EE068A1A8}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Merge.Client.Test", "Merge.Client.Test\Merge.Client.Test.csproj", "{6F36DC9B-1D6D-4BD7-B202-6ED89700FAF1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -16,13 +16,13 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8D54A66D-E9D5-417E-9BE5-8FEF3F7F660F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8D54A66D-E9D5-417E-9BE5-8FEF3F7F660F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8D54A66D-E9D5-417E-9BE5-8FEF3F7F660F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8D54A66D-E9D5-417E-9BE5-8FEF3F7F660F}.Release|Any CPU.Build.0 = Release|Any CPU
{ECDC139A-E6BD-4FDD-9966-4F7EE068A1A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ECDC139A-E6BD-4FDD-9966-4F7EE068A1A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ECDC139A-E6BD-4FDD-9966-4F7EE068A1A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ECDC139A-E6BD-4FDD-9966-4F7EE068A1A8}.Release|Any CPU.Build.0 = Release|Any CPU
{5940579A-1D95-4B3E-9CC6-F5D30AB2D95A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5940579A-1D95-4B3E-9CC6-F5D30AB2D95A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5940579A-1D95-4B3E-9CC6-F5D30AB2D95A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5940579A-1D95-4B3E-9CC6-F5D30AB2D95A}.Release|Any CPU.Build.0 = Release|Any CPU
{6F36DC9B-1D6D-4BD7-B202-6ED89700FAF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6F36DC9B-1D6D-4BD7-B202-6ED89700FAF1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6F36DC9B-1D6D-4BD7-B202-6ED89700FAF1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6F36DC9B-1D6D-4BD7-B202-6ED89700FAF1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
34 changes: 24 additions & 10 deletions src/Merge.Client/Accounting/AccountDetails/AccountDetailsClient.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,51 @@
using System.Net.Http;
using System.Text.Json;
using Merge.Client;
using Merge.Client.Accounting;
using Merge.Client.Core;

#nullable enable

namespace Merge.Client.Accounting;

public class AccountDetailsClient
public partial class AccountDetailsClient
{
private RawClient _client;

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

/// <summary>
/// Get details for a linked account.
/// </summary>
public async Task<AccountDetails> RetrieveAsync()
public async Task<AccountDetails> RetrieveAsync(RequestOptions? options = null)
{
var response = await _client.MakeRequestAsync(
new RawClient.JsonApiRequest
{
BaseUrl = _client.Options.BaseUrl,
Method = HttpMethod.Get,
Path = "accounting/v1/account-details"
Path = "accounting/v1/account-details",
Options = options
}
);
string responseBody = await response.Raw.Content.ReadAsStringAsync();
if (response.StatusCode >= 200 && response.StatusCode < 400)
var responseBody = await response.Raw.Content.ReadAsStringAsync();
if (response.StatusCode is >= 200 and < 400)
{
return JsonSerializer.Deserialize<AccountDetails>(responseBody);
try
{
return JsonUtils.Deserialize<AccountDetails>(responseBody)!;
}
catch (JsonException e)
{
throw new MergeException("Failed to deserialize response", e);
}
}
throw new Exception(responseBody);

throw new MergeApiException(
$"Error with status code {response.StatusCode}",
response.StatusCode,
responseBody
);
}
}
37 changes: 27 additions & 10 deletions src/Merge.Client/Accounting/AccountToken/AccountTokenClient.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,54 @@
using System.Net.Http;
using System.Text.Json;
using Merge.Client;
using Merge.Client.Accounting;
using Merge.Client.Core;

#nullable enable

namespace Merge.Client.Accounting;

public class AccountTokenClient
public partial class AccountTokenClient
{
private RawClient _client;

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

/// <summary>
/// Returns the account token for the end user with the provided public token.
/// </summary>
public async Task<AccountToken> RetrieveAsync(string publicToken)
public async Task<AccountToken> RetrieveAsync(
string publicToken,
RequestOptions? options = null
)
{
var response = await _client.MakeRequestAsync(
new RawClient.JsonApiRequest
{
BaseUrl = _client.Options.BaseUrl,
Method = HttpMethod.Get,
Path = $"accounting/v1/account-token/{publicToken}"
Path = $"accounting/v1/account-token/{publicToken}",
Options = options
}
);
string responseBody = await response.Raw.Content.ReadAsStringAsync();
if (response.StatusCode >= 200 && response.StatusCode < 400)
var responseBody = await response.Raw.Content.ReadAsStringAsync();
if (response.StatusCode is >= 200 and < 400)
{
return JsonSerializer.Deserialize<AccountToken>(responseBody);
try
{
return JsonUtils.Deserialize<AccountToken>(responseBody)!;
}
catch (JsonException e)
{
throw new MergeException("Failed to deserialize response", e);
}
}
throw new Exception(responseBody);

throw new MergeApiException(
$"Error with status code {response.StatusCode}",
response.StatusCode,
responseBody
);
}
}
7 changes: 3 additions & 4 deletions src/Merge.Client/Accounting/AccountingClient.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
using Merge.Client;
using Merge.Client.Accounting;
using Merge.Client.Core;

#nullable enable

namespace Merge.Client.Accounting;

public class AccountingClient
public partial class AccountingClient
{
private RawClient _client;

public AccountingClient(RawClient client)
internal AccountingClient(RawClient client)
{
_client = client;
AccountDetails = new AccountDetailsClient(_client);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
using System.Net.Http;
using System.Text.Json;
using Merge.Client;
using Merge.Client.Accounting;
using Merge.Client.Core;

#nullable enable

namespace Merge.Client.Accounting;

public class AccountingPeriodsClient
public partial class AccountingPeriodsClient
{
private RawClient _client;

public AccountingPeriodsClient(RawClient client)
internal AccountingPeriodsClient(RawClient client)
{
_client = client;
}

/// <summary>
/// Returns a list of `AccountingPeriod` objects.
/// </summary>
public async Task<PaginatedAccountingPeriodList> ListAsync(AccountingPeriodsListRequest request)
public async Task<PaginatedAccountingPeriodList> ListAsync(
AccountingPeriodsListRequest request,
RequestOptions? options = null
)
{
var _query = new Dictionary<string, object>() { };
if (request.Cursor != null)
Expand All @@ -40,25 +43,40 @@ public async Task<PaginatedAccountingPeriodList> ListAsync(AccountingPeriodsList
var response = await _client.MakeRequestAsync(
new RawClient.JsonApiRequest
{
BaseUrl = _client.Options.BaseUrl,
Method = HttpMethod.Get,
Path = "accounting/v1/accounting-periods",
Query = _query
Query = _query,
Options = options
}
);
string responseBody = await response.Raw.Content.ReadAsStringAsync();
if (response.StatusCode >= 200 && response.StatusCode < 400)
var responseBody = await response.Raw.Content.ReadAsStringAsync();
if (response.StatusCode is >= 200 and < 400)
{
return JsonSerializer.Deserialize<PaginatedAccountingPeriodList>(responseBody);
try
{
return JsonUtils.Deserialize<PaginatedAccountingPeriodList>(responseBody)!;
}
catch (JsonException e)
{
throw new MergeException("Failed to deserialize response", e);
}
}
throw new Exception(responseBody);

throw new MergeApiException(
$"Error with status code {response.StatusCode}",
response.StatusCode,
responseBody
);
}

/// <summary>
/// Returns an `AccountingPeriod` object with the given `id`.
/// </summary>
public async Task<AccountingPeriod> RetrieveAsync(
string id,
AccountingPeriodsRetrieveRequest request
AccountingPeriodsRetrieveRequest request,
RequestOptions? options = null
)
{
var _query = new Dictionary<string, object>() { };
Expand All @@ -69,16 +87,30 @@ AccountingPeriodsRetrieveRequest request
var response = await _client.MakeRequestAsync(
new RawClient.JsonApiRequest
{
BaseUrl = _client.Options.BaseUrl,
Method = HttpMethod.Get,
Path = $"accounting/v1/accounting-periods/{id}",
Query = _query
Query = _query,
Options = options
}
);
string responseBody = await response.Raw.Content.ReadAsStringAsync();
if (response.StatusCode >= 200 && response.StatusCode < 400)
var responseBody = await response.Raw.Content.ReadAsStringAsync();
if (response.StatusCode is >= 200 and < 400)
{
return JsonSerializer.Deserialize<AccountingPeriod>(responseBody);
try
{
return JsonUtils.Deserialize<AccountingPeriod>(responseBody)!;
}
catch (JsonException e)
{
throw new MergeException("Failed to deserialize response", e);
}
}
throw new Exception(responseBody);

throw new MergeApiException(
$"Error with status code {response.StatusCode}",
response.StatusCode,
responseBody
);
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
namespace Merge.Client.Accounting;

public class AccountingPeriodsListRequest
public record AccountingPeriodsListRequest
{
/// <summary>
/// The pagination cursor value.
/// </summary>
public string? Cursor { get; init; }
public string? Cursor { get; set; }

/// <summary>
/// Whether to include data that was marked as deleted by third party webhooks.
/// </summary>
public bool? IncludeDeletedData { get; init; }
public bool? IncludeDeletedData { get; set; }

/// <summary>
/// Whether to include the original data Merge fetched from the third-party to produce these models.
/// </summary>
public bool? IncludeRemoteData { get; init; }
public bool? IncludeRemoteData { get; set; }

/// <summary>
/// Number of results to return per page.
/// </summary>
public int? PageSize { get; init; }
public int? PageSize { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
namespace Merge.Client.Accounting;

public class AccountingPeriodsRetrieveRequest
public record AccountingPeriodsRetrieveRequest
{
/// <summary>
/// Whether to include the original data Merge fetched from the third-party to produce these models.
/// </summary>
public bool? IncludeRemoteData { get; init; }
public bool? IncludeRemoteData { get; set; }
}
Loading