Skip to content

Commit 69bc7d9

Browse files
authored
Merge pull request #35 from merge-api/fern-bot/08-27-2024-0159PM
Allow API call cancellation with CancellationTokens
2 parents fce1a17 + 2434afe commit 69bc7d9

File tree

1,370 files changed

+12020
-2013
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,370 files changed

+12020
-2013
lines changed

.gitignore

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
## Ignore Visual Studio temporary files, build results, and
22
## files generated by popular Visual Studio add-ons.
33
##
4-
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
4+
## Get latest from `dotnet new gitignore`
5+
6+
# dotenv files
7+
.env
58

69
# User-specific files
710
*.rsuser
@@ -399,6 +402,7 @@ FodyWeavers.xsd
399402

400403
# JetBrains Rider
401404
*.sln.iml
405+
.idea
402406

403407
##
404408
## Visual studio for Mac
@@ -475,3 +479,6 @@ $RECYCLE.BIN/
475479

476480
# Windows shortcuts
477481
*.lnk
482+
483+
# Vim temporary swap files
484+
*.swp

src/Merge.Client.Test/Merge.Client.Test.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2"/>
1616
<PackageReference Include="NUnit.Analyzers" Version="3.6.1"/>
1717
<PackageReference Include="coverlet.collector" Version="3.2.0"/>
18+
<PackageReference Include="WireMock.Net" Version="1.5.60" />
1819
<PackageReference Include="FluentAssertions.Json" Version="6.1.0" />
1920
</ItemGroup>
2021

src/Merge.Client.sln

+10-10
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
44
VisualStudioVersion = 17.0.31903.59
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Merge.Client", "Merge.Client\Merge.Client.csproj", "{5940579A-1D95-4B3E-9CC6-F5D30AB2D95A}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Merge.Client", "Merge.Client\Merge.Client.csproj", "{FC3BB5C9-688E-4EF8-82DF-ACA00A7A6052}"
77
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Merge.Client.Test", "Merge.Client.Test\Merge.Client.Test.csproj", "{6F36DC9B-1D6D-4BD7-B202-6ED89700FAF1}"
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Merge.Client.Test", "Merge.Client.Test\Merge.Client.Test.csproj", "{F421D601-C723-4774-A58A-7E4A3E74E3FB}"
99
EndProject
1010
Global
1111
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -16,13 +16,13 @@ Global
1616
HideSolutionNode = FALSE
1717
EndGlobalSection
1818
GlobalSection(ProjectConfigurationPlatforms) = postSolution
19-
{5940579A-1D95-4B3E-9CC6-F5D30AB2D95A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20-
{5940579A-1D95-4B3E-9CC6-F5D30AB2D95A}.Debug|Any CPU.Build.0 = Debug|Any CPU
21-
{5940579A-1D95-4B3E-9CC6-F5D30AB2D95A}.Release|Any CPU.ActiveCfg = Release|Any CPU
22-
{5940579A-1D95-4B3E-9CC6-F5D30AB2D95A}.Release|Any CPU.Build.0 = Release|Any CPU
23-
{6F36DC9B-1D6D-4BD7-B202-6ED89700FAF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24-
{6F36DC9B-1D6D-4BD7-B202-6ED89700FAF1}.Debug|Any CPU.Build.0 = Debug|Any CPU
25-
{6F36DC9B-1D6D-4BD7-B202-6ED89700FAF1}.Release|Any CPU.ActiveCfg = Release|Any CPU
26-
{6F36DC9B-1D6D-4BD7-B202-6ED89700FAF1}.Release|Any CPU.Build.0 = Release|Any CPU
19+
{FC3BB5C9-688E-4EF8-82DF-ACA00A7A6052}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20+
{FC3BB5C9-688E-4EF8-82DF-ACA00A7A6052}.Debug|Any CPU.Build.0 = Debug|Any CPU
21+
{FC3BB5C9-688E-4EF8-82DF-ACA00A7A6052}.Release|Any CPU.ActiveCfg = Release|Any CPU
22+
{FC3BB5C9-688E-4EF8-82DF-ACA00A7A6052}.Release|Any CPU.Build.0 = Release|Any CPU
23+
{F421D601-C723-4774-A58A-7E4A3E74E3FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24+
{F421D601-C723-4774-A58A-7E4A3E74E3FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
25+
{F421D601-C723-4774-A58A-7E4A3E74E3FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
26+
{F421D601-C723-4774-A58A-7E4A3E74E3FB}.Release|Any CPU.Build.0 = Release|Any CPU
2727
EndGlobalSection
2828
EndGlobal

src/Merge.Client/Accounting/AccountDetails/AccountDetailsClient.cs

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Net.Http;
22
using System.Text.Json;
3+
using System.Threading;
34
using Merge.Client.Core;
45

56
#nullable enable
@@ -18,16 +19,25 @@ internal AccountDetailsClient(RawClient client)
1819
/// <summary>
1920
/// Get details for a linked account.
2021
/// </summary>
21-
public async Task<AccountDetails> RetrieveAsync(RequestOptions? options = null)
22+
/// <example>
23+
/// <code>
24+
/// await client.Accounting.AccountDetails.RetrieveAsync();
25+
/// </code>
26+
/// </example>
27+
public async Task<AccountDetails> RetrieveAsync(
28+
RequestOptions? options = null,
29+
CancellationToken cancellationToken = default
30+
)
2231
{
2332
var response = await _client.MakeRequestAsync(
2433
new RawClient.JsonApiRequest
2534
{
2635
BaseUrl = _client.Options.BaseUrl,
2736
Method = HttpMethod.Get,
2837
Path = "accounting/v1/account-details",
29-
Options = options
30-
}
38+
Options = options,
39+
},
40+
cancellationToken
3141
);
3242
var responseBody = await response.Raw.Content.ReadAsStringAsync();
3343
if (response.StatusCode is >= 200 and < 400)

src/Merge.Client/Accounting/AccountToken/AccountTokenClient.cs

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Net.Http;
22
using System.Text.Json;
3+
using System.Threading;
34
using Merge.Client.Core;
45

56
#nullable enable
@@ -18,9 +19,15 @@ internal AccountTokenClient(RawClient client)
1819
/// <summary>
1920
/// Returns the account token for the end user with the provided public token.
2021
/// </summary>
22+
/// <example>
23+
/// <code>
24+
/// await client.Accounting.AccountToken.RetrieveAsync("public_token");
25+
/// </code>
26+
/// </example>
2127
public async Task<AccountToken> RetrieveAsync(
2228
string publicToken,
23-
RequestOptions? options = null
29+
RequestOptions? options = null,
30+
CancellationToken cancellationToken = default
2431
)
2532
{
2633
var response = await _client.MakeRequestAsync(
@@ -29,8 +36,9 @@ public async Task<AccountToken> RetrieveAsync(
2936
BaseUrl = _client.Options.BaseUrl,
3037
Method = HttpMethod.Get,
3138
Path = $"accounting/v1/account-token/{publicToken}",
32-
Options = options
33-
}
39+
Options = options,
40+
},
41+
cancellationToken
3442
);
3543
var responseBody = await response.Raw.Content.ReadAsStringAsync();
3644
if (response.StatusCode is >= 200 and < 400)

src/Merge.Client/Accounting/AccountingPeriods/AccountingPeriodsClient.cs

+26-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Net.Http;
22
using System.Text.Json;
3+
using System.Threading;
34
using Merge.Client.Core;
45

56
#nullable enable
@@ -18,12 +19,18 @@ internal AccountingPeriodsClient(RawClient client)
1819
/// <summary>
1920
/// Returns a list of `AccountingPeriod` objects.
2021
/// </summary>
22+
/// <example>
23+
/// <code>
24+
/// await client.Accounting.AccountingPeriods.ListAsync(new AccountingPeriodsListRequest());
25+
/// </code>
26+
/// </example>
2127
public async Task<PaginatedAccountingPeriodList> ListAsync(
2228
AccountingPeriodsListRequest request,
23-
RequestOptions? options = null
29+
RequestOptions? options = null,
30+
CancellationToken cancellationToken = default
2431
)
2532
{
26-
var _query = new Dictionary<string, object>() { };
33+
var _query = new Dictionary<string, object>();
2734
if (request.Cursor != null)
2835
{
2936
_query["cursor"] = request.Cursor;
@@ -47,8 +54,9 @@ public async Task<PaginatedAccountingPeriodList> ListAsync(
4754
Method = HttpMethod.Get,
4855
Path = "accounting/v1/accounting-periods",
4956
Query = _query,
50-
Options = options
51-
}
57+
Options = options,
58+
},
59+
cancellationToken
5260
);
5361
var responseBody = await response.Raw.Content.ReadAsStringAsync();
5462
if (response.StatusCode is >= 200 and < 400)
@@ -73,13 +81,22 @@ public async Task<PaginatedAccountingPeriodList> ListAsync(
7381
/// <summary>
7482
/// Returns an `AccountingPeriod` object with the given `id`.
7583
/// </summary>
84+
/// <example>
85+
/// <code>
86+
/// await client.Accounting.AccountingPeriods.RetrieveAsync(
87+
/// "id",
88+
/// new AccountingPeriodsRetrieveRequest()
89+
/// );
90+
/// </code>
91+
/// </example>
7692
public async Task<AccountingPeriod> RetrieveAsync(
7793
string id,
7894
AccountingPeriodsRetrieveRequest request,
79-
RequestOptions? options = null
95+
RequestOptions? options = null,
96+
CancellationToken cancellationToken = default
8097
)
8198
{
82-
var _query = new Dictionary<string, object>() { };
99+
var _query = new Dictionary<string, object>();
83100
if (request.IncludeRemoteData != null)
84101
{
85102
_query["include_remote_data"] = request.IncludeRemoteData.ToString();
@@ -91,8 +108,9 @@ public async Task<AccountingPeriod> RetrieveAsync(
91108
Method = HttpMethod.Get,
92109
Path = $"accounting/v1/accounting-periods/{id}",
93110
Query = _query,
94-
Options = options
95-
}
111+
Options = options,
112+
},
113+
cancellationToken
96114
);
97115
var responseBody = await response.Raw.Content.ReadAsStringAsync();
98116
if (response.StatusCode is >= 200 and < 400)

src/Merge.Client/Accounting/AccountingPeriods/Requests/AccountingPeriodsListRequest.cs

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
using Merge.Client.Core;
2+
3+
#nullable enable
4+
15
namespace Merge.Client.Accounting;
26

37
public record AccountingPeriodsListRequest
@@ -21,4 +25,9 @@ public record AccountingPeriodsListRequest
2125
/// Number of results to return per page.
2226
/// </summary>
2327
public int? PageSize { get; set; }
28+
29+
public override string ToString()
30+
{
31+
return JsonUtils.Serialize(this);
32+
}
2433
}

src/Merge.Client/Accounting/AccountingPeriods/Requests/AccountingPeriodsRetrieveRequest.cs

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
using Merge.Client.Core;
2+
3+
#nullable enable
4+
15
namespace Merge.Client.Accounting;
26

37
public record AccountingPeriodsRetrieveRequest
@@ -6,4 +10,9 @@ public record AccountingPeriodsRetrieveRequest
610
/// Whether to include the original data Merge fetched from the third-party to produce these models.
711
/// </summary>
812
public bool? IncludeRemoteData { get; set; }
13+
14+
public override string ToString()
15+
{
16+
return JsonUtils.Serialize(this);
17+
}
918
}

0 commit comments

Comments
 (0)