Overview

This SDK uses jQuery and AJAX to send requests to an eBillingHub Data Services API.

Prerequisites

This SDK uses jQuery 3.7.0, so the SDK generally supports any browser version that jQuery 3.7.0 supports. The exception is Internet Explorer. That release of jQuery supports IE9, but that version of Internet Explorer has limitations on its support for Cross-Origin Resource Sharing (CORS) where the web application and the web service reside on different sites, which will be the case when firms use this SDK from their web applications.

The SDK supports the following browsers:

Installation

  1. Download the SDK

    Download the sample and then unzip the downloaded file. The SDK contains the following files:

    ebhWebApi.js
    This JavaScript file contains objects for sending a request to the EBH Data Services API and receiving the response. An object is provided for each API so that your web application page can use parameter-based function calls. The functions in turn call the EBH Data Services API using appropriate URLs and query string parameters.
    TODO
    add sample HTML page that uses ebhWebApi
  2. Configure the SDK

    Edit the ebhWebApi.js file that was installed in the previous step:

    1. Locate the getEbhWebApiDefaultUrl function.
    2. Change the return value to the URL you were supplied by eBillingHub support:
      return "https://ds.ebillinghub.com/api/v1/";

SDK members

Using the SDK

  1. Create a new web page

    details....

  2. Add script references to the SDK's JavaScript files

    details....

    TODO: how to handle base64 jquery add-on

    <script type="text/javascript" src="YourScriptPath/jquery-3.7.0.min.js"></script>
    <script type="text/javascript" src="YourScriptPath/jquery.base64.js"></script>
    <script type="text/javascript" src="YourScriptPath/ebhWebApi.js"></script>
    <script type="text/javascript">
        // script segments will be added here in subsequent steps
    <script>
  3. Create and configure the ebhWebApi object

    details....

        var api;
        function createApi(username, password) {
            var baseUrl = getEbhWebApiDefaultUrl();
            var myApi = new EbhWebApi(baseUrl, username, password, apiSuccessHandler, apiErrorHandler);
            myApi.setResponseFormat("json");
            // myApi.setResponseFormat("xml");
            return myApi;
        }
  4. Create API success and failure handlers

    details....

  5. Call an API method

    details....

        function btnSendRequest_click() {
            // if the ebhWebApi object was created for an earlier action, reuse it.
            // otherwise, create a new object.
            if (!api) {
                var username = $("#txtUsername").val();
                var password = $("#txtPassword").val();
                api = createApi(username, password);
            }
            // ensure that the object was successfully created
            if (api) {
                // execute one of the following
                api.Invoices.GetAll();
                //api.Invoices.GetByInvoiceId($("#txtInvoiceId").val());
                //api.Invoices.GetByClientId($("#txtClientId").val());
                //api.Invoices.GetByInvoiceDate($("#txtInvStartDate").val(), $("#txtInvEndDate").val());
                //api.Invoices.GetByStatusDate($("#txtStatusStartDate").val(), $("#txtStatusEndDate").val());
                //api.Invoices.GetByMatterId($("#txtMatterId").val());
                //api.Invoices.GetByCurrentStatus($("#txtStatus").val());
                //api.Invoices.GetByVendor($("#txtVendor").val());
                //api.Invoices.GetByCurrency($("#txtCurrencyCode").val());
            }
            else
                alert("createApi failed");
        }

Complete example

A page that searches for invoices using an invoice ID might look similar to the following:
TODO: handle response

<!DOCTYPE html>
<html>
    <head>
        <script type="text/javascript" src="YourScriptPath/jquery-3.7.0.min.js"></script>
        <script type="text/javascript" src="YourScriptPath/jquery.base64.js"></script>
        <script type="text/javascript" src="YourScriptPath/ebhWebApi.js"></script>
        <script type="text/javascript">
            var api;

            function createApi(username, password) {
                var baseUrl = getEbhWebApiDefaultUrl();
                var myApi = new EbhWebApi(baseUrl, username, password, apiSuccessHandler, apiErrorHandler);
                myApi.setResponseFormat("json");
                return myApi;
            }

            function btnSendRequest_click() {
                // if the ebhWebApi object was created for an earlier action, reuse it.
                // otherwise, create a new object.
                if (!api) {
                    var username = $("#txtUsername").val();
                    var password = $("#txtPassword").val();
                    api = createApi(username, password);
                }
                // ensure that the object was successfully created
                if (api) {
                    api.Invoices.GetByInvoiceId($("#txtInvoiceId").val());
                }
                else
                    alert("createApi failed");
            }

            // TODO: use handlers here or do it in ebhWebApi? need to add args
            function apiSuccessHandler() {
            }
            function apiErrorHandler() {
            }
        <script>
    </head>
    <body>
        <p>
            Username:<br />
            <input type="text" id="txtUsername" />
        </p>
        <p>
            Password:<br />
            <input type="password" id="txtPassword" />
        </p>
        <p>
            Firm's invoice ID:<br />
            <input type="text" id="txtInvoiceId" />
        </p>
        <p>
            <input type="button" id="btnSendRequest" value="Send request" onclick="btnSendRequest_click()" />
        </p>
    </body>
</html>