use super::{AppTransfer, Credit, PasswordResetResponse, SmsNumber};
use crate::framework::endpoint::{HerokuEndpoint, Method};
pub struct AppTransferCreate<'a> {
pub params: AppTransferCreateParams<'a>,
}
#[cfg(feature = "builder")]
impl<'a> AppTransferCreate<'a> {
pub fn new(app: &'a str, recipient: &'a str) -> AppTransferCreate<'a> {
AppTransferCreate {
params: AppTransferCreateParams {
app: app,
recipient: recipient,
silent: None,
},
}
}
pub fn silent(&mut self, silent: bool) -> &mut Self {
self.params.silent = Some(silent);
self
}
pub fn build(&self) -> AppTransferCreate<'a> {
AppTransferCreate {
params: AppTransferCreateParams {
app: self.params.app,
recipient: self.params.recipient,
silent: self.params.silent,
},
}
}
}
#[serde_with::skip_serializing_none]
#[derive(Serialize, Clone, Debug)]
pub struct AppTransferCreateParams<'a> {
pub app: &'a str,
pub recipient: &'a str,
pub silent: Option<bool>,
}
impl<'a> HerokuEndpoint<AppTransfer, (), AppTransferCreateParams<'a>> for AppTransferCreate<'a> {
fn method(&self) -> Method {
Method::Post
}
fn path(&self) -> String {
format!("account/app-transfers")
}
fn body(&self) -> Option<AppTransferCreateParams<'a>> {
Some(self.params.clone())
}
}
pub struct AccountCreditCreate<'a> {
pub params: AccountCreditCreateParams<'a>,
}
#[cfg(feature = "builder")]
impl<'a> AccountCreditCreate<'a> {
pub fn new() -> AccountCreditCreate<'a> {
AccountCreditCreate {
params: AccountCreditCreateParams {
code1: None,
code2: None,
},
}
}
pub fn code_1(&mut self, code1: &'a str) -> &mut Self {
self.params.code1 = Some(code1);
self
}
pub fn code_2(&mut self, code2: &'a str) -> &mut Self {
self.params.code2 = Some(code2);
self
}
pub fn build(&self) -> AccountCreditCreate<'a> {
AccountCreditCreate {
params: AccountCreditCreateParams {
code1: self.params.code1,
code2: self.params.code2,
},
}
}
}
#[serde_with::skip_serializing_none]
#[derive(Serialize, Clone, Debug)]
pub struct AccountCreditCreateParams<'a> {
pub code1: Option<&'a str>,
pub code2: Option<&'a str>,
}
impl<'a> HerokuEndpoint<Credit, (), AccountCreditCreateParams<'a>> for AccountCreditCreate<'a> {
fn method(&self) -> Method {
Method::Post
}
fn path(&self) -> String {
format!("account/credits")
}
fn body(&self) -> Option<AccountCreditCreateParams<'a>> {
Some(self.params.clone())
}
}
pub struct PasswordReset<'a> {
pub params: PasswordResetParams<'a>,
}
#[cfg(feature = "builder")]
impl<'a> PasswordReset<'a> {
pub fn new(email: &'a str) -> PasswordReset {
PasswordReset {
params: PasswordResetParams { email },
}
}
}
#[derive(Serialize, Clone, Debug)]
pub struct PasswordResetParams<'a> {
pub email: &'a str, }
impl<'a> HerokuEndpoint<PasswordResetResponse, (), PasswordResetParams<'a>> for PasswordReset<'a> {
fn method(&self) -> Method {
Method::Post
}
fn path(&self) -> String {
format!("password-resets")
}
fn body(&self) -> Option<PasswordResetParams<'a>> {
Some(self.params.clone())
}
}
pub struct PasswordResetConfirm<'a> {
pub password_id: &'a str,
pub params: PasswordResetConfirmParams<'a>,
}
#[cfg(feature = "builder")]
impl<'a> PasswordResetConfirm<'a> {
pub fn new(password_id: &'a str) -> PasswordResetConfirm<'a> {
PasswordResetConfirm {
password_id,
params: PasswordResetConfirmParams {
password: None,
password_confirmation: None,
},
}
}
pub fn password(&mut self, password: &'a str) -> &mut Self {
self.params.password = Some(password);
self
}
pub fn password_confirmation(&mut self, password_confirmation: &'a str) -> &mut Self {
self.params.password_confirmation = Some(password_confirmation);
self
}
pub fn build(&self) -> PasswordResetConfirm<'a> {
PasswordResetConfirm {
password_id: self.password_id,
params: PasswordResetConfirmParams {
password: self.params.password,
password_confirmation: self.params.password_confirmation,
},
}
}
}
#[serde_with::skip_serializing_none]
#[derive(Serialize, Clone, Debug)]
pub struct PasswordResetConfirmParams<'a> {
pub password: Option<&'a str>,
pub password_confirmation: Option<&'a str>,
}
impl<'a> HerokuEndpoint<PasswordResetResponse, (), PasswordResetConfirmParams<'a>>
for PasswordResetConfirm<'a>
{
fn method(&self) -> Method {
Method::Post
}
fn path(&self) -> String {
format!("password-resets/{}/actions/finalize", self.password_id)
}
fn body(&self) -> Option<PasswordResetConfirmParams<'a>> {
Some(self.params.clone())
}
}
pub struct SmsNumberRecover<'a> {
pub account_id: &'a str,
}
#[cfg(feature = "builder")]
impl<'a> SmsNumberRecover<'a> {
pub fn new(account_id: &'a str) -> SmsNumberRecover<'a> {
SmsNumberRecover { account_id }
}
}
impl<'a> HerokuEndpoint<SmsNumber> for SmsNumberRecover<'a> {
fn method(&self) -> Method {
Method::Post
}
fn path(&self) -> String {
format!("users/{}/sms-number/actions/recover", self.account_id)
}
}
pub struct SmsNumberConfirm<'a> {
pub account_id: &'a str,
}
#[cfg(feature = "builder")]
impl<'a> SmsNumberConfirm<'a> {
pub fn new(account_id: &'a str) -> SmsNumberConfirm<'a> {
SmsNumberConfirm { account_id }
}
}
impl<'a> HerokuEndpoint<SmsNumber> for SmsNumberConfirm<'a> {
fn method(&self) -> Method {
Method::Post
}
fn path(&self) -> String {
format!("users/{}/sms-number/actions/confirm", self.account_id)
}
}