Skip to content

Commit 8e91e37

Browse files
authored
Merge pull request #31 from nanato12/update-0.1.2
Update 0.1.2
2 parents a5ca302 + 3550f11 commit 8e91e37

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
[package]
22
name = "line-bot-sdk-rust"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
authors = ["nanato12 <[email protected]>"]
55
edition = "2018"
66
description = "LINE Messaging API SDK for Rust"
77
readme = "README.md"
88
repository = "https://github.com/nanato12/line-bot-sdk-rust/"
9+
license = "Apache-2.0"
910
license-file = "LICENSE"
1011
keywords = ["line", "linebot", "line-bot-sdk", "line-messaging-api"]
1112
categories = ["api-bindings"]

src/bot.rs

+1-1
Original file line numberDiff line numberDiff 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

src/client.rs

+23
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ use reqwest::Url;
77
use serde_json::Value;
88

99
static 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)]
1213
pub struct HttpClient {
1314
client: Client,
1415
headers: HeaderMap,
1516
endpoint_base: String,
17+
endpoint_base_data: String,
1618
}
1719

1820
impl 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
/// ```

0 commit comments

Comments
 (0)