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
getLookupID String An identifier for the action that was based on your internal ids
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
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

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
expectedAtTimeStamp No The expected time stamp by when the action should be completed
lookup_id No A unique id that you can add to the user to identify
/**
  * 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>)
                                               .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();
    ...
  }
});

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.

[info] Added in Android SDK 0.3.1

HyperTrack.completeActionWithLookupId(lookupId);

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();
    ...
  }
});

Was this helpful? Yes, thanks! Not really

results matching ""

    No results matching ""