Skip to content

Commit

Permalink
chore(api): update api bindings (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
hougesen authored Nov 10, 2024
1 parent 8410b28 commit be10165
Show file tree
Hide file tree
Showing 6 changed files with 184 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [Unreleased](https://github.com/i18nhero/cli/compare/v0.0.0...HEAD)

- chore(api): update api bindings [`#72`](https://github.com/i18nhero/cli/pull/72)
- build(cargo-dist): bump to 0.25.1 [`#71`](https://github.com/i18nhero/cli/pull/71)
- fix(pull): check if file exists during git status [`#70`](https://github.com/i18nhero/cli/pull/70)
- build(deps): bump serde from 1.0.213 to 1.0.214 [`#67`](https://github.com/i18nhero/cli/pull/67)
- build(deps): bump reqwest from 0.12.8 to 0.12.9 [`#68`](https://github.com/i18nhero/cli/pull/68)
Expand Down
153 changes: 153 additions & 0 deletions packages/i18nhero/src/codegen/web_api/apis/auth_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ use crate::codegen::web_api::{apis::ResponseContent, models};
use reqwest;
use serde::{Deserialize, Serialize};

/// struct for typed errors of method [`get_non_verified_emails`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetNonVerifiedEmailsError {
Status401(models::GetUserById401Response),
UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`login_with_email`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
Expand Down Expand Up @@ -41,6 +49,66 @@ pub enum RegisterWithEmailError {
UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`resend_email_verification_email`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ResendEmailVerificationEmailError {
Status400(models::GetUserById401Response),
Status401(models::GetUserById401Response),
Status404(models::GetUserById401Response),
UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`verify_email_by_id`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum VerifyEmailByIdError {
Status404(models::GetUserById401Response),
UnknownValue(serde_json::Value),
}

pub async fn get_non_verified_emails(
configuration: &configuration::Configuration,
authorization: &str,
) -> Result<Vec<models::EmailMissingVerification>, Error<GetNonVerifiedEmailsError>> {
let local_var_configuration = configuration;

let local_var_client = &local_var_configuration.client;

let local_var_uri_str = format!(
"{}/auth/emails-missing-verification",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());

if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
local_var_req_builder =
local_var_req_builder.header("authorization", authorization.to_string());

let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;

let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;

if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetNonVerifiedEmailsError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}

pub async fn login_with_email(
configuration: &configuration::Configuration,
email_login_input: models::EmailLoginInput,
Expand Down Expand Up @@ -154,3 +222,88 @@ pub async fn register_with_email(
Err(Error::ResponseError(local_var_error))
}
}

pub async fn resend_email_verification_email(
configuration: &configuration::Configuration,
email_auth_id: &str,
authorization: &str,
) -> Result<(), Error<ResendEmailVerificationEmailError>> {
let local_var_configuration = configuration;

let local_var_client = &local_var_configuration.client;

let local_var_uri_str = format!(
"{}/auth/resend-verification-email/{email_auth_id}",
local_var_configuration.base_path,
email_auth_id = crate::codegen::web_api::apis::urlencode(email_auth_id)
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());

if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
local_var_req_builder =
local_var_req_builder.header("authorization", authorization.to_string());

let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;

let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;

if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
Ok(())
} else {
let local_var_entity: Option<ResendEmailVerificationEmailError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}

pub async fn verify_email_by_id(
configuration: &configuration::Configuration,
id: &str,
) -> Result<(), Error<VerifyEmailByIdError>> {
let local_var_configuration = configuration;

let local_var_client = &local_var_configuration.client;

let local_var_uri_str = format!(
"{}/auth/verify-email/{id}",
local_var_configuration.base_path,
id = crate::codegen::web_api::apis::urlencode(id)
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());

if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}

let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;

let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;

if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
Ok(())
} else {
let local_var_entity: Option<VerifyEmailByIdError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}
2 changes: 1 addition & 1 deletion packages/i18nhero/src/codegen/web_api/apis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String
unimplemented!("Only objects are supported with style=deepObject")
}

pub mod app_api;
pub mod auth_api;
pub mod default_api;
pub mod organization_invites_api;
pub mod organizations_api;
pub mod personal_access_tokens_api;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* @i18nhero/web-api
*
* Api for i18nhero.com
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://openapi-generator.tech
*/

use crate::codegen::web_api::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct EmailMissingVerification {
#[serde(rename = "_id")]
pub _id: String,
#[serde(rename = "email")]
pub email: String,
}

impl EmailMissingVerification {
pub fn new(_id: String, email: String) -> EmailMissingVerification {
EmailMissingVerification { _id, email }
}
}
2 changes: 2 additions & 0 deletions packages/i18nhero/src/codegen/web_api/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ pub mod create_translation_input;
pub use self::create_translation_input::CreateTranslationInput;
pub mod email_login_input;
pub use self::email_login_input::EmailLoginInput;
pub mod email_missing_verification;
pub use self::email_missing_verification::EmailMissingVerification;
pub mod email_register_input;
pub use self::email_register_input::EmailRegisterInput;
pub mod export_project_output;
Expand Down

0 comments on commit be10165

Please sign in to comment.