Class: Hubspot::BlogPost
- Inherits:
-
Object
- Object
- Hubspot::BlogPost
- Defined in:
- lib/hubspot/blog.rb
Constant Summary collapse
- GET_BLOG_POST_BY_ID_PATH =
"/content/api/v2/blog-posts/:blog_post_id"
Class Method Summary collapse
-
.find_by_blog_post_id(id) ⇒ Object
Returns a specific blog post by ID https://developers.hubspot.com/docs/methods/blogv2/get_blog_posts_blog_post_id.
Instance Method Summary collapse
- #[](property) ⇒ Object
- #created_at ⇒ Object
-
#initialize(response_hash) ⇒ BlogPost
constructor
A new instance of BlogPost.
- #topics ⇒ Object
Constructor Details
#initialize(response_hash) ⇒ BlogPost
Returns a new instance of BlogPost.
74 75 76 |
# File 'lib/hubspot/blog.rb', line 74 def initialize(response_hash) @properties = response_hash #no need to parse anything, we have properties end |
Class Method Details
.find_by_blog_post_id(id) ⇒ Object
Returns a specific blog post by ID https://developers.hubspot.com/docs/methods/blogv2/get_blog_posts_blog_post_id
69 70 71 72 |
# 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 |
Instance Method Details
#[](property) ⇒ Object
78 79 80 |
# File 'lib/hubspot/blog.rb', line 78 def [](property) @properties[property] end |
#created_at ⇒ Object
82 83 84 |
# File 'lib/hubspot/blog.rb', line 82 def created_at Time.at(@properties['created'] / 1000) end |
#topics ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 |
# 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 |