1 use {
2 reqwest::Client,
3 smbcloud_model::{account::SmbAuthorization, error_codes::ErrorResponse},
4 smbcloud_network::{environment::Environment, network::request},
5 smbcloud_networking::{constants::PATH_RESET_PASSWORD_INSTRUCTIONS, smb_client::SmbClient},
6 url_builder::URLBuilder,
7 };
8
9 pub async fn resend_reset_password_instruction(
10 env: Environment,
11 client: (&SmbClient, &str),
12 email: String,
13 ) -> Result<SmbAuthorization, ErrorResponse> {
14 let builder = Client::new()
15 .post(build_smb_resend_reset_password_instructions_url(
16 env, client,
17 ))
18 .body(format!("email={}", email))
19 .header("User-agent", client.0.id())
20 .header("Accept", "application/json")
21 .header("Content-Type", "application/x-www-form-urlencoded");
22
23 request(builder).await
24 }
25
26 pub fn build_resend_reset_password_instructions_url(
27 env: Environment,
28 client_id: &str,
29 client_secret: &str,
30 ) -> String {
31 let mut url_builder = URLBuilder::new();
32 url_builder
33 .set_protocol(&env.api_protocol())
34 .set_host(&env.api_host())
35 .add_param("client_id", client_id)
36 .add_param("client_secret", client_secret)
37 .add_route(PATH_RESET_PASSWORD_INSTRUCTIONS);
38 url_builder.build()
39 }
40
41 fn build_smb_resend_reset_password_instructions_url(
42 env: Environment,
43 client: (&SmbClient, &str),
44 ) -> String {
45 build_resend_reset_password_instructions_url(env, client.0.id(), client.1)
46 }