Connector Implementation: Classes for MYOB Acumatica Entities

You need to create a class for each MYOB Acumatica entitity to be synchronized with the external system through the connector. Classes for MYOB Acumatica entities are adapters for the entities of the contract-based REST API of MYOB Acumatica.

To implement these classes, you have two options: define the classes on your own, or use the classes defined for the predefined e-commerce integrations, which are available in the PX.Commerce.Core.API namespace. For example, if you need to work with customers in MYOB Acumatica, 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 can implement a custom class for this entity.

Base Class and Interface

The classes for MYOB Acumatica 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 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 names of the class and its properties should be exactly the same as the names of the corresponding contract-based API entity and its properties in the respective version of the eCommerce/24.200.001 endpoint.

Tip:
If the API defined in the eCommerce/24.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 WebServiceEndpoint and WebServiceVersion fields of BCBinding by using the corresponding CacheAttached event handlers in the graph of the configuration form. For details about the replacement, see CacheAttached: General Information.

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 Acumatica objects and fields on the mapping and filtering tabs of the Entities (BC202000) form.

Creation of Classes for MYOB Acumatica Entities

To create classes for the MYOB Acumatica entities to be synchronized with the external system through the connector, you generally do the following:

  1. On the Web Service Endpoints (SM207060) form, you open the eCommerce/24.200.001 endpoint and identify the entities and their fields, including the key fields, that you need to use. For example, for the Case entity, you may need to use the CaseID, Subject, Description, NoteID, and LastModifiedDateTime fields.
  2. You identify the predefined classes for MYOB Acumatica entities (which are available in the PX.Commerce.Core.API namespace) that you can use in your connector.
  3. If you need to implement your own classes for MYOB Acumatica entities, in the Visual Studio project of the extension library, for each MYOB Acumatica entity that you need to use, you create a class with the name of an MYOB Acumatica entity that you want to process in the connector.

Example

The following code shows an example of the implementation of a class derived from the CBAPIEntity.

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; }
}