-1

I know I'm going to get downvotes for even asking but I honestly have no clue how to do this and any assistance would be appreciated as I have never done this.

I have a client that migrated their blog to HubSpot and would like to have their blog posts displayed on their website. So how do I connect to HubSpot's API to display the blog in their website that I have in a Rails app?

Do I create MVC just for Blog API? Where do I put the URL to connect to?

Jake
  • 1,328
  • 1
  • 21
  • 51
  • There are few ruby gems designed for communicating with HubSpot but I am not seeing any that are well maintained or comprehensive. But still, you could look at their source code for ideas on how to consume HubSpot content. https://github.com/adimichele/hubspot-ruby – Sean Huber Jan 17 '18 at 15:18

1 Answers1

0

If you want to connect to an other API the best way to do this is to create service objects. These are plain old Ruby objects (aka PORO) that represent the API as a Ruby object. You are free to use any location you want, but I would stick them in lib/services or app/services. If the provided API uses the Rails (REST) standards than you might be able to use ActiveResource.

You could also look for gems that provide these service objects. A quick RubyGem search finds multiple (unofficial) gems. From witch hubspot-ruby seems the most used and active.

If the gems don't do what you want you could look through the code to find some inspiration and create you own objects. Another option is to fork a project and add the functionality you want.

Here is a link to answer the broader question you're asking: What is the proper "Rails Way" to consume a RESTful web service on another domain?

3limin4t0r
  • 19,353
  • 2
  • 31
  • 52