Sha256: d14ef249711af4c89cf7c7d7cc5492a16a8964c9c7e80225fd1951d0c4949b6e

Contents?: true

Size: 552 Bytes

Versions: 1

Compression:

Stored size: 552 Bytes

Contents

require 'json'
require 'faraday'

class GetaroundUtils::Utils::HttpReporter
  class AsyncQueue < GetaroundUtils::Utils::AsyncQueue
    def self.perform(url:, params: {}, headers: {}, body: nil)
      Faraday.post(url) do |req|
        req.params = params
        req.headers = headers
        req.body = body
      end
    end
  end

  def initialize(url:)
    @url = url
  end

  def report(event)
    AsyncQueue.perform_async(
      url: @url,
      headers: { 'Content-Type' => 'application/json' },
      body: JSON.generate(event)
    )
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
getaround_utils-0.1.14 lib/getaround_utils/utils/http_reporter.rb