calendar-api

* [Calendars](#calendars) * [Availability](#availabilty) * [Swagger Docs](#swagger-docs) * [Postman](#postman)

Usage no npm install needed!

<script type="module">
  import calendarApi from 'https://cdn.skypack.dev/calendar-api';
</script>

README

Calendar API

Calendars

Before availablility can be set, there must be a calendar created. The calendar contains the following object:

{
  "calendarId": {{shortId}},
  "calendarType": "NONE",
  "sellMode": "NONE"
}

Validation

  • calendarId is a required field, and must be a valid shortId
  • calendarType is one of ['INVENTORY', 'CONFIRMATION_METHOD'] With a default of INVENTORY
  • sellMode is one of [AVAILABLE', 'UNAVAILABLE', 'CALL_AND_REQUEST'] with a default of UNAVAILABLE

Routes

{{host}} is https://portal-dev.leisurelink.com or https://portal.leisurelink.com

Healthcheck

  • GET

  • {{host}}/calendar-api/v1/healthcheck

  • Sample Response (200):

      {
        "version": "calendar-api 1.0.3",
        "Inventory Round Trip": "0s 28.389224ms",
        "Calendar Round Trip": "0s 28.722085ms"
      }
    

Create Calendar

There are two ways to create a Calendar, with the preferred way to be with a PUT. The PUT will overwrite any previous data, where the POST will return a 409 if there is already a calendar object created with the supplied Id.

  • PUT
    • {{host}}/calendar-api/v1/en-US/calendars/{{calendarId}}

    • Sample Request:

        {
            "calendarType": "INVENTORY",
            "sellMode": "UNAVAILABLE"
        }
      
    • Responses:

      • 400 - For errors.
      • 200 - For a success
  • POST
    • {{host}}/calendar-api/v1/en-US/calendars

    • Sample Request:

        {
          "calendarId": {{shortId}},
          "calendarType": "INVENTORY",
          "sellMode": "UNAVAILABLE"
        }
      
    • Responses:

      • 409 - Is returned if the calendar already exists
      • 200 - For a success

Get Calendar

  • GET
    • {{host}}/calendar-api/v1/en-US/calendars/{calendarId}
    • Responses:
      • 404 - If the calendarId does not exits
      • 200 - For a success

Patch Calendar

  • PATCH
    • {{host}}/calendar-api/v1/en-US/calendars/{calendarId}
    • Responses:
      • 404 - If the calendarId does not exits
      • 200 - For a success

Delete Calendar

  • DELETE
    • {{host}}/calendar-api/v1/en-US/calendars/{calendarId}
    • Responses:
      • 404 - If the calendarId does not exits
      • 204 - For a success

Availability

Get Available Count

  • GET
  • {{host}}/calendar-api/v1/en-US/calendars/{calendarId}/availability-check?begin=2016-03-11&end=2016-03-20
  • Responses:
    • 404 - If the calendarId does not exist

    • 400 - Validation Errors

    • 200 - Success

        {
            available: 0
        }
      
    • Note - This returns the Math.Max across all days in the range. If there is no availability for a day in the range, the available will be returned as 0.

Get Availability By Day

  • GET
  • {{host}}/calendar-api/v1/en-US/calendars/{calendarId}/availability/{date}
  • Responses:
    • 404 - If the calendarId does not exits

    • 400 - Validation Errors

    • 200 - For a success

        {
            "sold": 0,
            "allocated": 6,
            "date": "2016-01-03",
            "available": 6
        }
      
    • Note - If there is not availability for the given calendar/date combo, a default availability object will be returned. The default availability will have the allocated as null

Get Availability By Date Range

  • GET
  • {{host}}/calendar-api/v1/en-US/calendars/{calendarId}/availability?begin={begin}&end={end}
  • Responses:
    • 404 - If the calendarId does not exits

    • 400 - Validation Errors

    • 200 - For a success

        [
          {
            "sold": 0,
            "allocated": 6,
            "date": "2016-01-01",
            "available": 6
          },
          {
            "sold": 0,
            "allocated": 6,
            "date": "2016-01-03",
            "available": 6
          }
        ]
      
    • Note - If there is not availability for the given calendar/date combo, a default availability object will be returned. The default availability will have the allocated as null

Put Availability By Day

  • PUT

  • {{host}}/calendar-api/v1/en-US/calendars/{calendarId}/availability/{date}

  • Request Body:

      {
          "allocated": 6
      }
    
  • Responses:

    • 404 - If the calendarId does not exits

    • 400 - Validation errors.

    • 200 - For a success

          {
            "sold": 0,
            "allocated": 6,
            "date": "2016-01-03",
            "available": 6
          }
      

Put Availability

  • PUT

  • {{host}}/calendar-api/v1/en-US/calendars/{calendarId}/availability

  • Request Body:

      [
          {
              "date": "2016-03-11",
              "allocated": 4
          },
          {
              "date": "2016-03-12",
              "allocated": 4
          }
      ]
    
  • Responses:

    • 404 - If the calendarId does not exits

    • 400 - Validation Errors

    • 400 - Duplicate Days

    • 200 - For a success

        [
          {
            "sold": 0,
            "allocated": 6,
            "date": "2016-01-01",
            "available": 6
          },
          {
            "sold": 0,
            "allocated": 6,
            "date": "2016-01-03",
            "available": 6
          }
        ]
      

Patch Availability by Ranges

  • PATCH

  • {{host}}/calendar-api/v1/en-US/calendars/{calendarId}/availability

  • Request Body:

      [  
          {
              "begin": "2016-03-11",
              "end": "2016-03-20",
              "availability": {
                "allocated": 2
              }
          },
          {
              "begin": "2016-03-24",
              "end": "2016-03-30",
              "availability": {
                "allocated": 3
              }
          }
      ]
    
  • Responses:

    • 404 - If the calendarId does not exits

    • 400 - Validation Errors

    • 400 - Duplicate Days

    • 200 - For a success

        [
          {
            "sold": 0,
            "allocated": 6,
            "date": "2016-01-01",
            "available": 6
          },
          {
            "sold": 0,
            "allocated": 6,
            "date": "2016-01-03",
            "available": 6
          }
        ]
      

Delete Availability By Day

  • DELETE
  • {{host}}/calendar-api/v1/en-US/calendars/{calendarId}/availability/{date}
  • Responses:
    • 404 - If the calendarId does not exits
    • 400 - Validation Errors.
    • 204 - For a success

Delete Availability By Date Range

  • DELETE
  • {{host}}/calendar-api/v1/en-US/calendars/{calendarId}/availability?begin={begin}&end={end}
  • Responses:
    • 404 - If the calendarId does not exits
    • 400 - Validation Errors
    • 204 - For a success

Swagger Docs

Postman

In the Leisurelink Postman library (you must be invited) there is a collection called calendar-api