-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/profile_specific_fallback_routing
- Loading branch information
Showing
35 changed files
with
3,512 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use common_utils::events::{ApiEventMetric, ApiEventsType}; | ||
|
||
use crate::user::{ConnectAccountRequest, ConnectAccountResponse}; | ||
|
||
impl ApiEventMetric for ConnectAccountResponse { | ||
fn get_api_event_type(&self) -> Option<ApiEventsType> { | ||
Some(ApiEventsType::User { | ||
merchant_id: self.merchant_id.clone(), | ||
user_id: self.user_id.clone(), | ||
}) | ||
} | ||
} | ||
|
||
impl ApiEventMetric for ConnectAccountRequest {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use common_utils::pii; | ||
use masking::Secret; | ||
|
||
#[derive(serde::Deserialize, Debug, Clone, serde::Serialize)] | ||
pub struct ConnectAccountRequest { | ||
pub email: pii::Email, | ||
pub password: Secret<String>, | ||
} | ||
|
||
#[derive(serde::Serialize, Debug, Clone)] | ||
pub struct ConnectAccountResponse { | ||
pub token: Secret<String>, | ||
pub merchant_id: String, | ||
pub name: Secret<String>, | ||
pub email: pii::Email, | ||
pub verification_days_left: Option<i64>, | ||
pub user_role: String, | ||
//this field is added for audit/debug reasons | ||
#[serde(skip_serializing)] | ||
pub user_id: String, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#[cfg(feature = "olap")] | ||
pub const MAX_NAME_LENGTH: usize = 70; | ||
#[cfg(feature = "olap")] | ||
pub const MAX_COMPANY_NAME_LENGTH: usize = 70; | ||
|
||
// USER ROLES | ||
#[cfg(any(feature = "olap", feature = "oltp"))] | ||
pub const ROLE_ID_ORGANIZATION_ADMIN: &str = "org_admin"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
use common_utils::errors::CustomResult; | ||
|
||
use crate::services::ApplicationResponse; | ||
|
||
pub type UserResult<T> = CustomResult<T, UserErrors>; | ||
pub type UserResponse<T> = CustomResult<ApplicationResponse<T>, UserErrors>; | ||
|
||
#[derive(Debug, thiserror::Error)] | ||
pub enum UserErrors { | ||
#[error("User InternalServerError")] | ||
InternalServerError, | ||
#[error("InvalidCredentials")] | ||
InvalidCredentials, | ||
#[error("UserExists")] | ||
UserExists, | ||
#[error("EmailParsingError")] | ||
EmailParsingError, | ||
#[error("NameParsingError")] | ||
NameParsingError, | ||
#[error("PasswordParsingError")] | ||
PasswordParsingError, | ||
#[error("CompanyNameParsingError")] | ||
CompanyNameParsingError, | ||
#[error("MerchantAccountCreationError: {0}")] | ||
MerchantAccountCreationError(String), | ||
#[error("InvalidEmailError")] | ||
InvalidEmailError, | ||
#[error("DuplicateOrganizationId")] | ||
DuplicateOrganizationId, | ||
} | ||
|
||
impl common_utils::errors::ErrorSwitch<api_models::errors::types::ApiErrorResponse> for UserErrors { | ||
fn switch(&self) -> api_models::errors::types::ApiErrorResponse { | ||
use api_models::errors::types::{ApiError, ApiErrorResponse as AER}; | ||
let sub_code = "UR"; | ||
match self { | ||
Self::InternalServerError => { | ||
AER::InternalServerError(ApiError::new("HE", 0, "Something Went Wrong", None)) | ||
} | ||
Self::InvalidCredentials => AER::Unauthorized(ApiError::new( | ||
sub_code, | ||
1, | ||
"Incorrect email or password", | ||
None, | ||
)), | ||
Self::UserExists => AER::BadRequest(ApiError::new( | ||
sub_code, | ||
3, | ||
"An account already exists with this email", | ||
None, | ||
)), | ||
Self::EmailParsingError => { | ||
AER::BadRequest(ApiError::new(sub_code, 7, "Invalid Email", None)) | ||
} | ||
Self::NameParsingError => { | ||
AER::BadRequest(ApiError::new(sub_code, 8, "Invalid Name", None)) | ||
} | ||
Self::PasswordParsingError => { | ||
AER::BadRequest(ApiError::new(sub_code, 9, "Invalid Password", None)) | ||
} | ||
Self::CompanyNameParsingError => { | ||
AER::BadRequest(ApiError::new(sub_code, 14, "Invalid Company Name", None)) | ||
} | ||
Self::MerchantAccountCreationError(error_message) => { | ||
AER::InternalServerError(ApiError::new(sub_code, 15, error_message, None)) | ||
} | ||
Self::InvalidEmailError => { | ||
AER::BadRequest(ApiError::new(sub_code, 16, "Invalid Email", None)) | ||
} | ||
Self::DuplicateOrganizationId => AER::InternalServerError(ApiError::new( | ||
sub_code, | ||
21, | ||
"An Organization with the id already exists", | ||
None, | ||
)), | ||
} | ||
} | ||
} |
Oops, something went wrong.