From e057f672faa8a624c6be853466ba92bef399b4fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan-=C8=98tefan=20Neac=C5=9Fu?= Date: Thu, 17 Oct 2024 17:03:48 +0300 Subject: [PATCH] Add topup req constructor (#4983) --- common/authenticator-requests/src/v3/request.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/common/authenticator-requests/src/v3/request.rs b/common/authenticator-requests/src/v3/request.rs index 61e0914c1d..32db17aed2 100644 --- a/common/authenticator-requests/src/v3/request.rs +++ b/common/authenticator-requests/src/v3/request.rs @@ -84,6 +84,22 @@ impl AuthenticatorRequest { ) } + pub fn new_topup_request(top_up_message: TopUpMessage, reply_to: Recipient) -> (Self, u64) { + let request_id = generate_random(); + ( + Self { + protocol: Protocol { + service_provider_type: ServiceProviderType::Authenticator, + version: VERSION, + }, + data: AuthenticatorRequestData::TopUpBandwidth(Box::new(top_up_message)), + reply_to, + request_id, + }, + request_id, + ) + } + pub fn to_bytes(&self) -> Result, bincode::Error> { use bincode::Options; make_bincode_serializer().serialize(self)