Consuming the API

The Saasu API can be consumed by any consumer or client capable of standard HTTP communication. This can be via generic REST clients such as this Advanced REST client. However we have provided a .Net implementation of a client proxy that enables convenient access to the Saasu API. For .Net applications, this makes it easy to integrate the consumption of the Saasu API into your applications.

.Net Client

The full solution and source code for a .Net client to consume the Saasu API can be found here. This is a solution that can be loaded into Visual Studio, is written in C# and comes complete with unit/integration tests to show how the API can be consumed. Client code for the older REST API and this API are both included. (Note: For more information with the older REST API, look here.

Example Usage

Listed below is some very brief sample code that shows how you can

  1. Authenticate against the API
  2. Make an API call to retrieve a list of invoices


        // First we authenticate to get an access token (and also a refresh token)
        var authProxy = new AuthorisationProxy();
        var scope = new AuthorisationScope[] { new AuthorisationScope { ScopeType = AuthorisationScopeType.Full } }.ToTextValues();
        var authResponse = authProxy.PasswordCredentialsGrantRequest("test@test.com", "SomeStrongPassword", scope);
            
        // Setup the invoice proxy with our acquired access token and perform the API call
        var invoiceProxy = new InvoicesProxy(authResponse.DataObject.AccessGrant.access_token);
        invoiceProxy.FileId = 123; // This needs to be specified. If not specified in code, it will attempt to retrieve from configuration
        var response = proxy.GetInvoices();
        if (response.IsSuccessfull)
        {
            foreach (var invoice in response.DataObject.Invoices)
            {
                // Do something with each invoice
                Console.WriteLine("Invoice Number: {0}",invoice.InvoiceNumber);
            }
        }