@@ -16,6 +16,8 @@ const DEFAULT_TIMEOUT: Duration = Duration::from_secs(10);
16
16
17
17
const DEFAULT_BASE_URL : & str = GENERAL_PURPOSE_MAINNET_URL ;
18
18
19
+ const DEFAULT_BASE_TOKEN : & str = "" ;
20
+
19
21
const DEFAULT_USER_AGENT : & str = "rust-xrpl-sdk-rippled-client/0.1.0" ;
20
22
21
23
pub type Result < T > = std:: result:: Result < T , Error > ;
@@ -36,6 +38,7 @@ pub struct RpcResponse<T> {
36
38
#[ derive( Default ) ]
37
39
pub struct ClientBuilder {
38
40
base_url : Option < String > ,
41
+ token : Option < String > ,
39
42
user_agent : Option < String > ,
40
43
http_client : Option < reqwest:: Client > ,
41
44
timeout : Option < Duration > ,
@@ -47,6 +50,11 @@ impl ClientBuilder {
47
50
self
48
51
}
49
52
53
+ pub fn token ( mut self , token : & str ) -> Self {
54
+ self . token = Some ( token. to_string ( ) ) ;
55
+ self
56
+ }
57
+
50
58
pub fn user_agent ( mut self , user_agent : & str ) -> Self {
51
59
self . user_agent = Some ( user_agent. to_string ( ) ) ;
52
60
self
@@ -68,6 +76,7 @@ impl ClientBuilder {
68
76
base_url : self
69
77
. base_url
70
78
. unwrap_or_else ( || DEFAULT_BASE_URL . to_string ( ) ) ,
79
+ token : self . token . unwrap_or_else ( || DEFAULT_BASE_TOKEN . to_string ( ) ) ,
71
80
user_agent : self
72
81
. user_agent
73
82
. unwrap_or_else ( || DEFAULT_USER_AGENT . to_string ( ) ) ,
@@ -85,6 +94,7 @@ impl ClientBuilder {
85
94
pub struct Client {
86
95
base_url : String ,
87
96
user_agent : String ,
97
+ token : String ,
88
98
// TODO: hm, not really used currently.
89
99
http_client : reqwest:: Client ,
90
100
}
@@ -125,6 +135,7 @@ impl Client {
125
135
. post ( & self . base_url )
126
136
. body ( body)
127
137
. header ( reqwest:: header:: USER_AGENT , & self . user_agent )
138
+ . bearer_auth ( & self . token )
128
139
. send ( )
129
140
. await ?;
130
141
0 commit comments