Skip to content

Commit db00769

Browse files
committed
fix: Remove first and last name
1 parent 2ff1f4a commit db00769

File tree

1 file changed

+2
-36
lines changed

1 file changed

+2
-36
lines changed

src/lib.rs

+2-36
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ where
5151
.collect()
5252
}
5353

54-
fn serialize_holiday_dates<S>(dates: &Vec<NaiveDate>, serializer: S) -> Result<S::Ok, S::Error>
54+
fn serialize_holiday_dates<S>(dates: &[NaiveDate], serializer: S) -> Result<S::Ok, S::Error>
5555
where
5656
S: Serializer,
5757
{
@@ -70,7 +70,7 @@ where
7070
let timestamp = i64::deserialize(deserializer)?;
7171
Utc.timestamp_opt(timestamp, 0)
7272
.single()
73-
.map(|ts| Some(ts))
73+
.map(Some)
7474
.ok_or_else(|| serde::de::Error::custom(format!("Invalid Unix timestamp: {}", timestamp)))
7575
}
7676

@@ -308,8 +308,6 @@ pub struct Following {
308308
pub struct User {
309309
id: u32,
310310
username: String,
311-
first_name: String,
312-
last_name: String,
313311
reputation: f64,
314312
following: Option<u32>,
315313
followers: Option<u32>,
@@ -335,14 +333,6 @@ impl User {
335333
&self.username
336334
}
337335

338-
pub fn get_first_name(&self) -> &str {
339-
&self.first_name
340-
}
341-
342-
pub fn get_last_name(&self) -> &str {
343-
&self.last_name
344-
}
345-
346336
pub fn get_reputation(&self) -> f64 {
347337
self.reputation
348338
}
@@ -783,20 +773,6 @@ impl TradingView {
783773
.expect("Username not found when parsing user from token")
784774
.to_string();
785775

786-
let first_name = response_body
787-
.split("first_name\":\"")
788-
.nth(1)
789-
.and_then(|s| s.split('\"').next())
790-
.expect("First name not found when parsing user from token")
791-
.to_string();
792-
793-
let last_name = response_body
794-
.split("last_name\":\"")
795-
.nth(1)
796-
.and_then(|s| s.split('\"').next())
797-
.expect("Last name not found when parsing user from token")
798-
.to_string();
799-
800776
let reputation = response_body
801777
.split("reputation\":")
802778
.nth(1)
@@ -852,8 +828,6 @@ impl TradingView {
852828
Ok(User {
853829
id,
854830
username,
855-
first_name,
856-
last_name,
857831
session: Some(session.to_string()),
858832
signature: Some(signature.to_string()),
859833
reputation,
@@ -1150,8 +1124,6 @@ mod tests {
11501124
"user": {
11511125
"id": 123,
11521126
"username": "test",
1153-
"first_name": "Test",
1154-
"last_name": "User",
11551127
"reputation": 5.0,
11561128
"following": 10,
11571129
"followers": 20,
@@ -1173,8 +1145,6 @@ mod tests {
11731145

11741146
assert_eq!(user.id, 123);
11751147
assert_eq!(user.username, "test");
1176-
assert_eq!(user.first_name, "Test");
1177-
assert_eq!(user.last_name, "User");
11781148
assert_eq!(user.reputation, 5.0);
11791149
assert_eq!(user.following, Some(10));
11801150
assert_eq!(user.signature, Some("efgh".to_string()));
@@ -1220,8 +1190,6 @@ mod tests {
12201190
"user": {
12211191
"id": 123,
12221192
"username": "test",
1223-
"first_name": "Test",
1224-
"last_name": "User",
12251193
"reputation": 5.0,
12261194
"following": 10,
12271195
"followers": 20,
@@ -1251,8 +1219,6 @@ mod tests {
12511219
let json = r#"{
12521220
"id": 123,
12531221
"username": "test",
1254-
"first_name": "Test",
1255-
"last_name": "User",
12561222
"reputation": 5.0,
12571223
"following": 10,
12581224
"followers": 20,

0 commit comments

Comments
 (0)