From e218a456edbd509664b125011bdb822c2e2c8e9d Mon Sep 17 00:00:00 2001 From: Rossen Georgiev Date: Wed, 10 Apr 2019 23:02:25 +0100 Subject: [PATCH] add code param to create_emergency_codes Add paramter to provide confirmation code for creating emergency codes. fix #187 --- steam/guard.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/steam/guard.py b/steam/guard.py index 60f7732..ac88f5c 100644 --- a/steam/guard.py +++ b/steam/guard.py @@ -234,14 +234,29 @@ class SteamAuthenticator(object): """ return self._send_request('QueryStatus', {'steamid': self.medium.steam_id}) - def create_emergency_codes(self): + def create_emergency_codes(self, code=None): """Generate emergency codes + :param code: SMS code + :type code: str :raises: :class:`SteamAuthenticatorError` :return: list of codes :rtype: list + + .. note:: + A confirmation code is required to generate emergency codes and this method needs + to be called twice as shown below. + + .. code:: python + + sa.create_emergency_codes() # request a SMS code + sa.create_emergency_codes(code='12345') # creates emergency codes """ - return self._send_request('CreateEmergencyCodes', {}).get('codes', []) + if code: + return self._send_request('createemergencycodes', {'code': code}).get('codes', []) + else: + self._send_request('createemergencycodes', {}) + return None def destroy_emergency_codes(self): """Destroy all emergency codes