Skip to content

Commit

Permalink
Add support for pages/managing endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Timur Polukeev committed Aug 12, 2014
1 parent 4f0d289 commit ef64aaf
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
1 change: 1 addition & 0 deletions Readme.md
Expand Up @@ -112,6 +112,7 @@ See [the documentation](http://rubydoc.info/gems/foursquare2/frames) or [foursqu
client.search_pages
client.herenow
client.page_venues
client.managed_pages
client.search_venues
client.search_venues_by_tip
client.venue_categories
Expand Down
12 changes: 12 additions & 0 deletions lib/foursquare2/pages.rb
Expand Up @@ -48,5 +48,17 @@ def page_venues(page_id, options={})
venues = Foursquare2.filter(venues, options[:query]) if options.has_key? :query
venues
end


#
# Returns a list of managed pages.
#

def managed_pages(options={})
response = connection.get do |req|
req.url "pages/managing", options
end
return_error_or_body(response, response.body.response.managing)
end
end
end
40 changes: 40 additions & 0 deletions test/fixtures/pages/managed_pages.json
@@ -0,0 +1,40 @@
{
"meta": {
"code": 200
},
"notifications": [{
"type": "notificationTray",
"item": {
"unreadCount": 0
}
}],
"response": {
"managing": [{
"id": "14046309",
"firstName": "Nashville Geeks",
"photo": "https:\/\/is1.4sqi.net\/userpix_thumbs\/IXHCY5SK3SDJC310.png",
"type": "page",
"followers": {
"count": 197,
"groups": []
},
"tips": {
"count": 15
},
"lists": {
"groups": [{
"type": "created",
"count": 1,
"items": []
}]
},
"gender": "none",
"homeCity": "Nashville, TN",
"bio": "",
"contact": {
"twitter": "nashvillegeeks",
"facebook": "119351084835752"
}
}]
}
}
7 changes: 7 additions & 0 deletions test/test_pages.rb
Expand Up @@ -27,5 +27,12 @@ class TestPages < Test::Unit::TestCase
venues.items.length.should == 2
venues.items.first.name.should == "Starbucks"
end

should "fetch pages for manager" do
stub_get("https://api.foursquare.com/v2/pages/managing?oauth_token=#{@client.oauth_token}", "pages/managed_pages.json")
pages = @client.managed_pages()
pages.first.firstName.should == "Nashville Geeks"
pages.first.type.should == "page"
end
end
end

0 comments on commit ef64aaf

Please sign in to comment.