Skip to main content

rship_entities/
action.rs

1use myko_macros::Eventable;
2use partially::Partial;
3use serde::{Deserialize, Serialize};
4use serde_json::Value;
5
6#[derive(Clone, Serialize, Deserialize, Debug, Partial, PartialEq, Eventable)]
7#[serde(rename_all = "camelCase")]
8#[partially(derive(Clone, Serialize, Deserialize, Default))]
9pub struct Action {
10    pub id: String,
11    pub hash: String,
12    pub name: String,
13    pub target_id: String,
14    pub service_id: String,
15    schema: Value,
16}
17
18impl Action {
19    pub fn new(
20        id: String,
21        target_id: String,
22        service_id: String,
23        name: String,
24        schema: Value,
25    ) -> Self {
26        Self {
27            id,
28            name,
29            hash: uuid::Uuid::new_v4().to_string(),
30            target_id,
31            service_id,
32            schema,
33        }
34    }
35}