-
Notifications
You must be signed in to change notification settings - Fork 4
New feature to get posts for a Facebook page. #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module Fb | ||
# @private | ||
class DataHelper | ||
def self.symbolize_keys(hash) | ||
{}.tap do |new_hash| | ||
hash.each_key{|key| new_hash[key.to_sym] = hash[key]} | ||
end | ||
end | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Ruby client to authenticate a Facebook user. | ||
# @see http://www.rubydoc.info/gems/Fb/ | ||
module Fb | ||
# Fb::Post reprensents a Facebook post. Post provides getters for: | ||
# :id, :title, :url, :created_time, and :type. | ||
class Post | ||
attr_reader :id, :title, :url, :created_time, :type | ||
|
||
# @param [Hash] options the options to initialize an instance of Fb::Post. | ||
# @option [String] :id The post id. | ||
# @option [String] :title The status message in the post or post story. | ||
# @option [String] :url URL to the permalink page of the post. | ||
# @option [String] :created_time The time the post was initially published. | ||
# @option [String] :type A string indicating the object type of this post. | ||
def initialize(options = {}) | ||
@id = options[:id] | ||
@url = options[:permalink_url] | ||
@created_time = options[:created_time] | ||
@type = options[:type] | ||
@title = options[:message] || options[:story] || build_title | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sometimes neither is available, so I give it a title. |
||
end | ||
|
||
# @return [String] the representation of the post. | ||
def to_s | ||
%Q(#<#{self.class.name} #{@id} "#{@type}">) | ||
end | ||
|
||
private | ||
|
||
def build_title | ||
"#{@type} posted #{@created_time} available at #{@url}" | ||
end | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe 'Fb::Page#posts' do | ||
context 'given valid options and an existing page with over 100 posts' do | ||
let(:posts) { Fb::Page.new(id: '221406534569729').posts } | ||
|
||
it 'returns an array of posts' do | ||
expect(posts).to be_a(Array) | ||
expect(posts).to all (be_a Fb::Post) | ||
expect(posts.map &:id).to all(be_a String) | ||
expect(posts.map &:url).to all(be_a String) | ||
expect(posts.map &:type).to all(be_a String) | ||
expect(posts.map &:created_time).to all(be_a String) | ||
expect(posts.map &:title).to all(be_a String) | ||
end | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe 'Fb::Post#to_s' do | ||
let(:post) { Fb::Post.new id: 123, type: 'video' } | ||
|
||
it 'returns a pretty string representation' do | ||
expect(post.to_s).to eq '#<Fb::Post 123 "video">' | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@claudiofullscreen how do we take care of
access_token
?