Class: ContiamoEvent::Base

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

Constant Summary collapse

ENDPOINT =
'https://track.contiamo.com/v3/'

Instance Method Summary collapse

Instance Method Details

#connectionObject



19
20
21
22
23
# File 'lib/contiamo_event/base.rb', line 19

def connection
  conn = Faraday.new(url: endpoint) do |faraday|
    faraday.adapter Faraday.default_adapter
  end
end

#endpointObject



15
16
17
# File 'lib/contiamo_event/base.rb', line 15

def endpoint
  ENDPOINT + "#{ContiamoEvent.configuration.token}/"
end

#headersObject



8
9
10
11
12
13
# File 'lib/contiamo_event/base.rb', line 8

def headers
  {
    'User-Agent'        => 'ContiamoEvent Ruby SDK',
    'Content-Type'      => 'application/json'
  }
end

#post(action, args) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/contiamo_event/base.rb', line 25

def post(action, args)
  resp = connection.post do |req|
    req.url "#{action}"
    req.headers = headers
    req.body = args.to_json
  end
  [resp.status, resp.body]
end