Interface RequestProvider



  • public interface RequestProvider

    A provider which will offer a higher level of abstraction compared to the RequestService
    You can create an instance of RequestProvider like this:

          import zendesk.support.RequestProvider;
          import zendesk.support.Support;
          ...
          RequestProvider provider = Support.INSTANCE.provider().requestProvider();
          ...
     

    Once you have an instance of the provider you can call methods on it and handle the results in callbacks. A success callback will give you the resource(s) that you are requesting, like requests, comments, and so on. The error callback will be called if there was some issue with the method call and it will define details about the error in an ErrorResponse

    For example you can list all your requests like this:

       provider.getAllRequests(new ZendeskCallback <List&lt;Request>>() {
            @Override
           public void onSuccess(List<Request> requests) {
               // Handle success
           }
    
            @Override
           public void onError(ErrorResponse errorResponse) {
               // Handle error
           }
      });
     
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method and Description
      void addComment(java.lang.String requestId, EndUserComment endUserComment, <any> callback)
      Add a EndUserComment to a request.
      void createRequest(CreateRequest request, <any> callback)
      Calls a request service to create a request on behalf of the end-user.
      void getAllRequests(<any> callback)
      Gets all requests that user has opened.
      void getComments(java.lang.String requestId, <any> callback)
      Gets all comments for a request.
      void getCommentsSince(java.lang.String requestId, java.util.Date since, boolean onlyAgent, <any> callback)
      Gets comments for a request since a specified point in time.
      void getRequest(java.lang.String requestId, <any> callback)
      Calls a request service to get a request for the given request id.
      void getRequests(java.lang.String status, <any> callback)
      Filters requests that user has opened by a status.
      void getTicketFormsById(java.util.List<java.lang.Long> ids, <any> callback)
      Get all available ticket forms.
      void getUpdatesForDevice(<any> callback)
      Gets the details of any updates to requests for this device.
      void markRequestAsRead(java.lang.String requestId, int commentCount)
      Marks a request as read on this device.
      void markRequestAsUnread(java.lang.String requestId)
      Marks a request as unread on this device, by incrementing its total number of comments.
    • Method Detail

      • createRequest

        void createRequest(CreateRequest request,
                           <any> callback)
        Calls a request service to create a request on behalf of the end-user.
        Parameters:
        request - The request to create
        callback - Callback that will deliver a newly created request of type Request or ErrorResponse
        Since:
        2.0.0.1
      • getAllRequests

        void getAllRequests(<any> callback)
        Gets all requests that user has opened.
        Parameters:
        callback - The callback to invoke which will return a list of Request or an ErrorResponse
        Since:
        1.0.0.1
      • getRequests

        void getRequests(java.lang.String status,
                         <any> callback)
        Filters requests that user has opened by a status.
        Parameters:
        status - A comma separated list of status to filter the results by status.
        • new
        • open
        • pending
        • hold
        • solved
        • closed
        callback - The callback to invoke which will return a list of Request or an ErrorResponse
        Since:
        1.0.0.1
      • getComments

        void getComments(java.lang.String requestId,
                         <any> callback)
        Gets all comments for a request.
        Parameters:
        requestId - Id of a request. This is a String Id that will have been returned by #getAllRequests(ZendeskCallback) or #getRequests(String, ZendeskCallback)
        callback - Callback that will deliver a CommentsResponse or ErrorResponse
        Since:
        1.0.0.1
      • getCommentsSince

        void getCommentsSince(java.lang.String requestId,
                              java.util.Date since,
                              boolean onlyAgent,
                              <any> callback)
        Gets comments for a request since a specified point in time.
        Parameters:
        requestId - Id of a request. This is a String Id that will have been returned by #getAllRequests(ZendeskCallback) or #getRequests(String, ZendeskCallback)
        since - Date used to filter the comments. Only comments submitted after this date will be returned.
        onlyAgent - true to fetch only agent comments, false to all comments.
        callback - Callback that will deliver a CommentsResponse or ErrorResponse
        Since:
        2.0.0.1
      • addComment

        void addComment(java.lang.String requestId,
                        EndUserComment endUserComment,
                        <any> callback)
        Add a EndUserComment to a request.
        Parameters:
        requestId - Id of a request to post this comment to
        endUserComment - A EndUserComment containing text and attachment tokens
        callback - Callback that will deliver a Comment or ErrorResponse
        Since:
        1.1.0.1
      • getRequest

        void getRequest(java.lang.String requestId,
                        <any> callback)
        Calls a request service to get a request for the given request id.
        Parameters:
        requestId - Id of a request
        callback - Callback that will deliver a Request or ErrorResponse
        Since:
        1.2.0.1
      • getTicketFormsById

        void getTicketFormsById(java.util.List<java.lang.Long> ids,
                                <any> callback)
        Get all available ticket forms.
        Parameters:
        ids - List of ticket form ids to fetch
        callback - Callback that will deliver a list of TicketForm or ErrorResponse
      • getUpdatesForDevice

        void getUpdatesForDevice(<any> callback)
        Gets the details of any updates to requests for this device.

        RequestUpdates are cached for up to one hour. Subsequent calls to this method within the hour will return the same object without querying the network. Calling this method once the hour has expired will query the network again, and cache the new results for the next hour.

        If using the Zendesk UI, viewing a request will update the stored RequestUpdates to remove the viewed request. If using the API providers only, a request can be removed from the stored RequestUpdates by calling RequestProvider.markRequestAsRead(String, int) with the request ID.

        It is important to note the difference in behaviour of this method users using AnonymousIdentity versus users using JwtIdentity. For an AnonymousIdentity, this method will only fetch updates for requests which were created from this device (since those are all an Anonymous user has access to). However, a JwtIdentity will fetch all of the users open requests, regardless of where they were created. Any request created on another channel is unknown to this instance of the Support SDK, and as such it will show in the resulting RequestUpdates with all of its comments counting as updates.

        Parameters:
        callback - Callback that will deliver the number of request updates or ErrorResponse
      • markRequestAsRead

        void markRequestAsRead(java.lang.String requestId,
                               int commentCount)
        Marks a request as read on this device.
        Parameters:
        requestId - the ID of the request to mark as read
        commentCount - the number of comments on this request that have been read
        See Also:
        for more information
      • markRequestAsUnread

        void markRequestAsUnread(java.lang.String requestId)
        Marks a request as unread on this device, by incrementing its total number of comments.

        This should be used to update a request as being "unread" after receiving a push notification for an update on that ticket, when using an SDK providers-only integration.

        If you are using the SDK UI module and Support.refreshRequest(String, Context) then you should not call this method. It is already being called for you, and calling it again will lead to inaccurate RequestUpdates.

        Parameters:
        requestId - the ID of the request to mark as unread