ForgeFlux/src/auth/application/services/process_authorization_response/command.rs
2024-05-08 15:02:02 +05:30

48 lines
1.1 KiB
Rust

use serde::{Deserialize, Serialize};
use url::Url;
use super::errors::*;
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
pub struct ProcessAuthorizationResponseCommand {
redirect_uri: Option<Url>,
state: String,
code: String,
oauth_provider: String,
}
impl ProcessAuthorizationResponseCommand {
pub fn redirect_uri(&self) -> Option<&Url> {
self.redirect_uri.as_ref()
}
pub fn state(&self) -> &str {
&self.state
}
pub fn oauth_provider(&self) -> &str {
&self.oauth_provider
}
pub fn code(&self) -> &str {
&self.code
}
pub fn new_command(
redirect_uri: Option<Url>,
state: String,
code: String,
oauth_provider: String,
) -> ProcessAuthorizationServiceResult<Self> {
let state = state.trim().to_string();
let oauth_provider = oauth_provider.trim().to_string();
let code = code.trim().to_string();
Ok(Self {
state,
code,
redirect_uri,
oauth_provider,
})
}
}