Working with the AccountRight Live API
The service classes accessible in the SDK provide the core HTTP operations available for each consumable endpoint. These include the following operators:
Get/GetRange – HTTP GET
Insert – HTTP POST
Update – HTTP PUT
Delete – HTTP DELETE
Each single endpoint documented online details which of these operators they support. The entire list of endpoints available for the AccountRight API and SDK can be found here
Let’s take the customer endpoint as an example, the online documentation tells us that all operators are supported here so we can create, retrieve, update and delete (CRUD) for customer.
To initialise a customer service that can be used to access the customer’s endpoint resources (contracts) you’ll firstly need to make sure you’re including the Contact services in your code in order to resolve the namespace:
Once this is done, you are able to now initialise the CustomerService by calling it like so: (custService is an example of a local variable name only).
var custService = new CustomerService(configuration);(c#)
Dim custService = new CustomerService(configuration)(vb.net)
To use the operators i.e. Insert (HTTP POST) to insert a new entity or Update (HTTP PUT) updating an existing entity, you can simply construct like so:
custService.Insert(companyFile, customers, credentials, OnError);
custService.Update(companyFile, customers, credentials, OnError);
For retrieving a single entity use Get (HTTP GET) and for a paged list of entities use GetRange
custSerivce.Get(companyFile, null, credentials);
custService.GetRange(companyFile, null, credentials);
Examples of synchronous versus asynchronous to come shortly...
Copyright © 2015 MYOB Technology Pty Ltd