Working with the AccountRight Live API
The SDK Contracts deliver a hierarchical representation of the JSON definitions available for all AccountRight API endpoints.
These are nested into a series of classes that unpack the resources inside each entity. Looking at the online documentation for an entity provides the full elements (field) schema broken down in its entirety with nested objects included.
Illustrated within the documentation are required fields that are mandatory as part of a POST (Insert) and PUT (Update) operation along with read-only elements. These are highlighted with relevant icons beside the element types.
Going back to the customer contact example introduced with SDK services, you’ll need to additionally include the Contact contracts in your code in order to start working with the resource:
Simple example of declaring a new customer use the following:
var customers = new Customer()
This will allow you to delve into the elements that are accessible to this contract.
Looking through the customer endpoint online documentation provides you with the full resource schema, this identifies the many nested objects inside the entity which encompass their own contract classes and reference links.
For example we have the following when using customer:
- SellingDetails and the CustomerSellingDetails contract
- PaymentDetails and the CustomerPaymentDetails contract
- Credit and the CustomerCredit contract
- Addresses array that has an Address contract used for all contact types i.e. Customer, Supplier, Employee
- TaxCode/FreightTaxCode requires the TaxCodeLink which acts as a reference to the GeneralLedger.TaxCode entity
- IncomeAccount requires the AccountLink which acts as a reference to the GeneralLedger.Account entity
Unpacking these different contracts and referencing them against the online endpoint documentation is designed to demonstrate the relationships and just exactly what each resource comprises of.
Copyright © 2020 MYOB Technology Pty Ltd