예제 #1
0
    def do_GET(self):
        """Handle GET request to redirect URI"""

        self.send_response(200)
        self.send_header('Content-type', 'text/html')
        self.end_headers()
        try:
            code = urlparse.urlparse(self.path)[4].split('=')[1]
            credentials = Venmo.exchange_token(code)
            Venmo.save_credentials(credentials)
            self.wfile.write('Your code has been saved in Alfred')
        except:
            self.wfile.write('Error with setting code')
def main(_):
    """Act of user action"""

    command = wf.args[0]
    if command == 'logout':
        Venmo.delete_credentials()
        return sys.stdout.write("logged out")
    elif command == 'login':
        return Venmo.open_auth_page()
    elif command == 'clear':
        Venmo.clear_cache()
        return sys.stdout.write("cache cleared")

    try:
        Venmo.complete_transaction(command)
        sys.stdout.write(util.create_post_message(command))
    except:
        sys.stdout.write("Payment failed")
예제 #3
0
def main(_):
    """
    List options for user
    """

    user_input = ""
    options = True if wf.args[0][0] == '>' else False

    if wf.update_available:
        Venmo.add_update()

    try:
        user_input = wf.args[0][1::].strip() if options else wf.args[0]
    except:
        user_input = wf.args[0]

    try:
        if options:
            Venmo.show_options(user_input)
        elif (len(user_input) and len(Venmo.findFriends(user_input)) == 1 and
              user_input.startswith(Venmo.findFriends(user_input)[0]['display_name'])):
            Venmo.show_formatting(user_input)
        elif len(user_input):
            Venmo.show_filtered_friends(user_input)
    except:
        Venmo.show_options('login')

    return 0