Module: Databasedotcom::Chatter::PhotoMethods::ClassMethods

Defined in:
lib/databasedotcom/chatter/photo_methods.rb

Overview

Defines class methods for resources that can have photos.

Instance Method Summary collapse

Instance Method Details

#delete_photo(client, resource_id) ⇒ Object

Deletes the photo for the resource with id resource_id.



28
29
30
# File 'lib/databasedotcom/chatter/photo_methods.rb', line 28

def delete_photo(client, resource_id)
  client.http_delete "/services/data/v#{client.version}/chatter/#{self.resource_name}/#{resource_id}/photo"
end

#photo(client, resource_id) ⇒ Object

Returns a Hash with urls for the small and large versions of the photo for a resource.



12
13
14
15
16
# File 'lib/databasedotcom/chatter/photo_methods.rb', line 12

def photo(client, resource_id)
  url = "/services/data/v#{client.version}/chatter/#{self.resource_name}/#{resource_id}/photo"
  result = client.http_get(url)
  JSON.parse(result.body)
end

#upload_photo(client, resource_id, io, file_type) ⇒ Object

Uploads a photo for a resource with id resource_id.

User.upload_photo(@client, "me", File.open("SomePicture.png"), "image/png")


21
22
23
24
25
# File 'lib/databasedotcom/chatter/photo_methods.rb', line 21

def upload_photo(client, resource_id, io, file_type)
  url = "/services/data/v#{client.version}/chatter/#{self.resource_name}/#{resource_id}/photo"
  result = client.http_multipart_post(url, {"fileUpload" => UploadIO.new(io, file_type)})
  JSON.parse(result.body)
end