{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Get all WaitingForInventory BigOrders that also have shipments"
   ]
  },
  {
   "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": [
    "shipments = BigApi.adminGet(\"/admin/shipper/shipments?statusNot=Cancelled\")\n",
    "bigOrders = BigApi.adminGet(\"/admin/shop/orders?origin=Shopify\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "for order in bigOrders[\"items\"]:\n",
    "    bigOrderId = order[\"id\"]\n",
    "    shipmentsPerOrder = 0\n",
    "    for shipment in shipments[\"items\"]:\n",
    "        if shipment[\"bigOrderId\"] == bigOrderId:\n",
    "            shipmentsPerOrder += 1\n",
    "    if shipmentsPerOrder > 1:\n",
    "        print(f\"https://main-ocean-arda.bigscreencloud.com/shop/order/{bigOrderId}\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "findBigOrderId = \"\"\n",
    "shipments = BigApi.adminGet(f\"/admin/shipper/shipments?bigOrderId={findBigOrderId}\")\n",
    "shipments"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "for order in bigOrders[\"items\"]:\n",
    "    bigOrderId = order[\"id\"]\n",
    "    for shipment in shipments[\"items\"]:\n",
    "        if shipment[\"bigOrderId\"] == bigOrderId:\n",
    "            print(f\"https://main-ocean-arda.bigscreencloud.com/shop/order/{bigOrderId}\")\n",
    "            break"
   ]
  }
 ],
 "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
}
