Sha256: 09a5721392769a698c9086ea4e9def63ce59d6da52db2fb8cc4c30cdeb5ba810
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
module Schet class TokenAuth include HTTParty format :plain attr_reader :username, :password, :options def initialize(username, password, options={}) @username, @password = username, password @options = {:ssl => false}.merge(options) options[:api_endpoint] ||= "localhost:3000" self.class.base_uri "http#{'s' if options[:ssl]}://#{options[:api_endpoint]}" end def get(uri, headers={}) self.class.get(uri, :headers => headers, :basic_auth => basic_auth) end def post(uri, body={}, headers={}) self.class.post(uri, :body => body.merge(:token => @options[:token]), :headers => headers, :basic_auth => basic_auth) end def put(uri, body={}, headers={}) self.class.put(uri, :body => body.merge(:token => @options[:token]), :headers => headers, :basic_auth => basic_auth) end def delete(uri, body={}, headers={}) self.class.delete(uri, :body => body.merge(:token => @options[:token]), :headers => headers, :basic_auth => basic_auth) end private def basic_auth @basic_auth ||= {:username => @username, :password => @password} end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
schet-1.1.0 | lib/schet/token_auth.rb |