Class: Tinycms::Blogs::Mapper

Inherits:
Object
  • Object
show all
Defined in:
lib/tinycms/blogs/mapper.rb

Class Method Summary collapse

Class Method Details

.map(response_body) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/tinycms/blogs/mapper.rb', line 6

def self.map(response_body)
  posts = response_body["posts"].map do |post_response|
    ::Tinycms::Posts::Mapper.map(post_response)
  end
  Blog.new(
    id: response_body["id"],
    name: response_body["name"],
    description: response_body["description"],
    posts: posts,
    created_at: Time.zone.parse(response_body["created_at"]),
    updated_at: Time.zone.parse(response_body["updated_at"])
  )
end