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 ACTION_TYPE_PICKUP, ACTION_TYPE_DELIVERY, ACTION_TYPE_DROPOFF, ACTION_TYPE_VISIT, ACTION_TYPE_STOPOVER, ACTION_TYPE_TASK, ACTION_TYPE_TRIP
getLookupId 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
getAssignedAT Date The time at which the action was assigned to the user
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. Can be one of ACTION_STATUS_CREATED, ACTION_STATUS_ASSIGNED, ACTION_STATUS_STARTED, ACTION_STATUS_COMPLETED, ACTION_STATUS_CANCELED, ACTION_STATUS_SUSPENDED
getSubStatus String The action sub status. Can be one of ACTION_SUB_STATUS_NOT_STARTED, ACTION_SUB_STATUS_IN_QUEUE, ACTION_SUB_STATUS_LEAVING_NOW, ACTION_SUB_STATUS_USER_ON_THE_WAY, ACTION_SUB_STATUS_USER_ARRIVING, ACTION_SUB_STATUS_USER_ARRIVED
getInitialETA Date The initial eta calculated for the action
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
getStartPlace Place The place object where the action was started.
getStartedAT Date The time at which the action was started
getCurrentDurationInMinutes Integer Duration of action since its started in minutes
getMetaData List<List<?>> Metadata as List 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, if action assigned user's 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 ACTION_TYPE_PICKUP, ACTION_TYPE_DELIVERY, ACTION_TYPE_DROPOFF, ACTION_TYPE_VISIT, ACTION_TYPE_STOPOVER, ACTION_TYPE_TASK, ACTION_TYPE_TRIP
expectedAtTimeStamp No The expected time stamp by when the action should be completed
lookupId 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 createAndAssignAction API call
metadata No A JSONObject denoting the metadata to be associated with the Action object
lookupIdAsShortCode No A flag indicating whether to set tracking url's unique Short Code as the Action's lookupId
/**
  * 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 Lookup_id.
  */
ActionParams actionParams = new ActionParamsBuilder().setExpectedPlace(expectedPlace)
                                               .setType(Action.ACTION_TYPE_VISIT)
                                               .setExpectedAt(expectedAtTimestamp)
                                               .setLookupId(<ACTION_LOOKUP_ID_HERE>)
                                               .setCollectionId(<COLLECTION_ID_HERE_IF_ANY>)
                                               .build();

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

  @Override
  public void onError(@NonNull ErrorResponse errorResponse) {
    // Handle createAndAssignAction 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 Lookup ID

Call HyperTrack.getActionsForLookupId API to fetch actions details for a given lookup id from HyperTrack Server.

Parameter Required Description
lookupId Yes Order ID or any internal Id that was used while action create
actionType No The type of the actions, possible values are ACTION_TYPE_PICKUP, ACTION_TYPE_DELIVERY, ACTION_TYPE_DROPOFF, ACTION_TYPE_VISIT, ACTION_TYPE_STOPOVER, ACTION_TYPE_TASK
HyperTrack.getActionsForLookupId(lookupID, actionType, new HyperTrackCallback() {
  @Override
  public void onSuccess(@NonNull SuccessResponse response) {
    // Handle getActionsForLookupId response here
    List<Action> actionListResponse = (List<Action>) response.getResponseObject();
    ...
  }

  @Override
  public void onError(@NonNull ErrorResponse errorResponse) {
    // Handle getActionsForLookupId 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 LookupId

Call HyperTrack.cancelActionWithLookupId API to cancel an Action.

[warning] Cancelled Actions

Canceled actions cannot be reassigned, removed or completed.

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

  @Override
  public void onError(@NonNull ErrorResponse errorResponse) {
  // Handle cancelActionWithLookupId 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 LookupId

Call completeActionWithLookupId API to mark an action complete using LookupId as the parameter.

Parameter Required Description
lookupId Yes Lookup ID associated with Action.
HyperTrack.completeActionWithLookupId(lookupId);

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 LookupId

Call HyperTrack.completeActionWithLookupIdInSync 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
lookupId Yes Action's Lookup ID casted as String
callback Yes Callback parameter casted as HyperTrackCallback
HyperTrack.completeActionWithLookupIdInSync(lookupId, new HyperTrackCallback() {
  @Override
  public void onSuccess(@NonNull SuccessResponse response) {
    // Handle completeActionWithLookupIdInSync response here
    List<Action> actions = (List<Action>) response.getResponseObject();
    ...
  }

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

Complete Action and Stop Tracking

Call completeActionAndStopTrackingIfNoPendingAction API to mark an action complete. It will call stopTracking API automatically if no pendings actions to be performed by user. This API makes a synchronous HTTP call to HyperTrack Server and returns an error if the device is offline.

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

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

results matching ""

    No results matching ""