Connector Implementation: Mapping Classes

For each pair of an internal entity and an external entity that should be synchronized, you need to implement a mapping class, which defines the correspondence between the properties of the internal and external entities.

Base Class and Interfaces

The mapping class implements the following interfaces:

The MappedEntity<ExternType, LocalType> class provides the default implementation of these interfaces. The class also provides the default constructors from which you can derive the constructors of the mapping classes. These constructors use the following as input parameters:
  • A string identifier of the mapped entities, which is exactly two characters long
  • A string identifier of the connector, which is defined in the ConnectorType property of the connector class

Example

The following code shows an example of the implementation of a mapping class.

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

namespace WooCommerceTest
{
    public class MappedCustomer : MappedEntity<CustomerData, Customer>
    {
        public const string TYPE = BCEntitiesAttribute.Customer;

        public MappedCustomer()
            : base(WooCommerceConnector.TYPE, TYPE)
        { }
        public MappedCustomer(Customer entity, Guid? id, DateTime? timestamp)
            : base(WooCommerceConnector.TYPE, TYPE, entity, id, timestamp) { }
        public MappedCustomer(CustomerData entity, string id, 
            DateTime? timestamp)
            : base(WooCommerceConnector.TYPE, TYPE, entity, 
            id, id,timestamp) { }
    }
}