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.
76 77 78 |
# File 'lib/hubspot/blog.rb', line 76 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
71 72 73 74 |
# File 'lib/hubspot/blog.rb', line 71 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
80 81 82 |
# File 'lib/hubspot/blog.rb', line 80 def [](property) @properties[property] end |
#created_at ⇒ Object
84 85 86 |
# File 'lib/hubspot/blog.rb', line 84 def created_at Time.at(@properties['created'] / 1000) end |
#topics ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/hubspot/blog.rb', line 88 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 |