Class: Superfeedee::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/superfeedee.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



8
9
10
11
12
# File 'lib/superfeedee.rb', line 8

def initialize options={}
  @auth = { :username => options[:user], :password => options[:pass] } unless options[:user].nil?
  self.class.headers options[:headers] unless options[:headers].nil?
  self.class.base_uri options[:hub] || 'https://superfeedr.com/hubbub'
end

Instance Method Details

#post(mode, options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/superfeedee.rb', line 14

def post(mode, options={})
  request_options = { :query => { 'hub.verify' => options[:verify_mode] || 'sync', 
                                  'hub.mode' => mode, 
                                  'hub.callback' => options[:callback_url], 
                                  'hub.topic' => options[:topic_url], 
                                  'hub.verify_token' => options[:verify_token] || '' } }
  
  request_options[:basic_auth] = @auth if @auth
  
  self.class.post('/', request_options)
end

#subscribe(options) ⇒ Object



26
27
28
# File 'lib/superfeedee.rb', line 26

def subscribe options
  post('subscribe', options)
end

#unsubscribe(options) ⇒ Object



30
31
32
# File 'lib/superfeedee.rb', line 30

def unsubscribe options
  post('unsubscribe', options)
end