diff options
Diffstat (limited to 'scripts/wallet.ipynb')
| -rw-r--r-- | scripts/wallet.ipynb | 153 |
1 files changed, 0 insertions, 153 deletions
diff --git a/scripts/wallet.ipynb b/scripts/wallet.ipynb deleted file mode 100644 index 12a90be..0000000 --- a/scripts/wallet.ipynb +++ /dev/null @@ -1,153 +0,0 @@ -{ - "cells": [ - { - "metadata": {}, - "cell_type": "code", - "source": [ - "import uuid\n", - "\n", - "import requests\n", - "from collections import Counter\n", - "\n", - "FSB_BASE_URL = \"https://fsb.generalresearch.com/\"\n", - "JB_BASE_URL = \"https://jamesbillings67.com/\"\n", - "product_id = \"888dbc589987425fa846d6e2a8daed04\"\n", - "bpuid = uuid.uuid4().hex" - ], - "id": "initial_id", - "outputs": [], - "execution_count": null - }, - { - "metadata": {}, - "cell_type": "code", - "source": [ - "# Check their balance\n", - "url = FSB_BASE_URL + f\"{product_id}/wallets/?bpuid={bpuid}\"\n", - "print(f\"{url=}\")\n", - "res = requests.get(url).json()\n", - "print(res['displayed_balances'][0])" - ], - "id": "74a8d7f3452c2372", - "outputs": [], - "execution_count": null - }, - { - "metadata": {}, - "cell_type": "code", - "source": [ - "# Get user cashout methods\n", - "url = FSB_BASE_URL + f\"{product_id}/cashout_methods/?bpuid={bpuid}\"\n", - "print(f\"{url=}\")\n", - "res = requests.get(url).json()\n", - "cms = res['cashout_methods']\n", - "print(dict(Counter(x['type'] for x in cms)))\n", - "\n", - "# Get the paypal method\n", - "paypal_cm = next(filter(lambda x: x['type'] == 'PAYPAL', cms))\n", - "print(paypal_cm['id'])" - ], - "id": "e5c4e61b4727912d", - "outputs": [], - "execution_count": null - }, - { - "metadata": {}, - "cell_type": "code", - "source": [ - "# Log in and retain the jb_session cookie for later requests\n", - "from urllib.parse import parse_qs, urlparse\n", - "\n", - "session = requests.Session()\n", - "email = 'your-email@gmail.com'\n", - "\n", - "res = session.post(\n", - " JB_BASE_URL + 'auth/magic-link/request/',\n", - " json={'email': email},\n", - ")\n", - "res.raise_for_status()\n", - "print(res.json())" - ], - "id": "38c7d77b3abf9948", - "outputs": [], - "execution_count": null - }, - { - "metadata": {}, - "cell_type": "code", - "source": [ - "# Paste the link from the login email. Exchanging it sets jb_session on `session`.\n", - "magic_link = \"https://jamesbillings67.com/auth/magic-link/?token=XXXX\"\n", - "token = parse_qs(urlparse(magic_link).query)['token'][0]\n", - "res = session.post(\n", - " JB_BASE_URL + 'auth/magic-link/exchange/',\n", - " json={'token': token},\n", - ")\n", - "res.raise_for_status()\n", - "\n", - "session_token = session.cookies['jb_session']\n", - "print(f'Logged in; captured jb_session ({len(session_token)} characters)')" - ], - "id": "db3caa6e440619fe", - "outputs": [], - "execution_count": null - }, - { - "metadata": {}, - "cell_type": "code", - "source": [ - "# Request a PayPal cashout using the authenticated session.\n", - "# The response confirms that the cashout confirmation email was sent;\n", - "# the payout event is created only after that email link is confirmed.\n", - "res = session.post(JB_BASE_URL + 'wallet/cashout/request/', json={\n", - " 'amount': 10_00,\n", - " 'cashout_method_id': paypal_cm['id'],\n", - "})\n", - "res.raise_for_status()\n", - "print(res.json())" - ], - "id": "774a00c08ab54d4f", - "outputs": [], - "execution_count": null - }, - { - "metadata": {}, - "cell_type": "code", - "source": [ - "# Paste link from email\n", - "magic_link = \"https://jamesbillings67.com/wallet/cashout/confirm/?token=XXXX\"\n", - "token = parse_qs(urlparse(magic_link).query)['token'][0]\n", - "res = session.post(\n", - " JB_BASE_URL + 'wallet/cashout/confirm/',\n", - " json={'token': token},\n", - ")\n", - "print(res.json())\n", - "res.raise_for_status()" - ], - "id": "894887ddc479eb1a", - "outputs": [], - "execution_count": null - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.6" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} |
