Class: TrafficMansion::Tracker

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

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, endpoint = ENV["TRAFFIC_MANSION_ENDPOINT"], http_host = ENV["TRAFFIC_MANSION_HTTP_HOST"], log_requests = ENV["TRAFFIC_MANSION_LOG_REQUESTS"], log_to_file = ENV["TRAFFIC_MANSION_LOG_TO_FILE"]) ⇒ Tracker

Returns a new instance of Tracker.



5
6
7
8
9
10
11
# File 'lib/traffic_mansion/tracker.rb', line 5

def initialize options = {}, endpoint = ENV["TRAFFIC_MANSION_ENDPOINT"], http_host = ENV["TRAFFIC_MANSION_HTTP_HOST"], log_requests = ENV["TRAFFIC_MANSION_LOG_REQUESTS"], log_to_file = ENV["TRAFFIC_MANSION_LOG_TO_FILE"]
  @endpoint = endpoint
  @http_host = http_host
  @log_requests = log_requests
  @log_to_file = log_to_file
  set_data options
end

Instance Method Details

#activate(options = {}) ⇒ Object



40
41
42
# File 'lib/traffic_mansion/tracker.rb', line 40

def activate options = {}
  auth false, options
end

#rebill(options = {}) ⇒ Object



48
49
50
# File 'lib/traffic_mansion/tracker.rb', line 48

def rebill  options = {}
  payment "rebill", options
end

#refund(options = {}) ⇒ Object



52
53
54
# File 'lib/traffic_mansion/tracker.rb', line 52

def refund  options = {}
  payment "refund", options
end

#sale(options = {}) ⇒ Object



44
45
46
# File 'lib/traffic_mansion/tracker.rb', line 44

def sale options = {}
  payment "sale", options
end

#set_data(data) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/traffic_mansion/tracker.rb', line 13

def set_data data
  @remote_addr = data[:remote_addr] ? data[:remote_addr] : nil
  @campaign_id = data[:campaign_id] ? data[:campaign_id] : nil
  @visit_id = data[:visit_id] ? data[:visit_id] : nil
  @affiliate_id = data[:affiliate_id] ? data[:affiliate_id] : nil
  @user_id = data[:user_id] ? data[:user_id] : nil
end

#signup(options = {}) ⇒ Object



36
37
38
# File 'lib/traffic_mansion/tracker.rb', line 36

def  options = {}
  auth true, options
end

#visit(options = {}) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/traffic_mansion/tracker.rb', line 21

def visit options = {}
  url = "#{@endpoint}/xd_visit.php"
  params = {
    "campaign_id" => @campaign_id,
    "keyword" => nil,
    "timestamp" => Time.now.to_i,
    "http_host" => @http_host,
    "remote_addr" => @remote_addr,
    "http_referer" => nil,
    "visit_id" => @visit_id,
    "affiliate_id" => @affiliate_id
  }.merge options
  get_response url, params
end