Interface ParkingAccess

All Known Implementing Classes:
ParkingAccessRestClient

public interface ParkingAccess

This is the client you must use to query the parking access api of Commuty.

To create this client, use the Configuration.Builder (via the Configuration.Builder.create() or Configuration.Builder.buildDefault(String, String).

  • Method Summary

    Modifier and Type Method Description
    java.lang.String authenticate()
    Retrieve a token based on the username and password you provided at the creation of the Builder.
    boolean isGranted​(java.lang.String parkingSiteId, UserId user)
    Check whether a UserId is allowed to enter the parking site (or not) when the request is made.
    java.util.Collection<AccessRight> listAccessRights​(java.time.LocalDate date, java.lang.Boolean unreadOnly)
    List all users (identified by one or more UserId) that are allowed or denied on the parking site for a given day.
    java.util.Collection<AccessRight> listAccessRightsForToday()
    List all users (identified by one or more UserId) that are allowed or denied on the parking site today.
    java.util.Collection<AccessRight> listAccessRightsForToday​(boolean unreadOnly)
    List all users (identified by one or more UserId) that are allowed or denied on the parking site today.
    java.lang.String reportAccessLog​(java.lang.String parkingSiteId, java.util.Collection<AccessLog> accessLogs)
    Report to Commuty one or more AccessLog of users that entered/exited the parking site.
    UserId reportMissingUserId​(UserId user)
    Report any user (identified by an id and a UserIdType) that is known by you but not by Commuty.
  • Method Details

    • authenticate

      java.lang.String authenticate() throws CredentialsException, HttpRequestException, HttpClientException

      Retrieve a token based on the username and password you provided at the creation of the Builder.

      By calling this method, the client will fetch a token and then save a local copy of it for further queries.

      You don't need to use this method as the client will handle authentication for you.

      Returns:
      The token generated by the api The token is valid for 24 hours.
      Throws:
      CredentialsException - Your username or password is invalid.
      HttpRequestException - The query was sent to the api but the status is unsuccessful (HTTP status code ≥ 400). See HttpRequestException for more details.
      HttpClientException - The query did not reached the api, i.e. there was a network issue.
    • isGranted

      boolean isGranted​(java.lang.String parkingSiteId, UserId user) throws CredentialsException, HttpRequestException, HttpClientException

      Check whether a UserId is allowed to enter the parking site (or not) when the request is made.

      If a user has more thant one identifier known by Commuty (i.e. a badge code and a number plate), only one identifier is required to check its grant status.

      Parameters:
      parkingSiteId - The identifier of the parking site that was given by Commuty.
      user - The UserId to check.
      Returns:
      true if the user is allowed on the site, false otherwise.
      Throws:
      CredentialsException - Your username or password is invalid.
      HttpRequestException - The query was sent to the api but the status is unsuccessful (HTTP status code ≥ 400). See HttpRequestException for more details.
      HttpClientException - The query did not reached the api, i.e. there was a network issue.
    • listAccessRightsForToday

      java.util.Collection<AccessRight> listAccessRightsForToday() throws CredentialsException, HttpRequestException, HttpClientException

      List all users (identified by one or more UserId) that are allowed or denied on the parking site today.

      This will return all accesses of the current day, even if they were already retrieved.

      Returns:
      One or more AccessRight. Each user known by Commuty will at least have one access (granted or not). A user can have multiple accesses.
      Throws:
      CredentialsException - Your username or password is invalid.
      HttpRequestException - The query was sent to the api but the status is unsuccessful (HTTP status code ≥ 400). See HttpRequestException for more details.
      HttpClientException - The query did not reached the api, i.e. there was a network issue.
    • listAccessRightsForToday

      java.util.Collection<AccessRight> listAccessRightsForToday​(boolean unreadOnly) throws CredentialsException, HttpRequestException, HttpClientException

      List all users (identified by one or more UserId) that are allowed or denied on the parking site today.

      If unreadOnly is false, all the accesses of the current day will be returned, even if they were already retrieved. This is the same as calling listAccessRightsForToday().

      If unreadOnly is true, only the new accesses (the ones that were never retrieved via an api call) will be listed.

      Parameters:
      unreadOnly - Whether you want to retrieve unread only accesses (true) or all accesses (false)
      Returns:
      One or more AccessRight. Each user known by Commuty will at least have one access (granted or not). A user can have multiple accesses.
      Throws:
      CredentialsException - Your username or password is invalid.
      HttpRequestException - The query was sent to the api but the status is unsuccessful (HTTP status code ≥ 400). See HttpRequestException for more details.
      HttpClientException - The query did not reached the api, i.e. there was a network issue.
    • listAccessRights

      java.util.Collection<AccessRight> listAccessRights​(java.time.LocalDate date, java.lang.Boolean unreadOnly) throws CredentialsException, HttpRequestException, HttpClientException

      List all users (identified by one or more UserId) that are allowed or denied on the parking site for a given day.

      The date parameter will filter accesses that occurs on or after midnight of the given day and before midnight of the next day.

      If unreadOnly is false, all the accesses of the current day will be returned, even if they were already retrieved. This is the same as calling listAccessRightsForToday().

      If unreadOnly is true, only the new accesses (the ones that were never retrieved via an api call) will be listed.

      Parameters:
      date - The LocalDate of the events you want to retrieve. If date is null, the accesses of the current day will be retrieved.
      unreadOnly - Whether you want to retrieve unread only accesses (true) or all accesses (false). If unreadOnly is null, all the accesses (read and unread) will be retrieved.
      Returns:
      One or more AccessRight. Each user known by Commuty will at least have one access (granted or not). A user can have multiple accesses.
      Throws:
      CredentialsException - Your username or password is invalid.
      HttpRequestException - The query was sent to the api but the status is unsuccessful (HTTP status code ≥ 400). See HttpRequestException for more details.
      HttpClientException - The query did not reached the api, i.e. there was a network issue.
    • reportAccessLog

      java.lang.String reportAccessLog​(java.lang.String parkingSiteId, java.util.Collection<AccessLog> accessLogs) throws CredentialsException, HttpRequestException, HttpClientException

      Report to Commuty one or more AccessLog of users that entered/exited the parking site.

      This will allow Commuty to create attendance reports for parking site owners.

      Upon success of this request, Commuty will reply with an unique identifier (an UUID). You can keep this identifier when Communicating with Commuty if there is an issue.

      Parameters:
      parkingSiteId - The identifier of the parking site that was given by Commuty.
      accessLogs - A collection of one or more AccessLog.
      Returns:
      An identifier of the request you made. This can be kept for further reference
      Throws:
      CredentialsException - Your username or password is invalid.
      HttpRequestException - The query was sent to the api but the status is unsuccessful (HTTP status code ≥ 400). See HttpRequestException for more details. This exception can happen if the parkingSiteId is not known.
      HttpClientException - The query did not reached the api, i.e. there was a network issue.
    • reportMissingUserId

      Report any user (identified by an id and a UserIdType) that is known by you but not by Commuty.

      This will allow Commuty to display a list of problematic users to parking site owners.

      Parameters:
      user - The UserId to report to Commuty.
      Returns:
      The reported user.
      Throws:
      CredentialsException - Your username or password is invalid.
      HttpRequestException - The query was sent to the api but the status is unsuccessful (HTTP status code ≥ 400). See HttpRequestException for more details.
      HttpClientException - The query did not reached the api, i.e. there was a network issue.