Skip to content

Commit ccbeca7

Browse files
committed
add next token support
1 parent 0682ae5 commit ccbeca7

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

Source/FikaAmazonAPI/Services/FinancialService.cs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,38 @@ public async Task<ListFinancialEventGroupsPayload> GetFinancialEventGroupListByN
5353
}
5454

5555

56-
public FinancialEvents ListFinancialEventsByGroupId(string eventGroupId) =>
56+
public List<FinancialEvents> ListFinancialEventsByGroupId(string eventGroupId) =>
5757
Task.Run(() => ListFinancialEventsByGroupIdAsync(eventGroupId)).ConfigureAwait(false).GetAwaiter().GetResult();
58-
public async Task<FinancialEvents> ListFinancialEventsByGroupIdAsync(string eventGroupId)
58+
public async Task<List<FinancialEvents>> ListFinancialEventsByGroupIdAsync(string eventGroupId)
5959
{
6060
await CreateAuthorizedRequestAsync(FinanceApiUrls.ListFinancialEventsByGroupId(eventGroupId), RestSharp.Method.GET);
6161
var response = await ExecuteRequestAsync<ListFinancialEventsResponse>(RateLimitType.Financial_ListFinancialEventsByGroupId);
62-
return response.Payload.FinancialEvents;
62+
63+
var nextToken = response.Payload.NextToken;
64+
65+
var list = new List<FinancialEvents>();
66+
list.Add(response.Payload.FinancialEvents);
67+
68+
while (!string.IsNullOrEmpty(nextToken))
69+
{
70+
var data = await ListFinancialEventsByGroupIdByNextTokenAsync(eventGroupId, nextToken);
71+
if (data.Payload != null && data.Payload.FinancialEvents != null)
72+
{
73+
list.Add(data.Payload.FinancialEvents);
74+
}
75+
nextToken = data.Payload.NextToken;
76+
}
77+
78+
return list;
79+
}
80+
private async Task<ListFinancialEventsResponse> ListFinancialEventsByGroupIdByNextTokenAsync(string eventGroupId, string nextToken)
81+
{
82+
List<KeyValuePair<string, string>> queryParameters = new List<KeyValuePair<string, string>>();
83+
queryParameters.Add(new KeyValuePair<string, string>("NextToken", nextToken));
84+
85+
86+
await CreateAuthorizedRequestAsync(FinanceApiUrls.ListFinancialEventsByGroupId(eventGroupId), RestSharp.Method.GET, queryParameters);
87+
return await ExecuteRequestAsync<ListFinancialEventsResponse>(RateLimitType.Financial_ListFinancialEventsByGroupId);
6388
}
6489

6590
public FinancialEvents ListFinancialEventsByOrderId(string orderId) =>

0 commit comments

Comments
 (0)