Method: Bremen::Mixcloud.from_api

Defined in:
lib/bremen/mixcloud.rb

.from_api(hash = {}) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/bremen/mixcloud.rb', line 33

def from_api hash = {}
  created_at = Time.parse(hash['created_time']).utc
  new({
    uid: hash['key'],
    url: hash['url'],
    title: hash['name'],
    author: Bremen::Author.new({
      uid: hash['user']['key'],
      url: hash['user']['url'],
      name: hash['user']['name'],
      thumbnail_url: hash['user']['pictures']['medium'],
    }),
    length: hash['audio_length'].to_i,
    thumbnail_url: hash['pictures']['medium'],
    created_at: created_at,
    updated_at: created_at,
  })
end