class Hubspot::BlogPost

Constants

GET_BLOG_POST_BY_ID_PATH

Public Class Methods

find_by_blog_post_id(id) click to toggle source

Returns a specific blog post by ID {developers.hubspot.com/docs/methods/blogv2/get_blog_posts_blog_post_id} @return Hubspot::BlogPost

# File lib/hubspot/blog.rb, line 69
def self.find_by_blog_post_id(id)
  response = Hubspot::Connection.get_json(GET_BLOG_POST_BY_ID_PATH, { blog_post_id: id })
  new(response)
end
new(response_hash) click to toggle source
# File lib/hubspot/blog.rb, line 74
def initialize(response_hash)
  @properties = response_hash #no need to parse anything, we have properties
end

Public Instance Methods

[](property) click to toggle source
# File lib/hubspot/blog.rb, line 78
def [](property)
  @properties[property]
end
created_at() click to toggle source
# File lib/hubspot/blog.rb, line 82
def created_at
  Time.at(@properties['created'] / 1000)
end
topics() click to toggle source
# File lib/hubspot/blog.rb, line 86
def topics
  @topics ||= begin
    if @properties['topic_ids'].empty?
      []
    else
      @properties['topic_ids'].map do |topic_id|
        Hubspot::Topic.find_by_topic_id(topic_id)
      end
    end
  end
end