// Copyright (c) Subzero Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

use serde::{Deserialize, Serialize};
use validator::Validate;

use super::rpc_response_context::RpcResponseContext;

/// Request parameters for the `getFeeForMessage` RPC method
#[derive(Debug, Serialize, Deserialize, Validate)]
pub struct GetFeeForMessageRequest {
    /// bincode-serialized versioned message in base64 format
    #[validate(length(min = 1, message = "Message cannot be empty"))]
    #[validate(custom(function = crate::validation::validate_base64))]
    pub message: String,
}

/// The 'inner' response message for a GetFeeForMessage request.
#[derive(Serialize, Deserialize, Debug)]
pub struct GetFeeForMessageResponse {
    pub context: RpcResponseContext,
    pub value: Option<u64>,
}

impl GetFeeForMessageResponse {
    pub fn new(slot: u64, value: Option<u64>) -> Self {
        Self {
            context: RpcResponseContext::new(slot),
            value,
        }
    }
}
