Class: Tweethook

Inherits:
Object
  • Object
show all
Defined in:
lib/tweethook.rb

Defined Under Namespace

Classes: Post, Result, Search

Class Method Summary collapse

Class Method Details

.get(path, *params) ⇒ Object



30
31
32
33
34
35
# File 'lib/tweethook.rb', line 30

def self.get(path,*params)
  params = params.empty? ? nil : params.first
  response = Typhoeus::Request.get(Tweethook.url(path), :params => params)
  return nil if response.code.eql?(403)
  result = JSON.parse(response.body)    
end

.passwordObject



16
17
18
# File 'lib/tweethook.rb', line 16

def self.password
  ENV['TWEETHOOK_API_PASS']
end

.post(path, params) ⇒ Object



24
25
26
27
28
# File 'lib/tweethook.rb', line 24

def self.post(path,params)
  response = Typhoeus::Request.post(Tweethook.url(path),
    :params => params)
  response.body.empty? ? nil : JSON.parse(response.body)
end

.signatureObject



20
21
22
# File 'lib/tweethook.rb', line 20

def self.signature
  ENV['TWEETHOOK_SIGNATURE']
end

.url(path) ⇒ Object



38
39
40
# File 'lib/tweethook.rb', line 38

def self.url(path)
  "https://#{Tweethook.user}:#{Tweethook.password}@api.tweethook.com#{path}"
end

.userObject



12
13
14
# File 'lib/tweethook.rb', line 12

def self.user
  ENV['TWEETHOOK_API_USER']
end