Class: Whatser::Media

Inherits:
Resource show all
Defined in:
lib/whatser/resources/media.rb

Instance Attribute Summary collapse

Attributes inherited from Resource

#json

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#api_request, api_request, client, convert_data_to_model, from_hash_to_model, #initialize, set

Constructor Details

This class inherits a constructor from Whatser::Resource

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



4
5
6
# File 'lib/whatser/resources/media.rb', line 4

def created_at
  @created_at
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/whatser/resources/media.rb', line 3

def id
  @id
end

#mid_picObject

Returns the value of attribute mid_pic.



4
5
6
# File 'lib/whatser/resources/media.rb', line 4

def mid_pic
  @mid_pic
end

#mimeObject

Returns the value of attribute mime.



4
5
6
# File 'lib/whatser/resources/media.rb', line 4

def mime
  @mime
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/whatser/resources/media.rb', line 4

def name
  @name
end

#poi_idObject

Returns the value of attribute poi_id.



3
4
5
# File 'lib/whatser/resources/media.rb', line 3

def poi_id
  @poi_id
end

#remote_resource=(value) ⇒ Object (writeonly)

Sets the attribute remote_resource

Parameters:

  • value

    the value to set the attribute remote_resource to.



5
6
7
# File 'lib/whatser/resources/media.rb', line 5

def remote_resource=(value)
  @remote_resource = value
end

#resource=(value) ⇒ Object (writeonly)

Sets the attribute resource

Parameters:

  • value

    the value to set the attribute resource to.



5
6
7
# File 'lib/whatser/resources/media.rb', line 5

def resource=(value)
  @resource = value
end

#small_picObject

Returns the value of attribute small_pic.



4
5
6
# File 'lib/whatser/resources/media.rb', line 4

def small_pic
  @small_pic
end

#thumb_picObject

Returns the value of attribute thumb_pic.



4
5
6
# File 'lib/whatser/resources/media.rb', line 4

def thumb_pic
  @thumb_pic
end

#urlObject

Returns the value of attribute url.



4
5
6
# File 'lib/whatser/resources/media.rb', line 4

def url
  @url
end

#user_idObject

Returns the value of attribute user_id.



3
4
5
# File 'lib/whatser/resources/media.rb', line 3

def user_id
  @user_id
end

Class Method Details

.create(poi_id, params = {}) ⇒ Object



16
17
18
# File 'lib/whatser/resources/media.rb', line 16

def create(poi_id, params={})
  api_request :post, "/api/poi/#{poi_id}/media", {:body => {'media' => params} }
end

.delete(poi_id, id) ⇒ Object



20
21
22
# File 'lib/whatser/resources/media.rb', line 20

def delete(poi_id, id)
  api_request :delete, "/api/poi/#{poi_id}/media/#{id}"
end

.find(poi_id, id, opts = {}) ⇒ Object



12
13
14
# File 'lib/whatser/resources/media.rb', line 12

def find(poi_id, id, opts={})
  api_request :get, "/api/poi/#{poi_id}/media/#{id}", {:query => opts}
end

.list(poi_id, opts = {}) ⇒ Object



8
9
10
# File 'lib/whatser/resources/media.rb', line 8

def list(poi_id, opts={})
  api_request :get, "/api/poi/#{poi_id}/media", {:query => opts}
end

Instance Method Details

#deleteObject



33
34
35
# File 'lib/whatser/resources/media.rb', line 33

def delete
  Whatser::Media.delete(poi_id, id)
end

#saveObject



25
26
27
28
29
30
31
# File 'lib/whatser/resources/media.rb', line 25

def save
  if id.blank?
    Whatser::Media.create(poi_id, to_params)
  else
    api_request :put, "/api/poi/#{poi_id}/media/#{id}", {:body => {'media' => to_params} }
  end
end

#to_paramsObject



37
38
39
# File 'lib/whatser/resources/media.rb', line 37

def to_params
  {:name=>name,:resource=>@resource,:remote_resource=>@remote_resource}
end