1
- use crate :: models:: * ;
1
+ use crate :: { models:: * , BuildQueryParametersExt } ;
2
2
use stellar_rust_sdk_derive:: Pagination ;
3
3
use crate :: Paginatable ;
4
4
@@ -14,6 +14,8 @@ pub struct NoTransactionsAccountId;
14
14
pub struct TransactionsForAccountRequest < I > {
15
15
/// The ID of the account for which the transactions are to be retrieved.
16
16
account_id : I ,
17
+ // Indicates whether or not to include failed operations in the response.
18
+ include_failed : Option < bool > ,
17
19
/// A pointer to a specific location in a collection of responses, derived from the
18
20
/// `paging_token` value of a record. Used for pagination control in the API response.
19
21
pub cursor : Option < u32 > ,
@@ -43,12 +45,24 @@ impl TransactionsForAccountRequest<NoTransactionsAccountId> {
43
45
self ,
44
46
account_id : String ,
45
47
) -> Result < TransactionsForAccountRequest < TransactionsAccountId > , String > {
46
- if let Err ( e) = is_public_key ( & account_id) {
47
- return Err ( e. to_string ( ) ) ;
48
- }
49
-
50
48
Ok ( TransactionsForAccountRequest {
51
49
account_id : TransactionsAccountId ( account_id) ,
50
+ include_failed : self . include_failed ,
51
+ cursor : self . cursor ,
52
+ limit : self . limit ,
53
+ order : self . order ,
54
+ } )
55
+ }
56
+ }
57
+
58
+ impl TransactionsForAccountRequest < TransactionsAccountId > {
59
+ pub fn set_include_failed (
60
+ self ,
61
+ include_failed : bool ,
62
+ ) -> Result < TransactionsForAccountRequest < TransactionsAccountId > , String > {
63
+ Ok ( TransactionsForAccountRequest {
64
+ account_id : self . account_id ,
65
+ include_failed : Some ( include_failed) ,
52
66
cursor : self . cursor ,
53
67
limit : self . limit ,
54
68
order : self . order ,
@@ -58,23 +72,28 @@ impl TransactionsForAccountRequest<NoTransactionsAccountId> {
58
72
59
73
impl Request for TransactionsForAccountRequest < TransactionsAccountId > {
60
74
fn get_query_parameters ( & self ) -> String {
61
- let mut query = String :: new ( ) ;
62
- query. push_str ( & format ! ( "{}" , self . account_id. 0 ) ) ;
63
-
64
- query. trim_end_matches ( '&' ) . to_string ( )
75
+ vec ! [
76
+ self . cursor. as_ref( ) . map( |c| format!( "cursor={}" , c) ) ,
77
+ self . limit. as_ref( ) . map( |l| format!( "limit={}" , l) ) ,
78
+ self . order. as_ref( ) . map( |o| format!( "order={}" , o) ) ,
79
+ self . include_failed
80
+ . as_ref( )
81
+ . map( |i| format!( "include_failed={}" , i) ) ,
82
+ ]
83
+ . build_query_parameters ( )
65
84
}
66
85
67
86
fn build_url ( & self , base_url : & str ) -> String {
68
- // This URL is not built with query paramaters, but with the account ID as addition to the path.
69
- // Therefore there is no `?` but a `/` in the formatted string.
70
- // Additionally, this request uses the API endpoint for `accounts`.
87
+ // TODO: Documentation
88
+ let account_id = & self . account_id . 0 ;
71
89
use crate :: accounts:: ACCOUNTS_PATH ;
72
90
format ! (
73
- "{}/{}/{}/{}" ,
91
+ "{}/{}/{}/{}{} " ,
74
92
base_url,
75
93
ACCOUNTS_PATH ,
94
+ account_id,
95
+ super :: TRANSACTIONS_PATH ,
76
96
self . get_query_parameters( ) ,
77
- super :: TRANSACTIONS_PATH
78
97
)
79
98
}
80
99
}
0 commit comments