use super::Formation;
use crate::framework::endpoint::{HerokuEndpoint, Method};
pub struct FormationUpdate<'a> {
pub app_id: &'a str,
pub formation_id: &'a str,
pub params: FormationUpdateParams<'a>,
}
#[cfg(feature = "builder")]
impl<'a> FormationUpdate<'a> {
pub fn new(app_id: &'a str, formation_id: &'a str) -> FormationUpdate<'a> {
FormationUpdate {
app_id,
formation_id,
params: FormationUpdateParams {
quantity: None,
size: None,
},
}
}
pub fn size(&mut self, size: &'a str) -> &mut Self {
self.params.size = Some(size);
self
}
pub fn quantity(&mut self, quantity: i32) -> &mut Self {
self.params.quantity = Some(quantity);
self
}
pub fn build(&self) -> FormationUpdate<'a> {
FormationUpdate {
app_id: self.app_id,
formation_id: self.app_id,
params: FormationUpdateParams {
quantity: self.params.quantity,
size: self.params.size,
},
}
}
}
#[serde_with::skip_serializing_none]
#[derive(Serialize, Clone, Debug)]
pub struct FormationUpdateParams<'a> {
pub quantity: Option<i32>,
pub size: Option<&'a str>,
}
impl<'a> HerokuEndpoint<Formation, (), FormationUpdateParams<'a>> for FormationUpdate<'a> {
fn method(&self) -> Method {
Method::Patch
}
fn path(&self) -> String {
format!("apps/{}/formation/{}", self.app_id, self.formation_id)
}
fn body(&self) -> Option<FormationUpdateParams<'a>> {
Some(self.params.clone())
}
}