Skip to content

Instantly share code, notes, and snippets.

@novikserg
Last active August 29, 2015 14:20
Show Gist options
  • Save novikserg/a9f2c844e00806ba640c to your computer and use it in GitHub Desktop.
Save novikserg/a9f2c844e00806ba640c to your computer and use it in GitHub Desktop.
class GetFacebookPages
def self.call(*args)
new(*args).call
end
include Virtus.model
attribute :account, FacebookAccount
def call
graph = Koala::Facebook::API.new(account.api_token)
pages = graph.get_connections('me', 'accounts?fields=id,name,picture')
pages.each do |page|
page['facebook_id'] = page.delete('id')
page['picture_url'] = page['picture']['data'].delete('url')
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment