Permalink
Browse files

Revoke an extended permission given by user.

  • Loading branch information...
Waseem Ahmad authored and mmangino committed Mar 22, 2010
1 parent fa31475 commit d22adbb20ce3bee564245752e9517f96d11b5cc2
Showing with 24 additions and 2 deletions.
  1. +6 −0 lib/facebooker/models/user.rb
  2. +7 −0 lib/facebooker/parser.rb
  3. +11 −2 test/facebooker_test.rb
@@ -477,6 +477,12 @@ def has_permissions?(ext_perms)
ext_perms.all?{|p| has_permission?(p)}
end
+ ##
+ ## Revoke any extended permission given by a user
+ def revoke_permission(ext_perm)
+ session.post('facebook.auth.revokeExtendedPermission', { :perm => ext_perm, :uid => uid }, false)
+ end
+
##
# Convenience method to send email to the current user
def send_email(subject, text=nil, fbml=nil)
View
@@ -164,6 +164,12 @@ def self.process(data)
end
end
+ class RevokeExtendedPermission < Parser#:nodoc:
+ def self.process(data)
+ booleanize(element('auth_revokeExtendedPermission_response', data).content.strip)
+ end
+ end
+
class CreateToken < Parser#:nodoc:
def self.process(data)
element('auth_createToken_response', data).content.strip
@@ -875,6 +881,7 @@ def self.process(data)
class Parser
PARSERS = {
'facebook.auth.revokeAuthorization' => RevokeAuthorization,
+ 'facebook.auth.revokeExtendedPermission' => RevokeExtendedPermission,
'facebook.auth.createToken' => CreateToken,
'facebook.auth.getSession' => GetSession,
'facebook.connect.registerUsers' => RegisterUsers,
View
@@ -403,7 +403,10 @@ def test_revoke_authorization_false
assert_equal false, @session.post('facebook.auth.revokeAuthorization', :uid => 123)
end
-
+ def test_revoke_extended_permission
+ expect_http_posts_with_responses(example_revoke_extended_permission)
+ assert_equal true, @session.post('facebook.auth.revokeExtendedPermission', {:perm => 'email', :uid => 123}, false)
+ end
def test_remove_comment_true
expect_http_posts_with_responses(example_remove_comment_true)
@@ -1182,7 +1185,13 @@ def example_revoke_authorization_false
"0"
end
-
+ def example_revoke_extended_permission
+ <<-XML
+ <?xml version="1.0" encoding="UTF-8"?>
+ <auth_revokeExtendedPermission_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">1</auth_revokeExtendedPermission_response>
+ XML
+ end
+
def example_remove_comment_true
"1"
end

0 comments on commit d22adbb

Please sign in to comment.