mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-26 07:19:22 +00:00
32 lines
645 B
Rust
32 lines
645 B
Rust
|
//! # 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()
|
||
|
}
|
||
|
}
|