2020-07-13 17:26:19 +00:00
|
|
|
//! # User like API entry
|
|
|
|
//!
|
|
|
|
//! @author Pierre Hubert
|
|
|
|
|
|
|
|
use serde::Serialize;
|
|
|
|
|
|
|
|
use crate::data::user_like::UserLike;
|
|
|
|
|
|
|
|
#[derive(Serialize)]
|
2020-07-13 17:41:48 +00:00
|
|
|
#[allow(non_snake_case)]
|
2020-07-13 17:26:19 +00:00
|
|
|
pub struct UserLikeAPI {
|
|
|
|
id: u64,
|
2020-07-13 17:41:48 +00:00
|
|
|
userID: u64,
|
2020-07-13 17:26:19 +00:00
|
|
|
time_sent: u64,
|
|
|
|
elem_type: String,
|
|
|
|
elem_id: u64,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl UserLikeAPI {
|
|
|
|
pub fn new(l: &UserLike) -> UserLikeAPI {
|
|
|
|
UserLikeAPI {
|
|
|
|
id: l.id,
|
2020-07-13 17:41:48 +00:00
|
|
|
userID: l.user_id.id(),
|
2020-07-13 17:26:19 +00:00
|
|
|
time_sent: l.time_sent,
|
|
|
|
elem_type: l.elem_type.clone(),
|
|
|
|
elem_id: l.elem_id,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-13 17:38:51 +00:00
|
|
|
pub fn for_list(l: &Vec<UserLike>) -> Vec<Self> {
|
2020-07-13 17:26:19 +00:00
|
|
|
l.iter().map(Self::new).collect()
|
|
|
|
}
|
|
|
|
}
|