Skip to content

Commit 8cace8c

Browse files
authored
Merge pull request #866 from alexhauser/FinancialEventsByGroupIdParameters
Allow passing query parameters to `ListFinancialEventsByGroupId`
2 parents 7fad7c5 + b49e2a6 commit 8cace8c

File tree

3 files changed

+35
-7
lines changed

3 files changed

+35
-7
lines changed

Source/FikaAmazonAPI.SampleCode/FinancialSample.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using FikaAmazonAPI.AmazonSpApiSDK.Models.Finances;
2+
using System;
23
using System.Collections.Generic;
34
using System.Linq;
45
using System.Text;
@@ -14,15 +15,27 @@ public FinancialSample(AmazonConnection amazonConnection)
1415
this.amazonConnection = amazonConnection;
1516
}
1617

17-
public void ListFinancialEventGroups()
18+
public IList<FinancialEventGroup> ListFinancialEventGroups()
1819
{
19-
amazonConnection.Financial.ListFinancialEventGroups(new Parameter.Finance.ParameterListFinancialEventGroup()
20+
return amazonConnection.Financial.ListFinancialEventGroups(new Parameter.Finance.ParameterListFinancialEventGroup()
2021
{
2122
FinancialEventGroupStartedAfter = DateTime.UtcNow.AddDays(-10),
2223
FinancialEventGroupStartedBefore = DateTime.UtcNow.AddDays(-1),
2324
MaxResultsPerPage = 55
2425
});
26+
}
2527

28+
public List<FinancialEvents> ListFinancialEventsByGroupId(string financialGroupId)
29+
{
30+
var financialEventsWithoutParams = amazonConnection.Financial.ListFinancialEventsByGroupId(financialGroupId);
31+
var financialEventsWithParams = amazonConnection.Financial.ListFinancialEventsByGroupId(financialGroupId,
32+
new Parameter.Finance.ParameterListFinancialEventsByGroupId()
33+
{
34+
PostedAfter = DateTime.UtcNow.AddDays(-170),
35+
PostedBefore = DateTime.UtcNow.AddMinutes(-60),
36+
MaxResultsPerPage = 55
37+
});
38+
return financialEventsWithParams;
2639
}
2740
}
2841
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using FikaAmazonAPI.Search;
2+
using System;
3+
4+
namespace FikaAmazonAPI.Parameter.Finance
5+
{
6+
public class ParameterListFinancialEventsByGroupId : ParameterBased
7+
{
8+
public int? MaxResultsPerPage { get; set; } = 100;
9+
public DateTime? PostedAfter { get; set; }
10+
public DateTime? PostedBefore { get; set; }
11+
public string NextToken { get; set; }
12+
}
13+
}

Source/FikaAmazonAPI/Services/FinancialService.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,13 @@ public async Task<ListFinancialEventGroupsPayload> GetFinancialEventGroupListByN
5555
}
5656

5757

58-
public List<FinancialEvents> ListFinancialEventsByGroupId(string eventGroupId) =>
59-
Task.Run(() => ListFinancialEventsByGroupIdAsync(eventGroupId)).ConfigureAwait(false).GetAwaiter().GetResult();
60-
public async Task<List<FinancialEvents>> ListFinancialEventsByGroupIdAsync(string eventGroupId, CancellationToken cancellationToken = default)
58+
public List<FinancialEvents> ListFinancialEventsByGroupId(string eventGroupId, ParameterListFinancialEventsByGroupId parameterListFinancialEventsByGroupId = null) =>
59+
Task.Run(() => ListFinancialEventsByGroupIdAsync(eventGroupId, parameterListFinancialEventsByGroupId)).ConfigureAwait(false).GetAwaiter().GetResult();
60+
public async Task<List<FinancialEvents>> ListFinancialEventsByGroupIdAsync(string eventGroupId, ParameterListFinancialEventsByGroupId parameterListFinancialEventsByGroupId = null,
61+
CancellationToken cancellationToken = default)
6162
{
62-
await CreateAuthorizedRequestAsync(FinanceApiUrls.ListFinancialEventsByGroupId(eventGroupId), RestSharp.Method.Get, cancellationToken: cancellationToken);
63+
var parameters = parameterListFinancialEventsByGroupId?.getParameters() ?? new List<KeyValuePair<string, string>>();
64+
await CreateAuthorizedRequestAsync(FinanceApiUrls.ListFinancialEventsByGroupId(eventGroupId), RestSharp.Method.Get, queryParameters: parameters, cancellationToken: cancellationToken);
6365
var response = await ExecuteRequestAsync<ListFinancialEventsResponse>(RateLimitType.Financial_ListFinancialEventsByGroupId, cancellationToken);
6466

6567
var nextToken = response.Payload.NextToken;

0 commit comments

Comments
 (0)