Skip to content

Send Event Request Overview

The data collector send event request provides various event models to send application & vehicle sensor events to the cloud. Telenav currently supports the below listed events for different scenarios, the corresponding data models provided facilitate building events by filling mandatory and optional data fields using the builder.

Send Event Request

This "input" API lets a producer report an event, generate and send the event data to DataCollector

Key methods

Method Details
setEvent(Event event) The specific event which comes from com.telenav.datacollector.model with event data included

Sample code

1
2
3
4
5
6
7
8
SendEventRequest.Builder builder = client.sendEventRequest();
SendEventResponse response = builder
    .setEvent(FavoriteEvent.builder()
            .setActionType(FavoriteEvent.ActionType.ADD)
            .setEntityId("faked_id")
            .build())
    .build()
    .execute();
1
2
3
4
5
6
7
8
SendEventRequest.Builder builder = client.sendEventRequest()
SendEventResponse response = builder
    .setEvent(FavoriteEvent.builder()
            .setActionType(FavoriteEvent.ActionType.ADD)
            .setEntityId("faked_id")
            .build())
    .build()
    .execute()

Response example

1
2
3
4
5
{
  "code": "SUCCESS",
  "message": "SendEventResponse Success",
  "response_time": 1
}

You can also call API asynchronously using asyncCall() method of builder if no need to cancel the request.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
SendEventRequest.Builder builder = client.sendEventRequest();
builder.setEvent(SetHomeEvent.builder()
    .setLabel("Label").setEntityId("faked_id")
    .setActionType(SetHomeEvent.ActionType.SET).setLat(31.201840).setLon(121.541237).build())
    .asyncCall(new Callback<SendEventResponse>() {

        @Override
        public void onSuccess(SendEventResponse response) {
            System.out.println("\n[Async SendEvent Response]: \n" + DataCollectorJsonConverter.toJson(response));
        }

        @Override
        public void onFailure(Throwable t) {
            if(t!= null) {
                t.printStackTrace();
            }
        }
    });
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
var builder = client.sendEventRequest();

builder.setEvent(SetHomeEvent.builder()
    .setLabel("Label").setEntityId("faked_id")
    .setActionType(SetHomeEvent.ActionType.SET).setLat(31.201840).setLon(121.541237).build())
    .asyncCall(new Callback<SendEventResponse>() {

        @Override
        public void onSuccess(SendEventResponse response) {
            System.out.println("\n[Async SendEvent Response]: \n" + DataCollectorJsonConverter.toJson(response));
        }

        @Override
        public void onFailure(Throwable t) {
            if(t!= null) {
                t.printStackTrace();
            }
        }
    });

Response example

1
2
3
4
5
{
  "code": "SUCCESS",
  "message": "SendEventResponse Success",
  "response_time": 1
}

Please see the API reference for the main classes related to Data Collector.

Event Categories

Currently, all supported events can be categorized as below, still working in progress: