nesh170 / asap-inventory-system

This is a concept inventory system for ECE458. It is built by ASAPsolutions
1 stars 0 forks source link

Updated disbursement #101

Closed nesh170 closed 7 years ago

nesh170 commented 7 years ago
  1. Get all disbursement (returns all if staff, and returns only receiver's disbursement if it is regular user) GET /api/disburse/ HTTP/1.1 Host: localhost:8000 Content-Type: application/json Authorization: Bearer

    {
    "count": 3,
    "next": null,
    "previous": null,
    "results": [
    {
      "id": 1,
      "disburser": {
        "id": 1,
        "username": "admin"
      },
      "receiver": {
        "id": 19,
        "username": "sl290"
      },
      "comment": "Test",
      "disbursements": [
        {
          "id": 8,
          "item": {
            "id": 1,
            "name": "Item_1",
            "quantity": 27
          },
          "quantity": 3,
          "item_id": 1,
          "cart_id": 1
        }
      ],
      "receiver_id": 19
    },
    {
      "id": 3,
      "disburser": {
        "id": 1,
        "username": "admin"
      },
      "receiver": {
        "id": 15,
        "username": "arp38"
      },
      "comment": "This cart is based on life",
      "disbursements": [],
      "receiver_id": 15
    },
    {
      "id": 4,
      "disburser": {
        "id": 1,
        "username": "admin"
      },
      "receiver": {
        "id": 2,
        "username": "Patrick"
      },
      "comment": "lol",
      "disbursements": [],
      "receiver_id": 2
    }
    ]
    }
  2. Cart Submission PATCH /api/disburse/ HTTP/1.1 Host: localhost:8000 Content-Type: application/json Authorization: Bearer

    {
    "comment":"lol",
    "receiver_id":2
    }

    Returns HTTP_200_OK if it works

  3. Get the active cart (or it creates a new one for the user if no active cart) GET /api/disburse/active/ HTTP/1.1 Host: localhost:8000 Content-Type: application/json Authorization: Bearer

Response:

{
  "id": 5,
  "disburser": {
    "id": 1,
    "username": "admin"
  },
  "receiver": null,
  "comment": null,
  "disbursements": [],
  "receiver_id": null
}
  1. Post a disbursement to a cart POST /api/disburse/disbursements/create/ HTTP/1.1 Host: localhost:8000 Content-Type: application/json Authorization: Bearer Request:
    {
      "quantity": 1,
      "item_id": 1,
      "cart_id": 5
    }

Response:

{
  "id": 11,
  "item": {
    "id": 1,
    "name": "Item_1",
    "quantity": 27
  },
  "quantity": 1,
  "item_id": 1,
  "cart_id": 5
}
  1. Delete a disbursement from a cart DELETE /api/disburse/disbursements/HTTP/1.1 Host: localhost:8000 Content-Type: application/json Authorization: Bearer

Returns a HTTP_204_NO_CONTENT on success 🗡

All the calls are protected against you can only act on an active cart