Package 

Class ServerRequest


  • 
    public abstract class ServerRequest
    
                        

    Abstract class defining the structure of a Branch Server request.

    • Constructor Detail

      • ServerRequest

        ServerRequest(Context context, Defines.RequestPath requestPath)
        Creates an instance of ServerRequest.
        Parameters:
        context - Application context.
        requestPath - Path to server for this request.
    • Method Detail

      • handleErrors

         abstract boolean handleErrors(Context context)

        Should be implemented by the child class.Specifies any error associated with request.If there are errors request will not be executed.

        Parameters:
        context - Application context.
      • onRequestSucceeded

         abstract void onRequestSucceeded(ServerResponse response, Branch branch)

        Called when execution of this request to server succeeds. Child class should implementits own logic for handling the post request execution.

        Parameters:
        response - A ServerResponse object containing server response for this request.
        branch - Current Branch instance
      • handleFailure

         abstract void handleFailure(int statusCode, String causeMsg)

        Called when there is an error on executing this request. Child class should handle the failureaccordingly.

        Parameters:
        statusCode - A Integer value specifying http return code or any branch specific error defined in BranchError.
        causeMsg - A String value specifying cause for the error if any.
      • isGetRequest

         abstract boolean isGetRequest()

        Specify whether the request is a GET or POST. Child class has to implement accordingly.

      • clearCallbacks

         abstract void clearCallbacks()

        Clears the callbacks associated to this request.

      • shouldRetryOnFail

         boolean shouldRetryOnFail()

        Specifies whether to retry this request on failure. By default request is not retried on fail.Those request which need to retry on failure should override and handle accordingly

      • getRequestUrl

         String getRequestUrl()

        Provides the complete url for executing this request. URl consist of API base url and requestpath. Child class need to extend this method if they need to add specific items to the url

      • isGAdsParamsRequired

         boolean isGAdsParamsRequired()

        Specifies whether this request need to be updated with Google Ads Id and LAT valueBy default update GAds params update is turned on. Override this on request which need to have GAds params

      • getGetParams

         JSONObject getGetParams()

        Returns a JsonObject with the parameters that needed to be set with the get request.

      • onRequestQueued

         void onRequestQueued()

        Called when request is added to teh queue

      • getQueueWaitTime

         long getQueueWaitTime()

        Returns the amount of time this request was in queque

      • addProcessWaitLock

         void addProcessWaitLock(ServerRequest.PROCESS_WAIT_LOCK lock)

        Set the specified process wait lock for this request. This request will not be blocked fromExecution until the waiting process finishes *

        Parameters:
        lock - PROCESS_WAIT_LOCK type of lock
      • removeProcessWaitLock

         void removeProcessWaitLock(ServerRequest.PROCESS_WAIT_LOCK lock)

        Unlock the specified lock from the request. Call this when the locked process finishes

        Parameters:
        lock - PROCESS_WAIT_LOCK type of lock
      • isWaitingOnProcessToFinish

         boolean isWaitingOnProcessToFinish()

        Check if this request is waiting on any operation to finish before processing

      • onPreExecute

         void onPreExecute()

        Called on UI thread just before executing a request. Do any final updates to the request here