Elements

Return a Element.

Parameters
  • idpath integerRequired

    Return a Element by specific Element id.

  • includequery string

    Include associations (delimited with comma). Available associations: element_options

GET/api/v1/elements/{id}

{
  const res = await fetch(`${BASE_URL}/api/v1/elements/${id}`, {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(data)});

  const data = await res.json();
}

RESPONSE

{
  "data": {
    "id": "fe32f8a2-f0ee-4c05-84c2-48ba2380aa0d",
    "type": "elements",
    "links": {
      "self": "/elements/fe32f8a2-f0ee-4c05-84c2-48ba2380aa0d"
    },
    "attributes": {
      "currency": "GBP",
      "dish-name": "Test Dish",
      "dish-price-per-item-cents": 3000,
      "notes": "This is an element note",
      "subsum-cents": 3000,
      "units": 1
    },
    "relationships": {
      "element-options": {
        "links": {
          "self": "/elements/fe32f8a2-f0ee-4c05-84c2-48ba2380aa0d/relationships/element-options",
          "related": "/elements/fe32f8a2-f0ee-4c05-84c2-48ba2380aa0d/element-options"
        }
      }
    }
  }
}

Create Element

Create a element of a order

Parameters
  • dataformData, objectRequired

    Form Data needed when creating a new Element.

    • typestringRequired

      Provide Element type. Current selection is only elements.

    • attributesformData, objectRequired

      Attributes object with a few required fields.

      • unitsintegerRequired

        Amount of given dish.

      • notesstring

        Additional notes for given dish

    • relationshipsformData, object

      Relationships object with order, dish or dish_options objects.

      • orderformData, object

        Add a relationships link between Element and related Order.

        • idstringRequired

          Related Order id.

        • typestring

          Order type; order

      • dishformData, object

        Add a relationships link between Element and related Dish.

        • idstringRequired

          Related Dish id.

        • typestring

          Dish type; dish

      • dish_optionsformData, object

        Add a relationships link between Element and related Dish Option.

        • idstring

          Related Dish Optionid.

        • typestring

          Dish Option type; dish_options

POST/api/v1/elements

{
  const res = await fetch(`${BASE_URL}/api/v1/elements`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(data)});

  const data = await res.json();
}

RESPONSE

{
  "data": {
    "id": "f37e8d3b-67c6-4e6f-b7ad-62dac2187ac2",
    "type": "elements",
    "links": {
      "self": "/elements/f37e8d3b-67c6-4e6f-b7ad-62dac2187ac2"
    },
    "attributes": {
      "currency": "GBP",
      "dish-name": "Test Dish",
      "dish-price-per-item-cents": 3000,
      "notes": null,
      "subsum-cents": 3000,
      "units": 1
    },
    "relationships": {
      "element-options": {
        "links": {
          "self": "/elements/f37e8d3b-67c6-4e6f-b7ad-62dac2187ac2/relationships/element-options",
          "related": "/elements/f37e8d3b-67c6-4e6f-b7ad-62dac2187ac2/element-options"
        }
      }
    }
  }
}

Update Element

Update a Element

Parameters
  • idpath integerRequired

    Update a Element by specific Element id.

  • dataformData, objectRequired

    Form Data needed when updating a Element.

    • idstringRequired

      Provide Element id.

    • typestringRequired

      Provide Element type. Current selection is only elements.

    • attributesformData, object

      Attributes object.

      • unitsinteger

        Amount of given dish

      • notesstring

        Additional notes for given dish

PATCH/api/v1/elements/{id}

{
  const res = await fetch(`${BASE_URL}/api/v1/elements/${id}`, {
    method: 'PATCH',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(data)});

  const data = await res.json();
}

RESPONSE

{
  "data": {
    "id": "fe32f8a2-f0ee-4c05-84c2-48ba2380aa0d",
    "type": "elements",
    "links": {
      "self": "/elements/fe32f8a2-f0ee-4c05-84c2-48ba2380aa0d"
    },
    "attributes": {
      "currency": "GBP",
      "dish-name": "Test Dish",
      "dish-price-per-item-cents": 3000,
      "notes": "This is an element note",
      "subsum-cents": 3000,
      "units": 1
    },
    "relationships": {
      "element-options": {
        "links": {
          "self": "/elements/fe32f8a2-f0ee-4c05-84c2-48ba2380aa0d/relationships/element-options",
          "related": "/elements/fe32f8a2-f0ee-4c05-84c2-48ba2380aa0d/element-options"
        }
      }
    }
  }
}

Delete Element

Delete a Element.

Parameters
  • idpath integerRequired

    Delete a Element by specific Element id.

DELETE/api/v1/elements/{id}

{
  const res = await fetch(`${BASE_URL}/api/v1/elements/${id}`, {
    method: 'DELETE',
    headers: {
      'Content-Type': 'application/json'
    }});
  const data = await res.json();
}