/*
 * asklyphe-common nats/bingservice.rs
 * - nats structs for external search engines
 *
 * Copyright (C) 2025 Real Microsoft, LLC
 *
 * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

use serde::{Deserialize, Serialize};

pub const BING_SERVICE: &str = "bingservice";
pub const BING_REPLY_SERVICE: &str = "bingservicereply";
pub const GOOGLE_SERVICE: &str = "googleservice";
pub const GOOGLE_REPLY_SERVICE: &str = "googleservicereply";

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BingServiceQuery {
    pub request: BingServiceRequest,
    /// if using comms::query_service, you don't need to set this
    pub replyto: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum BingServiceRequest {
    SearchRequest(BingSearchRequest),
    ImageRequest(BingImageRequest),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum BingServiceResponse {
    InvalidRequest,
    OtherError(String),
    SearchResponse(SearchResponse),
    ImageResponse(Vec<BingImageResult>),
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BingSearchRequest {
    pub query: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BingSearchResult {
    pub url: String,
    pub title: Option<String>,
    pub description: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SearchResponse {
    pub results: Vec<BingSearchResult>,
    pub blocked: Vec<(String, String)>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BingImageRequest {
    pub query: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BingImageResult {
    pub url: String,
}
