{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from api import BigApi\n",
    "BigApi.init(\".admin.env\")\n",
    "BigApi.adminLogin()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "state = \"WaitingForInventory\"\n",
    "queryResult = BigApi.adminGet(f\"/admin/shop/orders?state={state}&countryCode=US&origin=Shopify\")\n",
    "\n",
    "ipds = {}\n",
    "\n",
    "for bigOrder in queryResult[\"items\"]:\n",
    "    # If the bigOrder[\"currentLineItems\"] has a line item where \"type\" is \"PrescriptionLenses\" then bail out\n",
    "    if any(lineItem[\"type\"] == \"PrescriptionLenses\" for lineItem in bigOrder[\"currentLineItems\"]):\n",
    "        continue\n",
    "    if any(lineItem[\"type\"] == \"BigscreenBeyondV1\" for lineItem in bigOrder[\"currentLineItems\"]):\n",
    "        if ipds.get(bigOrder[\"ipd\"]) is None:\n",
    "            ipds[bigOrder[\"ipd\"]] = 0\n",
    "        ipds[bigOrder[\"ipd\"]] = ipds[bigOrder[\"ipd\"]] + 1\n",
    "\n",
    "sorted_keys = sorted(ipds.keys())\n",
    "for key in sorted_keys:\n",
    "    print(f\"{key}\\t{ipds[key]}\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
