Skip to content

Instantly share code, notes, and snippets.

@thomasfr
Last active August 29, 2015 14:03
Show Gist options
  • Save thomasfr/e236f256a29f748b7956 to your computer and use it in GitHub Desktop.
Save thomasfr/e236f256a29f748b7956 to your computer and use it in GitHub Desktop.
Eversport API

Example POST Request

Full Request / Response Format and documentation can be read here: http://jsonapi.org/format/

POST https://api.eversport.at/v2/venues/1234/orders
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json

{
  "links": {
    "orders.user": {
      "type": "users"
    }
  },
  "orders": [{
    "start":"2014-07-04T14:00:00+02:00",
    "end":"2014-07-04T16:00:00+02:00",
    "links": {
      "court": "3",
      "user": "947184"
      }
    },
  },
  {
    "start":"2014-07-04T16:00:00+02:00",
    "end":"2014-07-04T18:00:00+02:00",
    "links": {
      "court": "3",
      "user": "83932"
      }
    }
  },
  {
    "start":"2014-07-06T10:00:00+02:00",
    "end":"2014-07-06T12:00:00+02:00",
    "links": {
      "court": "2",
      "user": "83932"
      }
    }
  }],
  "linked": {
    "users": [{
      "id":"947184",
      "first_name": "Thomas",
      "last_name": "Fritz",
      "street": "Graumanngasse",
      "number": "7",
      "zip": "1150",
      "city": "Wien",
      "country": "AT",
      "telephone":"+436643420062",
      "email": "[email protected]"
    },
    {
      "id":"83932",
      "first_name": "Hanno",
      "last_name": "Lippitsch",
      "street": "Graumanngasse",
      "number": "7",
      "zip": "1150",
      "city": "Wien",
      "country": "AT",
      "telephone":"+43664123456789",
      "email": "[email protected]"
    }]
  }
}

General URL Structure for all eCourt APIs

Base URL for all HTTP requests to the Eversport API: https://api.eversport.at/v2

The URL structure will get used for the Eversport API and we assume this URL structure for external system like SMILE too. So SMILE should implement this URL structure:

All Request, Response and HTTP Parameters should be correct according to http://jsonapi.org/format/

User

GET       /users/
POST      /users/
GET       /users/{user_id}/
DELETE    /users/{user_id}/

Venues (Sportstätten)

GET       /venues/
POST      /venues/
GET       /venues/{venue_id}/
DELETE    /venues/{venue_id}/

Courts (Plätze, Courts, Felder, etc)

GET       /venues/{venue_id}/courts/
POST      /venues/{venue_id}/courts/
GET       /venues/{venue_id}/courts/{court_id}
DELETE    /venues/{venue_id}/courts/{court_id}

Orders (Buchungen)

GET       /venues/{venue_id}/orders/
POST      /venues/{venue_id}/orders/
GET       /venues/{venue_id}/orders/{order_id}
DELETE    /venues/{venue_id}/orders/{order_id}

Requests from external systems

External systems MUST NOT remember Eversport IDs. They just send their data with their IDs. Eversport takes care of mapping the systems external IDs to internal Eversport IDs. To avoid ID conflicts with possible other external systems all API requests coming from external systems should be made to namespaced URLs. It is also necessary to use "client side IDs" and therefore use HTTP PUT only instead of POST for all writing operations.

Orders

PUT       /system/{smile}/venues/{venue_id}/orders/{order_id}
DELETE    /system/{smile}/venues/{venue_id}/orders/{order_id}

It should not be allowed to use POST a new order without id, because we can not generate IDs for the external system and guarantee that the IDs is the same as in the external system

Eversport will send new orders for SMILE venues, made on Eversport. Eversport sends the user information with every order request to the external system API. If the user is new - Eversport does not have a external mapped user id yet - the user MUST BE created and mapped with the order request. To mark a user as "new" or "not mapped", the user id get set to 0 or, if more than one user is not mapped the user ids will be negative (0, -1, -2, etc.). In the response of the order request, the correct ids should be returned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment