Contact Properties and Strongly Typed Model Deserialization


#1

I'm struggling with the Contact model and the inability to use a strongly typed class for deserialization. We are a multi-tenant SAAS provider with tenants that will each have their own HubSpot account. That is very important to understand.

For example, let's say I have this class to deserialize to ( I cut a lot out for simplicity sake):

public class HubSpotContact
{
public int vid { get; set; }

    public class Properties
    {
        public HsValueVersions name { get; set; }
        public HsValueVersions firstname { get; set; }
        public HsValueVersions lastname { get; set; }
   }

}

That works fine, until we look at needing to supporting additional contact properties. Say for example one tenant wants a "childrencount" property and another wants a "subscriptionstatus" property. We can't endlessly add to the model, which requires dev, test and Code Push and isn't manageable.

The real question is why does properties use named variables rather than a name/value array? The Contact JSON model seems inconsistent with the Create/Update Contact model which DOES use an array for the properties with name/value pairs. This reminds me of some old APIs I saw where the results were returned using numbers as the variable name and not an array.

My current option is deserializing into a dynamic and having to "dig around" to see whats there, which just seems like bad programming. Anyone have a better way to parse out he contact properties?