Skip to content

Commit b7057c9

Browse files
authored
Rename support message delivery_status to status and remove agent ava… (#465)
* Rename support message delivery_status to status and remove agent avatar_url Regenerate iOS/Android typeshare bindings. This also syncs the generated Support/Stream models with the already-merged core simplification (drops the stale conversationId and SupportStreamEvent left by the core-only support merge). * Remove dead support conversation API from iOS and Android The core support simplification dropped SupportConversation/conversationId, but the core-only merge left getSupportConversation and related fields referencing removed types in the apps. Regenerating bindings exposed it as a build break (CI #465).
1 parent ef5f122 commit b7057c9

12 files changed

Lines changed: 18 additions & 153 deletions

File tree

android/data/services/remote-gem/src/main/kotlin/com/gemwallet/android/data/services/gemapi/GemDeviceApiClient.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import com.wallet.core.primitives.Rewards
2222
import com.wallet.core.primitives.ScanTransaction
2323
import com.wallet.core.primitives.ScanTransactionPayload
2424
import com.wallet.core.primitives.SupportAction
25-
import com.wallet.core.primitives.SupportConversation
2625
import com.wallet.core.primitives.SupportMessage
2726
import com.wallet.core.primitives.SupportMessageInput
2827
import com.wallet.core.primitives.Transaction
@@ -118,9 +117,6 @@ interface GemDeviceApiClient {
118117
@POST("/v2/devices/scan/transaction")
119118
suspend fun getScanTransaction(@Body payload: ScanTransactionPayload): ScanTransaction
120119

121-
@GET("/v2/devices/support")
122-
suspend fun getSupportConversation(): SupportConversation?
123-
124120
@GET("/v2/devices/support/messages")
125121
suspend fun getSupportMessages(
126122
@Query("from_timestamp") fromTimestamp: Long,

android/gemcore/src/main/kotlin/com/wallet/core/primitives/generated/Stream.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ sealed class StreamEvent {
6868
data class FiatTransaction(val data: StreamWalletUpdate): StreamEvent()
6969
@Serializable
7070
@SerialName("support")
71-
data class Support(val data: SupportStreamEvent): StreamEvent()
71+
data class Support(val data: SupportMessage): StreamEvent()
7272
}
7373

7474
@Serializable

android/gemcore/src/main/kotlin/com/wallet/core/primitives/generated/Support.kt

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,7 @@ import kotlinx.serialization.SerialName
99

1010
@Serializable
1111
data class SupportAgent (
12-
val name: String,
13-
val avatarUrl: String? = null
14-
)
15-
16-
@Serializable
17-
enum class SupportConversationStatus(val string: String) {
18-
@SerialName("open")
19-
Open("open"),
20-
@SerialName("resolved")
21-
Resolved("resolved"),
22-
}
23-
24-
@Serializable
25-
data class SupportConversation (
26-
val id: String,
27-
val status: SupportConversationStatus,
28-
val firstMessage: String? = null,
29-
val lastMessage: String? = null,
30-
val lastActivityAt: SerializedDate,
31-
val unreadCount: Int
12+
val name: String
3213
)
3314

3415
@Serializable
@@ -65,10 +46,9 @@ data class SupportMessageImage (
6546
@Serializable
6647
data class SupportMessage (
6748
val id: String,
68-
val conversationId: String,
6949
val content: String,
7050
val sender: SupportMessageSender,
71-
val deliveryStatus: SupportMessageDeliveryStatus,
51+
val status: SupportMessageDeliveryStatus,
7252
val createdAt: SerializedDate,
7353
val images: List<SupportMessageImage>
7454
)
@@ -88,16 +68,6 @@ sealed class SupportAction {
8868
object LastSeen: SupportAction()
8969
}
9070

91-
@Serializable
92-
sealed class SupportStreamEvent {
93-
@Serializable
94-
@SerialName("message")
95-
data class Message(val data: SupportMessage): SupportStreamEvent()
96-
@Serializable
97-
@SerialName("conversation")
98-
data class Conversation(val data: SupportConversation): SupportStreamEvent()
99-
}
100-
10171
@Serializable
10272
enum class SupportTypingStatus(val string: String) {
10373
@SerialName("on")

core/crates/primitives/src/support.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ pub enum SupportMessageDeliveryStatus {
1717
#[serde(rename_all = "camelCase")]
1818
pub struct SupportAgent {
1919
pub name: String,
20-
#[serde(skip_serializing_if = "Option::is_none")]
21-
pub avatar_url: Option<String>,
2220
}
2321

2422
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
@@ -70,7 +68,7 @@ pub struct SupportMessage {
7068
pub id: String,
7169
pub content: String,
7270
pub sender: SupportMessageSender,
73-
pub delivery_status: SupportMessageDeliveryStatus,
71+
pub status: SupportMessageDeliveryStatus,
7472
pub created_at: DateTime<Utc>,
7573
pub images: Vec<SupportMessageImage>,
7674
}

core/crates/support/src/chatwoot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ mod tests {
181181
id: id.to_string(),
182182
content: id.to_string(),
183183
sender: SupportMessageSender::User,
184-
delivery_status: SupportMessageDeliveryStatus::Sent,
184+
status: SupportMessageDeliveryStatus::Sent,
185185
created_at: chrono::DateTime::from_timestamp(timestamp, 0).unwrap(),
186186
images: vec![],
187187
}

core/crates/support/src/model.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ pub struct CustomAttributes {
109109
#[derive(Debug, Clone, Serialize, Deserialize)]
110110
pub struct Sender {
111111
pub name: Option<String>,
112-
pub avatar_url: Option<String>,
113-
pub thumbnail: Option<String>,
114112
pub custom_attributes: Option<CustomAttributes>,
115113
}
116114

@@ -205,10 +203,7 @@ impl Attachment {
205203
impl Sender {
206204
fn support_agent(&self) -> Option<SupportAgent> {
207205
let name = self.name.clone()?;
208-
Some(SupportAgent {
209-
name,
210-
avatar_url: self.avatar_url.clone().or_else(|| self.thumbnail.clone()).filter(|value| !value.is_empty()),
211-
})
206+
Some(SupportAgent { name })
212207
}
213208
}
214209

@@ -306,7 +301,7 @@ fn support_message(
306301
content_type: Option<&str>,
307302
private: Option<bool>,
308303
sender: SupportMessageSender,
309-
delivery_status: SupportMessageDeliveryStatus,
304+
status: SupportMessageDeliveryStatus,
310305
created_at: DateTime<Utc>,
311306
attachments: &[Attachment],
312307
) -> Option<SupportMessage> {
@@ -328,7 +323,7 @@ fn support_message(
328323
id: id.to_string(),
329324
content,
330325
sender,
331-
delivery_status,
326+
status,
332327
created_at,
333328
images,
334329
})
@@ -380,10 +375,9 @@ mod tests {
380375
messages[0].sender,
381376
SupportMessageSender::Agent(SupportAgent {
382377
name: "Test Agent".to_string(),
383-
avatar_url: None,
384378
})
385379
);
386-
assert_eq!(messages[0].delivery_status, SupportMessageDeliveryStatus::Sent);
380+
assert_eq!(messages[0].status, SupportMessageDeliveryStatus::Sent);
387381
}
388382

389383
#[test]

core/crates/support/tests/model_tests.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@ fn test_support_message_mapping() {
4343
message.sender,
4444
SupportMessageSender::Agent(SupportAgent {
4545
name: "Test Agent".to_string(),
46-
avatar_url: None,
4746
})
4847
);
49-
assert_eq!(message.delivery_status, SupportMessageDeliveryStatus::Sent);
48+
assert_eq!(message.status, SupportMessageDeliveryStatus::Sent);
5049
}
5150

5251
#[test]

ios/Packages/GemAPI/Sources/GemAPIService.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ public protocol GemAPIScanService: Sendable {
8787
}
8888

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

310309
extension GemAPIService: GemAPISupportService {
311-
public func getSupportConversation() async throws -> SupportConversation? {
312-
try await requestDevice(.getSupportConversation)
313-
.mapResponse(as: SupportConversation?.self)
314-
}
315-
316310
public func getSupportMessages(fromTimestamp: Int) async throws -> [SupportMessage] {
317311
try await requestDevice(.getSupportMessages(fromTimestamp: fromTimestamp))
318312
.mapResponse(as: [SupportMessage].self)

ios/Packages/GemAPI/Sources/GemDeviceAPI.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public enum GemDeviceAPI: TargetType {
2929
case scanTransaction(payload: ScanTransactionPayload)
3030
case getWalletConfiguration(walletId: WalletId)
3131

32-
case getSupportConversation
3332
case getSupportMessages(fromTimestamp: Int)
3433
case sendSupportMessage(input: SupportMessageInput)
3534
case sendSupportImage(image: Data, fileName: String, mimeType: String)
@@ -83,7 +82,6 @@ public enum GemDeviceAPI: TargetType {
8382
.getFiatTransactions,
8483
.getNameRecord,
8584
.getWalletConfiguration,
86-
.getSupportConversation,
8785
.getSupportMessages:
8886
.GET
8987
case .addDevice,
@@ -148,8 +146,6 @@ public enum GemDeviceAPI: TargetType {
148146
return "/v2/devices/scan/transaction"
149147
case .getWalletConfiguration:
150148
return "/v2/devices/wallet_configuration"
151-
case .getSupportConversation:
152-
return "/v2/devices/support"
153149
case let .getSupportMessages(fromTimestamp):
154150
return "/v2/devices/support/messages?from_timestamp=\(fromTimestamp)"
155151
case .sendSupportMessage:
@@ -237,7 +233,6 @@ public enum GemDeviceAPI: TargetType {
237233
.getFiatQuoteUrl,
238234
.getFiatTransactions,
239235
.getNameRecord,
240-
.getSupportConversation,
241236
.getSupportMessages:
242237
return .plain
243238
case let .getPriceAlerts(assetId):

ios/Packages/GemAPI/TestKit/GemAPISupportService+TestKit.swift

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,18 @@ import GemAPI
55
import Primitives
66

77
public actor GemAPISupportServiceMock: GemAPISupportService {
8-
private let conversation: SupportConversation?
98
private let messages: [SupportMessage]
109

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

1514
public init(
16-
conversation: SupportConversation? = nil,
1715
messages: [SupportMessage] = [],
1816
) {
19-
self.conversation = conversation
2017
self.messages = messages
2118
}
2219

23-
public func getSupportConversation() async throws -> SupportConversation? {
24-
conversation
25-
}
26-
2720
public func getSupportMessages(fromTimestamp _: Int) async throws -> [SupportMessage] {
2821
messages
2922
}
@@ -32,10 +25,9 @@ public actor GemAPISupportServiceMock: GemAPISupportService {
3225
sentMessages.append(input)
3326
return SupportMessage(
3427
id: "",
35-
conversationId: "",
3628
content: input.content,
3729
sender: .user,
38-
deliveryStatus: .sent,
30+
status: .sent,
3931
createdAt: Date(),
4032
images: [],
4133
)
@@ -45,10 +37,9 @@ public actor GemAPISupportServiceMock: GemAPISupportService {
4537
sentImages.append((image, fileName, mimeType))
4638
return SupportMessage(
4739
id: "",
48-
conversationId: "",
4940
content: "",
5041
sender: .user,
51-
deliveryStatus: .sent,
42+
status: .sent,
5243
createdAt: Date(),
5344
images: [],
5445
)

0 commit comments

Comments
 (0)