Chapter 4: PDF Reports and Data - zymbia-carpm/garagepro_sdk GitHub Wiki
Introduction
Once the scan process is completed successfully using the GaragePro Android SDK, you can access detailed scan data and our PDF reports through GaragePro APIs. These APIs provide seamless integration for accessing diagnostic information and generating comprehensive reports.
The GaragePro API is organized around REST. Our API has predictable, resource-oriented URLs, and uses HTTP response codes to indicate API errors. We use built-in HTTP features, like HTTP authentication and HTTP verbs, which are understood by off-the-shelf HTTP clients. JSON is returned by all API responses, including errors.
Getting Started Guide
To start using the GaragePro API, you need to make sure the following steps are followed -
- You must use a valid Authentication Token to send requests to the API endpoints. You can get your Authentication Token from Authentication API.
- The API only responds to HTTPS-secured communications. Any requests sent via HTTP, return an HTTP 301 redirect to the corresponding HTTPS resources.
- The API returns request responses in JSON format. When an API request returns an error, it is sent in the JSON response as an error key.
API Headers
In each API, except the Authentication API, the following set of headers need to be passed -
- 'Content-Type' -> application/json
- 'Accept' -> application/json
- 'X-User-Email' -> Email ID of the developer
- 'X-User-Token' -> Authentication Token, returned as a response from the authentication API
Webhooks
You can also set up a webhook with GaragePro to get updates on which function is being used in the GaragePro SDK by a inspector/mechanic.
Setup
You need to provide us the the webhook url and we will configure that in our GaragePro server. When a new event is created, a POST request is made to the callback URL you added to your GaragePro account.
Specifications
- Method: POST
- Header 'Content-Type' -> application/json
- There should not be any authentication token to receive the webhook
Sample Body:
{
"function_used": "report",
"function_id": 12345,
"report_url": "https://carpminspectionreports.s3.amazonaws.com/mechanic/reports/reports/003/069/889/original/Lovish__1671299055.pdf?1671299071",
"mechanic_email": "[email protected]",
"license_plate": "TEST-123"
}
50X response
An HTTP 50X response from our server indicates that there is an unexpected spike or there is some internal error in API. The server is usually operational within the next five minutes. If the outage persists or you receive any other form of an HTTP 5XX error, contact us at [email protected].
GaragePro API Endpoints
1. Authentication API - POST request
This request is used to generate an authentication token for the user, which will be used to access every other APIs.
// Request Headers
Content-Type => application/json
Accept => application/json
{{url}}/users/sign_in
// Body
{
"user": {
"email": "[email protected]",
"password": "12345678"
}
}
2. All Reports API - GET request
This request is used to get all the scan data and pdf reports data for the signed user.
// Request Headers
Content-Type => application/json
Accept => application/json
X-User-Email => {{email}}
X-User-Token => {{authentication_token}}
{{url}}/mechanic/reports/history?offset=10
// Query Parameter
offset => number (Optional)
3. Report Details API - GET request
This request is used to get all the details about a particular report for the signed user.
// Request Headers
Content-Type => application/json
Accept => application/json
X-User-Email => {{email}}
X-User-Token => {{authentication_token}}
{{url}}/mechanic/reports/get_report?scan_id=3069889
// Query Parameter
scan_id => scan id returned in the onScanCompleted function
4. User History API - GET request
This API is used to get the complete history for the signed user.
// Request Headers
Content-Type => application/json
Accept => application/json
X-User-Email => {{email}}
X-User-Token => {{authentication_token}}
{{url}}/user_histories?offset=20
// Query Parameter
offset => number (Optional)