Class ParkingAccessRestClient
- All Implemented Interfaces:
ParkingAccess
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionRetrieve a token based on the username and password you provided at the creation of the Builder.booleanCheck whether aUserIdis allowed to enter the parking site (or not) when the request is made.listAccessRights(LocalDate date, Boolean unreadOnly, Boolean dryRun, LocalDateTime createdAfter, Boolean granted, String parkingSiteId, UUID subjectId, Set<AccessRightAttributeName> includeAttributes) List all users (identified by one or moreUserId) that are allowed or denied on the parking site for a given day.List all users (identified by one or moreUserId) that are allowed or denied on the parking site today.listAccessRightsForToday(boolean unreadOnly) List all users (identified by one or moreUserId) that are allowed or denied on the parking site today.listParkingSpots(String parkingSiteId) Lists all the parking spot of a given parking site.reportAccessLog(String parkingSiteId, Collection<AccessLog> accessLogs) Report to Commuty one or moreAccessLogof users that entered/exited the parking site.This endpoint enables the submission of application logs to the server for storage, analysis, and monitoring purposes.reportAvailableSpotCount(String parkingSiteId, int count, Integer total) Report the number of available spots (and optionally the total number of spots) on a parking site.reportMissingUserId(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
- See Also:
-
ACCESS_REQUESTS_URL
- See Also:
-
ACCESS_RIGHTS_URL
- See Also:
-
PARKING_SPOTS_RIGHTS_URL
- See Also:
-
APPLICATION_LOGS_URL
- See Also:
-
REPORT_ACCESS_URL
- See Also:
-
REPORT_MISSING_IDS_URL
- See Also:
-
REPORT_AVAILABLE_SPOTS_COUNT_URL
- See Also:
-
DAY_PARAM
- See Also:
-
UNREAD_ONLY_PARAM
- See Also:
-
DRY_RUN_PARAM
- See Also:
-
CREATED_AFTER_PARAM
- See Also:
-
GRANTED_PARAM
- See Also:
-
PARKING_SITE_ID_PARAM
- See Also:
-
SUBJECT_ID_PARAM
- See Also:
-
INCLUDE_ATTRIBUTES_PARAM
- See Also:
-
-
Constructor Details
-
ParkingAccessRestClient
-
-
Method Details
-
authenticate
Description 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(String parkingSiteId, UserId user) throws CredentialsException, HttpRequestException, HttpClientException Description 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 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 Collection<AccessRight> listAccessRightsForToday(boolean unreadOnly) throws CredentialsException, HttpRequestException, HttpClientException Description 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 Collection<AccessRight> listAccessRights(LocalDate date, Boolean unreadOnly, Boolean dryRun, LocalDateTime createdAfter, Boolean granted, String parkingSiteId, UUID subjectId, Set<AccessRightAttributeName> includeAttributes) throws CredentialsException, HttpRequestException, HttpClientException Description 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.dryRun- Whether you want to prevent to flag the retrieve accesses as "read" (true) or not (false). IfunreadOnlyis null, all the accesses retrieved will be flagged as "read".createdAfter- Only retrieve events created after thisLocalDateTime. Represents aUTCtimestamp. IfcreatedAfteris null, all the accesses will be retrieved.granted- If set to `true`, only the access rights that are granted will be returned. If set to `false`, only the access rights that are denied will be returned. Ifgrantedis null, all the accesses will be retrieved.parkingSiteId- If set, only the access rights associated with the providedparkingSiteId(case-sensitive) will be returned. IfparkingSiteIdis null or blank, all the accesses will be retrieved.includeAttributes- Whether you want to fetch extra attributes about each access. The possible values are listed inAccessRightAttributeName.- 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 String reportAccessLog(String parkingSiteId, Collection<AccessLog> accessLogs) throws CredentialsException, HttpRequestException, HttpClientException Description 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, HttpClientException Description 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.
-
reportAvailableSpotCount
public Count reportAvailableSpotCount(String parkingSiteId, int count, Integer total) throws CredentialsException, HttpRequestException, HttpClientException Description copied from interface:ParkingAccessReport the number of available spots (and optionally the total number of spots) on a parking site.
- Specified by:
reportAvailableSpotCountin interfaceParkingAccess- 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.
-
listParkingSpots
public List<ParkingSpot> listParkingSpots(String parkingSiteId) throws CredentialsException, HttpRequestException, HttpClientException Description copied from interface:ParkingAccessLists all the parking spot of a given parking site.
It does not return the parking spots that have been deleted.
- Specified by:
listParkingSpotsin interfaceParkingAccess- Parameters:
parkingSiteId- The identifier of the parking site that was given by Commuty. must not be null or blank- Returns:
- the active (not deleted)
ParkingSpots for the given parking site. - 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.
-
reportApplicationLog
public UUID reportApplicationLog(ApplicationLog log) throws CredentialsException, HttpRequestException, HttpClientException Description copied from interface:ParkingAccessThis endpoint enables the submission of application logs to the server for storage, analysis, and monitoring purposes.
Application logs can be sent to this endpoint to record important events, troubleshoot issues, and enhance operational visibility.
While this endpoint is available for submitting application logs, it is essential to exercise discretion and prudence in its usage.
The system behind this endpoint is not designed as a comprehensive application log storage solution, but rather as a mechanism to capture and share specific logs that hold substantial relevance or utility beyond individual application contexts.
- Selectivity is Key: Reserve the use of this endpoint for logs that offer substantial insights, are crucial for monitoring, or are essential for cross-system analysis. Sending every log generated by the application can overwhelm the system and make it challenging to identify and address critical issues.
- Significant Events: Focus on logging significant events or milestones within the application, such as successful logins, critical errors, security-related incidents, or events that signify successful integrations with external systems. These logs should provide valuable information to developers, operators, or stakeholders.
- Troubleshooting and Analysis: Prioritize logs that are instrumental in diagnosing issues, detecting discrepancies, or aiding in performance optimization. Logs that contribute to troubleshooting and root cause analysis are particularly valuable.
- Avoid Noise: Refrain from sending routine or low-impact logs that do not significantly contribute to monitoring, debugging, or analysis. Examples include routine system health checks or verbose debugging messages meant solely for development purposes.
- Resource Considerations: Keep in mind that the system behind this endpoint may have resource limitations. Sending excessive, unnecessary logs can strain resources, impacting the system's overall performance and responsiveness.
- Adhere to Data Privacy and Compliance: Ensure that any logs sent through this endpoint comply with data privacy regulations and do not include sensitive or personally identifiable information (PII) unless necessary and appropriately protected.
- Documentation and Communication: Establish clear guidelines and documentation within your development team regarding which logs should be sent through this endpoint. Promote open communication among team members to ensure that only relevant logs are transmitted.
- Specified by:
reportApplicationLogin interfaceParkingAccess- Parameters:
log- The application log to send.- Returns:
- The application log's id once it is saved by the API.
- 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.
-