module Databasedotcom::Chatter::PhotoMethods::ClassMethods

Defines class methods for resources that can have photos.

Public Instance Methods

delete_photo(client, resource_id) click to toggle source

Deletes the photo for the resource with id resource_id.

# 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) click to toggle source

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

# 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) click to toggle source

Uploads a photo for a resource with id resource_id.

User.upload_photo(@client, "me", File.open("SomePicture.png"), "image/png")
# 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