Class: Garsh::Event

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

Constant Summary collapse

ENDPOINT =
"collect"
EVENT_ID =
"event"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Event

Returns a new instance of Event.



44
45
46
47
48
49
50
51
52
# File 'lib/garsh.rb', line 44

def initialize(opts={})
  # required
  @tracking_code = opts.fetch(:code)
  @action = opts.fetch(:action)
  # optional
  @client_id = opts.fetch(:client_id, "")
  @version = opts.fetch(:version, 1)
  @category = opts.fetch(:category, "")
end

Instance Attribute Details

#actionObject

Returns the value of attribute action.



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

def action
  @action
end

#categoryObject

Returns the value of attribute category.



37
38
39
# File 'lib/garsh.rb', line 37

def category
  @category
end

#client_idObject

Returns the value of attribute client_id.



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

def client_id
  @client_id
end

#tracking_codeObject (readonly)

Returns the value of attribute tracking_code.



35
36
37
# File 'lib/garsh.rb', line 35

def tracking_code
  @tracking_code
end

#versionObject (readonly)

Returns the value of attribute version.



34
35
36
# File 'lib/garsh.rb', line 34

def version
  @version
end

Instance Method Details

#to_paramsObject



54
55
56
57
58
59
60
61
62
63
# File 'lib/garsh.rb', line 54

def to_params
  {
    v: version,
    tid: tracking_code,
    cid: client_id,
    t: EVENT_ID,
    ec: category,
    ea: action
  }
end