Sha256: 05e78e3b353b2b773f043a54d4a2f624c4e32e0eb4e8d3a698ffe9689e6f3704

Contents?: true

Size: 704 Bytes

Versions: 1

Compression:

Stored size: 704 Bytes

Contents

require 'faraday'
require 'json'

module ContiamoEvent
  class Base
    ENDPOINT    = 'https://track.contiamo.com/v3/'

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

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

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

    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
contiamo_event-0.0.1 lib/contiamo_event/base.rb