Sha256: 0d5604ee8f6ab51aa14d9c47b3be349232b4f61a9bb0cb0d923cba4aa954f8cb

Contents?: true

Size: 1.14 KB

Versions: 147

Compression:

Stored size: 1.14 KB

Contents

dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
require File.join(dir, 'httparty')
require 'pp'
config = YAML.load(File.read(File.join(ENV['HOME'], '.delicious')))

class Delicious
  include HTTParty
  base_uri 'https://api.del.icio.us/v1'

  def initialize(u, p)
    @auth = { username: u, password: p }
  end

  # query params that filter the posts are:
  #   tag (optional). Filter by this tag.
  #   dt (optional). Filter by this date (CCYY-MM-DDThh:mm:ssZ).
  #   url (optional). Filter by this url.
  #   ie: posts(query: {tag: 'ruby'})
  def posts(options = {})
    options.merge!({ basic_auth: @auth })
    self.class.get('/posts/get', options)
  end

  # query params that filter the posts are:
  #   tag (optional). Filter by this tag.
  #   count (optional). Number of items to retrieve (Default:15, Maximum:100).
  def recent(options = {})
    options.merge!({ basic_auth: @auth })
    self.class.get('/posts/recent', options)
  end
end

delicious = Delicious.new(config['username'], config['password'])
pp delicious.posts(query: { tag: 'ruby' })
pp delicious.recent

delicious.recent['posts']['post'].each { |post| puts post['href'] }

Version data entries

147 entries across 122 versions & 6 rubygems

Version Path
harbr-0.2.0 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/delicious.rb
harbr-0.1.99 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/delicious.rb
harbr-0.1.98 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/delicious.rb
harbr-0.1.97 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/delicious.rb
harbr-0.1.96 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/delicious.rb
harbr-0.1.95 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/delicious.rb
harbr-0.1.94 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/delicious.rb
harbr-0.1.93 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/delicious.rb
harbr-0.1.91 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/delicious.rb
harbr-0.1.90 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/delicious.rb
harbr-0.1.89 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/delicious.rb
harbr-0.1.88 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/delicious.rb
harbr-0.1.87 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/delicious.rb
harbr-0.1.86 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/delicious.rb
harbr-0.1.85 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/delicious.rb
harbr-0.1.84 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/delicious.rb
harbr-0.1.83 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/delicious.rb
harbr-0.1.82 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/delicious.rb
harbr-0.1.81 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/delicious.rb
harbr-0.1.80 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/delicious.rb