Class: Statement::Facebook

Inherits:
Object
  • Object
show all
Defined in:
lib/statement/facebook.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFacebook

Returns a new instance of Facebook.



10
11
12
13
14
15
16
# File 'lib/statement/facebook.rb', line 10

def initialize
  @@config = Statement.config rescue nil || {}
  app_id = @@config[:app_id] || ENV['APP_ID']
  app_secret = @@config[:app_secret] || ENV['APP_SECRET']
  oauth = Koala::Facebook::OAuth.new(app_id, app_secret)
  @graph = Koala::Facebook::API.new(oauth.get_app_access_token)
end

Instance Attribute Details

#batch(member_ids, slice) ⇒ Object

given an array of congressional facebook ids, pulls feeds in slices.



24
25
26
# File 'lib/statement/facebook.rb', line 24

def batch
  @batch
end

#feed(member_id) ⇒ Object

Returns the value of attribute feed.



8
9
10
# File 'lib/statement/facebook.rb', line 8

def feed
  @feed
end

#graphObject

Returns the value of attribute graph.



8
9
10
# File 'lib/statement/facebook.rb', line 8

def graph
  @graph
end

Instance Method Details

#process_results(links) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/statement/facebook.rb', line 36

def process_results(links)
  results = []
  links.each do |link|
    facebook_id = link['id'].split('_').first
    results << { :id => link['id'], :body => link['message'], :link => link['link'], :title => link['name'], :type => link['type'], :status_type => link['status_type'], :created_time => DateTime.parse(link['created_time']), :updated_time => DateTime.parse(link['updated_time']), :facebook_id => facebook_id }
  end
  results
end