use super::OAuthClient;
use crate::framework::endpoint::{HerokuEndpoint, Method};
pub struct OAuthClientUpdate<'a> {
pub client_id: &'a str,
pub params: OAuthClientUpdateParams<'a>,
}
#[cfg(feature = "builder")]
impl<'a> OAuthClientUpdate<'a> {
pub fn new(client_id: &'a str) -> OAuthClientUpdate<'a> {
OAuthClientUpdate {
client_id,
params: OAuthClientUpdateParams {
name: None,
redirect_uri: None,
},
}
}
pub fn name(&mut self, name: &'a str) -> &mut Self {
self.params.name = Some(name);
self
}
pub fn redirect_uri(&mut self, redirect_uri: &'a str) -> &mut Self {
self.params.redirect_uri = Some(redirect_uri);
self
}
pub fn build(&self) -> OAuthClientUpdate<'a> {
OAuthClientUpdate {
client_id: self.client_id,
params: OAuthClientUpdateParams {
name: self.params.name,
redirect_uri: self.params.redirect_uri,
},
}
}
}
#[derive(Serialize, Clone, Debug)]
pub struct OAuthClientUpdateParams<'a> {
pub name: Option<&'a str>,
pub redirect_uri: Option<&'a str>,
}
impl<'a> HerokuEndpoint<OAuthClient, (), OAuthClientUpdateParams<'a>> for OAuthClientUpdate<'a> {
fn method(&self) -> Method {
Method::Patch
}
fn path(&self) -> String {
format!("oauth/clients/{}", self.client_id)
}
fn body(&self) -> Option<OAuthClientUpdateParams<'a>> {
Some(self.params.clone())
}
}