Closed cbisnett closed 5 years ago
@cbisnett Thank you for working on this! I haven't had time to look at this just yet but I will schedule the time to look at this on Friday (1/11) :)
Since I've migrated Contacts and Companies and all existing tests are passing, I'm going to merge this into master
to continue to develop there.
This PR provides a base object
Hubspot::Resource
that provides the base CRUD functionality (similar to ActiveRecord) for interacting with Hubspot resources. The goal of this refactoring is to provide a standard implementation across all of the Hubspot objects supported in this library.Some of the benefits of the Hubspot API and the drawbacks are that the returned data is very verbose. Without wrapper objects, it's annoying to traverse the several layers of nesting required to get some property. The Hubspot endpoints are also inconsistent with which HTTP methods are supported, the naming scheme of the properties, etc. Part of the goal of this refactoring and the library in general is to hide these inconsistencies from developers so they can easily and quickly interact with the Hubspot API through a familiar abstraction.
In addition to creating a basic
Hubspot::Resource
base class, I've added two new classesCompany2
andContact2
to demonstrate how easy it is to rewrite the existingCompany
andContact
classes and simplify the duplicated code. Both of these classes support creating, reading, updating, and deleting the resource as well as add some additional specialized methods for searching for a contact by email address and looking up companies with a specific domain.The same basic functionality works for
Company2
with much less code than previously and the implementation would be the same across all resource objects.This is a minimal working implementation and need some addition support for errors and other things but I think it's enough to show the idea and get some feedback. There is still a bunch of internal cleanup and standardization I want to tackle but getting a standardized interface like this into v1.0 means we can tackle the internal stuff without breaking changes. Please let me know what you think.