Module: Smartfm::MediaSupport

Included in:
Item, Sentence
Defined in:
lib/smartfm/modules/media_support.rb

Instance Method Summary collapse

Instance Method Details

#add_image(auth, params) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/smartfm/modules/media_support.rb', line 13

def add_image(auth, params)
  post_params = if params.is_a?(String)
    {'image[url]' => params}
  else
    {
      'image[url]' => params[:url],
      'image[list_id]' => params[:list_id]
    }.merge(attribution_params(params[:attribution]))
  end
  self.rest_client.add_image(auth, post_params.merge(:id => self.id))
end

#add_sound(auth, params) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/smartfm/modules/media_support.rb', line 25

def add_sound(auth, params)
  post_params = if params.is_a?(String)
    {'sound[url]' => params}
  else
    {
      'sound[url]' => params[:url],
      'sound[list_id]' => params[:list_id]
    }.merge(attribution_params(params[:attribution]))
  end
  self.rest_client.add_sound(auth, post_params.merge(:id => self.id))
end

#attribution_params(attr_params) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/smartfm/modules/media_support.rb', line 3

def attribution_params(attr_params)
  return {} unless attr_params
  {
    'attribution[medias_entity]'           => attr_params[:media_entity],
    'attribution[author]'                  => attr_params[:author],
    'attribution[author_url]'              => attr_params[:author_url],
    'attributions[attribution_license_id]' => attr_params[:attribution_license_id]
  }
end