From 08589cb6cfc0d851ba9968533673fb4ef6ac845a Mon Sep 17 00:00:00 2001 From: Chung Tran Date: Fri, 26 Jan 2024 13:29:18 +0700 Subject: [PATCH] fix: models --- .../Repository/Dto/Request/DeleteDeviceTokenDto.swift | 7 +++++++ .../Repository/Dto/Request/DeviceTokenDto.swift | 8 ++++++++ .../Repository/Dto/Request/DeviceTokenInfoDto.swift | 6 ++++++ .../Repository/Dto/Response/DeviceTokenResposeDto.swift | 6 ++++++ .../Repository/NotificationRepository.swift | 4 ++-- 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/p2p_wallet/Common/Services/NotificationsService/Repository/Dto/Request/DeleteDeviceTokenDto.swift b/p2p_wallet/Common/Services/NotificationsService/Repository/Dto/Request/DeleteDeviceTokenDto.swift index 4891bcb0e0..06eebde122 100644 --- a/p2p_wallet/Common/Services/NotificationsService/Repository/Dto/Request/DeleteDeviceTokenDto.swift +++ b/p2p_wallet/Common/Services/NotificationsService/Repository/Dto/Request/DeleteDeviceTokenDto.swift @@ -5,4 +5,11 @@ struct DeleteDeviceTokenDto: Encodable { let clientId: String let ethPubkey: String? let type = "device" + + enum CodingKeys: String, CodingKey { + case deviceToken = "device_token" + case clientId = "client_id" + case ethPubkey = "eth_pubkey" + case type + } } diff --git a/p2p_wallet/Common/Services/NotificationsService/Repository/Dto/Request/DeviceTokenDto.swift b/p2p_wallet/Common/Services/NotificationsService/Repository/Dto/Request/DeviceTokenDto.swift index 1b9e511267..dda23910b7 100644 --- a/p2p_wallet/Common/Services/NotificationsService/Repository/Dto/Request/DeviceTokenDto.swift +++ b/p2p_wallet/Common/Services/NotificationsService/Repository/Dto/Request/DeviceTokenDto.swift @@ -6,4 +6,12 @@ struct DeviceTokenDto: Encodable { let ethPubkey: String? let type = "device" let deviceInfo: DeviceTokenInfo? + + enum CodingKeys: String, CodingKey { + case deviceToken = "device_token" + case clientId = "client_id" + case ethPubkey = "eth_pubkey" + case type + case deviceInfo = "device_info" + } } diff --git a/p2p_wallet/Common/Services/NotificationsService/Repository/Dto/Request/DeviceTokenInfoDto.swift b/p2p_wallet/Common/Services/NotificationsService/Repository/Dto/Request/DeviceTokenInfoDto.swift index 43b7825a3b..3f0ce430aa 100644 --- a/p2p_wallet/Common/Services/NotificationsService/Repository/Dto/Request/DeviceTokenInfoDto.swift +++ b/p2p_wallet/Common/Services/NotificationsService/Repository/Dto/Request/DeviceTokenInfoDto.swift @@ -4,4 +4,10 @@ struct DeviceTokenInfo: Codable { let osName: String let osVersion: String let deviceModel: String + + enum CodingKeys: String, CodingKey { + case osName = "os_name" + case osVersion = "os_version" + case deviceModel = "device_model" + } } diff --git a/p2p_wallet/Common/Services/NotificationsService/Repository/Dto/Response/DeviceTokenResposeDto.swift b/p2p_wallet/Common/Services/NotificationsService/Repository/Dto/Response/DeviceTokenResposeDto.swift index 6cbc05dc56..f541b5f10c 100644 --- a/p2p_wallet/Common/Services/NotificationsService/Repository/Dto/Response/DeviceTokenResposeDto.swift +++ b/p2p_wallet/Common/Services/NotificationsService/Repository/Dto/Response/DeviceTokenResposeDto.swift @@ -4,4 +4,10 @@ struct DeviceTokenResponseDto: Decodable { let deviceToken: String let timestamp: String let clientId: String + + enum CodingKeys: String, CodingKey { + case deviceToken = "device_token" + case timestamp + case clientId = "client_id" + } } diff --git a/p2p_wallet/Common/Services/NotificationsService/Repository/NotificationRepository.swift b/p2p_wallet/Common/Services/NotificationsService/Repository/NotificationRepository.swift index 9c9730a175..1431232594 100644 --- a/p2p_wallet/Common/Services/NotificationsService/Repository/NotificationRepository.swift +++ b/p2p_wallet/Common/Services/NotificationsService/Repository/NotificationRepository.swift @@ -29,7 +29,7 @@ final class NotificationRepositoryImpl: NotificationRepository { header: header, body: .init( method: "add_device", - params: model + params: [model] ) ) } catch let error as JSONRPCError { @@ -53,7 +53,7 @@ final class NotificationRepositoryImpl: NotificationRepository { header: header, body: .init( method: "delete_device", - params: model + params: [model] ) ) }