anomaly / gallagher

The missing toolkit for extending Gallagher Command Centre, featuring a CLI, SQL interface, TUI and a Python idiomatic SDK
https://anomaly.github.io/gallagher/
MIT License
11 stars 2 forks source link

Reconsider use of `DELETE` HTTP Verb where the REST API has a `remove` operation for objects #56

Open devraj opened 2 months ago

devraj commented 2 months ago

Describe the bug I have been using the HTTP delete method to remove things like card assignments from a cardholder. While this works as expected, I noticed that the PATCH verb supports update, remove operations which allows extra attributes like status where we can provide reasons for the change.

  "cards": {
    "add": [
      {
        "type": {
          "href": "https://localhost:8904/api/card_types/354"
        },
        "pin": "153624"
      },
      {
        "type": {
          "href": "https://localhost:8904/api/card_types/600"
        },
        "number": "Jock's iPhone 8",
        "status": {
          "value": "Pending sign-off"
        },
        "invitation": {
          "email": "jock@example.com"
        }
      }
    ],
    "update": [
      {
        "href": "https://localhost:8904/api/cardholders/325/cards/97b6a24ard6d4500a9d",
        "issueLevel": 2,
        "until": "",
        "status": {
          "value": "Stolen"
        },
        "pin": "153624"
      }
    ],
    "remove": [
      {
        "href": "https://localhost:8904/api/cardholders/325/cards/77e8affe7c7e4b56",
        "status": {
          "value": "Lost"
        }
      }
    ]
  },

To Reproduce Not quite applicable, attempt sending the same payload via HTTP delete method vs http patch.

Expected behavior

Screenshots NA

Desktop (please complete the following information): NA

Smartphone (please complete the following information): NA

Additional context See REST docs.