- 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.Stringauthenticate()Retrieve a token based on the username and password you provided at the creation of the Builder.booleanisGranted(java.lang.String parkingSiteId, UserId user)Check whether aUserIdis 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 moreUserId) 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 moreUserId) that are allowed or denied on the parking site today.java.util.Collection<AccessRight>listAccessRightsForToday(boolean unreadOnly)List all users (identified by one or moreUserId) that are allowed or denied on the parking site today.java.lang.StringreportAccessLog(java.lang.String parkingSiteId, java.util.Collection<AccessLog> accessLogs)Report to Commuty one or moreAccessLogof users that entered/exited the parking site.CountreportAvailableSpotCount(java.lang.String parkingSiteId, int count, java.lang.Integer total)Report the number of available spots (and optionally the total number of spots) on a parking site.UserIdreportMissingUserId(UserId user)Report any user (identified by an id and aUserIdType) that is known by you but not by Commuty.
-
Method Details
-
authenticate
java.lang.String authenticate() throws CredentialsException, HttpRequestException, HttpClientExceptionRetrieve 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). SeeHttpRequestExceptionfor 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, HttpClientExceptionCheck whether a
UserIdis 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- TheUserIdto check.- Returns:
trueif the user is allowed on the site,falseotherwise.- 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). SeeHttpRequestExceptionfor 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, HttpClientExceptionList 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). SeeHttpRequestExceptionfor 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, HttpClientExceptionList all users (identified by one or more
UserId) that are allowed or denied on the parking site today.If
unreadOnlyisfalse, all the accesses of the current day will be returned, even if they were already retrieved. This is the same as callinglistAccessRightsForToday().If
unreadOnlyistrue, 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). SeeHttpRequestExceptionfor 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, HttpClientExceptionList all users (identified by one or more
UserId) that are allowed or denied on the parking site for a given day.The
dateparameter will filter accesses that occurs on or after midnight of the given day and before midnight of the next day.If
unreadOnlyisfalse, all the accesses of the current day will be returned, even if they were already retrieved. This is the same as callinglistAccessRightsForToday().If
unreadOnlyistrue, only the new accesses (the ones that were never retrieved via an api call) will be listed.- Parameters:
date- TheLocalDateof the events you want to retrieve. Ifdateis null, the accesses of the current day will be retrieved.unreadOnly- Whether you want to retrieve unread only accesses (true) or all accesses (false). IfunreadOnlyis 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). SeeHttpRequestExceptionfor 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, HttpClientExceptionReport to Commuty one or more
AccessLogof 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 moreAccessLog.- 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). SeeHttpRequestExceptionfor more details. This exception can happen if theparkingSiteIdis not known.HttpClientException- The query did not reached the api, i.e. there was a network issue.
-
reportMissingUserId
UserId reportMissingUserId(UserId user) throws CredentialsException, HttpRequestException, HttpClientExceptionReport 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- TheUserIdto 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). SeeHttpRequestExceptionfor more details.HttpClientException- The query did not reached the api, i.e. there was a network issue.
-
reportAvailableSpotCount
Count reportAvailableSpotCount(java.lang.String parkingSiteId, int count, java.lang.Integer total) throws CredentialsException, HttpRequestException, HttpClientExceptionReport the number of available spots (and optionally the total number of spots) on a parking site.
- Parameters:
parkingSiteId- The identifier of the parking site that was given by Commuty.count- The number of available spots at the time of the submission.total- The total number of spots (the size of the parking site) at the time of the submission. Ca benull.- Returns:
- The reported counts.
- 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). SeeHttpRequestExceptionfor more details.HttpClientException- The query did not reached the api, i.e. there was a network issue.
-