Creating Classes For The Stripe Connector

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. For example, if you want to parse the Customer Create message from the Stripe API you must create a class that defines the structure for that message and create a class in your Visual Studio project that represents that structure.

Using a sample message sent from Stripe, the process for creating a Class file for the Customer Create message is 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

Creating Classes For The Stripe Connector

Analyzing The Stripe Connection

Starting The Stripe Messaging Framework Project

Generating The Stripe Message Connector Code

Reviewing Sample Stripe Connector Generated Code