Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import com.wallet.core.primitives.Rewards
import com.wallet.core.primitives.ScanTransaction
import com.wallet.core.primitives.ScanTransactionPayload
import com.wallet.core.primitives.SupportAction
import com.wallet.core.primitives.SupportConversation
import com.wallet.core.primitives.SupportMessage
import com.wallet.core.primitives.SupportMessageInput
import com.wallet.core.primitives.Transaction
Expand Down Expand Up @@ -118,9 +117,6 @@ interface GemDeviceApiClient {
@POST("/v2/devices/scan/transaction")
suspend fun getScanTransaction(@Body payload: ScanTransactionPayload): ScanTransaction

@GET("/v2/devices/support")
suspend fun getSupportConversation(): SupportConversation?

@GET("/v2/devices/support/messages")
suspend fun getSupportMessages(
@Query("from_timestamp") fromTimestamp: Long,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ sealed class StreamEvent {
data class FiatTransaction(val data: StreamWalletUpdate): StreamEvent()
@Serializable
@SerialName("support")
data class Support(val data: SupportStreamEvent): StreamEvent()
data class Support(val data: SupportMessage): StreamEvent()
}

@Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,7 @@ import kotlinx.serialization.SerialName

@Serializable
data class SupportAgent (
val name: String,
val avatarUrl: String? = null
)

@Serializable
enum class SupportConversationStatus(val string: String) {
@SerialName("open")
Open("open"),
@SerialName("resolved")
Resolved("resolved"),
}

@Serializable
data class SupportConversation (
val id: String,
val status: SupportConversationStatus,
val firstMessage: String? = null,
val lastMessage: String? = null,
val lastActivityAt: SerializedDate,
val unreadCount: Int
val name: String
)

@Serializable
Expand Down Expand Up @@ -65,10 +46,9 @@ data class SupportMessageImage (
@Serializable
data class SupportMessage (
val id: String,
val conversationId: String,
val content: String,
val sender: SupportMessageSender,
val deliveryStatus: SupportMessageDeliveryStatus,
val status: SupportMessageDeliveryStatus,
val createdAt: SerializedDate,
val images: List<SupportMessageImage>
)
Expand All @@ -88,16 +68,6 @@ sealed class SupportAction {
object LastSeen: SupportAction()
}

@Serializable
sealed class SupportStreamEvent {
@Serializable
@SerialName("message")
data class Message(val data: SupportMessage): SupportStreamEvent()
@Serializable
@SerialName("conversation")
data class Conversation(val data: SupportConversation): SupportStreamEvent()
}

@Serializable
enum class SupportTypingStatus(val string: String) {
@SerialName("on")
Expand Down
4 changes: 1 addition & 3 deletions core/crates/primitives/src/support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ pub enum SupportMessageDeliveryStatus {
#[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, PartialEq, Eq, Serialize, Deserialize)]
Expand Down Expand Up @@ -70,7 +68,7 @@ pub struct SupportMessage {
pub id: String,
pub content: String,
pub sender: SupportMessageSender,
pub delivery_status: SupportMessageDeliveryStatus,
pub status: SupportMessageDeliveryStatus,
pub created_at: DateTime<Utc>,
pub images: Vec<SupportMessageImage>,
}
Expand Down
2 changes: 1 addition & 1 deletion core/crates/support/src/chatwoot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ mod tests {
id: id.to_string(),
content: id.to_string(),
sender: SupportMessageSender::User,
delivery_status: SupportMessageDeliveryStatus::Sent,
status: SupportMessageDeliveryStatus::Sent,
created_at: chrono::DateTime::from_timestamp(timestamp, 0).unwrap(),
images: vec![],
}
Expand Down
14 changes: 4 additions & 10 deletions core/crates/support/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ pub struct CustomAttributes {
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Sender {
pub name: Option<String>,
pub avatar_url: Option<String>,
pub thumbnail: Option<String>,
pub custom_attributes: Option<CustomAttributes>,
}

Expand Down Expand Up @@ -205,10 +203,7 @@ impl Attachment {
impl Sender {
fn support_agent(&self) -> Option<SupportAgent> {
let name = self.name.clone()?;
Some(SupportAgent {
name,
avatar_url: self.avatar_url.clone().or_else(|| self.thumbnail.clone()).filter(|value| !value.is_empty()),
})
Some(SupportAgent { name })
}
}

Expand Down Expand Up @@ -306,7 +301,7 @@ fn support_message(
content_type: Option<&str>,
private: Option<bool>,
sender: SupportMessageSender,
delivery_status: SupportMessageDeliveryStatus,
status: SupportMessageDeliveryStatus,
created_at: DateTime<Utc>,
attachments: &[Attachment],
) -> Option<SupportMessage> {
Expand All @@ -328,7 +323,7 @@ fn support_message(
id: id.to_string(),
content,
sender,
delivery_status,
status,
created_at,
images,
})
Expand Down Expand Up @@ -380,10 +375,9 @@ mod tests {
messages[0].sender,
SupportMessageSender::Agent(SupportAgent {
name: "Test Agent".to_string(),
avatar_url: None,
})
);
assert_eq!(messages[0].delivery_status, SupportMessageDeliveryStatus::Sent);
assert_eq!(messages[0].status, SupportMessageDeliveryStatus::Sent);
}

#[test]
Expand Down
3 changes: 1 addition & 2 deletions core/crates/support/tests/model_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ fn test_support_message_mapping() {
message.sender,
SupportMessageSender::Agent(SupportAgent {
name: "Test Agent".to_string(),
avatar_url: None,
})
);
assert_eq!(message.delivery_status, SupportMessageDeliveryStatus::Sent);
assert_eq!(message.status, SupportMessageDeliveryStatus::Sent);
}

#[test]
Expand Down
6 changes: 0 additions & 6 deletions ios/Packages/GemAPI/Sources/GemAPIService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ public protocol GemAPIScanService: Sendable {
}

public protocol GemAPISupportService: Sendable {
func getSupportConversation() async throws -> SupportConversation?
func getSupportMessages(fromTimestamp: Int) async throws -> [SupportMessage]
func sendSupportMessage(input: SupportMessageInput) async throws -> SupportMessage
func sendSupportImage(image: Data, fileName: String, mimeType: String) async throws -> SupportMessage
Expand Down Expand Up @@ -308,11 +307,6 @@ extension GemAPIService: GemAPIScanService {
}

extension GemAPIService: GemAPISupportService {
public func getSupportConversation() async throws -> SupportConversation? {
try await requestDevice(.getSupportConversation)
.mapResponse(as: SupportConversation?.self)
}

public func getSupportMessages(fromTimestamp: Int) async throws -> [SupportMessage] {
try await requestDevice(.getSupportMessages(fromTimestamp: fromTimestamp))
.mapResponse(as: [SupportMessage].self)
Expand Down
5 changes: 0 additions & 5 deletions ios/Packages/GemAPI/Sources/GemDeviceAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public enum GemDeviceAPI: TargetType {
case scanTransaction(payload: ScanTransactionPayload)
case getWalletConfiguration(walletId: WalletId)

case getSupportConversation
case getSupportMessages(fromTimestamp: Int)
case sendSupportMessage(input: SupportMessageInput)
case sendSupportImage(image: Data, fileName: String, mimeType: String)
Expand Down Expand Up @@ -83,7 +82,6 @@ public enum GemDeviceAPI: TargetType {
.getFiatTransactions,
.getNameRecord,
.getWalletConfiguration,
.getSupportConversation,
.getSupportMessages:
.GET
case .addDevice,
Expand Down Expand Up @@ -148,8 +146,6 @@ public enum GemDeviceAPI: TargetType {
return "/v2/devices/scan/transaction"
case .getWalletConfiguration:
return "/v2/devices/wallet_configuration"
case .getSupportConversation:
return "/v2/devices/support"
case let .getSupportMessages(fromTimestamp):
return "/v2/devices/support/messages?from_timestamp=\(fromTimestamp)"
case .sendSupportMessage:
Expand Down Expand Up @@ -237,7 +233,6 @@ public enum GemDeviceAPI: TargetType {
.getFiatQuoteUrl,
.getFiatTransactions,
.getNameRecord,
.getSupportConversation,
.getSupportMessages:
return .plain
case let .getPriceAlerts(assetId):
Expand Down
13 changes: 2 additions & 11 deletions ios/Packages/GemAPI/TestKit/GemAPISupportService+TestKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,18 @@ import GemAPI
import Primitives

public actor GemAPISupportServiceMock: GemAPISupportService {
private let conversation: SupportConversation?
private let messages: [SupportMessage]

public private(set) var sentMessages: [SupportMessageInput] = []
public private(set) var sentImages: [(image: Data, fileName: String, mimeType: String)] = []
public private(set) var sentActions: [SupportAction] = []

public init(
conversation: SupportConversation? = nil,
messages: [SupportMessage] = [],
) {
self.conversation = conversation
self.messages = messages
}

public func getSupportConversation() async throws -> SupportConversation? {
conversation
}

public func getSupportMessages(fromTimestamp _: Int) async throws -> [SupportMessage] {
messages
}
Expand All @@ -32,10 +25,9 @@ public actor GemAPISupportServiceMock: GemAPISupportService {
sentMessages.append(input)
return SupportMessage(
id: "",
conversationId: "",
content: input.content,
sender: .user,
deliveryStatus: .sent,
status: .sent,
createdAt: Date(),
images: [],
)
Expand All @@ -45,10 +37,9 @@ public actor GemAPISupportServiceMock: GemAPISupportService {
sentImages.append((image, fileName, mimeType))
return SupportMessage(
id: "",
conversationId: "",
content: "",
sender: .user,
deliveryStatus: .sent,
status: .sent,
createdAt: Date(),
images: [],
)
Expand Down
4 changes: 2 additions & 2 deletions ios/Packages/Primitives/Sources/Generated/Stream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public enum StreamEvent: Codable, Sendable {
case perpetual(StreamWalletUpdate)
case inAppNotification(StreamNotificationUpdate)
case fiatTransaction(StreamWalletUpdate)
case support(SupportStreamEvent)
case support(SupportMessage)

enum CodingKeys: String, CodingKey, Codable {
case prices,
Expand Down Expand Up @@ -130,7 +130,7 @@ public enum StreamEvent: Codable, Sendable {
return
}
case .support:
if let content = try? container.decode(SupportStreamEvent.self, forKey: .data) {
if let content = try? container.decode(SupportMessage.self, forKey: .data) {
self = .support(content)
return
}
Expand Down
Loading
Loading