11using Asaas . Sdk . Config ;
2+ using Asaas . Sdk . Exceptions ;
23using Asaas . Sdk . Http ;
4+ using Asaas . Sdk . Models ;
35
46namespace Asaas . Sdk . Services ;
57
@@ -8,15 +10,26 @@ namespace Asaas.Sdk.Services;
810/// </summary>
911public class FinancialTransactionService : BaseService
1012{
13+ /// <summary>
14+ /// Initializes a new instance of the <see cref="FinancialTransactionService"/> class.
15+ /// </summary>
16+ /// <param name="httpClient">HTTP client instance</param>
17+ /// <param name="config">SDK configuration</param>
1118 public FinancialTransactionService ( HttpClient httpClient , AsaasSdkConfig config )
1219 : base ( httpClient , config )
1320 {
1421 }
1522
1623 /// <summary>
17- /// List financial transactions
24+ /// List financial transactions with optional filters
1825 /// </summary>
19- public async Task < dynamic > ListFinancialTransactionsAsync (
26+ /// <param name="startDate">Start date for filtering transactions</param>
27+ /// <param name="endDate">End date for filtering transactions</param>
28+ /// <param name="offset">Offset for pagination</param>
29+ /// <param name="limit">Limit for pagination</param>
30+ /// <param name="cancellationToken">Cancellation token</param>
31+ /// <returns>List of financial transactions</returns>
32+ public async Task < FinancialTransactionListResponseDto > ListFinancialTransactionsAsync (
2033 DateTime ? startDate = null ,
2134 DateTime ? endDate = null ,
2235 long ? offset = null ,
@@ -30,46 +43,70 @@ public async Task<dynamic> ListFinancialTransactionsAsync(
3043 . AddQueryParam ( "limit" , limit ) ;
3144
3245 var request = requestBuilder . Build ( GetBaseUrl ( ) ) ;
33- return await ExecuteAsync < dynamic > ( request ) ;
46+ return await ExecuteAsync < FinancialTransactionListResponseDto > ( request ) ;
3447 }
3548
3649 /// <summary>
3750 /// Get financial transaction by ID
3851 /// </summary>
39- public async Task < dynamic > GetFinancialTransactionAsync (
52+ /// <param name="id">Financial transaction identifier</param>
53+ /// <param name="cancellationToken">Cancellation token</param>
54+ /// <returns>Financial transaction details</returns>
55+ public async Task < FinancialTransactionGetResponseDto > GetFinancialTransactionAsync (
4056 string id ,
4157 CancellationToken cancellationToken = default )
4258 {
59+ if ( string . IsNullOrEmpty ( id ) )
60+ {
61+ throw new ValidationException ( "Financial transaction ID is required" ) ;
62+ }
63+
4364 var requestBuilder = new RequestBuilder ( HttpMethod . Get , $ "v3/financialTransactions/{ id } ") ;
4465 var request = requestBuilder . Build ( GetBaseUrl ( ) ) ;
45- return await ExecuteAsync < dynamic > ( request ) ;
66+ return await ExecuteAsync < FinancialTransactionGetResponseDto > ( request ) ;
4667 }
4768
4869 /// <summary>
49- /// Get payment anticipation financial transaction
70+ /// Get financial transactions related to a payment anticipation
5071 /// </summary>
51- public async Task < dynamic > GetPaymentAnticipationFinancialTransactionAsync (
72+ /// <param name="anticipationId">Anticipation identifier</param>
73+ /// <param name="cancellationToken">Cancellation token</param>
74+ /// <returns>List of financial transactions related to the anticipation</returns>
75+ public async Task < FinancialTransactionListResponseDto > GetPaymentAnticipationFinancialTransactionAsync (
5276 string anticipationId ,
5377 CancellationToken cancellationToken = default )
5478 {
79+ if ( string . IsNullOrEmpty ( anticipationId ) )
80+ {
81+ throw new ValidationException ( "Anticipation ID is required" ) ;
82+ }
83+
5584 var requestBuilder = new RequestBuilder ( HttpMethod . Get , "v3/financialTransactions" )
5685 . AddQueryParam ( "anticipation" , anticipationId ) ;
5786
5887 var request = requestBuilder . Build ( GetBaseUrl ( ) ) ;
59- return await ExecuteAsync < dynamic > ( request ) ;
88+ return await ExecuteAsync < FinancialTransactionListResponseDto > ( request ) ;
6089 }
6190
6291 /// <summary>
63- /// Get payment financial transaction
92+ /// Get financial transactions related to a payment
6493 /// </summary>
65- public async Task < dynamic > GetPaymentFinancialTransactionAsync (
94+ /// <param name="paymentId">Payment identifier</param>
95+ /// <param name="cancellationToken">Cancellation token</param>
96+ /// <returns>List of financial transactions related to the payment</returns>
97+ public async Task < FinancialTransactionListResponseDto > GetPaymentFinancialTransactionAsync (
6698 string paymentId ,
6799 CancellationToken cancellationToken = default )
68100 {
101+ if ( string . IsNullOrEmpty ( paymentId ) )
102+ {
103+ throw new ValidationException ( "Payment ID is required" ) ;
104+ }
105+
69106 var requestBuilder = new RequestBuilder ( HttpMethod . Get , "v3/financialTransactions" )
70107 . AddQueryParam ( "payment" , paymentId ) ;
71108
72109 var request = requestBuilder . Build ( GetBaseUrl ( ) ) ;
73- return await ExecuteAsync < dynamic > ( request ) ;
110+ return await ExecuteAsync < FinancialTransactionListResponseDto > ( request ) ;
74111 }
75112}
0 commit comments