Class ResourceManager

    • Constructor Detail

      • ResourceManager

        protected ResourceManager​(String basePath,
                                  Config config,
                                  okhttp3.OkHttpClient client)
    • Method Detail

      • post

        protected String post​(String path,
                              String body)
                       throws OnfidoException
        Makes a POST http call to the specified path and request body.
        Parameters:
        path - the path to the desired endpoint
        body - the request body for the http call
        Returns:
        the response as a json string
        Throws:
        OnfidoException - the onfido exception
      • get

        protected String get​(String path)
                      throws OnfidoException
        Makes a GET http call to the specified path
        Parameters:
        path - the path to the desired endpoint
        Returns:
        the response as a json string
        Throws:
        OnfidoException - the onfido exception
      • put

        protected String put​(String path,
                             String body)
                      throws OnfidoException
        Makes a PUT http call to the specified path and request body.
        Parameters:
        path - the path to the desired endpoint
        body - the request body for the http call
        Returns:
        the response as a json string
        Throws:
        OnfidoException - the onfido exception
      • deleteRequest

        protected String deleteRequest​(String path)
                                throws OnfidoException
        Makes a DELETE http call to the specified path
        Parameters:
        path - the path to the desired endpoint
        Returns:
        the response as a json string
        Throws:
        OnfidoException - the onfido exception
      • uploadRequest

        protected String uploadRequest​(String path,
                                       okhttp3.RequestBody body)
                                throws OnfidoException
        Makes a POST http call to the specified path and multipart request body.
        Parameters:
        path - the path to the desired endpoint
        body - the request body for the http call
        Returns:
        the response as a json string
        Throws:
        OnfidoException - the onfido exception
      • downloadRequest

        protected FileDownload downloadRequest​(String path)
                                        throws OnfidoException
        Makes a GET http call to the specified path
        Parameters:
        path - the path to the desired endpoint
        Returns:
        the file content and type in the form of a FileDownload object
        Throws:
        OnfidoException - the onfido exception
      • readInputStream

        protected byte[] readInputStream​(InputStream inputStream)
                                  throws IOException
        Converts an InputStream to a byte[] to be sent as part of a multipart request body
        Parameters:
        inputStream - the InputStream
        Returns:
        the byte[] made from the InputStream
        Throws:
        IOException - the io exception
      • addFormDataParam

        protected void addFormDataParam​(okhttp3.MultipartBody.Builder builder,
                                        String key,
                                        Object value)