{
 "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": [
    "# run the checklist to get the nextAction\n",
    "data = BigApi.adminGet(f\"/admin/shop/order/{bigOrderId}/checklist\")\n",
    "assert data[\"nextAction\"] == \"SendScanRequest\", f\"nextAction should be SendScanRequest (actual: {data['nextAction']})\"\n",
    "\n",
    "result = BigApi.adminPut(f\"/admin/shop/order/{bigOrderId}\", {\"action\": \"SendScanRequest\", \"silentEmail\": True})\n",
    "print(f\"https://main-ocean-arda.bigscreencloud.com/shop/order/{bigOrderId}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "scanRequestId = \"\"\n",
    "correctTopologyOverride = \"\"\n",
    "\n",
    "# Force topology update for the scan request\n",
    "data = BigApi.adminGet(f\"/admin/fabricator/scan_request/{scanRequestId}/topology/{correctTopologyOverride}\")\n",
    "\n",
    "# Verify the scan request\n",
    "data = BigApi.adminGet(f\"/admin/fabricator/scan_request/{scanRequestId}/verify\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "scanRequestId = \"\"\n",
    "\n",
    "data = BigApi.adminGetRaw(f\"/admin/fabricator/scan_request/{scanRequestId}/scan\")\n",
    "\n",
    "# stream the requests output to a file\n",
    "with open(\"scan.zip\", \"wb\") as f:\n",
    "    data.raw.decode_content = True\n",
    "    f.write(data.content)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "for scanRequestId in scanRequestIds:\n",
    "    data = BigApi.adminGet(f\"/admin/fabricator/scan_request/{scanRequestId}/topology\")\n",
    "    print(data)\n",
    "\n",
    "data1 = BigApi.adminGet(f\"/admin/fabricator/scan_request/{scanRequestId}/topology\")\n",
    "data2 = BigApi.adminGet(f\"/admin/fabricator/scan_request/{scanRequestId}/verify\")\n",
    "\n",
    "data2"
   ]
  }
 ],
 "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
}
