Action

An Action is a pickup, delivery, visit or any other transaction event being performed by the User.

Action object

Method Type Description
getId uuid String Unique identifier for the object
getUser User The user object to which the action was assigned
getType String The type of the action, possible values are TYPE_PICKUP, TYPE_DELIVERY, TYPE_DROPOFF, TYPE_VISIT, TYPE_STOPOVER, TYPE_TASK, TYPE_TRIP. See below for more detail
getUniqueId String A unique id in your system which can be mapped to the HyperTrack Action entity for looking up HyperTrack Action
getCollectionId String An id to club a list of Actions together. It can be used to power dashboard widgets and live tracking experience for actions in this collection
getExpectedAT Date The expected time by when the action should be completed
getExpectedPlace Place The expected place object where the action suppose to be completed
getStatus String The action status. See below for possible values.
getArrivalStatus String Current arrival status of the action. Will be null for a completed/cancelled action. See below for possible values.
getETA Date The current eta for the action, calculated in real-time
getCompletedPlace Place The place where the action was completed
getCompletedAT Date The time at which the action was completed
getTrackingURL String The URL at which this action can be tracked
getDistance String Distance travelled by the user in meters
getStartedPlace Place The place object where the action was started.
getMetaData Object Metadata as Object provided as ActionParams while creating the action
getDistanceUnit String Unit of distance travelled according to region where Action has consumed. mi for miles and km for kilometers
isTrackable boolean Method to check whether given Action is trackable or not. Returns true, only if action is assigned to user and his location is enabled and connected to internet otherwise, false.

Create and Assign Action

Create a new Action and assign it to User to start tracking. Returns a Action object through HyperTrackCallback on successful call.

Parameter required to create ActionParams
Parameter Required Description
expectedPlace No The Place object where the action will be performed. Only one of expected_place or expected_place_id must be specified.
expectedPlaceId No The id of the Place where the action will be performed
actionType No The type of the action, possible values are TYPE_PICKUP, TYPE_DELIVERY, TYPE_DROPOFF, TYPE_VISIT, TYPE_STOPOVER, TYPE_TASK, TYPE_TRIP
expectedAtTimeStamp No The expected time stamp by when the action should be completed
uniqueId No A unique id in your system which can be mapped to the HyperTrack Action entity for looking up HyperTrack Action
collectionId No An id to club a list of Actions together. It can be used to power dashboard widgets and live tracking experience for actions in this collection
locationTimeoutInSeconds No An integer denoting the timeout (in seconds) for collecting device's current location before createAction API call
metadata No A JSONObject denoting the metadata to be associated with the Action object
uniqueIdAsShortCode No A flag indicating whether to set tracking url's unique Short Code as the Action's unique Id
autocompleteRule No Rules to autocomplete actions. More detail about action rules here
autocancelAfter No Action will automatically cancel after those many hours if not completed prior
/**
  * Construct a place object for Action's expected place
  *
  * @NOTE: Either the coordinates for the Action's location
  * or it's address can be used to construct the expected place
  */
Place expectedPlace = new Place().setLocation(latitude, longitude)
                                 .setAddress(address)
                                 .setName(name);

/**
  * Create ActionParams object specifying the Visit Action parameters including 
  * ExpectedPlace, ExpectedAt time and Action's UniqueId.
  */
ActionParams actionParams = new ActionParamsBuilder().setExpectedPlace(expectedPlace)
                                               .setType(Action.TYPE_VISIT)
                                               .setExpectedAt(expectedAtTimestamp)
                                               .setUniqueId(<ACTION_UNIQUE_ID_HERE>)
                                               .setCollectionId(<COLLECTION_ID_HERE_IF_ANY>)
                                               .build();

/**
  * Call createAction to assign Visit action to the current user
  * configured in the SDK using the ActionParams created above.
  */
HyperTrack.createAction(actionParams, new HyperTrackCallback() {
  @Override
  public void onSuccess(@NonNull SuccessResponse response) {
    // Handle createAction success here
    Action action = (Action) response.getResponseObject();
    ...
  }

  @Override
  public void onError(@NonNull ErrorResponse errorResponse) {
    // Handle createAction error here
    Toast.makeText(this, errorResponse.getErrorMessage(), Toast.LENGTH_SHORT).show();
    ...
  }
});

Get Action

Call HyperTrack.getAction API to fetch action details for a given action id from HyperTrack Server.

Parameter Required Description
actionId Yes Action ID of Action whose detail is required
HyperTrack.getAction(actionId, new HyperTrackCallback() {
  @Override
  public void onSuccess(@NonNull SuccessResponse response) {
    // Handle getAction response here
    Action actionResponse = (Action) response.getResponseObject();
    ...
  }

  @Override
  public void onError(@NonNull ErrorResponse errorResponse) {
    // Handle getAction error here
    Toast.makeText(this, errorResponse.getErrorMessage(), Toast.LENGTH_SHORT).show();
    ...
  }
});

Get Actions For Unique ID

Call HyperTrack.getActionsForUniqueId API to fetch actions details for a given Unique id from HyperTrack Server.

Parameter Required Description
uniqueId Yes Order ID or any internal Id that was used while action create
actionType No The type of the actions, possible values are TYPE_PICKUP, TYPE_DELIVERY, TYPE_DROPOFF, TYPE_VISIT, TYPE_STOPOVER, TYPE_TASK
HyperTrack.getActionsForUniqueId(uniqueId, actionType, new HyperTrackCallback() {
  @Override
  public void onSuccess(@NonNull SuccessResponse response) {
    // Handle getActionsForUniqueId response here
    List<Action> actionListResponse = (List<Action>) response.getResponseObject();
    ...
  }

  @Override
  public void onError(@NonNull ErrorResponse errorResponse) {
    // Handle getActionsForUniqueId error here
    Toast.makeText(this, errorResponse.getErrorMessage(), Toast.LENGTH_SHORT).show();
    ...
  }
});

Get Actions For Short Code

Call HyperTrack.getActionForShortCode API to fetch actions details for a given short code (unique code in Action's trackingUrl) from HyperTrack Server.

Parameter Required Description
shortCode Yes Unique code in Action's trackingUrl
HyperTrack.getActionForShortCode(shortCode, new HyperTrackCallback() {
  @Override
  public void onSuccess(@NonNull SuccessResponse response) {
    // Handle getActionForShortCode response here
    List<Action> actionListResponse = (List<Action>) response.getResponseObject();
    ...
  }

  @Override
  public void onError(@NonNull ErrorResponse errorResponse) {
    // Handle getActionForShortCode error here
    Toast.makeText(this, errorResponse.getErrorMessage(), Toast.LENGTH_SHORT).show();
    ...
  }
});

Cancel Action

Call HyperTrack.cancelAction API to cancel an Action.

[warning] Cancelled Actions

Canceled actions cannot be reassigned, removed or completed.

Parameter Required Description
actionId Yes Action ID of Action
HyperTrack.cancelAction(actionId,  new HyperTrackCallback() {
  @Override
  public void onSuccess(@NonNull SuccessResponse response) {
    // Handle cancelAction response here
    Action action = (Action) response.getResponseObject();
    ...
  }

  @Override
  public void onError(@NonNull ErrorResponse errorResponse) {
    // Handle cancelAction error here
    Toast.makeText(MainActivity.this, errorResponse.getErrorMessage(), Toast.LENGTH_SHORT).show();
    ...
  }
});

Cancel Action using Action's UniqueId

Call HyperTrack.cancelActionWithUniqueId API to cancel an Action.

[warning] Cancelled Actions

Canceled actions cannot be reassigned, removed or completed.

Parameter Required Description
uniqueId Yes Unique ID of Action casted as String
callback Yes Callback parameter casted as HyperTrackCallback
HyperTrack.cancelActionWithUniqueId(uniqueId, new HyperTrackCallback() {
  @Override
  public void onSuccess(@NonNull SuccessResponse response) {
    // Handle cancelActionWithUniqueId response here
    List<Action> actions = (List<Action>) response.getResponseObject();
    ...
  }

  @Override
  public void onError(@NonNull ErrorResponse errorResponse) {
  // Handle cancelActionWithUniqueId error here
    Toast.makeText(MainActivity.this, errorResponse.getErrorMessage(), Toast.LENGTH_SHORT).show();
  }
});

Complete Action

Call completeAction API to mark an action complete.

Parameter Required Description
actionId Yes Action ID of Action
HyperTrack.completeAction(actionId);

Complete Action using Unique

Call completeActionWithUniqueId API to mark an action complete using UniqueId as the parameter.

Parameter Required Description
uniqueId Yes Unique ID associated with Action.
HyperTrack.completeActionWithUniqueId(UniqueId);

Complete Action In Sync on HyperTrack Server

Call HyperTrack.completeActionInSync API to cancel an Action. Note that this API will make an HTTP call and will not be retried later in case of a failure.

Parameter Required Description
actionId Yes Action ID casted as String
callback Yes Callback parameter casted as HyperTrackCallback
HyperTrack.completeActionInSync(actionId, new HyperTrackCallback() {
  @Override
  public void onSuccess(@NonNull SuccessResponse response) {
    // Handle completeActionInSync response here
    Action action = (Action) response.getResponseObject();
    ...
  }

  @Override
  public void onError(@NonNull ErrorResponse errorResponse) {
  // Handle completeActionInSync error here
    Toast.makeText(MainActivity.this, errorResponse.getErrorMessage(), Toast.LENGTH_SHORT).show();
  }
});

Complete Action In Sync on HyperTrack Server using Action's UniqueId

Call HyperTrack.completeActionWithUniqueIdInSync API to cancel an Action. Note that this API will make an HTTP call and will not be retried later in case of a failure.

Parameter Required Description
uniqueId Yes Action's Unique ID casted as String
callback Yes Callback parameter casted as HyperTrackCallback
HyperTrack.completeActionWithUniqueIdInSync(uniqueId, new HyperTrackCallback() {
  @Override
  public void onSuccess(@NonNull SuccessResponse response) {
    // Handle completeActionWithUniqueIdInSync response here
    List<Action> actions = (List<Action>) response.getResponseObject();
    ...
  }

  @Override
  public void onError(@NonNull ErrorResponse errorResponse) {
  // Handle completeActionWithUniqueIdInSync error here
    Toast.makeText(MainActivity.this, errorResponse.getErrorMessage(), Toast.LENGTH_SHORT).show();
  }
});

Status And Arrival Status

The possible values for status are:

  • STATUS_CREATED: action created successfully
  • STATUS_COMPLETED: action completed successfully
  • STATUS_AUTO_COMPLETED: action automatically completed successfully due to isautocomplete_at* flags
  • STATUS_CANCELED: action canceled successfully
  • STATUS_AUTO_CANCELED: action automatically canceled successfully due to autocancel_after flag

The possible values for arrival_status are:

  • ARRIVAL_STATUS_LEAVING_NOW : When user has moved <100 meter from the place where tracking started
  • ARRIVAL_STATUS_USER_ON_THE_WAY : When user has moved >100 meter from the place where tracking started
  • ARRIVAL_STATUS_USER_ARRIVING : When user is <400 meter from expected_place
  • ARRIVAL_STATUS_USER_ARRIVED : When user is <100 meter from expected_place

results matching ""

    No results matching ""