File tree Expand file tree Collapse file tree 3 files changed +26
-2
lines changed
Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 11[package ]
22name = " line-bot-sdk-rust"
3- version = " 0.1.1 "
3+ version = " 0.1.2 "
44authors = [" nanato12 <admin@nanato12.info>" ]
55edition = " 2018"
66description = " LINE Messaging API SDK for Rust"
77readme = " README.md"
88repository = " https://github.com/nanato12/line-bot-sdk-rust/"
9+ license = " Apache-2.0"
910license-file = " LICENSE"
1011keywords = [" line" , " linebot" , " line-bot-sdk" , " line-messaging-api" ]
1112categories = [" api-bindings" ]
Original file line number Diff line number Diff line change @@ -224,7 +224,7 @@ impl LineBot {
224224 /// ```
225225 pub fn get_content ( & self , message_id : & str ) -> Result < Response , Error > {
226226 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 ! ( { } ) )
228228 }
229229
230230 /// # Note
Original file line number Diff line number Diff line change @@ -7,12 +7,14 @@ use reqwest::Url;
77use serde_json:: Value ;
88
99static BASE_URL : & str = "https://api.line.me/v2/bot" ;
10+ static BASEDATA_URL : & str = "https://api-data.line.me/v2/bot" ;
1011
1112#[ derive( Debug ) ]
1213pub struct HttpClient {
1314 client : Client ,
1415 headers : HeaderMap ,
1516 endpoint_base : String ,
17+ endpoint_base_data : String ,
1618}
1719
1820impl HttpClient {
@@ -33,6 +35,7 @@ impl HttpClient {
3335 client : Client :: new ( ) ,
3436 headers : headers,
3537 endpoint_base : String :: from ( BASE_URL ) ,
38+ endpoint_base_data : String :: from ( BASEDATA_URL ) ,
3639 }
3740 }
3841
@@ -56,6 +59,26 @@ impl HttpClient {
5659 . send ( )
5760 }
5861
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+
5982 /// # Note
6083 /// `POST` request
6184 /// ```
You can’t perform that action at this time.
0 commit comments