Creating Message Classes

The Connector you develop using the Messaging Framework must be able to parse the messages received from the sending API. To parse the message, the Connector must understand the data structure for each message object. The easiest way to modify the project to parse messages is to use a sample message from the sending API and paste it as a class into the Item.cs file as follows: 

  1. In Visual Studio, open your Connector project
  2. In the Solution Explorer, open the Models node. The Wizard has created a class called item.cs, which is the template for the message to be processed.

  3. Here you will update the following section:
    public class Item
         {
             public string Name { get; set; }
         }
  4. Copy the event message provided by the sending API. For the Stripe Sample Connector copy the sample message in Stripe Message Sample.

  5. In Visual Studio, highlight everything inside the outermost set of brackets after namespace in item.cs.
  6. Select Edit > Paste Special > Paste JSON as Classes. The message generated by the API is converted to a class file and looks similar to the following: 

  7. Visual Studio has done much of the work for you. If you see anything wrong in the data types, you can update them.  While there is nothing actually wrong, there is a clearer way to show the entity. In this example instead of the Entity being named Object, change it to Customer

  8. Next go back to the connector.cs to and modify the code there to reflect the change made in item.cs 

  9. Next go back to the connector.cs to and modify the code there to reflect the change made in item.cs.
  10. In the Connector class, change this:
    return this.Start.Register<Item>

    To this:

    return this.Start.Register<Rootobject, Customer>(ro => ro.data._object);
  11. Save the changes to the connector.cs and item.cs files.

See

Setup Messaging Framework Connector Project