first commit
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tokio_postgres::{Error, Row};
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct Contact {
|
||||
pub id: Uuid,
|
||||
pub interviewee_id: Uuid,
|
||||
pub primary_origin_id: Uuid,
|
||||
pub contact_type: String,
|
||||
pub raw_value: String,
|
||||
pub normalized_value: String,
|
||||
pub relationship_kind: String,
|
||||
pub label: Option<String>,
|
||||
pub confidence: f32,
|
||||
pub status: String,
|
||||
pub discovered_in_run_id: Option<Uuid>,
|
||||
pub first_seen_at: DateTime<Utc>,
|
||||
pub last_seen_at: DateTime<Utc>,
|
||||
pub last_verified_at: Option<DateTime<Utc>>,
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
pub deleted_at: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct NewContact {
|
||||
pub interviewee_id: Uuid,
|
||||
pub primary_origin_id: Uuid,
|
||||
pub contact_type: String,
|
||||
pub raw_value: String,
|
||||
pub normalized_value: String,
|
||||
pub relationship_kind: String,
|
||||
pub label: Option<String>,
|
||||
pub confidence: f32,
|
||||
pub discovered_in_run_id: Option<Uuid>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
||||
pub struct ContactPatch {
|
||||
pub relationship_kind: Option<String>,
|
||||
pub label: Option<String>,
|
||||
pub confidence: Option<f32>,
|
||||
pub status: Option<String>,
|
||||
}
|
||||
|
||||
impl Contact {
|
||||
pub fn from_row(row: &Row) -> Result<Self, Error> {
|
||||
Ok(Self {
|
||||
id: row.try_get("id")?,
|
||||
interviewee_id: row.try_get("interviewee_id")?,
|
||||
primary_origin_id: row.try_get("primary_origin_id")?,
|
||||
contact_type: row.try_get("contact_type")?,
|
||||
raw_value: row.try_get("raw_value")?,
|
||||
normalized_value: row.try_get("normalized_value")?,
|
||||
relationship_kind: row.try_get("relationship_kind")?,
|
||||
label: row.try_get("label")?,
|
||||
confidence: row.try_get("confidence")?,
|
||||
status: row.try_get("status")?,
|
||||
discovered_in_run_id: row.try_get("discovered_in_run_id")?,
|
||||
first_seen_at: row.try_get("first_seen_at")?,
|
||||
last_seen_at: row.try_get("last_seen_at")?,
|
||||
last_verified_at: row.try_get("last_verified_at")?,
|
||||
created_at: row.try_get("created_at")?,
|
||||
updated_at: row.try_get("updated_at")?,
|
||||
deleted_at: row.try_get("deleted_at")?,
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user