Class: Optify::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(access_token) ⇒ Client

Returns a new instance of Client.



9
10
11
# File 'lib/optify/client.rb', line 9

def initialize(access_token)
  self.class.default_params :access_token => access_token
end

Instance Method Details

#all_sites(options = {}) ⇒ Object



13
14
15
16
# File 'lib/optify/client.rb', line 13

def all_sites(options={})
  site_path = "/v1/sites.json"
  self.class.get(site_path, :query => clean(options)).parsed_response
end

#all_visitors(site_id, options = {}) ⇒ Object



23
24
25
26
# File 'lib/optify/client.rb', line 23

def all_visitors(site_id,options={})
  site_path = "/v1/sites/#{site_id.to_s}/visitors.json"
  self.class.get(site_path, :query => clean(options)).parsed_response
end

#site(site_id, options = {}) ⇒ Object



18
19
20
21
# File 'lib/optify/client.rb', line 18

def site(site_id,options={})
  site_path = "/v1/sites/#{site_id.to_s}.json"
  self.class.get(site_path, :query => clean(options)).parsed_response
end

#visitor(site_id, visitor_id, options = {}) ⇒ Object



28
29
30
31
# File 'lib/optify/client.rb', line 28

def visitor(site_id,visitor_id,options = {})
  site_path = "/v1/sites/#{site_id.to_s}/visitors/#{visitor_id.to_s}.json"
  self.class.get(site_path, :query => clean(options)).parsed_response
end

#who_am_iObject



33
34
35
36
# File 'lib/optify/client.rb', line 33

def who_am_i
  whois_path = "/whoami"
  self.class.get(whois_path, :format => 'text/plain').parsed_response.chomp
end