1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-26 07:19:22 +00:00
comunicapiv3/src/api_data/user_like_api.rs

32 lines
645 B
Rust
Raw Normal View History

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)]
pub struct UserLikeAPI {
id: u64,
user_id: u64,
time_sent: u64,
elem_type: String,
elem_id: u64,
}
impl UserLikeAPI {
pub fn new(l: &UserLike) -> UserLikeAPI {
UserLikeAPI {
id: l.id,
user_id: l.user_id.id(),
time_sent: l.time_sent,
elem_type: l.elem_type.clone(),
elem_id: l.elem_id,
}
}
pub fn for_list(l: &Vec<UserLike>) -> Vec<UserLikeAPI> {
l.iter().map(Self::new).collect()
}
}