{
 "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": [
    "bigShipmentId = \"\"\n",
    "\n",
    "BigApi.adminPut(f\"/admin/shipper/shipment/{bigShipmentId}\", { \n",
    "    \"action\": \"Cancel\"\n",
    "})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bigOrderId = \"u6mtDIBVLCAiEHHz\"\n",
    "\n",
    "BigApi.adminDelete(f\"/admin/shop/order/{bigOrderId}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "status = \"InStock\"\n",
    "type = \"BigscreenBeyondV1\"\n",
    "inventoryQueryResponse = BigApi.adminGet(f\"/admin/inventory/items?status={status}&type={type}\")\n",
    "inventoryItems = inventoryQueryResponse[\"items\"]\n",
    "print(len(inventoryItems))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "inventoryItems = inventoryQueryResponse[\"items\"]\n",
    "for item in inventoryItems:\n",
    "    itemId = item[\"id\"]\n",
    "    try:\n",
    "        BigApi.adminDelete(f\"/admin/inventory/item/{itemId}?force=1\")\n",
    "    except Exception as e:\n",
    "        print(e)\n",
    "        pass"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Find RMAs\n",
    "import json\n",
    "codes = [\n",
    "    \"BS1712B010079R\",\n",
    "    \"BS1692C010399R\",\n",
    "    \"BS1692B010136R\",\n",
    "    \"BS1692B010027R\",\n",
    "    \"BS1692B010252R\",\n",
    "    \"BS1692B010194R\",\n",
    "    \"BS1692C010359R\",\n",
    "    \"BS1682B010055R\",\n",
    "    \"BS1692B010084R\",\n",
    "    \"BS1652A010012R\",\n",
    "    \"BS16927010045R\",\n",
    "    \"BS1652B010144R\",\n",
    "    \"BS1622C010125R\",\n",
    "    \"BS1632C010129R\",\n",
    "    \"BS1642B010029R\",\n",
    "    \"BS1652B010165R\",\n",
    "    \"BS1642B010030R\",\n",
    "    \"BS1642B010096R\",\n",
    "    \"BS16531010246R\",\n",
    "    \"BS1652B010202R\",\n",
    "    \"BS1652B010183R\",\n",
    "    \"BS1642B010245R\",\n",
    "    \"BS1642B010052R\",\n",
    "    \"BS1642B010264R\",\n",
    "    \"BS1632C010075R\",\n",
    "    \"BS1622C010121R\",\n",
    "    \"BS1722B010044R\"\n",
    "]\n",
    "\n",
    "for code in codes:\n",
    "    try:\n",
    "        data = BigApi.adminGet(f\"/admin/inventory/items?serialNumberLike={code}\")\n",
    "        print(json.dumps(data[\"items\"], indent=2))\n",
    "\n",
    "        if (data[\"count\"] != 1):\n",
    "            print(f\"code {code} not found\")\n",
    "    except Exception as e:\n",
    "        print(e)\n",
    "        pass"
   ]
  }
 ],
 "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
}
