class Feedbook::Notifiers::FacebookNotifier

Attributes

client[R]

Public Instance Methods

load_configuration(configuration = {}) click to toggle source

Load configuration for FacebookNotifier @param configuration = {} [Hash] Configuration hash (required: token, optional: app_secret)

@return [NilClass] nil @raise [Feedbook::Errors::NotifierConfigurationError] if notifier configuration fails

# File lib/feedbook/notifiers/facebook_notifier.rb, line 31
def load_configuration(configuration = {})
  @client = Koala::Facebook::API.new(configuration.fetch('token'), configuration.fetch('app_secret', nil))

  puts 'Configuration loaded for FacebookNotifier'
rescue Koala::KoalaError => e
  raise Errors::NotifierConfigurationError.new(:facebook, e.message)
end
notify(message) click to toggle source

Sends notification to Facebook wall @param message [String] message to be send to Facebook wall

@return [NilClass] nil @raise [Feedbook::Errors::NotifierNotifyError] if notify method fails

# File lib/feedbook/notifiers/facebook_notifier.rb, line 15
def notify(message)
  if client.nil?
    puts "Message has not been notified on Facebook: #{message} because of invalid client configuration"
  else
    client.put_wall_post(message)
    puts "New message has been notified on Facebook: #{message}"
  end
rescue Koala::KoalaError => e
  p "FacebookNotifier did not notify because of client error (#{e.message})."
end