module StackExchange::Client

Public Instance Methods

access_token() click to toggle source
# File lib/rest-core/client/stackexchange.rb, line 43
def access_token
  data['access_token']
end
access_token=(token) click to toggle source
# File lib/rest-core/client/stackexchange.rb, line 47
def access_token= token
  data['access_token'] = token
end
authorize!(payload={}) { |data = parse_query| ... } click to toggle source
# File lib/rest-core/client/stackexchange.rb, line 57
def authorize! payload={}, opts={}, &cb
  p = {:client_id  => client_id, :client_secret => client_secret}.
      merge(payload)

  args = ['https://stackexchange.com/oauth/access_token', p,
          {:access_token => false, :key => false, :site => false},
          {:json_response => false}.merge(opts)]

  if block_given?
    post(*args){ |r| yield(self.data = ParseQuery.parse_query(r)) }
  else
    self.data = ParseQuery.parse_query(post(*args))
  end
end
authorize_url(query={}) click to toggle source
# File lib/rest-core/client/stackexchange.rb, line 51
def authorize_url query={}, opts={}
  url('https://stackexchange.com/oauth',
    {:access_token => false, :key => false, :site => false,
     :client_id => client_id}.merge(query), opts)
end
authorized?() click to toggle source
# File lib/rest-core/client/stackexchange.rb, line 72
def authorized?
  !!access_token
end
me(query={}) click to toggle source
# File lib/rest-core/client/stackexchange.rb, line 39
def me query={}, opts={}, &cb
  get('me', query, opts, &cb)
end

Private Instance Methods

default_data() click to toggle source
# File lib/rest-core/client/stackexchange.rb, line 77
def default_data ;                                      {}; end
default_query() click to toggle source
# File lib/rest-core/client/stackexchange.rb, line 78
def default_query; {:key => key, :site => 'stackoverflow'}; end