feature/cicd
claude/smbcloud-github-app-k9641p
development
feature/apps
feature/build-release
feature/ci-docs
feature/ci-ruby-gems
feature/cicd
feature/completion
feature/dist-nuget
feature/fix-ci-sdk-pypi-rubygem
feature/fix-clippy-on-stable-channel
feature/fix-deployment-script
feature/github-email
feature/gresiq-v1
feature/project-new-structure
feature/rsync-deploy
feature/ruby-runner
feature/sdk-npm
feature/sdk-workflows
feature/smbcloud-cli-release-npm
feature/smbcloud-deploy
feature/wasm
main
release/v0.7.4
| 1 | use { |
| 2 | crate::client_credentials::{ClientCredentials, base_url_builder as tenant_base_url_builder}, |
| 3 | reqwest::Client, |
| 4 | smbcloud_model::{ |
| 5 | error_codes::ErrorResponse, |
| 6 | signup::{SignupEmailParams, SignupResult, SignupUserEmail}, |
| 7 | }, |
| 8 | smbcloud_network::{environment::Environment, network::request}, |
| 9 | smbcloud_networking::{constants::PATH_USERS, smb_base_url_builder, smb_client::SmbClient}, |
| 10 | }; |
| 11 | |
| 12 | pub async fn signup( |
| 13 | env: Environment, |
| 14 | client: (&SmbClient, &str), |
| 15 | email: String, |
| 16 | password: String, |
| 17 | ) -> Result<SignupResult, ErrorResponse> { |
| 18 | let params = SignupEmailParams { |
| 19 | user: SignupUserEmail { email, password }, |
| 20 | }; |
| 21 | let builder = Client::new() |
| 22 | .post(build_smb_signup_url(env, client)) |
| 23 | .json(¶ms) |
| 24 | .header("User-agent", client.0.id()); |
| 25 | request(builder).await |
| 26 | } |
| 27 | |
| 28 | pub async fn signup_with_client( |
| 29 | env: Environment, |
| 30 | client: ClientCredentials<'_>, |
| 31 | email: String, |
| 32 | password: String, |
| 33 | ) -> Result<SignupResult, ErrorResponse> { |
| 34 | let params = SignupEmailParams { |
| 35 | user: SignupUserEmail { email, password }, |
| 36 | }; |
| 37 | let builder = Client::new() |
| 38 | .post(build_signup_url_with_client(env, client)) |
| 39 | .json(¶ms) |
| 40 | .header("User-agent", client.app_id); |
| 41 | request(builder).await |
| 42 | } |
| 43 | |
| 44 | fn build_smb_signup_url(env: Environment, client: (&SmbClient, &str)) -> String { |
| 45 | let mut url_builder = smb_base_url_builder(env, client); |
| 46 | url_builder.add_route(PATH_USERS); |
| 47 | url_builder.build() |
| 48 | } |
| 49 | |
| 50 | fn build_signup_url_with_client(env: Environment, client: ClientCredentials<'_>) -> String { |
| 51 | let mut url_builder = tenant_base_url_builder(env, client); |
| 52 | url_builder.add_route("v1/client/users"); |
| 53 | url_builder.build() |
| 54 | } |