Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

README.md

A collection of methods to interact with the Saasu REST API


Create a new instance

You can have many different instances, each corresponds to a unique Saasu account.

saasuAccount = new Saasu();

Initialize Saasu key and file id

if ( Meteor.isServer ) {
    saasuAccount.init({
        accessKey: "YOUR_KEY"
        , fileId: "YOUR_FILEID"
    });
}

Initialize inventory items and payment accounts UIDs

saasuAccount.init({
    inventoryItems: {
        "Item1": "UID_OF_ITEM"
        , "Item2": "UID_OF_ITEM"
    }
    , paymentAccounts: {
        "Account1": "UID_OF_ACCOUNT"
        "Account2": "UID_OF_ACCOUNT"
    }
});

After these values are initialized, you can conveniently retrieve them with

saasuAccount.getInventoryItemUid[itemName]
saasuAccount.getPaymentAccountUid[accountName]

Methods available on both client and server

  • init
  • getInventoryItemUid
  • getPaymentAccountUid

Methods available on server

  • get
  • post
  • parseResponse

Examples

Get contact from contactID

On server-side, you can call the method directly:

var response = saasuAccount.get('contact', {contactID: 'C1-2345'});
console.log( saasuAccount.parseResponse(response) );

To receive the result on client-side, define a Meteor method and call it with a callback:

Meteor.methods({
    'saasuGet': function(type, options) {
        var response = saasuAccount.get(type, options);
        return saasuAccount.parseResponse(response);
    }
});
Meteor.call('saasuGet', 'contact', {contactID: 'C1-2345'}, function(err, res) {
    console.log( res );
});

Insert new contact

saasuAccount.post('contact', {
    salutation: 'Mr'
    , givenName: 'Phuc'
    , familyName: 'Nguyen'
    , organisationName: 'UsefulIO'
    , contactID: 'C1-1234'
});

Insert new item sale (single item)

saasuAccount.post('invoice', {
    transactionType: 'S'
    , date: '2014-04-19'
    , layout: 'I'
    , status: 'I'
    , purchaseOrderNumber: 'S1-1111'
    , summary: 'Test item sale'
    , invoiceItems: {
        itemInvoiceItem: {
            quantity: 1
            , inventoryItemUid: Saasu.getInventoryItemUid('Item1')
            , unitPriceInclTax: 150
        }
    }
});

Insert new item sale (multiple items)

saasuAccount.post('invoice', {
    transactionType: 'S'
    , date: '2014-04-19'
    , layout: 'I'
    , status: 'I'
    , purchaseOrderNumber: 'S1-1111'
    , summary: 'Test item sale'
    , invoiceItems: {
         itemInvoiceItem: [
             {
                 quantity: 1
                 , inventoryItemUid: saasu.getInventoryItemUid('Item1')
                 , unitPriceInclTax: 150
             },
             {
                 quantity: 2
                 , inventoryItemUid: saasu.getInventoryItemUid('Item2')
                 , unitPriceInclTax: 250
             }
         ]
    }
});

Insert payment for sales

saasuAccount.post('invoicePayment', {
    transactionType: 'SP'
    , date: '2014-04-19'
    , paymentAccountUid: Saasu.getPaymentAccountUid('Account1')
    , invoicePaymentItems: {
        invoicePaymentItem: {
            invoiceUid: '123456'
            , amount: '25'
        }
    }
});

About

SaaSu API Integration

Resources

Releases

No releases published

Packages

No packages published
You can’t perform that action at this time.