Skip to content

Instantly share code, notes, and snippets.

@nichotined
Created February 20, 2020 16:31
Show Gist options
  • Save nichotined/8dd4fe317fb8811c235b38a7ece00ba0 to your computer and use it in GitHub Desktop.
Save nichotined/8dd4fe317fb8811c235b38a7ece00ba0 to your computer and use it in GitHub Desktop.
from API import Get, Post
import requests
class Login(Post):
def __init__(self, phone_number: str):
super().__init__()
self.url = "https://somedomain.com/login"
self.headers = {
"Content-Type": "application/json"
}
self.json = {
"phone_number": phone_number
}
self.execute()
class VerifyOtp(Post):
def __init__(self, otp: str):
super().__init__()
self.url = "https://somedomain.com/verify_otp"
self.headers = {
"Content-Type": "application/json"
}
self.json = {
"otp": otp
}
self.execute()
if __name__ == "__main__":
login = Login("8123456789")
assert login.response.ok
verify_otp = VerifyOtp(login.json_object.otp)
assert verify_otp.response.ok
assert verify_otp.json_object.token is not None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment