class Plurb::Client

Constants

QUALIFIERS

Public Class Methods

new(app_key, app_secret) click to toggle source
# File lib/plurb/client.rb, line 10
def initialize(app_key, app_secret)
  @oauth_consumer = OAuth::Consumer.new(
    app_key,
    app_secret,
    {
      scheme:             :header,
      http_method:        :post,
      site:               ::Plurb::URL::SITE,
      request_token_path: ::Plurb::URL::REQUEST_TOKEN,
      access_token_path:  ::Plurb::URL::ACCESS_TOKEN,
      authorize_path:     ::Plurb::URL::AUTHORIZE
    }
  )
end

Public Instance Methods

authorize(token, token_secret) click to toggle source
# File lib/plurb/client.rb, line 25
def authorize(token, token_secret)
  @client = OAuth::AccessToken.new(@oauth_consumer, token, token_secret)
end
delete_plurk(plurk_id) click to toggle source
# File lib/plurb/client.rb, line 49
def delete_plurk(plurk_id)
  get_response(
    ::Plurb::URL::PLURK_DELETE,
    plurk_id: plurk_id
  )
end
edit_plurk(plurk_id, content) click to toggle source
# File lib/plurb/client.rb, line 56
def edit_plurk(plurk_id, content)
  get_response(
    ::Plurb::URL::PLURK_EDIT,
    {
      plurk_id: plurk_id,
      content: content
    }
  )
end
get_plurks(options={}) click to toggle source
# File lib/plurb/client.rb, line 29
def get_plurks(options={})
  get_response(
    ::Plurb::URL::GET_PLURKS,
    options
  )
end
plurk(content, qualifier='', options={}) click to toggle source
# File lib/plurb/client.rb, line 36
def plurk(content, qualifier='', options={})
  q = qualifier.downcase
  q = QUALIFIERS.include?(q) ? q : ''

  get_response(
    ::Plurb::URL::PLURK_ADD,
    {
      content: content,
      qualifier: q
    }.merge(options)
  )
end

Private Instance Methods

get_response(target_path, request_data) click to toggle source
# File lib/plurb/client.rb, line 67
def get_response(target_path, request_data)
  response = @client.post(
    target_path,
    request_data
  )
  JSON.parse(response.body)
end