class User

Attributes

access_token[RW]
email[RW]
id[RW]
login_url[RW]
password[RW]

Public Class Methods

new(attrs) click to toggle source
# File lib/sacrifice/user.rb, line 10
def initialize(attrs)
  attrs.each do |field, value|
    instance_variable_set("@#{field}", value) if respond_to?(field)
  end
end

Public Instance Methods

attrs() click to toggle source
# File lib/sacrifice/user.rb, line 58
def attrs
  {id: id, access_token: access_token, login_url: login_url, email: email, password: password}
end
birthday() click to toggle source

Facebook test users all share the same birthday. Perhaps it’s the developer’s!

# File lib/sacrifice/user.rb, line 35
def birthday
  Date.new(1980, 8, 8)
end
change(options = {}) click to toggle source
# File lib/sacrifice/user.rb, line 16
def change(options = {})
  handle_bad_request do
    JSON.parse(RestClient.post("#{GRAPH_API_BASE}/#{id}", {access_token: access_token}.merge(options)))['success']
  end
end
destroy() click to toggle source
# File lib/sacrifice/user.rb, line 28
def destroy
  handle_bad_request(raise_error=false) do
    RestClient.delete("#{GRAPH_API_BASE}/#{id}?access_token=#{URI.escape(access_token.to_s)}")
  end
end
invalid_gender(gender) click to toggle source
# File lib/sacrifice/user.rb, line 45
def invalid_gender(gender)
  if gender.nil?
    return
  end
  handle_bad_request do
    result = JSON.parse(RestClient.get("#{GRAPH_API_BASE}/#{id}?fields=gender&access_token=#{access_token}").body)
    if result['gender'] == gender
      return
    end
  end
  true
end
owner_apps(app) click to toggle source
# File lib/sacrifice/user.rb, line 22
def owner_apps(app)
  handle_bad_request do
    RestClient.get("#{GRAPH_API_BASE}/#{id}/ownerapps?access_token=#{URI.escape(app.access_token.to_s)}")
  end
end
send_friend_request_to(other) click to toggle source
# File lib/sacrifice/user.rb, line 39
def send_friend_request_to(other)
  handle_bad_request do
    RestClient.post("#{GRAPH_API_BASE}/#{id}/friends/#{other.id}", 'access_token' => access_token.to_s)
  end
end