Class: API

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

Instance Method Summary collapse

Constructor Details

#initialize(apikey) ⇒ API

Returns a new instance of API.



8
9
10
# File 'lib/anecdotally/api.rb', line 8

def initialize(apikey)
  @apikey = apikey
end

Instance Method Details

#execute(endpoint, filter = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/anecdotally/api.rb', line 12

def execute(endpoint, filter={})
  #define the api extension we're going to call
  endpoint = "/" + endpoint
  #set the payload
  filter[:apikey] = @apikey
  options = {:query => filter }
  #call the web service
  response = self.class.get(endpoint, options)
  
  if response["status"]=="success"
    return response["response"]
  else
    return {}
  end
end