Classes for MYOB Advanced Entities

Classes for MYOB Advanced entities are adapters for the entities of the contract-based REST API of MYOB Advanced. To implement these classes, you have two options: Define the classes on your own, or use the classes defined for the default BigCommerce and Shopify integrations, which are available in the PX.Commerce.Core.API namespace. For example, if you need to work with customers in MYOB Advanced, you can use the predefined PX.Commerce.Core.API.Customer class. If the entity is not implemented in the PX.Commerce.Core.API namespace, you implement a custom class for this entity.

Base Class and Interface

The classes for MYOB Advanced entities derive from the PX.Commerce.Core.API.CBAPIEntity base class, which implements the PX.Commerce.Core.ILocalEntity interface. The CBAPIEntity class includes the set of standard properties of a contract-based API entity, such as Id, RowNumber, Delete, and ReturnBehavior. This class also defines a set of properties that are necessary for the synchronization of the entity with an entity from an external e-commerce system, such as SyncID or SyncTime.

Properties of Each Custom Class

In each custom class, you define only the properties of the contract-based API entity that you need to use, including the key fields of the entity. The name of the class and its properties should be exactly the names of the corresponding contract-based API entity and its properties in the eCommerce/20.200.001 endpoint.

Tip: If the API defined in the eCommerce/20.200.001 endpoint is not sufficient for the implementation of your connector, you can create a custom endpoint and use it for your connector. For details about the creation of a custom endpoint, see To Create a Custom Endpoint in the Integration Development Guide. To use the custom endpoint for your connector, you need to replace the PXDefault attribute of the BCBinding.WebServiceEndpoint and BCBinding.WebServiceVersion fields by using the corresponding CacheAttached event handlers in the graph of the configuration form. For details about the replacement, see Replacement of Attributes for DAC Fields in CacheAttached.

You assign the PX.Commerce.Core.CommerceDescription attributes with the names of the entity and its properties to the class and its properties, respectively. These names are used as the names of the MYOB Advanced objects and fields on the mapping and filtering tabs of the Entities (BC202000) form.

Example

An example of the implementation of a class derived from the CBAPIEntity is shown in the following code.

Tip: You can see this code on GitHub.
using PX.Commerce.Core.API;
using PX.Api.ContractBased.Models;
using PX.Commerce.Core;

[CommerceDescription("Case")]
public partial class Case : CBAPIEntity
{
	public GuidValue NoteID { get; set; }

	public DateTimeValue LastModifiedDateTime { get; set; }

	[CommerceDescription("CaseCD")]
	public StringValue CaseCD { get; set; }

	[CommerceDescription("Subject")]
	public StringValue Subject { get; set; }

	[CommerceDescription("Description")]
	public StringValue Description { get; set; }
}