Skip to content

chamilton-ccn/HubSpot.NET

 
 

Repository files navigation

Before you proceed ...

This is a work in progress! It is NOT READY for production use. What you are looking at is an ambitious re-write of the most recent fork of this library.

Main goals for this fork:

  • Upgrading from RestSharp 105.2.3 -> 110.2.0
  • Language update: >= C# 8.0 (Haven't decided if we're staying at 8.0)
  • Updating to V3/V4 API endpoints
  • Standardizing model implementations
  • Standardizing API calls / method names
  • Simplify serialization/deserialization by modifying models to closely resemble HubSpot requests/responses.
    • This is a bigger issue than it sounds. With the V3/V4 API, HubSpot's API has become more standardized with respect to the structure of requests and responses, so objects are being refactored to more closely match that structure, which will (hopefully) result in a lot less jiggery-pokery when serializing/deserializing. (see RequestDataConverter.cs for a good example of what I mean -- no disrespect toward the original author(s); earlier versions of HubSpot's API were all over the place; see this for more details.)

To-do list

This list is subject to change as progress continues

  • Refactoring existing objects
    • Company
      • Model (IHubSpotModel) Interface
      • ModelList (IHubSpotModelList) Interface
      • Refactor Unit Tests
      • Refactor examples
      • Comprehensive documentation (XML comments, examples, etc.)
    • Contacts
      • Model (IHubSpotModel) Interface
      • ModelList (IHubSpotModelList) Interface
      • Refactor Unit Tests
      • Refactor examples
      • Comprehensive documentation (XML comments, examples, etc.)
    • ContactList
      • Model (IHubSpotModel) Interface
      • ModelList (IHubSpotModelList) Interface
      • Refactor Unit Tests
      • Refactor examples
      • Comprehensive documentation (XML comments, examples, etc.)
    • Deal
      • Model (IHubSpotModel) Interface
      • ModelList (IHubSpotModelList) Interface
      • Refactor Unit Tests
      • Refactor examples
      • Comprehensive documentation (XML comments, examples, etc.)
    • EmailSubscription
      • Model (IHubSpotModel) Interface
      • ModelList (IHubSpotModelList) Interface
      • Refactor Unit Tests
      • Refactor examples
      • Comprehensive documentation (XML comments, examples, etc.)
    • Engagement
      • Model (IHubSpotModel) Interface
      • ModelList (IHubSpotModelList) Interface
      • Refactor Unit Tests
      • Refactor examples
      • Comprehensive documentation (XML comments, examples, etc.)
    • Files
      • Model (IHubSpotModel) Interface
      • ModelList (IHubSpotModelList) Interface
      • Refactor Unit Tests
      • Refactor examples
      • Comprehensive documentation (XML comments, examples, etc.)
    • Owner
      • Model (IHubSpotModel) Interface
      • ModelList (IHubSpotModelList) Interface
      • Refactor Unit Tests
      • Refactor examples
      • Comprehensive documentation (XML comments, examples, etc.)
    • Task
      • Model (IHubSpotModel) Interface
      • ModelList (IHubSpotModelList) Interface
      • Refactor Unit Tests
      • Refactor examples
      • Comprehensive documentation (XML comments, examples, etc.)
    • Ticket
      • Model (IHubSpotModel) Interface
      • ModelList (IHubSpotModelList) Interface
      • Refactor Unit Tests
      • Refactor examples
      • Comprehensive documentation (XML comments, examples, etc.)
    • Properties
      • Model (IHubSpotModel) Interface
      • ModelList (IHubSpotModelList) Interface
      • Refactor Unit Tests
      • Refactor examples
      • Comprehensive documentation (XML comments, examples, etc.)
  • Adding new(-ish) objects; Note: Some of these may have existed in one way or another but were either incomplete or in need of updating for the V3/V4 API.
    • Associations (new-ish)
      • Model (IHubSpotModel) Interface
      • ModelList (IHubSpotModelList) Interface
      • Refactor Unit Tests
      • Refactor examples
      • Comprehensive documentation (XML comments, examples, etc.)
      • A word on "types" vs "labels": All of HubSpot's default association types are "unlabeled" types, however you can create your own custom association types that can be either labeled or unlabeled. A label merely describes the association. A type represents an association that could exist between two object types. So when creating a CustomAssociationTypeHubSpotModel instance, if you do not want it to be labeled, set the Label property to null. Creating an unlabeled custom association type is analogous to "enabling" an association type from within the Associations tab of an object's settings. Probably the only time you want to do this is when creating an association type between two objects where either one or both of those objects are custom objects.
    • Refactor Search
      • SearchRequestOptions interface?
      • Unit Tests
      • Examples
      • Comprehensive documentation (XML comments, examples, etc.)
  • Custom object types (TODO list TBD)
  • Object Properties/Schema (TODO list TBD)
  • Ensure all DateTime properties are ISO 8601 formatted (yyyy-MM-ddThh:mm:ss.fffZ)

HubSpot.NET

C# .NET Wrapper around the common HubSpot APIs:

  • Contact
  • Company
  • Deal
  • Engagement
  • Owners
  • COS Files API (adds the ability to upload files to use as attachments to engagements)

Getting Started

To get started, install the Nuget package and create a instance of HubSpotApi passing your API Key as the only parameter.

  var api = new HubSpotApi("MY API KEY");
  
  // Create a contact
  var contact = api.Contact.Create(new ContactHubSpotModel()
  {
      Email = "[email protected]",
      FirstName = "John",
      LastName = "Smith",
      Phone = "00000 000000",
      Company = "Squared Up Ltd."
  });
  

For more examples see the HubSpot.NET.Examples project.

Using your own models

As HubSpot lets you create and add custom properties to your contacts, companies and deals it's likely you'll want to implement your own models. This is straightforward, simply extend the models shipped with this library, e.g. ContactHubSpotModel and add your own properties. Use the DataMember attributes to indicate the internal name. For example

  public class Contact : ContactHubSpotModel
  {
      [DataMember(Name = "activities")]
      public string Activities { get; set; }

      [DataMember(Name = "type")]
      public string Type { get; set; }
  }

Using checkbox/radio properties

These properties should be of type string and set as a semicolon delimited list of values, e.g. "value1;value2". This is required by HubSpot, see here for more details.

Contributing

Please read CONTRIBUTING.md for more information on how to contribute. PRs welcome!

Authors

  • Dave Clarke

License

This project is licensed under the MIT License - see the LICENSE file for details

Acknowledgements

  • Initial version based on dotnetcore-hubspot-client by skarpdev, expanded to additional APIs and heavily refactored to use RestSharp etc.

About

C# .NET Wrapper around the common HubSpot APIs.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%