class SocialProfile::Person

Attributes

access_token[R]
options[R]
uid[R]

Public Class Methods

get(provider, uid, access_token, options = {}) click to toggle source
# File lib/social_profile/person.rb, line 13
def self.get(provider, uid, access_token, options = {})
  return if provider.nil?

  klass = case provider.to_s
    when "facebook" then People::Facebook
    when "vkontakte" then People::Vkontakte
    when "twitter" then People::Twitter
    when "instagram" then People::Instagram
    when "instagram_parser" then People::InstagramParser
    when "google" then People::Google
    else Person
  end

  klass.new(uid, access_token, options)
end
new(uid, access_token, options = {}) click to toggle source
# File lib/social_profile/person.rb, line 7
def initialize(uid, access_token, options = {})
  @uid = uid
  @access_token = access_token
  @options = options
end

Public Instance Methods

album!(options = {}) click to toggle source

Create new album id

# File lib/social_profile/person.rb, line 35
def album!(options = {})
  raise NotImplementedError("Subclasses should implement this!")
end
fetch_album(album_id) click to toggle source

Find album by id

# File lib/social_profile/person.rb, line 30
def fetch_album(album_id)
  raise NotImplementedError("Subclasses should implement this!")
end
find_album(album_id) click to toggle source
# File lib/social_profile/person.rb, line 39
def find_album(album_id)
  return if album_id.nil?

  begin
    fetch_album(album_id)
  rescue Exception => e
    return nil
  end
end
find_or_create_album(album_id, options = {}) click to toggle source
# File lib/social_profile/person.rb, line 49
def find_or_create_album(album_id, options = {})
  record = find_album(album_id)
  record ||= album!(options)
  record
end
followers_count(options = {}) click to toggle source

Get followers count

# File lib/social_profile/person.rb, line 79
def followers_count(options = {})
  nil
end
friends_count(options = {}) click to toggle source

Get friends count

# File lib/social_profile/person.rb, line 74
def friends_count(options = {})
  nil
end
share_photo!(album_id, filepath, options = {}) click to toggle source
# File lib/social_profile/person.rb, line 55
def share_photo!(album_id, filepath, options = {})
  album = find_or_create_album(album_id, options[:album])

  data = {
    :source => File.new(filepath)
  }.merge(options[:photo] || {})

  album.photo!(data)
end
tag_object!(object, tags) click to toggle source
# File lib/social_profile/person.rb, line 65
def tag_object!(object, tags)
  tags = Array.wrap(tags)

  return if tags.empty? || object.nil?

  object.tag!(:tags => tags)
end