# References (Android)

## ChallengesSyncStatus

| Value                                     | Description                                                                      |
| ----------------------------------------- | -------------------------------------------------------------------------------- |
| SUCCESS                                   | Synchronization has been successfully performed.                                 |
| CACHE\_DATA\_ONLY                         | SynchronizationType has been set to `CACHE`.                                     |
| FAILED\_TO\_SYNC\_CHALLENGES\_CACHE\_ONLY | Synchronization has failed, only challenges previously synchronized are returned |
| SYNC\_ALREADY\_IN\_PROGRESS               | Another challenge list synchronization is already in progress                    |

## Challenge

| Field                 | Type                                   | Description                                                                                                                                                                                                 |
| --------------------- | -------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| challengeId           | String                                 | Unique identifier of the challenge                                                                                                                                                                          |
| challengeType         | [ChallengeType](#challengetype)        | Type of the challenge                                                                                                                                                                                       |
| title                 | String                                 | Title of the challenge                                                                                                                                                                                      |
| description           | String                                 | Description of the challenge                                                                                                                                                                                |
| conditionsDescription | String?                                | Description of the challenge’s conditions to be filled.                                                                                                                                                     |
| startDate             | Date                                   | Challenge’s start date                                                                                                                                                                                      |
| endDate               | Date                                   | Challenge’s end date                                                                                                                                                                                        |
| conditions            | Map\<String, String>                   | <p>Required conditions to participate. </p><p>Possible keys of the map are: <code>km</code> and <code>nbTrip</code>.</p><p><strong>Remark:</strong> All conditions must be met in order to participate.</p> |
| rankKey               | String?                                | *Deprecated*.                                                                                                                                                                                               |
| themeCode             | Int                                    | *Deprecated*                                                                                                                                                                                                |
| type                  | Int                                    | *Deprecated.*                                                                                                                                                                                               |
| isRegistered          | Boolean                                | Equals `true` if the user participates in the challenge.                                                                                                                                                    |
| conditionsFilled      | Boolean                                | Equals `true` if the conditions are filled by the user to access the challenge.                                                                                                                             |
| driverConditions      | Map\<String, String>                   | <p>Current driver values for conditions to participate in the challenge.</p><p>Possible keys of the map are: <code>km</code> and <code>nbTrip</code></p>                                                    |
| groups                | List<[ChallengeGroup](#challengetype)> | Groups that can view and participate to the challenge                                                                                                                                                       |
| rules                 | String?                                | Rules of the current challenge                                                                                                                                                                              |
| optinText             | String?                                | Opt-in text of the current challenge                                                                                                                                                                        |
| status                | [ChallengeStatus](#challengestatus)    | Current status of the challenge                                                                                                                                                                             |
| nbDriverRegistered    | Int                                    | Number of drivers registered for this challenge                                                                                                                                                             |
| nbDriverRanked        | Int                                    | Number of drivers ranked for this challenge                                                                                                                                                                 |
| rank                  | Int                                    | <p>Current rank of the driver.<br>Equals <code>0</code> if the driver is not registered or not ranked for this challenge.</p>                                                                               |

## ChallengeType

| Value              | Description                                                                         |
| ------------------ | ----------------------------------------------------------------------------------- |
| SAFETY             | The challenge is based on the safety score                                          |
| ECODRIVING         | The challenge is based on the ecodriving score                                      |
| DISTRACTION        | The challenge is based on the distraction score                                     |
| SPEEDING           | The challenge is based on the speeding score                                        |
| HARD\_BRAKING      | The challenge is based on the number of hard braking                                |
| HARD\_ACCELERATION | The challenge is based on the number of hard acceleration                           |
| DEPRECATED         | The challenge type is deprecated. You should ignore it in your graphical interface. |
| UNKNOWN            | The challenge type is unknown. You have to ignore it in your graphical interface.   |

<table><thead><tr><th width="100">Value</th><th>Description</th></tr></thead><tbody><tr><td>101</td><td>Challenge based on eco driving score</td></tr><tr><td>201</td><td>Challenge based on safety score</td></tr><tr><td>205</td><td>Challenge based on the number of hard brakings</td></tr><tr><td>209</td><td>Challenge based on the number of hard acceleration</td></tr><tr><td>221</td><td>Challenge based on distraction score</td></tr><tr><td>401</td><td>Challenge based on speeding score</td></tr></tbody></table>

## ChallengeGroup

| Field | Type   | Description        |
| ----- | ------ | ------------------ |
| id    | String | Group identifier   |
| label | String | Label of the group |

## ChallengeStatus

<table><thead><tr><th width="188">Value</th><th>Description</th></tr></thead><tbody><tr><td>FINISHED</td><td>The challenge is finished.</td></tr><tr><td>SCHEDULED</td><td>The challenge has not started yet.</td></tr><tr><td>PENDING</td><td>The challenge is in progress.</td></tr><tr><td>ARCHIVED</td><td>The challenge is finished and is archived. It should not appear in the list</td></tr></tbody></table>

## ChallengeDetailSyncStatus

| Value                                            | Description                                                                            |
| ------------------------------------------------ | -------------------------------------------------------------------------------------- |
| SUCCESS                                          | Synchronisation has been successfully performed.                                       |
| CHALLENGE\_NOT\_FOUND                            | There is no existing challenge with this *challengeId*.                                |
| CACHE\_DATA\_ONLY                                | synchronizationType has been set to `CACHE`.                                           |
| FAILED\_TO\_SYNC\_CHALLENGE\_DETAIL\_CACHE\_ONLY | Synchronisation has failed, only challenge detail previously synchronized is returned. |
| SYNC\_ALREADY\_IN\_PROGRESS                      | Another challenge detail retrieval for this identifier is already in progress          |

## ChallengeDetail

| Field              | Type                                                   | Description                                                      |
| ------------------ | ------------------------------------------------------ | ---------------------------------------------------------------- |
| challengeId        | String                                                 | Identifier of the challenge                                      |
| driverStats        | [ChallengeDriverStats](#challengedriverstats)          | Driver’s statistics of the challenge                             |
| challengeStats     | [ChallengeStats](#challengestats)                      | Global statistics of the challenge                               |
| driversRanked      | List<[ChallengeDriverRanked](#challengedriverranked)>? | Ranked drivers list.                                             |
| userIndex          | Int                                                    | Position of the user in the `driversRanked` list                 |
| nbDriverRegistered | Int                                                    | Number of drivers registered for this challenge                  |
| nbDriverRanked     | Int                                                    | Number of drivers ranked for this challenge                      |
| isRegistered       | Boolean                                                | Equals `true` if the user is registered to the challenge         |
| conditionsFilled   | Boolean                                                | Equals `true` if the user has filled the condition to be ranked. |
| itinIds            | List\<String>                                          | List of itinerary IDs made by the user during the challenge.     |

## ChallengeDriverStats

| Field      | Type   | Description                                                      |
| ---------- | ------ | ---------------------------------------------------------------- |
| rank       | Int    | Driver’s rank for this challenge                                 |
| numberTrip | Int    | Number of trips made during the challenge                        |
| distance   | Double | Total distance (in km) made during the challenge                 |
| duration   | Double | Total duration (in hours) of the trips made during the challenge |
| score      | Double | Score for the challenge                                          |

## ChallengeStats

| Field        | Type   | Description                                            |
| ------------ | ------ | ------------------------------------------------------ |
| numberDriver | Int    | Total number of drivers participating in the challenge |
| numberTrip   | Int    | Total number of trips done for this challenge          |
| distance     | Double | Total distance (in km) travelled for this challenge    |
| duration     | Double | Total trips duration (in hours) of the challenge       |
| score        | Double | Average challenge score                                |
| minScore     | Double | Lowest score for this challenge                        |
| maxScore     | Double | Best score for this challenge                          |

## ChallengeDriverRanked

| Field        | Type   | Description                              |
| ------------ | ------ | ---------------------------------------- |
| pseudo       | String | Pseudo of the driver                     |
| rank         | Int    | Driver’s rank                            |
| score        | Double | Driver’s score on ten                    |
| previousRank | Int    | Driver’s previous rank                   |
| distance     | Double | Distance travelled by the driver (in km) |

## JoinChallengeSyncStatus

| Value                 | Description                                                                   |
| --------------------- | ----------------------------------------------------------------------------- |
| JOIN\_SUCCESS         | The challenge is joined successfully                                          |
| ALREADY\_JOINED       | The user has already joined the given challenge                               |
| CHALLENGE\_NOT\_FOUND | There is no existing challenge with this *challengeId*                        |
| FAILED\_TO\_JOIN      | Couldn’t join the challenge. Can occur for example if the user has no network |
