Sha256: 7001b6933e53d56174d2cbbe3379f4460a80e0107e3798f240eedb7c3a54512d
Contents?: true
Size: 1.55 KB
Versions: 1
Compression:
Stored size: 1.55 KB
Contents
require 'httparty' class Tasty include HTTParty VERSION = '1.0.0'.freeze DEFAULT_HEADERS = { 'User-Agent' => "tasty gem #{VERSION}" } headers(DEFAULT_HEADERS) DELICIOUS_API_URL = 'https://api.del.icio.us/v1/' attr_accessor :delicious_api_url attr_accessor :username attr_accessor :password # Initialize with your API token def initialize(username, password, delicious_api_url = DELICIOUS_API_URL) @username = username @password = password @delicious_api_url = delicious_api_url end def debug(location = $stderr) self.class.debug_output(location) end def set_http_headers(http_headers = {}) http_headers.merge!(DEFAULT_HEADERS) headers(http_headers) end # Call del.icio.us using a particular API method, api_method. The options hash is where you can add any parameters appropriate for the API call. def get(api_method, options = {}) query = {} query.merge!(authorization_hash) query.merge!({:query => options}) self.class.get(@delicious_api_url + api_method, query) end # Post to del.icio.us using a particular API method, api_method. The parameters hash is where you add all the required parameters appropriate for the API call. def post(api_method, options = {}) query = {} query.merge!(authorization_hash) query.merge!({:body => options}) self.class.post(@delicious_api_url + api_method, query) end private def authorization_hash {:basic_auth => {:username => @username, :password => @password}} end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tasty-1.0.0 | lib/tasty.rb |