lib/wcc/blogs/post.rb in wcc-blogs-client-0.4.0 vs lib/wcc/blogs/post.rb in wcc-blogs-client-0.4.1
- old
+ new
@@ -4,11 +4,11 @@
class Post
extend WCC::Blogs::Utils
require 'time'
def self.find(slug)
- new(WCC::Blogs.client.blog_post(slug).raw, client: WCC::Blogs.client)
+ new(WCC::Blogs.client.blog_show(slug).raw, client: WCC::Blogs.client)
end
def self.find_all
PostSummary.find_all.map(&:full_post)
end
@@ -25,11 +25,11 @@
[author.firstName, author.lastName].compact.join(' ')
end
def html
- @html ||= @client.get(URI.join(host, fragment_path).to_s)
+ @html ||= @client.get(_links.fragment)
.body
.force_encoding('UTF-8')
end
def metadata
@@ -51,10 +51,11 @@
define_camelcase_alias(
'id',
'title',
'subtitle',
+ 'summary',
'slug',
'host',
'path',
'digest',
'fragment_path'
@@ -77,10 +78,18 @@
'thumbnail_image'
) do |camelcase|
OpenStruct.new(raw[camelcase]) if raw[camelcase]
end
- define_camelcase_alias('publishing_targets') do |camelcase|
+ def _links
+ OpenStruct.new(raw['_links'] || {})
+ end
+
+ define_camelcase_alias(
+ 'published_properties',
+ 'categories',
+ 'tags'
+ ) do |camelcase|
targets = raw[camelcase] || []
targets.map { |val| OpenStruct.new(val) if val }
end