File tree 2 files changed +24
-1
lines changed
2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -224,7 +224,7 @@ impl LineBot {
224
224
/// ```
225
225
pub fn get_content ( & self , message_id : & str ) -> Result < Response , Error > {
226
226
let endpoint = format ! ( "/message/{messageId}/content" , messageId = message_id) ;
227
- self . http_client . get ( & endpoint, vec ! [ ] , json ! ( { } ) )
227
+ self . http_client . get_data ( & endpoint, vec ! [ ] , json ! ( { } ) )
228
228
}
229
229
230
230
/// # Note
Original file line number Diff line number Diff line change @@ -7,12 +7,14 @@ use reqwest::Url;
7
7
use serde_json:: Value ;
8
8
9
9
static BASE_URL : & str = "https://api.line.me/v2/bot" ;
10
+ static BASEDATA_URL : & str = "https://api-data.line.me/v2/bot" ;
10
11
11
12
#[ derive( Debug ) ]
12
13
pub struct HttpClient {
13
14
client : Client ,
14
15
headers : HeaderMap ,
15
16
endpoint_base : String ,
17
+ endpoint_base_data : String ,
16
18
}
17
19
18
20
impl HttpClient {
@@ -33,6 +35,7 @@ impl HttpClient {
33
35
client : Client :: new ( ) ,
34
36
headers : headers,
35
37
endpoint_base : String :: from ( BASE_URL ) ,
38
+ endpoint_base_data : String :: from ( BASEDATA_URL ) ,
36
39
}
37
40
}
38
41
@@ -56,6 +59,26 @@ impl HttpClient {
56
59
. send ( )
57
60
}
58
61
62
+ /// # Note
63
+ /// `GET` request
64
+ /// ```
65
+ /// let res: Result<Response, Error> = http_client.get_data("https://example.com");
66
+ /// ```
67
+ pub fn get_data (
68
+ & self ,
69
+ endpoint : & str ,
70
+ query : Vec < ( & str , & str ) > ,
71
+ data : Value ,
72
+ ) -> Result < Response , Error > {
73
+ let uri = Url :: parse ( & format ! ( "{}{}" , self . endpoint_base_data, endpoint) ) . unwrap ( ) ;
74
+ self . client
75
+ . get ( uri)
76
+ . query ( & query)
77
+ . headers ( self . headers . clone ( ) )
78
+ . json ( & data)
79
+ . send ( )
80
+ }
81
+
59
82
/// # Note
60
83
/// `POST` request
61
84
/// ```
You can’t perform that action at this time.
0 commit comments