Skip to content
On this page

API Reference

Version: v0.44.0

The Reservation API (services.opencui.reservation.IReservation) is applied to booking scenarios, including creating bookings, querying bookings, and canceling bookings, which exposes most of the features available in the reservation scenario.

  • To utilize this service, ensure that you have an existing provider that implements it.
  • To invoke this service, ensure that your project has imported it and used it within your target skill/frame type.

Location

The places where bookable resources are located. For example, restaurants, hotels, or hair salons.

  • Fields

    PropertyTypeDescription
    idkotlin.StringThe unique ID for the location.
    nameLocationNameThe location name as seen by customers. Must be unique for the customer.
    timezonejava.time.ZoneIdThe timezone of the location.
  • Methods

    MethodDescription
    listLocationReturns a list of locations for the reservation services.

listLocation

Returns a list of locations for the reservation services.

  • Parameters

    No parameters

  • Return

    If successful, this method returns a list of locations in the response body.

    TypeDescription
    Location[]A list of locations.
  • Example

    kotlin
    val locationList = listLocation()

Resource

The bookable resources are provided for customers, such as tables in a restaurant, doctors in a hospital, hairdressers in a hair salon, etc. Resource object is an abstract object.

  • Fields

    PropertyTypeDescription
    idkotlin.StringThe unique ID for the bookable resource.
    typeResourceTypeThe type of the bookable resource.
    nameResourceNameThe name of the bookable resource.
    durationskotlin.Int[]The durations of the Resource.
    timezonejava.time.zoneIdThe timezone of the resource.
  • Methods

    MethodDescription
    getResourceInfoGets information about a resource.
    listResourceReturns a list of resources on the specified type for one location.
    resourceAvailableChecks whether there are available resources.

getResourceInfo

Gets information about one resource based on resource id.

  • Parameters

    LabelTypeDescription
    resourceIdkotlin.StringRequired. The unique id of the resource to retrieve.
  • Return

    If successful, the response body contains an instance of resource. When no one matches, it returns null.

    TypeDescription
    ResourceThe details of the instance of the resource's subclass, based on the resource id.
  • Example

    kotlin
    val resource = getResourceInfo("resource id")

listResource

Returns a list of resources on the specified type for one location.

  • Parameters

    LabelTypeDescription
    locationLocationRequired. The specified place that owns resources.
    typeResourceTypeRequired. The type of resource to retrieve.
    durationkotlin.intRequired. The duration of the resource to retrieve.
    datejava.time.LocalDateOptional. The date of resources to retrieve.
    timejava.time.LocalTimeOptional. The time of resources to retrieve.
  • Return Type

    If successful, this method returns a list of resources. If not found, it returns null.

    TypeDescription
    Resource[]A list of resources that matches the specified parameter value in the request.
  • Code Example

    kotlin
    val location = listLocation().first()
    val resourceType = ResourceType("table")
    val date = LocalDate.of(2023, 2, 20)
    val time = LocalTime.of(14, 0, 0, 0)
    val duration = 3600
    
    val resourceList = listResource(location, resourceType, date, time, duration)

resourceAvailable

Checks whether there are available resources, and returns ValidationResult.

  • Parameters

    LabelTypeDescription
    resourceResourceRequired. The resource to retrieve.
    durationkotlin.intRequired. The duration of the resource to retrieve.
    datejava.time.LocalDateOptional. The date of the resource to retrieve.
    timejava.time.LocalTimeOptional. The time of the resource to retrieve.
  • Example

    kotlin
    val location = listLocation().first()
    val resourceType = ResourceType("table")
    val date = LocalDate.of(2023, 2, 20)
    val time = LocalTime.of(14, 0, 0, 0)
    val duration = 3600
    val resource = listResource(location, resourceType, date, time, duration).first()
    
    val result = resourceAvailable(date, time, duration, resource)

Date

availableDates

Returns a list of available dates on the specified resource.

  • Parameters

    LabelTypeDescription
    resourceResourceRequired. Specify the resource to retrieve.
    durationkotlin.intRequired. Specify the duration of the resource to retrieve.
    timejava.time.LocalTimeOptional. Specify the time of the resource to retrieve.
  • Return

    TypeDescription
    java.time.localDate[]A list of available dates on the specified resource that matches the specified parameter value in the request.
  • Code Example

    kotlin
    val location = listLocation().first()
    val resourceType = ResourceType("table")
    val time = LocalTime.of(14, 0, 0, 0)
    val duration = 3600
    val resource = listResource(location, resourceType, null, time, duration).first()
    
    val dateList = availableDates(time, duration, resource)

Time

availableTimes

Returns a list of available times on the specified resource.

  • Parameters

    LabelTypeDescription
    resourceResourceRequired. Specify the resource to retrieve.
    durationkotlin.intRequired. Specify the duration of the resource to retrieve.
    datejava.time.LocalDateOptional. Specify the date of the resource to retrieve.
  • Return

    TypeDescription
    java.time.localTime[]A list of available times on the specified resource that matches the specified parameter value in the request.
  • Example

    kotlin
    val location = listLocation().first()
    val resourceType = ResourceType("table")
    val date = LocalDate.of(2023, 2, 20)
    val duration = 3600
    val resource = listResource(location, resourceType, date, null, duration).first()
    
    val timeList = availableTimes(date, duration, resource)

Reservation

A reservation represents the booking of one resource at one location. Each reservation is a unique booking created by a customer.

  • Fields

    PropertyTypeDescription
    idkotlin.StringThe unique ID of the reservation.
    resourceIdkotlin.StringThe resource ID of the reservation.
    userIdkotlin.StringThe unique ID of the customer.
    startjava.time.OffsetDateTimeThe start date and time of a reservation.
    endjava.time.OffsetDateTimeThe end date and time of a reservation.
    offsetkotlin.IntThe zone offset.
  • Methods

    MethodDescription
    makeReservationCreates a reservation.
    listReservationReturns a list of reservations for the specified customer.
    cancelReservationDeletes a reservation.
    updateReservationnUpdates a reservation.
    reservationCancelableChecks whether a reservation can be cancelled.
    reservationUpdatableChecks whether a reservation can be updated.

makeReservation

Creates a reservation.

  • Parameters

    LabelTypeDescription
    userIdkotlin.StringRequired. The unique ID of the customer.
    resourceResourceRequired. The resource of the reservation.
    durationkotlin.intRequired. The resource duration of the reservation.
    datejava.time.LocalDateOptional. The date of the reservation.
    timejava.time.LocalTimeOptional. The time of the reservation.
  • Return

    If successful, this method returns a reservation in the response body, null on failure.

    TypeDescription
    ReservationA reservation instance by the customer.
  • Example

    kotlin
    val location = listLocation().first()
    val resourceType = ResourceType("table")
    val date = LocalDate.of(2023, 2, 20)
    val time = LocalTime.of(14, 0, 0, 0)
    val duration = 3600
    val resource = listResource(location, resourceType, date, time, duration).first()
    
    val reservation = makeReservation("TestUser", date, time, duration, resource)

listReservation

Returns a list of reservations for the specified customer.

  • Parameters

    LabelTypeDescription
    userIdkotlin.StringRequired. The unique ID of the customer.
    locationLocationOptional. The location of the reservations to retrieve.
    resourceTypeResourceTypeOptional. The resource type of the reservations to retrieve.
  • Return

    If successful, this method returns a list of reservations in the response body.

    TypeDescription
    Reservation[]A list of reservations by the specified customer.
  • Example

    kotlin
    val location = listLocation().first()
    val resourceType = ResourceType("table")
    
    val reservationList = listReservation("TestUser", location, resourceType)

cancelReservation

Deletes a reservation, and returns the ValidationResult object indicating whether the status of the cancellation operation was successful.

  • Parameters

    LabelTypeDescription
    reservationReservationRequired. The specified reservation needs to be cancelled.
  • Example

    kotlin
    val location = listLocation().first()
    val resourceType = ResourceType("table")
    val reservaion = listReservation("TestUser", location, resourceType).first()
    
    val result = cancelReservation(reservation)

updateReservation

Update a reservation, and returns the ValidationResult object indicating whether the status of the update operation was successful.

  • Parameters

    LabelTypeDescription
    reservationreservationRequired. The specified reservation needs to be updated.
    resourceResourceRequired. The resource of the reservation.
    durationkotlin.intRequired. The resource duration of the reservation.
    datejava.time.LocalDateOptional. The date of the reservation.
    timejava.time.LocalTimeOptional. The time of the reservation.
  • Example

    kotlin
    val location = listLocation().first()
    val resourceType = ResourceType("table")
    val reservaion = listReservation("TestUser", location, resourceType).first()
    val date = LocalDate.of(2023, 2, 20)
    val time = LocalTime.of(14, 0, 0, 0)
    val duration = 3600
    val resource = listResource(location, resourceType, date, time, duration).first()
    
    val result = updateReservation(reservation, date, time, duration, resource)

reservationCancelable

Checks whether a reservation can be cancelled, and returns the ValidationResult object indicating whether the specified reservation can be cancelled.

  • Parameters

    LabelTypeDescription
    reservationReservationRequired. The specified reservation needs to be cancelled.
  • Example

    kotlin
    val location = listLocation().first()
    val resourceType = ResourceType("table")
    val reservation = listReservation("TestUser", location, resourceType).first()
    
    val result = reservationCancelable(reservation)

reservationUpdatable

Checks whether a reservation can be updated, and returns the ValidationResult object indicating whether the specified reservation can be updated.

  • Parameters

    LabelTypeDescription
    reservationreservationRequired. The specified reservation needs to be updated.
    resourceResourceRequired. The resource of the reservation.
    durationkotlin.intRequired. The resource duration of the reservation.
    datejava.time.LocalDateOptional. The date of the reservation.
    timejava.time.LocalTimeOptional. The time of the reservation.
  • Example

    kotlin
    val location = listLocation().first()
    val resourceType = ResourceType("table")
    val reservaion = listReservation("TestUser", location, resourceType).first()
    val date = LocalDate.of(2023, 2, 20)
    val time = LocalTime.of(14, 0, 0, 0)
    val duration = 3600
    val resource = listResource(location, resourceType, date, time, duration).first()
    
    val result = reservationUpdatable(reservation, date, time, duration, resource)

ValidationResult

The result object indicates whether the verification or the operation was successful.

PropertyTypeDescription
successkotlin.BooleanThe result of the verification or the operation, true or false.
invalidFeatureKeyskotlin.String[]The invalid feature.
messagekotlin.StringThe error message of the invalid feature.