use std::{
future::{Future, IntoFuture},
pin::Pin,
};
use serde::Serialize;
use crate::{api::API, errors::ConogramError, impl_into_future, request::RequestT};
#[derive(Debug, Clone, Serialize)]
pub struct SetMyNameParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub language_code: Option<String>,
}
impl_into_future!(SetMyNameRequest<'a>);
#[derive(Clone)]
pub struct SetMyNameRequest<'a> {
api: &'a API,
params: SetMyNameParams,
}
impl<'a> RequestT for SetMyNameRequest<'a> {
type ParamsType = SetMyNameParams;
type ReturnType = bool;
fn get_name() -> &'static str {
"setMyName"
}
fn get_api_ref(&self) -> &API {
self.api
}
fn get_params_ref(&self) -> &Self::ParamsType {
&self.params
}
fn is_multipart() -> bool {
false
}
}
impl<'a> SetMyNameRequest<'a> {
pub fn new(api: &'a API) -> Self {
Self {
api,
params: SetMyNameParams {
name: Option::default(),
language_code: Option::default(),
},
}
}
#[must_use]
pub fn name(mut self, name: impl Into<String>) -> Self {
self.params.name = Some(name.into());
self
}
#[must_use]
pub fn language_code(mut self, language_code: impl Into<String>) -> Self {
self.params.language_code = Some(language_code.into());
self
}
}
impl API {
pub fn set_my_name(&self) -> SetMyNameRequest {
SetMyNameRequest::new(self)
}
}