-
Notifications
You must be signed in to change notification settings - Fork 53
feat(support): add support-chat domain models #1162
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,65 @@ | ||||||
| use chrono::{DateTime, Utc}; | ||||||
| use serde::{Deserialize, Serialize}; | ||||||
| use typeshare::typeshare; | ||||||
|
|
||||||
| #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] | ||||||
| #[typeshare(swift = "Equatable, CaseIterable, Sendable")] | ||||||
| #[serde(rename_all = "lowercase")] | ||||||
| pub enum SupportConversationStatus { | ||||||
| Open, | ||||||
| Resolved, | ||||||
| } | ||||||
|
|
||||||
| #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] | ||||||
| #[typeshare(swift = "Equatable, CaseIterable, Sendable")] | ||||||
| #[serde(rename_all = "lowercase")] | ||||||
| pub enum SupportMessageDirection { | ||||||
| Incoming, | ||||||
| Outgoing, | ||||||
| } | ||||||
|
|
||||||
| #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] | ||||||
| #[typeshare(swift = "Equatable, CaseIterable, Sendable")] | ||||||
| #[serde(rename_all = "lowercase")] | ||||||
| pub enum SupportMessageDeliveryStatus { | ||||||
| Sending, | ||||||
| Sent, | ||||||
| Failed, | ||||||
| } | ||||||
|
|
||||||
| #[derive(Debug, Clone, Serialize, Deserialize)] | ||||||
| #[typeshare(swift = "Sendable, Equatable")] | ||||||
| #[serde(rename_all = "camelCase")] | ||||||
| pub struct SupportAgent { | ||||||
| pub name: String, | ||||||
| #[serde(skip_serializing_if = "Option::is_none")] | ||||||
| pub avatar_url: Option<String>, | ||||||
| } | ||||||
|
|
||||||
| #[derive(Debug, Clone, Serialize, Deserialize)] | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||
| #[typeshare(swift = "Sendable, Equatable, Hashable, Identifiable")] | ||||||
| #[serde(rename_all = "camelCase")] | ||||||
| pub struct SupportConversation { | ||||||
| pub id: String, | ||||||
| pub status: SupportConversationStatus, | ||||||
| #[serde(skip_serializing_if = "Option::is_none")] | ||||||
| pub first_message: Option<String>, | ||||||
| #[serde(skip_serializing_if = "Option::is_none")] | ||||||
| pub last_message: Option<String>, | ||||||
| pub last_activity_at: DateTime<Utc>, | ||||||
| pub unread_count: i32, | ||||||
| } | ||||||
|
|
||||||
| #[derive(Debug, Clone, Serialize, Deserialize)] | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||
| #[typeshare(swift = "Sendable, Equatable")] | ||||||
| #[serde(rename_all = "camelCase")] | ||||||
| pub struct SupportMessage { | ||||||
| pub id: String, | ||||||
| pub conversation_id: String, | ||||||
| pub content: String, | ||||||
| pub direction: SupportMessageDirection, | ||||||
| pub delivery_status: SupportMessageDeliveryStatus, | ||||||
| #[serde(skip_serializing_if = "Option::is_none")] | ||||||
| pub agent: Option<SupportAgent>, | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's do non optional |
||||||
| pub created_at: DateTime<Utc>, | ||||||
| } | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
SupportAgentstruct is marked with#[typeshare(swift = "Sendable, Equatable")], indicating it should be equatable. However, the Rust struct does not derivePartialEqorEq. To ensure consistency between the Rust models and the generated Swift models, and to allow equality comparisons in Rust (especially useful for testing), please derivePartialEqandEq.