mirror of
https://github.com/jnunemaker/httparty
synced 2023-03-27 23:23:07 -04:00
25 lines
540 B
Ruby
25 lines
540 B
Ruby
|
dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
||
|
require File.join(dir, 'httparty')
|
||
|
require 'pp'
|
||
|
|
||
|
class StackExchange
|
||
|
include HTTParty
|
||
|
base_uri 'api.stackexchange.com'
|
||
|
|
||
|
def initialize(service, page)
|
||
|
@options = { :query => {:site => service, :page => page} }
|
||
|
end
|
||
|
|
||
|
def questions
|
||
|
self.class.get("/2.2/questions", @options)
|
||
|
end
|
||
|
|
||
|
def users
|
||
|
self.class.get("/2.2/users", @options)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
stack_exchange = StackExchange.new("stackoverflow", 1)
|
||
|
pp stack_exchange.questions
|
||
|
pp stack_exchange.users
|