Sha256: 1e8aeb8361cdf9dce5871a159180a0df85d8b5f90857d0a1cc363143b71d4970

Contents?: true

Size: 540 Bytes

Versions: 13

Compression:

Stored size: 540 Bytes

Contents

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

Version data entries

13 entries across 12 versions & 4 rubygems

Version Path
alloy_sdk-0.1.0 vendor/bundle/ruby/3.0.0/gems/httparty-0.13.1/examples/stackexchange.rb
alloy_sdk-0.1.0 vendor/bundle/ruby/2.6.0/gems/httparty-0.13.1/examples/stackexchange.rb
allegro_api_client-0.0.9 gems/ruby/2.1.0/gems/httparty-0.13.1/examples/stackexchange.rb
allegro_api_client-0.0.8 gems/ruby/2.1.0/gems/httparty-0.13.1/examples/stackexchange.rb
allegro_api_client-0.0.7 gems/ruby/2.1.0/gems/httparty-0.13.1/examples/stackexchange.rb
asana2flowdock-1.0.0 vendor/bundle/ruby/1.9.1/gems/httparty-0.13.1/examples/stackexchange.rb
allegro_api_client-0.0.6 gems/ruby/2.1.0/gems/httparty-0.13.1/examples/stackexchange.rb
allegro_api_client-0.0.5 gems/ruby/2.1.0/gems/httparty-0.13.1/examples/stackexchange.rb
allegro_api_client-0.0.4 gems/ruby/2.1.0/gems/httparty-0.13.1/examples/stackexchange.rb
allegro_api_client-0.0.3 gems/ruby/2.1.0/gems/httparty-0.13.1/examples/stackexchange.rb
allegro_api_client-0.0.2 gems/ruby/2.1.0/gems/httparty-0.13.1/examples/stackexchange.rb
allegro_api_client-0.0.1 gems/ruby/2.1.0/gems/httparty-0.13.1/examples/stackexchange.rb
httparty-0.13.1 examples/stackexchange.rb