Module: Databasedotcom::Chatter::PhotoMethods

Included in:
Group, User
Defined in:
lib/databasedotcom/chatter/photo_methods.rb

Overview

Defines methods for entities that can have photos i.e. Users, Groups.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) included(base)



5
6
7
# File 'lib/databasedotcom/chatter/photo_methods.rb', line 5

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

- (Object) delete_photo

Deletes the photo for this resource.



49
50
51
52
# File 'lib/databasedotcom/chatter/photo_methods.rb', line 49

def delete_photo
  self.class.delete_photo(self.client, self.id)
  photo
end

- (Object) photo

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

User.find(@client, "me").photo  #=>  {"smallPhotoUrl"=>"/small/photo/url", "largePhotoUrl"=>"/large/photo/url"}


36
37
38
# File 'lib/databasedotcom/chatter/photo_methods.rb', line 36

def photo
  self.raw_hash["photo"]
end

- (Object) upload_photo(io, file_type)

Uploads a photo for this resource.

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


44
45
46
# File 'lib/databasedotcom/chatter/photo_methods.rb', line 44

def upload_photo(io, file_type)
  self.class.upload_photo(self.client, self.id, io, file_type)
end