diff --git a/CHANGELOG.md b/CHANGELOG.md index ad8f512..855b5dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). #### [Unreleased](https://github.com/i18nhero/cli/compare/v0.0.1...HEAD) - chore: bump package version to v0.0.2-dev [`#79`](https://github.com/i18nhero/cli/pull/79) +- refactor: use new public api [`05d1afd`](https://github.com/i18nhero/cli/commit/05d1afda229797809f05eaac8cfb97810ec53413) #### [v0.0.1](https://github.com/i18nhero/cli/compare/v0.0.0...v0.0.1) diff --git a/justfile b/justfile index a76015e..b5d5776 100644 --- a/justfile +++ b/justfile @@ -40,34 +40,22 @@ test-coverage: changelog: npx auto-changelog -u -generate-web-api: - rm -rf web_api - npx @openapitools/openapi-generator-cli generate -g rust -o web_api -i https://web.api.i18nhero.com/docs-json --global-property=modelDocs=false,apiDocs=false - find ./web_api -type f -exec sed -i 's/crate::/crate::codegen::web_api::/g' {} \; - mkdir -p packages/i18nhero/src/codegen/web_api - rm -rf packages/i18nhero/src/codegen/web_api - mv web_api/src/lib.rs web_api/src/mod.rs - mv web_api/src packages/i18nhero/src/codegen/web_api - rm -rf web_api - cargo fmt - update-help: cargo run -p i18nhero-codegen -generate-cli-api: - rm -rf cli_api - npx @openapitools/openapi-generator-cli generate -g rust -o cli_api -i https://cli.api.i18nhero.com/spec --global-property=modelDocs=false,apiDocs=false - find ./cli_api -type f -exec sed -i 's/crate::/crate::codegen::cli_api::/g' {} \; - mkdir -p packages/i18nhero/src/codegen/cli_api - rm -rf packages/i18nhero/src/codegen/cli_api - mv cli_api/src/lib.rs cli_api/src/mod.rs - mv cli_api/src packages/i18nhero/src/codegen/cli_api - rm -rf cli_api +generate-api-bindings: + rm -rf public_api + npx @openapitools/openapi-generator-cli generate -g rust -o public_api -i https://api.i18nhero.com/docs-json --global-property=modelDocs=false,apiDocs=false + find ./public_api -type f -exec sed -i 's/crate::/crate::codegen::public_api::/g' {} \; + mkdir -p packages/i18nhero/src/codegen/public_api + rm -rf packages/i18nhero/src/codegen/public_api + mv public_api/src/lib.rs public_api/src/mod.rs + mv public_api/src packages/i18nhero/src/codegen/public_api + rm -rf public_api cargo fmt precommit: - just generate-cli-api - just generate-web-api + just generate-api-bindings just changelog cargo clean just dist diff --git a/mdsf.json b/mdsf.json index 60affc3..61e8db6 100644 --- a/mdsf.json +++ b/mdsf.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/hougesen/mdsf/main/schemas/v0.2.7/mdsf.schema.json", + "$schema": "https://raw.githubusercontent.com/hougesen/mdsf/main/schemas/v0.3.0/mdsf.schema.json", "languages": { "bash": "shfmt", "fish": "fish_indent", diff --git a/packages/i18nhero/src/codegen/cli_api/apis/configuration.rs b/packages/i18nhero/src/codegen/cli_api/apis/configuration.rs deleted file mode 100644 index 7fbfc8d..0000000 --- a/packages/i18nhero/src/codegen/cli_api/apis/configuration.rs +++ /dev/null @@ -1,48 +0,0 @@ -/* - * @i18nhero/public-api - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 0.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -#[derive(Debug, Clone)] -pub struct Configuration { - pub base_path: String, - pub user_agent: Option, - pub client: reqwest::Client, - pub basic_auth: Option, - pub oauth_access_token: Option, - pub bearer_access_token: Option, - pub api_key: Option, -} - -pub type BasicAuth = (String, Option); - -#[derive(Debug, Clone)] -pub struct ApiKey { - pub prefix: Option, - pub key: String, -} - -impl Configuration { - pub fn new() -> Configuration { - Configuration::default() - } -} - -impl Default for Configuration { - fn default() -> Self { - Configuration { - base_path: "https://api.i18nhero.com".to_owned(), - user_agent: Some("OpenAPI-Generator/0.0.0/rust".to_owned()), - client: reqwest::Client::new(), - basic_auth: None, - oauth_access_token: None, - bearer_access_token: None, - api_key: None, - } - } -} diff --git a/packages/i18nhero/src/codegen/cli_api/apis/default_api.rs b/packages/i18nhero/src/codegen/cli_api/apis/default_api.rs deleted file mode 100644 index 8a647a0..0000000 --- a/packages/i18nhero/src/codegen/cli_api/apis/default_api.rs +++ /dev/null @@ -1,130 +0,0 @@ -/* - * @i18nhero/public-api - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 0.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -use super::{configuration, Error}; -use crate::codegen::cli_api::{apis::ResponseContent, models}; -use reqwest; -use serde::{Deserialize, Serialize}; - -/// struct for typed errors of method [`get_organization_projects`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum GetOrganizationProjectsError { - Status401(models::PersonalAccessTokenNotFoundError), - Status403(models::ForbiddenError), - Status500(models::DatabaseError), - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`get_organizations`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum GetOrganizationsError { - Status401(models::PersonalAccessTokenNotFoundError), - Status500(models::DatabaseError), - UnknownValue(serde_json::Value), -} - -pub async fn get_organization_projects( - configuration: &configuration::Configuration, - x_api_key: &str, - organization_id: &str, -) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/organizations/{organization_id}/projects", - local_var_configuration.base_path, - organization_id = crate::codegen::cli_api::apis::urlencode(organization_id) - ); - 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("x-api-key", x_api_key.to_string()); - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, - }; - local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value); - }; - - 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 = - 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 get_organizations( - configuration: &configuration::Configuration, - x_api_key: &str, -) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/organizations", 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("x-api-key", x_api_key.to_string()); - if let Some(ref local_var_apikey) = local_var_configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, - }; - local_var_req_builder = local_var_req_builder.header("x-api-key", local_var_value); - }; - - 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 = - 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)) - } -} diff --git a/packages/i18nhero/src/codegen/cli_api/models/database_error.rs b/packages/i18nhero/src/codegen/cli_api/models/database_error.rs deleted file mode 100644 index 8f8b87f..0000000 --- a/packages/i18nhero/src/codegen/cli_api/models/database_error.rs +++ /dev/null @@ -1,24 +0,0 @@ -/* - * @i18nhero/public-api - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 0.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -use crate::codegen::cli_api::models; -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct DatabaseError { - #[serde(rename = "message")] - pub message: String, -} - -impl DatabaseError { - pub fn new(message: String) -> DatabaseError { - DatabaseError { message } - } -} diff --git a/packages/i18nhero/src/codegen/cli_api/models/forbidden_error.rs b/packages/i18nhero/src/codegen/cli_api/models/forbidden_error.rs deleted file mode 100644 index 73c49d9..0000000 --- a/packages/i18nhero/src/codegen/cli_api/models/forbidden_error.rs +++ /dev/null @@ -1,24 +0,0 @@ -/* - * @i18nhero/public-api - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 0.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -use crate::codegen::cli_api::models; -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct ForbiddenError { - #[serde(rename = "message")] - pub message: String, -} - -impl ForbiddenError { - pub fn new(message: String) -> ForbiddenError { - ForbiddenError { message } - } -} diff --git a/packages/i18nhero/src/codegen/cli_api/models/mod.rs b/packages/i18nhero/src/codegen/cli_api/models/mod.rs deleted file mode 100644 index 18948c7..0000000 --- a/packages/i18nhero/src/codegen/cli_api/models/mod.rs +++ /dev/null @@ -1,10 +0,0 @@ -pub mod database_error; -pub use self::database_error::DatabaseError; -pub mod forbidden_error; -pub use self::forbidden_error::ForbiddenError; -pub mod organization; -pub use self::organization::Organization; -pub mod personal_access_token_not_found_error; -pub use self::personal_access_token_not_found_error::PersonalAccessTokenNotFoundError; -pub mod project; -pub use self::project::Project; diff --git a/packages/i18nhero/src/codegen/cli_api/models/organization.rs b/packages/i18nhero/src/codegen/cli_api/models/organization.rs deleted file mode 100644 index 55f8c0e..0000000 --- a/packages/i18nhero/src/codegen/cli_api/models/organization.rs +++ /dev/null @@ -1,26 +0,0 @@ -/* - * @i18nhero/public-api - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 0.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -use crate::codegen::cli_api::models; -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct Organization { - #[serde(rename = "_id")] - pub _id: String, - #[serde(rename = "title")] - pub title: String, -} - -impl Organization { - pub fn new(_id: String, title: String) -> Organization { - Organization { _id, title } - } -} diff --git a/packages/i18nhero/src/codegen/cli_api/models/personal_access_token_not_found_error.rs b/packages/i18nhero/src/codegen/cli_api/models/personal_access_token_not_found_error.rs deleted file mode 100644 index 64c5f13..0000000 --- a/packages/i18nhero/src/codegen/cli_api/models/personal_access_token_not_found_error.rs +++ /dev/null @@ -1,24 +0,0 @@ -/* - * @i18nhero/public-api - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 0.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -use crate::codegen::cli_api::models; -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct PersonalAccessTokenNotFoundError { - #[serde(rename = "message")] - pub message: String, -} - -impl PersonalAccessTokenNotFoundError { - pub fn new(message: String) -> PersonalAccessTokenNotFoundError { - PersonalAccessTokenNotFoundError { message } - } -} diff --git a/packages/i18nhero/src/codegen/cli_api/models/project.rs b/packages/i18nhero/src/codegen/cli_api/models/project.rs deleted file mode 100644 index e12c602..0000000 --- a/packages/i18nhero/src/codegen/cli_api/models/project.rs +++ /dev/null @@ -1,26 +0,0 @@ -/* - * @i18nhero/public-api - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 0.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -use crate::codegen::cli_api::models; -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct Project { - #[serde(rename = "_id")] - pub _id: String, - #[serde(rename = "title")] - pub title: String, -} - -impl Project { - pub fn new(_id: String, title: String) -> Project { - Project { _id, title } - } -} diff --git a/packages/i18nhero/src/codegen/mod.rs b/packages/i18nhero/src/codegen/mod.rs index e586688..07ba78b 100644 --- a/packages/i18nhero/src/codegen/mod.rs +++ b/packages/i18nhero/src/codegen/mod.rs @@ -1,9 +1,6 @@ #[allow(clippy::all)] #[allow(dead_code)] -pub mod cli_api; -#[allow(clippy::all)] -#[allow(dead_code)] -pub mod web_api; +pub mod public_api; #[inline] fn default_user_agent() -> String { @@ -12,27 +9,14 @@ fn default_user_agent() -> String { format!("@i18nhero/cli/v{package_version} +http://i18nhero.com") } -const DEFAULT_CLI_API_HOST: &str = "https://cli.api.i18nhero.com"; - -#[inline] -pub fn setup_web_api_configuration( - host: Option, -) -> web_api::apis::configuration::Configuration { - web_api::apis::configuration::Configuration { - base_path: host.unwrap_or_else(|| DEFAULT_WEB_API_HOST.to_owned()), - user_agent: Some(default_user_agent()), - ..Default::default() - } -} - -const DEFAULT_WEB_API_HOST: &str = "https://web.api.i18nhero.com"; +const DEFAULT_API_HOST: &str = "https://api.i18nhero.com"; #[inline] -pub fn setup_cli_api_configuration( +pub fn setup_api_configuration( host: Option, -) -> cli_api::apis::configuration::Configuration { - cli_api::apis::configuration::Configuration { - base_path: host.unwrap_or_else(|| DEFAULT_CLI_API_HOST.to_owned()), +) -> public_api::apis::configuration::Configuration { + public_api::apis::configuration::Configuration { + base_path: host.unwrap_or_else(|| DEFAULT_API_HOST.to_owned()), user_agent: Some(default_user_agent()), ..Default::default() } diff --git a/packages/i18nhero/src/codegen/web_api/apis/configuration.rs b/packages/i18nhero/src/codegen/public_api/apis/configuration.rs similarity index 89% rename from packages/i18nhero/src/codegen/web_api/apis/configuration.rs rename to packages/i18nhero/src/codegen/public_api/apis/configuration.rs index 67d8716..9885671 100644 --- a/packages/i18nhero/src/codegen/web_api/apis/configuration.rs +++ b/packages/i18nhero/src/codegen/public_api/apis/configuration.rs @@ -1,7 +1,7 @@ /* - * @i18nhero/web-api + * @i18nhero/public-api * - * Api for i18nhero.com + * Public api for i18nhero.com * * The version of the OpenAPI document: 1.0.0 * @@ -36,7 +36,7 @@ impl Configuration { impl Default for Configuration { fn default() -> Self { Configuration { - base_path: "https://web.api.i18nhero.com".to_owned(), + base_path: "https://api.i18nhero.com".to_owned(), user_agent: Some("OpenAPI-Generator/1.0.0/rust".to_owned()), client: reqwest::Client::new(), basic_auth: None, diff --git a/packages/i18nhero/src/codegen/cli_api/apis/mod.rs b/packages/i18nhero/src/codegen/public_api/apis/mod.rs similarity index 98% rename from packages/i18nhero/src/codegen/cli_api/apis/mod.rs rename to packages/i18nhero/src/codegen/public_api/apis/mod.rs index 3abf5ce..5a038a9 100644 --- a/packages/i18nhero/src/codegen/cli_api/apis/mod.rs +++ b/packages/i18nhero/src/codegen/public_api/apis/mod.rs @@ -92,6 +92,7 @@ pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String unimplemented!("Only objects are supported with style=deepObject") } -pub mod default_api; +pub mod organizations_api; +pub mod projects_api; pub mod configuration; diff --git a/packages/i18nhero/src/codegen/web_api/apis/users_api.rs b/packages/i18nhero/src/codegen/public_api/apis/organizations_api.rs similarity index 65% rename from packages/i18nhero/src/codegen/web_api/apis/users_api.rs rename to packages/i18nhero/src/codegen/public_api/apis/organizations_api.rs index 712f586..0610c31 100644 --- a/packages/i18nhero/src/codegen/web_api/apis/users_api.rs +++ b/packages/i18nhero/src/codegen/public_api/apis/organizations_api.rs @@ -1,7 +1,7 @@ /* - * @i18nhero/web-api + * @i18nhero/public-api * - * Api for i18nhero.com + * Public api for i18nhero.com * * The version of the OpenAPI document: 1.0.0 * @@ -9,47 +9,51 @@ */ use super::{configuration, Error}; -use crate::codegen::web_api::{apis::ResponseContent, models}; +use crate::codegen::public_api::{apis::ResponseContent, models}; use reqwest; use serde::{Deserialize, Serialize}; -/// struct for typed errors of method [`get_organizations_by_user_id`] +/// struct for typed errors of method [`get_organization_by_id`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum GetOrganizationsByUserIdError { - Status401(models::GetUserById401Response), +pub enum GetOrganizationByIdError { + Status400(models::GetOrganizations403Response), + Status403(models::GetOrganizations403Response), + Status404(models::GetOrganizations403Response), UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`get_user_by_id`] +/// struct for typed errors of method [`get_organization_projects`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum GetUserByIdError { - Status401(models::GetUserById401Response), +pub enum GetOrganizationProjectsError { + Status400(models::GetOrganizations403Response), + Status403(models::GetOrganizations403Response), + Status404(models::GetOrganizations403Response), UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`leave_organization`] +/// struct for typed errors of method [`get_organizations`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum LeaveOrganizationError { - Status401(models::GetUserById401Response), +pub enum GetOrganizationsError { + Status403(models::GetOrganizations403Response), UnknownValue(serde_json::Value), } -pub async fn get_organizations_by_user_id( +pub async fn get_organization_by_id( configuration: &configuration::Configuration, - user_id: &str, - authorization: &str, -) -> Result, Error> { + x_api_key: &str, + organization_id: &str, +) -> Result> { let local_var_configuration = configuration; let local_var_client = &local_var_configuration.client; let local_var_uri_str = format!( - "{}/users/{user_id}/organizations", + "{}/organizations/{organization_id}", local_var_configuration.base_path, - user_id = crate::codegen::web_api::apis::urlencode(user_id) + organization_id = crate::codegen::public_api::apis::urlencode(organization_id) ); let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); @@ -58,8 +62,7 @@ pub async fn get_organizations_by_user_id( 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()); + local_var_req_builder = local_var_req_builder.header("x-api-key", x_api_key.to_string()); let local_var_req = local_var_req_builder.build()?; let local_var_resp = local_var_client.execute(local_var_req).await?; @@ -70,7 +73,7 @@ pub async fn get_organizations_by_user_id( 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 = + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_error = ResponseContent { status: local_var_status, @@ -81,19 +84,19 @@ pub async fn get_organizations_by_user_id( } } -pub async fn get_user_by_id( +pub async fn get_organization_projects( configuration: &configuration::Configuration, - user_id: &str, - authorization: &str, -) -> Result> { + x_api_key: &str, + organization_id: &str, +) -> Result, Error> { let local_var_configuration = configuration; let local_var_client = &local_var_configuration.client; let local_var_uri_str = format!( - "{}/users/{user_id}", + "{}/organizations/{organization_id}/projects", local_var_configuration.base_path, - user_id = crate::codegen::web_api::apis::urlencode(user_id) + organization_id = crate::codegen::public_api::apis::urlencode(organization_id) ); let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); @@ -102,8 +105,7 @@ pub async fn get_user_by_id( 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()); + local_var_req_builder = local_var_req_builder.header("x-api-key", x_api_key.to_string()); let local_var_req = local_var_req_builder.build()?; let local_var_resp = local_var_client.execute(local_var_req).await?; @@ -114,7 +116,7 @@ pub async fn get_user_by_id( 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 = + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_error = ResponseContent { status: local_var_status, @@ -125,31 +127,23 @@ pub async fn get_user_by_id( } } -pub async fn leave_organization( +pub async fn get_organizations( configuration: &configuration::Configuration, - user_id: &str, - organization_id: &str, - authorization: &str, -) -> Result<(), Error> { + x_api_key: &str, +) -> Result, Error> { let local_var_configuration = configuration; let local_var_client = &local_var_configuration.client; - let local_var_uri_str = format!( - "{}/users/{user_id}/organizations/{organization_id}/leave", - local_var_configuration.base_path, - user_id = crate::codegen::web_api::apis::urlencode(user_id), - organization_id = crate::codegen::web_api::apis::urlencode(organization_id) - ); + let local_var_uri_str = format!("{}/organizations", local_var_configuration.base_path); let mut local_var_req_builder = - local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + 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()); + local_var_req_builder = local_var_req_builder.header("x-api-key", x_api_key.to_string()); let local_var_req = local_var_req_builder.build()?; let local_var_resp = local_var_client.execute(local_var_req).await?; @@ -158,9 +152,9 @@ pub async fn leave_organization( let local_var_content = local_var_resp.text().await?; if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - Ok(()) + serde_json::from_str(&local_var_content).map_err(Error::from) } else { - let local_var_entity: Option = + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_error = ResponseContent { status: local_var_status, diff --git a/packages/i18nhero/src/codegen/web_api/apis/webhooks_api.rs b/packages/i18nhero/src/codegen/public_api/apis/projects_api.rs similarity index 62% rename from packages/i18nhero/src/codegen/web_api/apis/webhooks_api.rs rename to packages/i18nhero/src/codegen/public_api/apis/projects_api.rs index 72e3b0c..92b2601 100644 --- a/packages/i18nhero/src/codegen/web_api/apis/webhooks_api.rs +++ b/packages/i18nhero/src/codegen/public_api/apis/projects_api.rs @@ -1,7 +1,7 @@ /* - * @i18nhero/web-api + * @i18nhero/public-api * - * Api for i18nhero.com + * Public api for i18nhero.com * * The version of the OpenAPI document: 1.0.0 * @@ -9,60 +9,62 @@ */ use super::{configuration, Error}; -use crate::codegen::web_api::{apis::ResponseContent, models}; +use crate::codegen::public_api::{apis::ResponseContent, models}; use reqwest; use serde::{Deserialize, Serialize}; -/// struct for typed errors of method [`delete_project_webhook_by_id`] +/// struct for typed errors of method [`get_project_by_id`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum DeleteProjectWebhookByIdError { - Status401(models::GetUserById401Response), - Status404(models::GetUserById401Response), +pub enum GetProjectByIdError { + Status400(models::GetOrganizations403Response), + Status403(models::GetOrganizations403Response), + Status404(models::GetOrganizations403Response), UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`get_project_webhook_by_id`] +/// struct for typed errors of method [`pull_project`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum GetProjectWebhookByIdError { - Status401(models::GetUserById401Response), - Status404(models::GetUserById401Response), +pub enum PullProjectError { + Status400(models::GetOrganizations403Response), + Status403(models::GetOrganizations403Response), + Status404(models::GetOrganizations403Response), UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`update_project_webhook_by_id`] +/// struct for typed errors of method [`push_locales_to_project`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] -pub enum UpdateProjectWebhookByIdError { - Status401(models::GetUserById401Response), - Status404(models::GetUserById401Response), +pub enum PushLocalesToProjectError { + Status400(models::GetOrganizations403Response), + Status403(models::GetOrganizations403Response), + Status404(models::GetOrganizations403Response), UnknownValue(serde_json::Value), } -pub async fn delete_project_webhook_by_id( +pub async fn get_project_by_id( configuration: &configuration::Configuration, - project_webhook_id: &str, - authorization: &str, -) -> Result<(), Error> { + x_api_key: &str, + project_id: &str, +) -> Result> { let local_var_configuration = configuration; let local_var_client = &local_var_configuration.client; let local_var_uri_str = format!( - "{}/webhooks/project/{project_webhook_id}", + "{}/projects/{project_id}", local_var_configuration.base_path, - project_webhook_id = crate::codegen::web_api::apis::urlencode(project_webhook_id) + project_id = crate::codegen::public_api::apis::urlencode(project_id) ); let mut local_var_req_builder = - local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + 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()); + local_var_req_builder = local_var_req_builder.header("x-api-key", x_api_key.to_string()); let local_var_req = local_var_req_builder.build()?; let local_var_resp = local_var_client.execute(local_var_req).await?; @@ -71,9 +73,9 @@ pub async fn delete_project_webhook_by_id( let local_var_content = local_var_resp.text().await?; if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - Ok(()) + serde_json::from_str(&local_var_content).map_err(Error::from) } else { - let local_var_entity: Option = + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_error = ResponseContent { status: local_var_status, @@ -84,29 +86,30 @@ pub async fn delete_project_webhook_by_id( } } -pub async fn get_project_webhook_by_id( +pub async fn pull_project( configuration: &configuration::Configuration, - project_webhook_id: &str, - authorization: &str, -) -> Result> { + project_id: &str, + x_api_key: &str, + partial_export_project_config_input: models::PartialExportProjectConfigInput, +) -> Result, Error> { let local_var_configuration = configuration; let local_var_client = &local_var_configuration.client; let local_var_uri_str = format!( - "{}/webhooks/project/{project_webhook_id}", + "{}/projects/{project_id}/pull", local_var_configuration.base_path, - project_webhook_id = crate::codegen::web_api::apis::urlencode(project_webhook_id) + project_id = crate::codegen::public_api::apis::urlencode(project_id) ); let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + 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()); + local_var_req_builder = local_var_req_builder.header("x-api-key", x_api_key.to_string()); + local_var_req_builder = local_var_req_builder.json(&partial_export_project_config_input); let local_var_req = local_var_req_builder.build()?; let local_var_resp = local_var_client.execute(local_var_req).await?; @@ -117,7 +120,7 @@ pub async fn get_project_webhook_by_id( 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 = + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_error = ResponseContent { status: local_var_status, @@ -128,20 +131,20 @@ pub async fn get_project_webhook_by_id( } } -pub async fn update_project_webhook_by_id( +pub async fn push_locales_to_project( configuration: &configuration::Configuration, - project_webhook_id: &str, - authorization: &str, - update_project_webhook_input: models::UpdateProjectWebhookInput, -) -> Result> { + project_id: &str, + x_api_key: &str, + push_locale_input: models::PushLocaleInput, +) -> Result> { let local_var_configuration = configuration; let local_var_client = &local_var_configuration.client; let local_var_uri_str = format!( - "{}/webhooks/project/{project_webhook_id}", + "{}/projects/{project_id}/push", local_var_configuration.base_path, - project_webhook_id = crate::codegen::web_api::apis::urlencode(project_webhook_id) + project_id = crate::codegen::public_api::apis::urlencode(project_id) ); let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); @@ -150,9 +153,8 @@ pub async fn update_project_webhook_by_id( 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()); - local_var_req_builder = local_var_req_builder.json(&update_project_webhook_input); + local_var_req_builder = local_var_req_builder.header("x-api-key", x_api_key.to_string()); + local_var_req_builder = local_var_req_builder.json(&push_locale_input); let local_var_req = local_var_req_builder.build()?; let local_var_resp = local_var_client.execute(local_var_req).await?; @@ -163,7 +165,7 @@ pub async fn update_project_webhook_by_id( 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 = + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); let local_var_error = ResponseContent { status: local_var_status, diff --git a/packages/i18nhero/src/codegen/cli_api/mod.rs b/packages/i18nhero/src/codegen/public_api/mod.rs similarity index 100% rename from packages/i18nhero/src/codegen/cli_api/mod.rs rename to packages/i18nhero/src/codegen/public_api/mod.rs diff --git a/packages/i18nhero/src/codegen/web_api/models/export_project_output.rs b/packages/i18nhero/src/codegen/public_api/models/export_project_output.rs similarity index 89% rename from packages/i18nhero/src/codegen/web_api/models/export_project_output.rs rename to packages/i18nhero/src/codegen/public_api/models/export_project_output.rs index 4d6928b..80c3d52 100644 --- a/packages/i18nhero/src/codegen/web_api/models/export_project_output.rs +++ b/packages/i18nhero/src/codegen/public_api/models/export_project_output.rs @@ -1,14 +1,14 @@ /* - * @i18nhero/web-api + * @i18nhero/public-api * - * Api for i18nhero.com + * Public 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 crate::codegen::public_api::models; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/packages/i18nhero/src/codegen/web_api/models/file_format.rs b/packages/i18nhero/src/codegen/public_api/models/file_format.rs similarity index 87% rename from packages/i18nhero/src/codegen/web_api/models/file_format.rs rename to packages/i18nhero/src/codegen/public_api/models/file_format.rs index 7e43ab5..d29d4fc 100644 --- a/packages/i18nhero/src/codegen/web_api/models/file_format.rs +++ b/packages/i18nhero/src/codegen/public_api/models/file_format.rs @@ -1,14 +1,14 @@ /* - * @i18nhero/web-api + * @i18nhero/public-api * - * Api for i18nhero.com + * Public 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 crate::codegen::public_api::models; use serde::{Deserialize, Serialize}; /// diff --git a/packages/i18nhero/src/codegen/web_api/models/get_user_by_id_401_response.rs b/packages/i18nhero/src/codegen/public_api/models/get_organizations_403_response.rs similarity index 58% rename from packages/i18nhero/src/codegen/web_api/models/get_user_by_id_401_response.rs rename to packages/i18nhero/src/codegen/public_api/models/get_organizations_403_response.rs index 8a4462c..445409e 100644 --- a/packages/i18nhero/src/codegen/web_api/models/get_user_by_id_401_response.rs +++ b/packages/i18nhero/src/codegen/public_api/models/get_organizations_403_response.rs @@ -1,27 +1,27 @@ /* - * @i18nhero/web-api + * @i18nhero/public-api * - * Api for i18nhero.com + * Public 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 crate::codegen::public_api::models; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct GetUserById401Response { +pub struct GetOrganizations403Response { #[serde(rename = "message")] pub message: String, #[serde(rename = "statusCode")] pub status_code: f64, } -impl GetUserById401Response { - pub fn new(message: String, status_code: f64) -> GetUserById401Response { - GetUserById401Response { +impl GetOrganizations403Response { + pub fn new(message: String, status_code: f64) -> GetOrganizations403Response { + GetOrganizations403Response { message, status_code, } diff --git a/packages/i18nhero/src/codegen/public_api/models/mod.rs b/packages/i18nhero/src/codegen/public_api/models/mod.rs new file mode 100644 index 0000000..19ded40 --- /dev/null +++ b/packages/i18nhero/src/codegen/public_api/models/mod.rs @@ -0,0 +1,20 @@ +pub mod export_project_output; +pub use self::export_project_output::ExportProjectOutput; +pub mod file_format; +pub use self::file_format::FileFormat; +pub mod get_organizations_403_response; +pub use self::get_organizations_403_response::GetOrganizations403Response; +pub mod organization; +pub use self::organization::Organization; +pub mod partial_export_project_config_input; +pub use self::partial_export_project_config_input::PartialExportProjectConfigInput; +pub mod project; +pub use self::project::Project; +pub mod project_localization; +pub use self::project_localization::ProjectLocalization; +pub mod push_locale_input; +pub use self::push_locale_input::PushLocaleInput; +pub mod push_locale_input_file; +pub use self::push_locale_input_file::PushLocaleInputFile; +pub mod push_locale_result; +pub use self::push_locale_result::PushLocaleResult; diff --git a/packages/i18nhero/src/codegen/web_api/models/organization.rs b/packages/i18nhero/src/codegen/public_api/models/organization.rs similarity index 69% rename from packages/i18nhero/src/codegen/web_api/models/organization.rs rename to packages/i18nhero/src/codegen/public_api/models/organization.rs index ebb11cf..a864f92 100644 --- a/packages/i18nhero/src/codegen/web_api/models/organization.rs +++ b/packages/i18nhero/src/codegen/public_api/models/organization.rs @@ -1,20 +1,18 @@ /* - * @i18nhero/web-api + * @i18nhero/public-api * - * Api for i18nhero.com + * Public 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 crate::codegen::public_api::models; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct Organization { - #[serde(rename = "users")] - pub users: Vec, #[serde(rename = "_id")] pub _id: String, #[serde(rename = "title")] @@ -25,28 +23,22 @@ pub struct Organization { pub created_at: String, #[serde(rename = "modified_at")] pub modified_at: String, - #[serde(rename = "deleted_at", deserialize_with = "Option::deserialize")] - pub deleted_at: Option, } impl Organization { pub fn new( - users: Vec, _id: String, title: String, allow_ai_translations: bool, created_at: String, modified_at: String, - deleted_at: Option, ) -> Organization { Organization { - users, _id, title, allow_ai_translations, created_at, modified_at, - deleted_at, } } } diff --git a/packages/i18nhero/src/codegen/web_api/models/partial_export_project_config_input.rs b/packages/i18nhero/src/codegen/public_api/models/partial_export_project_config_input.rs similarity index 89% rename from packages/i18nhero/src/codegen/web_api/models/partial_export_project_config_input.rs rename to packages/i18nhero/src/codegen/public_api/models/partial_export_project_config_input.rs index 0d5bca5..4465cc0 100644 --- a/packages/i18nhero/src/codegen/web_api/models/partial_export_project_config_input.rs +++ b/packages/i18nhero/src/codegen/public_api/models/partial_export_project_config_input.rs @@ -1,14 +1,14 @@ /* - * @i18nhero/web-api + * @i18nhero/public-api * - * Api for i18nhero.com + * Public 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 crate::codegen::public_api::models; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/packages/i18nhero/src/codegen/web_api/models/project.rs b/packages/i18nhero/src/codegen/public_api/models/project.rs similarity index 87% rename from packages/i18nhero/src/codegen/web_api/models/project.rs rename to packages/i18nhero/src/codegen/public_api/models/project.rs index 38768f2..df48194 100644 --- a/packages/i18nhero/src/codegen/web_api/models/project.rs +++ b/packages/i18nhero/src/codegen/public_api/models/project.rs @@ -1,14 +1,14 @@ /* - * @i18nhero/web-api + * @i18nhero/public-api * - * Api for i18nhero.com + * Public 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 crate::codegen::public_api::models; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] @@ -35,8 +35,6 @@ pub struct Project { pub created_at: String, #[serde(rename = "modified_at")] pub modified_at: String, - #[serde(rename = "deleted_at", deserialize_with = "Option::deserialize")] - pub deleted_at: Option, } impl Project { @@ -52,7 +50,6 @@ impl Project { allow_ai_translations: bool, created_at: String, modified_at: String, - deleted_at: Option, ) -> Project { Project { localizations, @@ -66,7 +63,6 @@ impl Project { allow_ai_translations, created_at, modified_at, - deleted_at, } } } diff --git a/packages/i18nhero/src/codegen/web_api/models/project_localization.rs b/packages/i18nhero/src/codegen/public_api/models/project_localization.rs similarity index 89% rename from packages/i18nhero/src/codegen/web_api/models/project_localization.rs rename to packages/i18nhero/src/codegen/public_api/models/project_localization.rs index f3b5cb3..ecd4dcf 100644 --- a/packages/i18nhero/src/codegen/web_api/models/project_localization.rs +++ b/packages/i18nhero/src/codegen/public_api/models/project_localization.rs @@ -1,14 +1,14 @@ /* - * @i18nhero/web-api + * @i18nhero/public-api * - * Api for i18nhero.com + * Public 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 crate::codegen::public_api::models; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/packages/i18nhero/src/codegen/web_api/models/push_locale_input.rs b/packages/i18nhero/src/codegen/public_api/models/push_locale_input.rs similarity index 83% rename from packages/i18nhero/src/codegen/web_api/models/push_locale_input.rs rename to packages/i18nhero/src/codegen/public_api/models/push_locale_input.rs index 8f0e586..ced2cf1 100644 --- a/packages/i18nhero/src/codegen/web_api/models/push_locale_input.rs +++ b/packages/i18nhero/src/codegen/public_api/models/push_locale_input.rs @@ -1,14 +1,14 @@ /* - * @i18nhero/web-api + * @i18nhero/public-api * - * Api for i18nhero.com + * Public 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 crate::codegen::public_api::models; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/packages/i18nhero/src/codegen/web_api/models/push_locale_input_file.rs b/packages/i18nhero/src/codegen/public_api/models/push_locale_input_file.rs similarity index 88% rename from packages/i18nhero/src/codegen/web_api/models/push_locale_input_file.rs rename to packages/i18nhero/src/codegen/public_api/models/push_locale_input_file.rs index cf96df4..5721094 100644 --- a/packages/i18nhero/src/codegen/web_api/models/push_locale_input_file.rs +++ b/packages/i18nhero/src/codegen/public_api/models/push_locale_input_file.rs @@ -1,14 +1,14 @@ /* - * @i18nhero/web-api + * @i18nhero/public-api * - * Api for i18nhero.com + * Public 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 crate::codegen::public_api::models; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/packages/i18nhero/src/codegen/web_api/models/push_locale_result.rs b/packages/i18nhero/src/codegen/public_api/models/push_locale_result.rs similarity index 84% rename from packages/i18nhero/src/codegen/web_api/models/push_locale_result.rs rename to packages/i18nhero/src/codegen/public_api/models/push_locale_result.rs index 26ac403..4fcfab4 100644 --- a/packages/i18nhero/src/codegen/web_api/models/push_locale_result.rs +++ b/packages/i18nhero/src/codegen/public_api/models/push_locale_result.rs @@ -1,14 +1,14 @@ /* - * @i18nhero/web-api + * @i18nhero/public-api * - * Api for i18nhero.com + * Public 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 crate::codegen::public_api::models; use serde::{Deserialize, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] diff --git a/packages/i18nhero/src/codegen/web_api/apis/app_api.rs b/packages/i18nhero/src/codegen/web_api/apis/app_api.rs deleted file mode 100644 index 14d4e81..0000000 --- a/packages/i18nhero/src/codegen/web_api/apis/app_api.rs +++ /dev/null @@ -1,56 +0,0 @@ -/* - * @i18nhero/web-api - * - * Api for i18nhero.com - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -use super::{configuration, Error}; -use crate::codegen::web_api::{apis::ResponseContent, models}; -use reqwest; -use serde::{Deserialize, Serialize}; - -/// struct for typed errors of method [`get_hello`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum GetHelloError { - UnknownValue(serde_json::Value), -} - -pub async fn get_hello( - configuration: &configuration::Configuration, -) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/", 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()); - } - - 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 = 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)) - } -} diff --git a/packages/i18nhero/src/codegen/web_api/apis/auth_api.rs b/packages/i18nhero/src/codegen/web_api/apis/auth_api.rs deleted file mode 100644 index 5275d40..0000000 --- a/packages/i18nhero/src/codegen/web_api/apis/auth_api.rs +++ /dev/null @@ -1,309 +0,0 @@ -/* - * @i18nhero/web-api - * - * Api for i18nhero.com - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -use super::{configuration, Error}; -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)] -pub enum LoginWithEmailError { - Status400(models::GetUserById401Response), - Status404(models::GetUserById401Response), - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`refresh_auth_tokens`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum RefreshAuthTokensError { - Status400(models::GetUserById401Response), - Status404(models::GetUserById401Response), - Status418(models::GetUserById401Response), - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`register_with_email`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum RegisterWithEmailError { - Status400(models::GetUserById401Response), - Status409(models::GetUserById401Response), - 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, Error> { - 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 = - 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, -) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/auth/login/email", local_var_configuration.base_path); - 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.json(&email_login_input); - - 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 = - 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 refresh_auth_tokens( - configuration: &configuration::Configuration, - refresh_auth_tokens_input: models::RefreshAuthTokensInput, -) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/auth/refresh", local_var_configuration.base_path); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::POST, 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.json(&refresh_auth_tokens_input); - - 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 = - 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 register_with_email( - configuration: &configuration::Configuration, - email_register_input: models::EmailRegisterInput, -) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/auth/register/email", local_var_configuration.base_path); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::POST, 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.json(&email_register_input); - - 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 = - 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 resend_email_verification_email( - configuration: &configuration::Configuration, - email_auth_id: &str, - authorization: &str, -) -> Result<(), Error> { - 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 = - 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> { - 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 = - 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)) - } -} diff --git a/packages/i18nhero/src/codegen/web_api/apis/mod.rs b/packages/i18nhero/src/codegen/web_api/apis/mod.rs deleted file mode 100644 index 81c5f0b..0000000 --- a/packages/i18nhero/src/codegen/web_api/apis/mod.rs +++ /dev/null @@ -1,105 +0,0 @@ -use std::error; -use std::fmt; - -#[derive(Debug, Clone)] -pub struct ResponseContent { - pub status: reqwest::StatusCode, - pub content: String, - pub entity: Option, -} - -#[derive(Debug)] -pub enum Error { - Reqwest(reqwest::Error), - Serde(serde_json::Error), - Io(std::io::Error), - ResponseError(ResponseContent), -} - -impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let (module, e) = match self { - Error::Reqwest(e) => ("reqwest", e.to_string()), - Error::Serde(e) => ("serde", e.to_string()), - Error::Io(e) => ("IO", e.to_string()), - Error::ResponseError(e) => ("response", format!("status code {}", e.status)), - }; - write!(f, "error in {}: {}", module, e) - } -} - -impl error::Error for Error { - fn source(&self) -> Option<&(dyn error::Error + 'static)> { - Some(match self { - Error::Reqwest(e) => e, - Error::Serde(e) => e, - Error::Io(e) => e, - Error::ResponseError(_) => return None, - }) - } -} - -impl From for Error { - fn from(e: reqwest::Error) -> Self { - Error::Reqwest(e) - } -} - -impl From for Error { - fn from(e: serde_json::Error) -> Self { - Error::Serde(e) - } -} - -impl From for Error { - fn from(e: std::io::Error) -> Self { - Error::Io(e) - } -} - -pub fn urlencode>(s: T) -> String { - ::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect() -} - -pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String, String)> { - if let serde_json::Value::Object(object) = value { - let mut params = vec![]; - - for (key, value) in object { - match value { - serde_json::Value::Object(_) => params.append(&mut parse_deep_object( - &format!("{}[{}]", prefix, key), - value, - )), - serde_json::Value::Array(array) => { - for (i, value) in array.iter().enumerate() { - params.append(&mut parse_deep_object( - &format!("{}[{}][{}]", prefix, key, i), - value, - )); - } - } - serde_json::Value::String(s) => { - params.push((format!("{}[{}]", prefix, key), s.clone())) - } - _ => params.push((format!("{}[{}]", prefix, key), value.to_string())), - } - } - - return params; - } - - unimplemented!("Only objects are supported with style=deepObject") -} - -pub mod app_api; -pub mod auth_api; -pub mod organization_invites_api; -pub mod organizations_api; -pub mod personal_access_tokens_api; -pub mod projects_api; -pub mod translations_api; -pub mod users_api; -pub mod webhooks_api; - -pub mod configuration; diff --git a/packages/i18nhero/src/codegen/web_api/apis/organization_invites_api.rs b/packages/i18nhero/src/codegen/web_api/apis/organization_invites_api.rs deleted file mode 100644 index ffa16ca..0000000 --- a/packages/i18nhero/src/codegen/web_api/apis/organization_invites_api.rs +++ /dev/null @@ -1,66 +0,0 @@ -/* - * @i18nhero/web-api - * - * Api for i18nhero.com - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -use super::{configuration, Error}; -use crate::codegen::web_api::{apis::ResponseContent, models}; -use reqwest; -use serde::{Deserialize, Serialize}; - -/// struct for typed errors of method [`delete_organization_invite_by_id`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum DeleteOrganizationInviteByIdError { - Status401(models::GetUserById401Response), - UnknownValue(serde_json::Value), -} - -pub async fn delete_organization_invite_by_id( - configuration: &configuration::Configuration, - invite_id: &str, - authorization: &str, -) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/organization-invites/{invite_id}", - local_var_configuration.base_path, - invite_id = crate::codegen::web_api::apis::urlencode(invite_id) - ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::DELETE, 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 = - 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)) - } -} diff --git a/packages/i18nhero/src/codegen/web_api/apis/organizations_api.rs b/packages/i18nhero/src/codegen/web_api/apis/organizations_api.rs deleted file mode 100644 index 2e3c7b7..0000000 --- a/packages/i18nhero/src/codegen/web_api/apis/organizations_api.rs +++ /dev/null @@ -1,485 +0,0 @@ -/* - * @i18nhero/web-api - * - * Api for i18nhero.com - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -use super::{configuration, Error}; -use crate::codegen::web_api::{apis::ResponseContent, models}; -use reqwest; -use serde::{Deserialize, Serialize}; - -/// struct for typed errors of method [`create_organization`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CreateOrganizationError { - Status401(models::GetUserById401Response), - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`get_organization_by_id`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum GetOrganizationByIdError { - Status401(models::GetUserById401Response), - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`get_organization_members`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum GetOrganizationMembersError { - Status401(models::GetUserById401Response), - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`get_organization_project_overview`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum GetOrganizationProjectOverviewError { - Status401(models::GetUserById401Response), - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`get_pending_organization_invites`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum GetPendingOrganizationInvitesError { - Status401(models::GetUserById401Response), - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`get_projects_by_organization_id`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum GetProjectsByOrganizationIdError { - Status401(models::GetUserById401Response), - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`invite_user_to_organization`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum InviteUserToOrganizationError { - Status401(models::GetUserById401Response), - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`remove_user_from_organization`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum RemoveUserFromOrganizationError { - Status401(models::GetUserById401Response), - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`update_organization_by_id`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum UpdateOrganizationByIdError { - Status401(models::GetUserById401Response), - UnknownValue(serde_json::Value), -} - -pub async fn create_organization( - configuration: &configuration::Configuration, - authorization: &str, - create_organization_input: models::CreateOrganizationInput, -) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/organizations", local_var_configuration.base_path); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::POST, 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()); - local_var_req_builder = local_var_req_builder.json(&create_organization_input); - - 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 = - 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 get_organization_by_id( - configuration: &configuration::Configuration, - organization_id: &str, - authorization: &str, -) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/organizations/{organization_id}", - local_var_configuration.base_path, - organization_id = crate::codegen::web_api::apis::urlencode(organization_id) - ); - 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 = - 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 get_organization_members( - configuration: &configuration::Configuration, - organization_id: &str, - authorization: &str, -) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/organizations/{organization_id}/users", - local_var_configuration.base_path, - organization_id = crate::codegen::web_api::apis::urlencode(organization_id) - ); - 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 = - 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 get_organization_project_overview( - configuration: &configuration::Configuration, - organization_id: &str, - authorization: &str, -) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/organizations/{organization_id}/overview/projects", - local_var_configuration.base_path, - organization_id = crate::codegen::web_api::apis::urlencode(organization_id) - ); - 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 = - 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 get_pending_organization_invites( - configuration: &configuration::Configuration, - organization_id: &str, - authorization: &str, -) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/organizations/{organization_id}/invites", - local_var_configuration.base_path, - organization_id = crate::codegen::web_api::apis::urlencode(organization_id) - ); - 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 = - 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 get_projects_by_organization_id( - configuration: &configuration::Configuration, - organization_id: &str, - authorization: &str, -) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/organizations/{organization_id}/projects", - local_var_configuration.base_path, - organization_id = crate::codegen::web_api::apis::urlencode(organization_id) - ); - 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 = - 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 invite_user_to_organization( - configuration: &configuration::Configuration, - organization_id: &str, - authorization: &str, - create_organization_invite_input: models::CreateOrganizationInviteInput, -) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/organizations/{organization_id}/invites", - local_var_configuration.base_path, - organization_id = crate::codegen::web_api::apis::urlencode(organization_id) - ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::POST, 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()); - local_var_req_builder = local_var_req_builder.json(&create_organization_invite_input); - - 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 = - 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 remove_user_from_organization( - configuration: &configuration::Configuration, - organization_id: &str, - user_id: &str, - authorization: &str, -) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/organizations/{organization_id}/users/{user_id}/remove", - local_var_configuration.base_path, - organization_id = crate::codegen::web_api::apis::urlencode(organization_id), - user_id = crate::codegen::web_api::apis::urlencode(user_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 = - 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 update_organization_by_id( - configuration: &configuration::Configuration, - organization_id: &str, - authorization: &str, - update_organization_input: models::UpdateOrganizationInput, -) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/organizations/{organization_id}", - local_var_configuration.base_path, - organization_id = crate::codegen::web_api::apis::urlencode(organization_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()); - local_var_req_builder = local_var_req_builder.json(&update_organization_input); - - 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 = - 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)) - } -} diff --git a/packages/i18nhero/src/codegen/web_api/apis/personal_access_tokens_api.rs b/packages/i18nhero/src/codegen/web_api/apis/personal_access_tokens_api.rs deleted file mode 100644 index cb78466..0000000 --- a/packages/i18nhero/src/codegen/web_api/apis/personal_access_tokens_api.rs +++ /dev/null @@ -1,168 +0,0 @@ -/* - * @i18nhero/web-api - * - * Api for i18nhero.com - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -use super::{configuration, Error}; -use crate::codegen::web_api::{apis::ResponseContent, models}; -use reqwest; -use serde::{Deserialize, Serialize}; - -/// struct for typed errors of method [`create_personal_access_token`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CreatePersonalAccessTokenError { - Status401(models::GetUserById401Response), - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`get_personal_access_tokens`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum GetPersonalAccessTokensError { - Status401(models::GetUserById401Response), - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`invalidate_personal_access_token_by_id`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum InvalidatePersonalAccessTokenByIdError { - Status401(models::GetUserById401Response), - UnknownValue(serde_json::Value), -} - -pub async fn create_personal_access_token( - configuration: &configuration::Configuration, - authorization: &str, - create_personal_access_token_input: models::CreatePersonalAccessTokenInput, -) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/personal-access-tokens", - local_var_configuration.base_path - ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::POST, 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()); - local_var_req_builder = local_var_req_builder.json(&create_personal_access_token_input); - - 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 = - 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 get_personal_access_tokens( - configuration: &configuration::Configuration, - authorization: &str, -) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/personal-access-tokens", - 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 = - 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 invalidate_personal_access_token_by_id( - configuration: &configuration::Configuration, - key_id: &str, - authorization: &str, -) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/personal-access-tokens/{key_id}", - local_var_configuration.base_path, - key_id = crate::codegen::web_api::apis::urlencode(key_id) - ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::DELETE, 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 = - 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)) - } -} diff --git a/packages/i18nhero/src/codegen/web_api/apis/projects_api.rs b/packages/i18nhero/src/codegen/web_api/apis/projects_api.rs deleted file mode 100644 index ac15035..0000000 --- a/packages/i18nhero/src/codegen/web_api/apis/projects_api.rs +++ /dev/null @@ -1,591 +0,0 @@ -/* - * @i18nhero/web-api - * - * Api for i18nhero.com - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -use super::{configuration, Error}; -use crate::codegen::web_api::{apis::ResponseContent, models}; -use reqwest; -use serde::{Deserialize, Serialize}; - -/// struct for typed errors of method [`create_project`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CreateProjectError { - Status401(models::GetUserById401Response), - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`create_project_webhook`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CreateProjectWebhookError { - Status401(models::GetUserById401Response), - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`create_translation`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CreateTranslationError { - Status401(models::GetUserById401Response), - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`download_project`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum DownloadProjectError { - Status401(models::GetUserById401Response), - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`get_project_by_id`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum GetProjectByIdError { - Status401(models::GetUserById401Response), - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`get_project_metrics`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum GetProjectMetricsError { - Status401(models::GetUserById401Response), - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`get_project_translations`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum GetProjectTranslationsError { - Status401(models::GetUserById401Response), - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`get_project_webhooks`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum GetProjectWebhooksError { - Status401(models::GetUserById401Response), - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`pull_project`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum PullProjectError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`push_locales_to_project`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum PushLocalesToProjectError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`update_project_by_id`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum UpdateProjectByIdError { - Status401(models::GetUserById401Response), - UnknownValue(serde_json::Value), -} - -pub async fn create_project( - configuration: &configuration::Configuration, - authorization: &str, - create_project_input: models::CreateProjectInput, -) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/projects", local_var_configuration.base_path); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::POST, 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()); - local_var_req_builder = local_var_req_builder.json(&create_project_input); - - 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 = - 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 create_project_webhook( - configuration: &configuration::Configuration, - project_id: &str, - authorization: &str, - create_project_webhook_input: models::CreateProjectWebhookInput, -) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/projects/{project_id}/webhooks", - local_var_configuration.base_path, - project_id = crate::codegen::web_api::apis::urlencode(project_id) - ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::POST, 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()); - local_var_req_builder = local_var_req_builder.json(&create_project_webhook_input); - - 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 = - 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 create_translation( - configuration: &configuration::Configuration, - project_id: &str, - authorization: &str, - create_translation_input: models::CreateTranslationInput, -) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/projects/{project_id}/translations", - local_var_configuration.base_path, - project_id = crate::codegen::web_api::apis::urlencode(project_id) - ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::POST, 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()); - local_var_req_builder = local_var_req_builder.json(&create_translation_input); - - 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 = - 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 download_project( - configuration: &configuration::Configuration, - project_id: &str, - authorization: &str, - partial_export_project_config_input: models::PartialExportProjectConfigInput, -) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/projects/{project_id}/download", - local_var_configuration.base_path, - project_id = crate::codegen::web_api::apis::urlencode(project_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()); - local_var_req_builder = local_var_req_builder.json(&partial_export_project_config_input); - - 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 = - 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 get_project_by_id( - configuration: &configuration::Configuration, - project_id: &str, - authorization: &str, -) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/projects/{project_id}", - local_var_configuration.base_path, - project_id = crate::codegen::web_api::apis::urlencode(project_id) - ); - 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 = - 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 get_project_metrics( - configuration: &configuration::Configuration, - project_id: &str, - authorization: &str, -) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/projects/{project_id}/metrics", - local_var_configuration.base_path, - project_id = crate::codegen::web_api::apis::urlencode(project_id) - ); - 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 = - 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 get_project_translations( - configuration: &configuration::Configuration, - project_id: &str, - authorization: &str, -) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/projects/{project_id}/translations", - local_var_configuration.base_path, - project_id = crate::codegen::web_api::apis::urlencode(project_id) - ); - 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 = - 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 get_project_webhooks( - configuration: &configuration::Configuration, - project_id: &str, - authorization: &str, -) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/projects/{project_id}/webhooks", - local_var_configuration.base_path, - project_id = crate::codegen::web_api::apis::urlencode(project_id) - ); - 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 = - 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 pull_project( - configuration: &configuration::Configuration, - project_id: &str, - x_api_key: &str, - partial_export_project_config_input: models::PartialExportProjectConfigInput, -) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/projects/{project_id}/pull", - local_var_configuration.base_path, - project_id = crate::codegen::web_api::apis::urlencode(project_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("x-api-key", x_api_key.to_string()); - local_var_req_builder = local_var_req_builder.json(&partial_export_project_config_input); - - 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 = - 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 push_locales_to_project( - configuration: &configuration::Configuration, - project_id: &str, - x_api_key: &str, - push_locale_input: models::PushLocaleInput, -) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/projects/{project_id}/push", - local_var_configuration.base_path, - project_id = crate::codegen::web_api::apis::urlencode(project_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("x-api-key", x_api_key.to_string()); - local_var_req_builder = local_var_req_builder.json(&push_locale_input); - - 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 = - 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 update_project_by_id( - configuration: &configuration::Configuration, - project_id: &str, - authorization: &str, - update_project_input: models::UpdateProjectInput, -) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/projects/{project_id}", - local_var_configuration.base_path, - project_id = crate::codegen::web_api::apis::urlencode(project_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()); - local_var_req_builder = local_var_req_builder.json(&update_project_input); - - 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 = - 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)) - } -} diff --git a/packages/i18nhero/src/codegen/web_api/apis/translations_api.rs b/packages/i18nhero/src/codegen/web_api/apis/translations_api.rs deleted file mode 100644 index 880aac9..0000000 --- a/packages/i18nhero/src/codegen/web_api/apis/translations_api.rs +++ /dev/null @@ -1,280 +0,0 @@ -/* - * @i18nhero/web-api - * - * Api for i18nhero.com - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -use super::{configuration, Error}; -use crate::codegen::web_api::{apis::ResponseContent, models}; -use reqwest; -use serde::{Deserialize, Serialize}; - -/// struct for typed errors of method [`delete_translation_by_id`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum DeleteTranslationByIdError { - Status401(models::GetUserById401Response), - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`get_translation_by_id`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum GetTranslationByIdError { - Status401(models::GetUserById401Response), - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`translate_using_ai`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum TranslateUsingAiError { - Status401(models::GetUserById401Response), - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`update_translation_by_id`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum UpdateTranslationByIdError { - Status401(models::GetUserById401Response), - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`update_translation_locale`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum UpdateTranslationLocaleError { - Status401(models::GetUserById401Response), - UnknownValue(serde_json::Value), -} - -pub async fn delete_translation_by_id( - configuration: &configuration::Configuration, - translation_id: &str, - authorization: &str, -) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/translations/{translation_id}", - local_var_configuration.base_path, - translation_id = crate::codegen::web_api::apis::urlencode(translation_id) - ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::DELETE, 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 = - 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 get_translation_by_id( - configuration: &configuration::Configuration, - translation_id: &str, - authorization: &str, -) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/translations/{translation_id}", - local_var_configuration.base_path, - translation_id = crate::codegen::web_api::apis::urlencode(translation_id) - ); - 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 = - 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 translate_using_ai( - configuration: &configuration::Configuration, - translation_id: &str, - authorization: &str, - translate_ai_input: models::TranslateAiInput, -) -> Result, Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/translations/{translation_id}/ai", - local_var_configuration.base_path, - translation_id = crate::codegen::web_api::apis::urlencode(translation_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()); - } - local_var_req_builder = - local_var_req_builder.header("authorization", authorization.to_string()); - local_var_req_builder = local_var_req_builder.json(&translate_ai_input); - - 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 = - 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 update_translation_by_id( - configuration: &configuration::Configuration, - translation_id: &str, - authorization: &str, - update_translation_input: models::UpdateTranslationInput, -) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/translations/{translation_id}", - local_var_configuration.base_path, - translation_id = crate::codegen::web_api::apis::urlencode(translation_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()); - local_var_req_builder = local_var_req_builder.json(&update_translation_input); - - 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 = - 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 update_translation_locale( - configuration: &configuration::Configuration, - translation_id: &str, - authorization: &str, - update_translation_locale_input: models::UpdateTranslationLocaleInput, -) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/translations/{translation_id}", - local_var_configuration.base_path, - translation_id = crate::codegen::web_api::apis::urlencode(translation_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()); - } - local_var_req_builder = - local_var_req_builder.header("authorization", authorization.to_string()); - local_var_req_builder = local_var_req_builder.json(&update_translation_locale_input); - - 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 = - 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)) - } -} diff --git a/packages/i18nhero/src/codegen/web_api/mod.rs b/packages/i18nhero/src/codegen/web_api/mod.rs deleted file mode 100644 index 9556a0a..0000000 --- a/packages/i18nhero/src/codegen/web_api/mod.rs +++ /dev/null @@ -1,11 +0,0 @@ -#![allow(unused_imports)] -#![allow(clippy::too_many_arguments)] - -extern crate reqwest; -extern crate serde; -extern crate serde_json; -extern crate serde_repr; -extern crate url; - -pub mod apis; -pub mod models; diff --git a/packages/i18nhero/src/codegen/web_api/models/auth_tokens.rs b/packages/i18nhero/src/codegen/web_api/models/auth_tokens.rs deleted file mode 100644 index 007bada..0000000 --- a/packages/i18nhero/src/codegen/web_api/models/auth_tokens.rs +++ /dev/null @@ -1,29 +0,0 @@ -/* - * @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 AuthTokens { - #[serde(rename = "access_token")] - pub access_token: String, - #[serde(rename = "refresh_token")] - pub refresh_token: String, -} - -impl AuthTokens { - pub fn new(access_token: String, refresh_token: String) -> AuthTokens { - AuthTokens { - access_token, - refresh_token, - } - } -} diff --git a/packages/i18nhero/src/codegen/web_api/models/create_organization_input.rs b/packages/i18nhero/src/codegen/web_api/models/create_organization_input.rs deleted file mode 100644 index bed3a64..0000000 --- a/packages/i18nhero/src/codegen/web_api/models/create_organization_input.rs +++ /dev/null @@ -1,24 +0,0 @@ -/* - * @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 CreateOrganizationInput { - #[serde(rename = "title")] - pub title: String, -} - -impl CreateOrganizationInput { - pub fn new(title: String) -> CreateOrganizationInput { - CreateOrganizationInput { title } - } -} diff --git a/packages/i18nhero/src/codegen/web_api/models/create_organization_invite_input.rs b/packages/i18nhero/src/codegen/web_api/models/create_organization_invite_input.rs deleted file mode 100644 index 8331d42..0000000 --- a/packages/i18nhero/src/codegen/web_api/models/create_organization_invite_input.rs +++ /dev/null @@ -1,24 +0,0 @@ -/* - * @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 CreateOrganizationInviteInput { - #[serde(rename = "email")] - pub email: String, -} - -impl CreateOrganizationInviteInput { - pub fn new(email: String) -> CreateOrganizationInviteInput { - CreateOrganizationInviteInput { email } - } -} diff --git a/packages/i18nhero/src/codegen/web_api/models/create_personal_access_token_input.rs b/packages/i18nhero/src/codegen/web_api/models/create_personal_access_token_input.rs deleted file mode 100644 index 56af9e1..0000000 --- a/packages/i18nhero/src/codegen/web_api/models/create_personal_access_token_input.rs +++ /dev/null @@ -1,24 +0,0 @@ -/* - * @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 CreatePersonalAccessTokenInput { - #[serde(rename = "description")] - pub description: String, -} - -impl CreatePersonalAccessTokenInput { - pub fn new(description: String) -> CreatePersonalAccessTokenInput { - CreatePersonalAccessTokenInput { description } - } -} diff --git a/packages/i18nhero/src/codegen/web_api/models/create_project_input.rs b/packages/i18nhero/src/codegen/web_api/models/create_project_input.rs deleted file mode 100644 index 3f92707..0000000 --- a/packages/i18nhero/src/codegen/web_api/models/create_project_input.rs +++ /dev/null @@ -1,44 +0,0 @@ -/* - * @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 CreateProjectInput { - #[serde(rename = "localizations")] - pub localizations: Vec, - #[serde(rename = "title")] - pub title: String, - #[serde(rename = "organization_id")] - pub organization_id: String, - #[serde(rename = "description")] - pub description: String, - #[serde(rename = "is_public")] - pub is_public: bool, -} - -impl CreateProjectInput { - pub fn new( - localizations: Vec, - title: String, - organization_id: String, - description: String, - is_public: bool, - ) -> CreateProjectInput { - CreateProjectInput { - localizations, - title, - organization_id, - description, - is_public, - } - } -} diff --git a/packages/i18nhero/src/codegen/web_api/models/create_project_input_localization.rs b/packages/i18nhero/src/codegen/web_api/models/create_project_input_localization.rs deleted file mode 100644 index db7f152..0000000 --- a/packages/i18nhero/src/codegen/web_api/models/create_project_input_localization.rs +++ /dev/null @@ -1,36 +0,0 @@ -/* - * @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 CreateProjectInputLocalization { - #[serde(rename = "language_code")] - pub language_code: String, - #[serde(rename = "country_code", deserialize_with = "Option::deserialize")] - pub country_code: Option, - #[serde(rename = "enabled")] - pub enabled: bool, -} - -impl CreateProjectInputLocalization { - pub fn new( - language_code: String, - country_code: Option, - enabled: bool, - ) -> CreateProjectInputLocalization { - CreateProjectInputLocalization { - language_code, - country_code, - enabled, - } - } -} diff --git a/packages/i18nhero/src/codegen/web_api/models/create_project_webhook_input.rs b/packages/i18nhero/src/codegen/web_api/models/create_project_webhook_input.rs deleted file mode 100644 index fb6108a..0000000 --- a/packages/i18nhero/src/codegen/web_api/models/create_project_webhook_input.rs +++ /dev/null @@ -1,40 +0,0 @@ -/* - * @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 CreateProjectWebhookInput { - #[serde(rename = "triggers")] - pub triggers: Vec, - #[serde(rename = "description")] - pub description: String, - #[serde(rename = "url")] - pub url: String, - #[serde(rename = "enabled")] - pub enabled: bool, -} - -impl CreateProjectWebhookInput { - pub fn new( - triggers: Vec, - description: String, - url: String, - enabled: bool, - ) -> CreateProjectWebhookInput { - CreateProjectWebhookInput { - triggers, - description, - url, - enabled, - } - } -} diff --git a/packages/i18nhero/src/codegen/web_api/models/create_translation_input.rs b/packages/i18nhero/src/codegen/web_api/models/create_translation_input.rs deleted file mode 100644 index a531acc..0000000 --- a/packages/i18nhero/src/codegen/web_api/models/create_translation_input.rs +++ /dev/null @@ -1,36 +0,0 @@ -/* - * @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 CreateTranslationInput { - #[serde(rename = "locales")] - pub locales: std::collections::HashMap, - #[serde(rename = "identifier")] - pub identifier: String, - #[serde(rename = "description")] - pub description: String, -} - -impl CreateTranslationInput { - pub fn new( - locales: std::collections::HashMap, - identifier: String, - description: String, - ) -> CreateTranslationInput { - CreateTranslationInput { - locales, - identifier, - description, - } - } -} diff --git a/packages/i18nhero/src/codegen/web_api/models/email_login_input.rs b/packages/i18nhero/src/codegen/web_api/models/email_login_input.rs deleted file mode 100644 index 4337a65..0000000 --- a/packages/i18nhero/src/codegen/web_api/models/email_login_input.rs +++ /dev/null @@ -1,26 +0,0 @@ -/* - * @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 EmailLoginInput { - #[serde(rename = "email")] - pub email: String, - #[serde(rename = "password")] - pub password: String, -} - -impl EmailLoginInput { - pub fn new(email: String, password: String) -> EmailLoginInput { - EmailLoginInput { email, password } - } -} diff --git a/packages/i18nhero/src/codegen/web_api/models/email_missing_verification.rs b/packages/i18nhero/src/codegen/web_api/models/email_missing_verification.rs deleted file mode 100644 index d9c1e53..0000000 --- a/packages/i18nhero/src/codegen/web_api/models/email_missing_verification.rs +++ /dev/null @@ -1,26 +0,0 @@ -/* - * @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 } - } -} diff --git a/packages/i18nhero/src/codegen/web_api/models/email_register_input.rs b/packages/i18nhero/src/codegen/web_api/models/email_register_input.rs deleted file mode 100644 index 850a0d6..0000000 --- a/packages/i18nhero/src/codegen/web_api/models/email_register_input.rs +++ /dev/null @@ -1,32 +0,0 @@ -/* - * @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 EmailRegisterInput { - #[serde(rename = "email")] - pub email: String, - #[serde(rename = "password")] - pub password: String, - #[serde(rename = "full_name")] - pub full_name: String, -} - -impl EmailRegisterInput { - pub fn new(email: String, password: String, full_name: String) -> EmailRegisterInput { - EmailRegisterInput { - email, - password, - full_name, - } - } -} diff --git a/packages/i18nhero/src/codegen/web_api/models/mod.rs b/packages/i18nhero/src/codegen/web_api/models/mod.rs deleted file mode 100644 index 046b0f8..0000000 --- a/packages/i18nhero/src/codegen/web_api/models/mod.rs +++ /dev/null @@ -1,80 +0,0 @@ -pub mod auth_tokens; -pub use self::auth_tokens::AuthTokens; -pub mod create_organization_input; -pub use self::create_organization_input::CreateOrganizationInput; -pub mod create_organization_invite_input; -pub use self::create_organization_invite_input::CreateOrganizationInviteInput; -pub mod create_personal_access_token_input; -pub use self::create_personal_access_token_input::CreatePersonalAccessTokenInput; -pub mod create_project_input; -pub use self::create_project_input::CreateProjectInput; -pub mod create_project_input_localization; -pub use self::create_project_input_localization::CreateProjectInputLocalization; -pub mod create_project_webhook_input; -pub use self::create_project_webhook_input::CreateProjectWebhookInput; -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; -pub use self::export_project_output::ExportProjectOutput; -pub mod file_format; -pub use self::file_format::FileFormat; -pub mod get_user_by_id_401_response; -pub use self::get_user_by_id_401_response::GetUserById401Response; -pub mod organization; -pub use self::organization::Organization; -pub mod organization_invite; -pub use self::organization_invite::OrganizationInvite; -pub mod organization_member; -pub use self::organization_member::OrganizationMember; -pub mod organization_project_overview; -pub use self::organization_project_overview::OrganizationProjectOverview; -pub mod organization_user; -pub use self::organization_user::OrganizationUser; -pub mod partial_export_project_config_input; -pub use self::partial_export_project_config_input::PartialExportProjectConfigInput; -pub mod personal_access_token; -pub use self::personal_access_token::PersonalAccessToken; -pub mod project; -pub use self::project::Project; -pub mod project_localization; -pub use self::project_localization::ProjectLocalization; -pub mod project_metrics; -pub use self::project_metrics::ProjectMetrics; -pub mod project_webhook; -pub use self::project_webhook::ProjectWebhook; -pub mod project_webhook_event; -pub use self::project_webhook_event::ProjectWebhookEvent; -pub mod push_locale_input; -pub use self::push_locale_input::PushLocaleInput; -pub mod push_locale_input_file; -pub use self::push_locale_input_file::PushLocaleInputFile; -pub mod push_locale_result; -pub use self::push_locale_result::PushLocaleResult; -pub mod refresh_auth_tokens_input; -pub use self::refresh_auth_tokens_input::RefreshAuthTokensInput; -pub mod translate_ai_input; -pub use self::translate_ai_input::TranslateAiInput; -pub mod translate_ai_result; -pub use self::translate_ai_result::TranslateAiResult; -pub mod translation; -pub use self::translation::Translation; -pub mod update_organization_input; -pub use self::update_organization_input::UpdateOrganizationInput; -pub mod update_project_input; -pub use self::update_project_input::UpdateProjectInput; -pub mod update_project_input_localization; -pub use self::update_project_input_localization::UpdateProjectInputLocalization; -pub mod update_project_webhook_input; -pub use self::update_project_webhook_input::UpdateProjectWebhookInput; -pub mod update_translation_input; -pub use self::update_translation_input::UpdateTranslationInput; -pub mod update_translation_locale_input; -pub use self::update_translation_locale_input::UpdateTranslationLocaleInput; -pub mod user; -pub use self::user::User; diff --git a/packages/i18nhero/src/codegen/web_api/models/organization_invite.rs b/packages/i18nhero/src/codegen/web_api/models/organization_invite.rs deleted file mode 100644 index 76f2a2c..0000000 --- a/packages/i18nhero/src/codegen/web_api/models/organization_invite.rs +++ /dev/null @@ -1,48 +0,0 @@ -/* - * @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 OrganizationInvite { - #[serde(rename = "_id")] - pub _id: String, - #[serde(rename = "email")] - pub email: String, - #[serde(rename = "organization_id")] - pub organization_id: String, - #[serde(rename = "created_at")] - pub created_at: String, - #[serde(rename = "modified_at")] - pub modified_at: String, - #[serde(rename = "deleted_at", deserialize_with = "Option::deserialize")] - pub deleted_at: Option, -} - -impl OrganizationInvite { - pub fn new( - _id: String, - email: String, - organization_id: String, - created_at: String, - modified_at: String, - deleted_at: Option, - ) -> OrganizationInvite { - OrganizationInvite { - _id, - email, - organization_id, - created_at, - modified_at, - deleted_at, - } - } -} diff --git a/packages/i18nhero/src/codegen/web_api/models/organization_member.rs b/packages/i18nhero/src/codegen/web_api/models/organization_member.rs deleted file mode 100644 index 7bc1ab1..0000000 --- a/packages/i18nhero/src/codegen/web_api/models/organization_member.rs +++ /dev/null @@ -1,40 +0,0 @@ -/* - * @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 OrganizationMember { - #[serde(rename = "user_id")] - pub user_id: String, - #[serde(rename = "full_name")] - pub full_name: String, - #[serde(rename = "email")] - pub email: String, - #[serde(rename = "profile_image_url")] - pub profile_image_url: String, -} - -impl OrganizationMember { - pub fn new( - user_id: String, - full_name: String, - email: String, - profile_image_url: String, - ) -> OrganizationMember { - OrganizationMember { - user_id, - full_name, - email, - profile_image_url, - } - } -} diff --git a/packages/i18nhero/src/codegen/web_api/models/organization_project_overview.rs b/packages/i18nhero/src/codegen/web_api/models/organization_project_overview.rs deleted file mode 100644 index 1ea0442..0000000 --- a/packages/i18nhero/src/codegen/web_api/models/organization_project_overview.rs +++ /dev/null @@ -1,29 +0,0 @@ -/* - * @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 OrganizationProjectOverview { - #[serde(rename = "projects")] - pub projects: f64, - #[serde(rename = "total_identifiers")] - pub total_identifiers: f64, -} - -impl OrganizationProjectOverview { - pub fn new(projects: f64, total_identifiers: f64) -> OrganizationProjectOverview { - OrganizationProjectOverview { - projects, - total_identifiers, - } - } -} diff --git a/packages/i18nhero/src/codegen/web_api/models/organization_user.rs b/packages/i18nhero/src/codegen/web_api/models/organization_user.rs deleted file mode 100644 index c1dc769..0000000 --- a/packages/i18nhero/src/codegen/web_api/models/organization_user.rs +++ /dev/null @@ -1,24 +0,0 @@ -/* - * @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 OrganizationUser { - #[serde(rename = "user_id")] - pub user_id: String, -} - -impl OrganizationUser { - pub fn new(user_id: String) -> OrganizationUser { - OrganizationUser { user_id } - } -} diff --git a/packages/i18nhero/src/codegen/web_api/models/personal_access_token.rs b/packages/i18nhero/src/codegen/web_api/models/personal_access_token.rs deleted file mode 100644 index 271b7ab..0000000 --- a/packages/i18nhero/src/codegen/web_api/models/personal_access_token.rs +++ /dev/null @@ -1,44 +0,0 @@ -/* - * @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 PersonalAccessToken { - #[serde(rename = "_id")] - pub _id: String, - #[serde(rename = "secret")] - pub secret: String, - #[serde(rename = "user_id")] - pub user_id: String, - #[serde(rename = "description")] - pub description: String, - #[serde(rename = "created_at")] - pub created_at: String, -} - -impl PersonalAccessToken { - pub fn new( - _id: String, - secret: String, - user_id: String, - description: String, - created_at: String, - ) -> PersonalAccessToken { - PersonalAccessToken { - _id, - secret, - user_id, - description, - created_at, - } - } -} diff --git a/packages/i18nhero/src/codegen/web_api/models/project_metrics.rs b/packages/i18nhero/src/codegen/web_api/models/project_metrics.rs deleted file mode 100644 index eb51b7e..0000000 --- a/packages/i18nhero/src/codegen/web_api/models/project_metrics.rs +++ /dev/null @@ -1,36 +0,0 @@ -/* - * @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 ProjectMetrics { - #[serde(rename = "locales")] - pub locales: std::collections::HashMap, - #[serde(rename = "project_id")] - pub project_id: String, - #[serde(rename = "identifier_count")] - pub identifier_count: f64, -} - -impl ProjectMetrics { - pub fn new( - locales: std::collections::HashMap, - project_id: String, - identifier_count: f64, - ) -> ProjectMetrics { - ProjectMetrics { - locales, - project_id, - identifier_count, - } - } -} diff --git a/packages/i18nhero/src/codegen/web_api/models/project_webhook.rs b/packages/i18nhero/src/codegen/web_api/models/project_webhook.rs deleted file mode 100644 index c0f55df..0000000 --- a/packages/i18nhero/src/codegen/web_api/models/project_webhook.rs +++ /dev/null @@ -1,64 +0,0 @@ -/* - * @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 ProjectWebhook { - #[serde(rename = "triggers")] - pub triggers: Vec, - #[serde(rename = "_id")] - pub _id: String, - #[serde(rename = "organization_id")] - pub organization_id: String, - #[serde(rename = "project_id")] - pub project_id: String, - #[serde(rename = "description")] - pub description: String, - #[serde(rename = "url")] - pub url: String, - #[serde(rename = "enabled")] - pub enabled: bool, - #[serde(rename = "created_at")] - pub created_at: String, - #[serde(rename = "modified_at")] - pub modified_at: String, - #[serde(rename = "deleted_at", deserialize_with = "Option::deserialize")] - pub deleted_at: Option, -} - -impl ProjectWebhook { - pub fn new( - triggers: Vec, - _id: String, - organization_id: String, - project_id: String, - description: String, - url: String, - enabled: bool, - created_at: String, - modified_at: String, - deleted_at: Option, - ) -> ProjectWebhook { - ProjectWebhook { - triggers, - _id, - organization_id, - project_id, - description, - url, - enabled, - created_at, - modified_at, - deleted_at, - } - } -} diff --git a/packages/i18nhero/src/codegen/web_api/models/project_webhook_event.rs b/packages/i18nhero/src/codegen/web_api/models/project_webhook_event.rs deleted file mode 100644 index 6fba40c..0000000 --- a/packages/i18nhero/src/codegen/web_api/models/project_webhook_event.rs +++ /dev/null @@ -1,48 +0,0 @@ -/* - * @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, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] -pub enum ProjectWebhookEvent { - #[serde(rename = "key:created")] - Created, - #[serde(rename = "key:bulk:created")] - BulkColonCreated, - #[serde(rename = "key:updated")] - Updated, - #[serde(rename = "key:bulk:updated")] - BulkColonUpdated, - #[serde(rename = "key:deleted")] - Deleted, - #[serde(rename = "key:bulk:deleted")] - BulkColonDeleted, -} - -impl std::fmt::Display for ProjectWebhookEvent { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - match self { - Self::Created => write!(f, "key:created"), - Self::BulkColonCreated => write!(f, "key:bulk:created"), - Self::Updated => write!(f, "key:updated"), - Self::BulkColonUpdated => write!(f, "key:bulk:updated"), - Self::Deleted => write!(f, "key:deleted"), - Self::BulkColonDeleted => write!(f, "key:bulk:deleted"), - } - } -} - -impl Default for ProjectWebhookEvent { - fn default() -> ProjectWebhookEvent { - Self::Created - } -} diff --git a/packages/i18nhero/src/codegen/web_api/models/refresh_auth_tokens_input.rs b/packages/i18nhero/src/codegen/web_api/models/refresh_auth_tokens_input.rs deleted file mode 100644 index b00db37..0000000 --- a/packages/i18nhero/src/codegen/web_api/models/refresh_auth_tokens_input.rs +++ /dev/null @@ -1,24 +0,0 @@ -/* - * @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 RefreshAuthTokensInput { - #[serde(rename = "refresh_token")] - pub refresh_token: String, -} - -impl RefreshAuthTokensInput { - pub fn new(refresh_token: String) -> RefreshAuthTokensInput { - RefreshAuthTokensInput { refresh_token } - } -} diff --git a/packages/i18nhero/src/codegen/web_api/models/translate_ai_input.rs b/packages/i18nhero/src/codegen/web_api/models/translate_ai_input.rs deleted file mode 100644 index b850ecf..0000000 --- a/packages/i18nhero/src/codegen/web_api/models/translate_ai_input.rs +++ /dev/null @@ -1,24 +0,0 @@ -/* - * @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 TranslateAiInput { - #[serde(rename = "from")] - pub from: String, -} - -impl TranslateAiInput { - pub fn new(from: String) -> TranslateAiInput { - TranslateAiInput { from } - } -} diff --git a/packages/i18nhero/src/codegen/web_api/models/translate_ai_result.rs b/packages/i18nhero/src/codegen/web_api/models/translate_ai_result.rs deleted file mode 100644 index f1f7b83..0000000 --- a/packages/i18nhero/src/codegen/web_api/models/translate_ai_result.rs +++ /dev/null @@ -1,26 +0,0 @@ -/* - * @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 TranslateAiResult { - #[serde(rename = "locale")] - pub locale: String, - #[serde(rename = "translated")] - pub translated: String, -} - -impl TranslateAiResult { - pub fn new(locale: String, translated: String) -> TranslateAiResult { - TranslateAiResult { locale, translated } - } -} diff --git a/packages/i18nhero/src/codegen/web_api/models/translation.rs b/packages/i18nhero/src/codegen/web_api/models/translation.rs deleted file mode 100644 index 458fe64..0000000 --- a/packages/i18nhero/src/codegen/web_api/models/translation.rs +++ /dev/null @@ -1,60 +0,0 @@ -/* - * @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 Translation { - #[serde(rename = "locales")] - pub locales: std::collections::HashMap, - #[serde(rename = "_id")] - pub _id: String, - #[serde(rename = "organization_id")] - pub organization_id: String, - #[serde(rename = "project_id")] - pub project_id: String, - #[serde(rename = "identifier")] - pub identifier: String, - #[serde(rename = "description")] - pub description: String, - #[serde(rename = "created_at")] - pub created_at: String, - #[serde(rename = "modified_at")] - pub modified_at: String, - #[serde(rename = "deleted_at", deserialize_with = "Option::deserialize")] - pub deleted_at: Option, -} - -impl Translation { - pub fn new( - locales: std::collections::HashMap, - _id: String, - organization_id: String, - project_id: String, - identifier: String, - description: String, - created_at: String, - modified_at: String, - deleted_at: Option, - ) -> Translation { - Translation { - locales, - _id, - organization_id, - project_id, - identifier, - description, - created_at, - modified_at, - deleted_at, - } - } -} diff --git a/packages/i18nhero/src/codegen/web_api/models/update_organization_input.rs b/packages/i18nhero/src/codegen/web_api/models/update_organization_input.rs deleted file mode 100644 index 732bbea..0000000 --- a/packages/i18nhero/src/codegen/web_api/models/update_organization_input.rs +++ /dev/null @@ -1,24 +0,0 @@ -/* - * @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 UpdateOrganizationInput { - #[serde(rename = "title")] - pub title: String, -} - -impl UpdateOrganizationInput { - pub fn new(title: String) -> UpdateOrganizationInput { - UpdateOrganizationInput { title } - } -} diff --git a/packages/i18nhero/src/codegen/web_api/models/update_project_input.rs b/packages/i18nhero/src/codegen/web_api/models/update_project_input.rs deleted file mode 100644 index 3c46f11..0000000 --- a/packages/i18nhero/src/codegen/web_api/models/update_project_input.rs +++ /dev/null @@ -1,40 +0,0 @@ -/* - * @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 UpdateProjectInput { - #[serde(rename = "localizations")] - pub localizations: Vec, - #[serde(rename = "title")] - pub title: String, - #[serde(rename = "description")] - pub description: String, - #[serde(rename = "is_public")] - pub is_public: bool, -} - -impl UpdateProjectInput { - pub fn new( - localizations: Vec, - title: String, - description: String, - is_public: bool, - ) -> UpdateProjectInput { - UpdateProjectInput { - localizations, - title, - description, - is_public, - } - } -} diff --git a/packages/i18nhero/src/codegen/web_api/models/update_project_input_localization.rs b/packages/i18nhero/src/codegen/web_api/models/update_project_input_localization.rs deleted file mode 100644 index 991d863..0000000 --- a/packages/i18nhero/src/codegen/web_api/models/update_project_input_localization.rs +++ /dev/null @@ -1,36 +0,0 @@ -/* - * @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 UpdateProjectInputLocalization { - #[serde(rename = "language_code")] - pub language_code: String, - #[serde(rename = "country_code", deserialize_with = "Option::deserialize")] - pub country_code: Option, - #[serde(rename = "enabled")] - pub enabled: bool, -} - -impl UpdateProjectInputLocalization { - pub fn new( - language_code: String, - country_code: Option, - enabled: bool, - ) -> UpdateProjectInputLocalization { - UpdateProjectInputLocalization { - language_code, - country_code, - enabled, - } - } -} diff --git a/packages/i18nhero/src/codegen/web_api/models/update_project_webhook_input.rs b/packages/i18nhero/src/codegen/web_api/models/update_project_webhook_input.rs deleted file mode 100644 index 7e70485..0000000 --- a/packages/i18nhero/src/codegen/web_api/models/update_project_webhook_input.rs +++ /dev/null @@ -1,40 +0,0 @@ -/* - * @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 UpdateProjectWebhookInput { - #[serde(rename = "triggers")] - pub triggers: Vec, - #[serde(rename = "description")] - pub description: String, - #[serde(rename = "url")] - pub url: String, - #[serde(rename = "enabled")] - pub enabled: bool, -} - -impl UpdateProjectWebhookInput { - pub fn new( - triggers: Vec, - description: String, - url: String, - enabled: bool, - ) -> UpdateProjectWebhookInput { - UpdateProjectWebhookInput { - triggers, - description, - url, - enabled, - } - } -} diff --git a/packages/i18nhero/src/codegen/web_api/models/update_translation_input.rs b/packages/i18nhero/src/codegen/web_api/models/update_translation_input.rs deleted file mode 100644 index 114389b..0000000 --- a/packages/i18nhero/src/codegen/web_api/models/update_translation_input.rs +++ /dev/null @@ -1,36 +0,0 @@ -/* - * @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 UpdateTranslationInput { - #[serde(rename = "locales")] - pub locales: std::collections::HashMap, - #[serde(rename = "identifier")] - pub identifier: String, - #[serde(rename = "description")] - pub description: String, -} - -impl UpdateTranslationInput { - pub fn new( - locales: std::collections::HashMap, - identifier: String, - description: String, - ) -> UpdateTranslationInput { - UpdateTranslationInput { - locales, - identifier, - description, - } - } -} diff --git a/packages/i18nhero/src/codegen/web_api/models/update_translation_locale_input.rs b/packages/i18nhero/src/codegen/web_api/models/update_translation_locale_input.rs deleted file mode 100644 index 687b6ad..0000000 --- a/packages/i18nhero/src/codegen/web_api/models/update_translation_locale_input.rs +++ /dev/null @@ -1,26 +0,0 @@ -/* - * @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 UpdateTranslationLocaleInput { - #[serde(rename = "locale")] - pub locale: String, - #[serde(rename = "value")] - pub value: String, -} - -impl UpdateTranslationLocaleInput { - pub fn new(locale: String, value: String) -> UpdateTranslationLocaleInput { - UpdateTranslationLocaleInput { locale, value } - } -} diff --git a/packages/i18nhero/src/codegen/web_api/models/user.rs b/packages/i18nhero/src/codegen/web_api/models/user.rs deleted file mode 100644 index 714b7b6..0000000 --- a/packages/i18nhero/src/codegen/web_api/models/user.rs +++ /dev/null @@ -1,44 +0,0 @@ -/* - * @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 User { - #[serde(rename = "_id")] - pub _id: String, - #[serde(rename = "full_name")] - pub full_name: String, - #[serde(rename = "created_at")] - pub created_at: String, - #[serde(rename = "modified_at")] - pub modified_at: String, - #[serde(rename = "deleted_at", deserialize_with = "Option::deserialize")] - pub deleted_at: Option, -} - -impl User { - pub fn new( - _id: String, - full_name: String, - created_at: String, - modified_at: String, - deleted_at: Option, - ) -> User { - User { - _id, - full_name, - created_at, - modified_at, - deleted_at, - } - } -} diff --git a/packages/i18nhero/src/commands/init.rs b/packages/i18nhero/src/commands/init.rs index e8a0d31..89c7184 100644 --- a/packages/i18nhero/src/commands/init.rs +++ b/packages/i18nhero/src/commands/init.rs @@ -7,5 +7,5 @@ pub struct InitCommandArguments { pub overwrite: bool, #[arg(long, hide = true)] - pub cli_api_host: Option, + pub api_host: Option, } diff --git a/packages/i18nhero/src/commands/pull.rs b/packages/i18nhero/src/commands/pull.rs index b6f2a0b..cf0f7e1 100644 --- a/packages/i18nhero/src/commands/pull.rs +++ b/packages/i18nhero/src/commands/pull.rs @@ -13,5 +13,5 @@ pub struct PullCommandArguments { pub api_key: Option, #[arg(long, hide = true)] - pub web_api_host: Option, + pub api_host: Option, } diff --git a/packages/i18nhero/src/commands/push.rs b/packages/i18nhero/src/commands/push.rs index 29f1e2b..d546564 100644 --- a/packages/i18nhero/src/commands/push.rs +++ b/packages/i18nhero/src/commands/push.rs @@ -7,5 +7,5 @@ pub struct PushCommandArguments { pub api_key: Option, #[arg(long, hide = true)] - pub web_api_host: Option, + pub api_host: Option, } diff --git a/packages/i18nhero/src/config/mod.rs b/packages/i18nhero/src/config/mod.rs index 5707a23..4f81cf8 100644 --- a/packages/i18nhero/src/config/mod.rs +++ b/packages/i18nhero/src/config/mod.rs @@ -1,6 +1,6 @@ use json_comments::{CommentSettings, StripComments}; -use crate::{codegen::web_api::models::FileFormat, error::CliError}; +use crate::{codegen::public_api::models::FileFormat, error::CliError}; pub const CONFIG_PATH: &str = "i18nhero.json"; diff --git a/packages/i18nhero/src/error/mod.rs b/packages/i18nhero/src/error/mod.rs index a374d29..f39c16c 100644 --- a/packages/i18nhero/src/error/mod.rs +++ b/packages/i18nhero/src/error/mod.rs @@ -4,12 +4,12 @@ use crate::codegen; pub enum CliError { Io(std::io::Error), PushLocaleHttp( - codegen::web_api::apis::Error< - codegen::web_api::apis::projects_api::PushLocalesToProjectError, + codegen::public_api::apis::Error< + codegen::public_api::apis::projects_api::PushLocalesToProjectError, >, ), PullLocaleHttp( - codegen::web_api::apis::Error, + codegen::public_api::apis::Error, ), ConfigAlreadyExists, MissingProjectId, @@ -27,11 +27,13 @@ pub enum CliError { AuthConfigSave(std::io::Error), AuthConfigLoad(std::io::Error), GetOrganizations( - codegen::cli_api::apis::Error, + codegen::public_api::apis::Error< + codegen::public_api::apis::organizations_api::GetOrganizationsError, + >, ), GetOrganizationProjects( - codegen::cli_api::apis::Error< - codegen::cli_api::apis::default_api::GetOrganizationProjectsError, + codegen::public_api::apis::Error< + codegen::public_api::apis::organizations_api::GetOrganizationProjectsError, >, ), diff --git a/packages/i18nhero/src/init/mod.rs b/packages/i18nhero/src/init/mod.rs index a6eadf0..3a4103d 100644 --- a/packages/i18nhero/src/init/mod.rs +++ b/packages/i18nhero/src/init/mod.rs @@ -2,7 +2,7 @@ use dialoguer::{theme::ColorfulTheme, Select}; use crate::{ auth::AuthConfig, - codegen::{self, setup_cli_api_configuration}, + codegen::{self, setup_api_configuration}, commands::init::InitCommandArguments, config::{CliConfig, CliConfigOutputFormat, CONFIG_PATH}, error::CliError, @@ -11,17 +11,17 @@ use crate::{ #[inline] async fn get_organizations( - configuration: &codegen::cli_api::apis::configuration::Configuration, + configuration: &codegen::public_api::apis::configuration::Configuration, api_key: &str, -) -> Result, CliError> { - codegen::cli_api::apis::default_api::get_organizations(configuration, api_key) +) -> Result, CliError> { + codegen::public_api::apis::organizations_api::get_organizations(configuration, api_key) .await .map_err(CliError::GetOrganizations) } #[inline] fn select_organization( - organizations: &Vec, + organizations: &Vec, ) -> Result { let mut options = Vec::with_capacity(organizations.len()); @@ -38,11 +38,11 @@ fn select_organization( #[inline] async fn get_organization_projects( - configuration: &codegen::cli_api::apis::configuration::Configuration, + configuration: &codegen::public_api::apis::configuration::Configuration, api_key: &str, organization_id: &str, -) -> Result, CliError> { - codegen::cli_api::apis::default_api::get_organization_projects( +) -> Result, CliError> { + codegen::public_api::apis::organizations_api::get_organization_projects( configuration, api_key, organization_id, @@ -53,7 +53,7 @@ async fn get_organization_projects( #[inline] fn select_project( - projects: &Vec, + projects: &Vec, ) -> Result { let mut options = Vec::with_capacity(projects.len()); @@ -97,9 +97,9 @@ pub async fn run(arguments: &InitCommandArguments) -> Result<(), CliError> { let auth = AuthConfig::load()?; - let cli_api_config = setup_cli_api_configuration(arguments.cli_api_host.clone()); + let api_config = setup_api_configuration(arguments.api_host.clone()); - let organizations = get_organizations(&cli_api_config, &auth.api_key).await?; + let organizations = get_organizations(&api_config, &auth.api_key).await?; if organizations.is_empty() { return Err(CliError::NoConnectedOrganizations); @@ -111,8 +111,7 @@ pub async fn run(arguments: &InitCommandArguments) -> Result<(), CliError> { let selected_organization = organizations.get(organization_index).unwrap(); let projects = - get_organization_projects(&cli_api_config, &auth.api_key, &selected_organization._id) - .await?; + get_organization_projects(&api_config, &auth.api_key, &selected_organization._id).await?; if projects.is_empty() { return Err(CliError::NoAvailableProjects(( diff --git a/packages/i18nhero/src/pull/mod.rs b/packages/i18nhero/src/pull/mod.rs index ad34f6b..f232f73 100644 --- a/packages/i18nhero/src/pull/mod.rs +++ b/packages/i18nhero/src/pull/mod.rs @@ -3,11 +3,11 @@ use path_absolutize::Absolutize; use crate::{ auth::AuthConfig, codegen::{ - setup_web_api_configuration, - web_api::{ + public_api::{ self, models::{ExportProjectOutput, FileFormat, PartialExportProjectConfigInput}, }, + setup_api_configuration, }, commands::pull::PullCommandArguments, config::{CliConfig, CliConfigOutput, CliConfigOutputFormat}, @@ -17,7 +17,7 @@ use crate::{ #[inline] async fn fetch_locales( - web_api_config: &web_api::apis::configuration::Configuration, + api_config: &public_api::apis::configuration::Configuration, api_key: &str, project_id: &str, flags: &CliConfigOutput, @@ -28,7 +28,7 @@ async fn fetch_locales( keep_empty_fields: flags.keep_empty_fields, }; - web_api::apis::projects_api::pull_project(web_api_config, project_id, api_key, body) + public_api::apis::projects_api::pull_project(api_config, project_id, api_key, body) .await .map_err(CliError::PullLocaleHttp) } @@ -143,9 +143,9 @@ pub async fn run(arguments: &PullCommandArguments, config: &CliConfig) -> Result AuthConfig::load()?.api_key }; - let web_api_config = setup_web_api_configuration(arguments.web_api_host.clone()); + let api_config = setup_api_configuration(arguments.api_host.clone()); - let locales = fetch_locales(&web_api_config, &auth, &config.project_id, &config.output).await?; + let locales = fetch_locales(&api_config, &auth, &config.project_id, &config.output).await?; save_locales(config, locales).await } diff --git a/packages/i18nhero/src/push/mod.rs b/packages/i18nhero/src/push/mod.rs index 20a27cf..cc66ebd 100644 --- a/packages/i18nhero/src/push/mod.rs +++ b/packages/i18nhero/src/push/mod.rs @@ -1,11 +1,11 @@ use crate::{ auth::AuthConfig, codegen::{ - setup_web_api_configuration, - web_api::{ + public_api::{ self, models::{FileFormat, PushLocaleInput, PushLocaleInputFile}, }, + setup_api_configuration, }, commands::push::PushCommandArguments, config::{CliConfig, CliConfigOutputFormat}, @@ -45,13 +45,13 @@ fn read_locales( #[inline] async fn upload_locales( - web_api_config: &web_api::apis::configuration::Configuration, + api_config: &public_api::apis::configuration::Configuration, api_key: &str, project_id: &str, locales: Vec, -) -> Result { - web_api::apis::projects_api::push_locales_to_project( - web_api_config, +) -> Result { + public_api::apis::projects_api::push_locales_to_project( + api_config, project_id, api_key, PushLocaleInput { files: locales }, @@ -66,7 +66,7 @@ pub async fn run(arguments: &PushCommandArguments, config: &CliConfig) -> Result let locales = read_locales(&config.output.path, config.output.format)?; - let web_api_config = setup_web_api_configuration(arguments.web_api_host.clone()); + let api_config = setup_api_configuration(arguments.api_host.clone()); if locales.is_empty() { // TODO: convert to error? @@ -80,7 +80,7 @@ pub async fn run(arguments: &PushCommandArguments, config: &CliConfig) -> Result let locale_count = locales.len(); - upload_locales(&web_api_config, &auth, &config.project_id, locales).await?; + upload_locales(&api_config, &auth, &config.project_id, locales).await?; print_pushed_locales(locale_count); }