- All Implemented Interfaces:
ParkingAccess
public class ParkingAccessRestClient extends java.lang.Object implements ParkingAccess
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringACCESS_REQUESTS_URLstatic java.lang.StringACCESS_RIGHTS_URLstatic java.lang.StringDAY_PARAMstatic java.lang.StringREPORT_ACCESS_URLstatic java.lang.StringREPORT_MISSING_IDS_URLstatic java.lang.StringTOKEN_REQUESTS_URLstatic java.lang.StringUNREAD_ONLY_PARAM -
Constructor Summary
Constructors Constructor Description ParkingAccessRestClient(Configuration configuration) -
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.UserIdreportMissingUserId(UserId user)Report any user (identified by an id and aUserIdType) that is known by you but not by Commuty.
-
Field Details
-
TOKEN_REQUESTS_URL
public static final java.lang.String TOKEN_REQUESTS_URL- See Also:
- Constant Field Values
-
ACCESS_REQUESTS_URL
public static final java.lang.String ACCESS_REQUESTS_URL- See Also:
- Constant Field Values
-
ACCESS_RIGHTS_URL
public static final java.lang.String ACCESS_RIGHTS_URL- See Also:
- Constant Field Values
-
REPORT_ACCESS_URL
public static final java.lang.String REPORT_ACCESS_URL- See Also:
- Constant Field Values
-
REPORT_MISSING_IDS_URL
public static final java.lang.String REPORT_MISSING_IDS_URL- See Also:
- Constant Field Values
-
DAY_PARAM
public static final java.lang.String DAY_PARAM- See Also:
- Constant Field Values
-
UNREAD_ONLY_PARAM
public static final java.lang.String UNREAD_ONLY_PARAM- See Also:
- Constant Field Values
-
-
Constructor Details
-
Method Details
-
authenticate
public java.lang.String authenticate() throws CredentialsException, HttpRequestException, HttpClientExceptionDescription copied from interface:ParkingAccessRetrieve 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.
- Specified by:
authenticatein interfaceParkingAccess- 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
public boolean isGranted(java.lang.String parkingSiteId, UserId user) throws CredentialsException, HttpRequestException, HttpClientExceptionDescription copied from interface:ParkingAccessCheck 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.
- Specified by:
isGrantedin interfaceParkingAccess- 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
public java.util.Collection<AccessRight> listAccessRightsForToday() throws CredentialsException, HttpRequestException, HttpClientExceptionDescription copied from interface:ParkingAccessList 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.
- Specified by:
listAccessRightsForTodayin interfaceParkingAccess- 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
public java.util.Collection<AccessRight> listAccessRightsForToday(boolean unreadOnly) throws CredentialsException, HttpRequestException, HttpClientExceptionDescription copied from interface:ParkingAccessList 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 callingParkingAccess.listAccessRightsForToday().If
unreadOnlyistrue, only the new accesses (the ones that were never retrieved via an api call) will be listed.- Specified by:
listAccessRightsForTodayin interfaceParkingAccess- 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
public java.util.Collection<AccessRight> listAccessRights(java.time.LocalDate date, java.lang.Boolean unreadOnly) throws CredentialsException, HttpRequestException, HttpClientExceptionDescription copied from interface:ParkingAccessList 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 callingParkingAccess.listAccessRightsForToday().If
unreadOnlyistrue, only the new accesses (the ones that were never retrieved via an api call) will be listed.- Specified by:
listAccessRightsin interfaceParkingAccess- 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
public java.lang.String reportAccessLog(java.lang.String parkingSiteId, java.util.Collection<AccessLog> accessLogs) throws CredentialsException, HttpRequestException, HttpClientExceptionDescription copied from interface:ParkingAccessReport 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.
- Specified by:
reportAccessLogin interfaceParkingAccess- 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
public UserId reportMissingUserId(UserId user) throws CredentialsException, HttpRequestException, HttpClientExceptionDescription copied from interface:ParkingAccessReport 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.
- Specified by:
reportMissingUserIdin interfaceParkingAccess- 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.
-