add remove_authenticator

This commit is contained in:
Carson McManus 2021-08-09 23:08:51 -04:00
parent 555b47b3fb
commit c3d3f33ec3

View file

@ -436,6 +436,32 @@ impl SteamApiClient {
return Ok(resp.response); return Ok(resp.response);
} }
/// Host: api.steampowered.com
/// Endpoint: POST /ITwoFactorService/RemoveAuthenticator/v0001
pub fn remove_authenticator(&self, revocation_code: String) -> anyhow::Result<RemoveAuthenticatorResponse> {
let params = hashmap!{
"steamid" => self.session.as_ref().unwrap().steam_id.to_string(),
"steamguard_scheme" => "2".into(),
"revocation_code" => revocation_code,
"access_token" => self.session.as_ref().unwrap().token.to_string(),
};
let resp = self
.post(format!(
"{}/ITwoFactorService/RemoveAuthenticator/v0001",
STEAM_API_BASE.to_string()
))
.form(&params)
.send()?;
let text = resp.text()?;
trace!("raw remove authenticator response: {}", text);
let resp: SteamApiResponse<RemoveAuthenticatorResponse> = serde_json::from_str(text.as_str())?;
return Ok(resp.response);
}
} }
#[test] #[test]
@ -567,6 +593,11 @@ pub struct FinalizeAddAuthenticatorResponse {
pub success: bool, pub success: bool,
} }
#[derive(Debug, Clone, Deserialize)]
pub struct RemoveAuthenticatorResponse {
pub success: bool
}
fn parse_json_string_as_number<'de, D>(deserializer: D) -> Result<u64, D::Error> fn parse_json_string_as_number<'de, D>(deserializer: D) -> Result<u64, D::Error>
where where
D: Deserializer<'de>, D: Deserializer<'de>,