From d3099d76860fc3488f02f6c52251e6b3b8f1b0e6 Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Mon, 5 Dec 2022 10:28:10 -0500 Subject: [PATCH] implement phone_validate --- steamguard/src/steamapi.rs | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/steamguard/src/steamapi.rs b/steamguard/src/steamapi.rs index a779f41..3370081 100644 --- a/steamguard/src/steamapi.rs +++ b/steamguard/src/steamapi.rs @@ -442,14 +442,26 @@ impl SteamApiClient { /// Provides lots of juicy information, like if the number is a VOIP number. /// Host: store.steampowered.com /// Endpoint: POST /phone/validate + /// Body format: form data + /// Example: + /// ``` + /// sessionID=FOO&phoneNumber=%2B1+1234567890 + /// ``` /// Found on page: https://store.steampowered.com/phone/add - pub fn phone_validate(&self, phone_number: String) -> anyhow::Result { + pub fn phone_validate(&self, phone_number: &String) -> anyhow::Result { let params = hashmap! { - "sessionID" => "", - "phoneNumber" => "", + "sessionID" => self.session.as_ref().unwrap().expose_secret().session_id.as_str(), + "phoneNumber" => phone_number.as_str(), }; - todo!(); + let resp = self + .client + .post("https://store.steampowered.com/phone/validate") + .form(¶ms) + .send()? + .json::()?; + + return Ok(resp); } /// Starts the authenticator linking process. @@ -678,6 +690,16 @@ pub struct FinalizeAddAuthenticatorResponse { pub success: bool, } +#[derive(Debug, Clone, Deserialize)] +#[allow(dead_code)] +pub struct PhoneValidateResponse { + success: bool, + number: String, + is_valid: bool, + is_voip: bool, + is_fixed: bool, +} + #[derive(Debug, Clone, Deserialize)] pub struct RemoveAuthenticatorResponse { pub success: bool,