postwill/postwill

View on GitHub
lib/postwill/providers/facebook.rb

Summary

Maintainability
A
0 mins
Test Coverage
module Postwill
  module Providers
    class Facebook < Base
      def initialize(options)
        @client ||= ::Koala::Facebook::API.new(options[:access_token])
      end

      private

      def post(options)
        image = options[:image]
        text = options[:text]

        if image
          client.put_picture(image, { message: text })
        else
          client.put_connections('me', 'feed', message: text)
        end
      end
    end
  end
end