use std::str::FromStr;
use crate::ID;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct UserToken {
pub user: String,
pub token: String,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct CreateAccountQuery {
pub name: String,
pub is_bot: bool,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct HubCreateQuery {
pub account: ID,
pub name: String,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct ChannelCreateQuery {
pub account: ID,
pub hub: ID,
pub name: String,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct MessageSendQuery {
pub account: ID,
pub hub: ID,
pub channel: ID,
pub message: String,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct ChannelsQuery {
pub account: ID,
pub hub: ID,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct LastMessagesQuery {
pub account: ID,
pub hub: ID,
pub channel: ID,
pub count: u128,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct AuthQuery {
pub state: String,
pub code: String,
pub expires: Option<u128>,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct AccountTokenResponse {
pub id: String,
pub token: String,
}
pub enum Service {
GitHub,
}
impl FromStr for Service {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_ascii_lowercase().as_str() {
"github" => Ok(Self::GitHub),
_ => Err(()),
}
}
}
impl ToString for Service {
fn to_string(&self) -> String {
match self {
&Service::GitHub => "github".to_string(),
}
}
}