Sha256: dae678587650c60fa257266c67fd8e1f2c3d22eb42c4797ecd6ae54899260832
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
require 'net/http' module Stocktwits module Dispatcher class Basic include Stocktwits::Dispatcher::Shared attr_accessor :user def initialize(user) raise Stocktwits::Error, 'Dispatcher must be initialized with a User.' unless user.is_a?(Stocktwits::BasicUser) self.user = user end def request(http_method, path, body=nil, *arguments) path = Stocktwits.path_prefix + path path = append_extension_to(path) response = Stocktwits.net.start{ |http| req = "Net::HTTP::#{http_method.to_s.capitalize}".constantize.new(path, *arguments) req.basic_auth user.login, user.password req.set_form_data(body) unless body.nil? http.request(req) } handle_response(response) end def get(path, *arguments) request(:get, path, *arguments) end def post(path, body='', *arguments) request(:post, path, body, *arguments) end def put(path, body='', *arguments) request(:put, path, body, *arguments) end def delete(path, *arguments) request(:delete, path, *arguments) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stocktwits-1.0.0 | lib/stocktwits/dispatcher/basic.rb |