Beispiel #1
0
def login(username, password):
    resp = helper.request(method="POST",
                          uri="/auth/login",
                          body={
                              'username': username,
                              'password': password
                          })
    if resp.ok:
        helper.token = resp.json().get('token')
        return True
    return False
Beispiel #2
0
def signup(username, password, email, address, firstName, lastName):
    resp = helper.request(method="POST",
                          uri="/auth/signup",
                          body={
                              'username': username,
                              'password': password,
                              'email': email,
                              'address': address,
                              'firstName': firstName,
                              'lastName': lastName
                          })
    if resp.ok:
        return True
    return False
Beispiel #3
0
def updatePerson(username, firstName=None, lastName=None, address=None):
    d = {}
    if firstName:
        d['firstName'] = firstName
    if lastName:
        d['lastName'] = lastName
    if address:
        d['address'] = address
    resp = helper.request(method="PATCH",
                          uri="/person/{}".format(username),
                          body=d)
    if resp.ok:
        return resp.json()
    return False
Beispiel #4
0
def deleteFriend(friendUsername):
    resp = helper.request(method="DELETE",
                          uri="/person/{}/friend".format(friendUsername))
    if resp.ok:
        return resp.json()
    return False
Beispiel #5
0
def addFriend(friendUsername):
    resp = helper.request(method="PUT",
                          uri="/person/{}/friend".format(friendUsername))
    if resp.ok:
        return resp.json()
    return False
Beispiel #6
0
def getPersonFriends(username):
    resp = helper.request(method="GET",
                          uri="/person/{}/friends".format(username))
    if resp.ok:
        return resp.json()
    return False
Beispiel #7
0
def searchPerson(query):
    resp = helper.request(method="GET", uri="/person/{}/search".format(query))
    if resp.ok:
        return resp.json()
    return False