class Piping::Client

Attributes

base_uri[R]

Public Class Methods

new(base_uri: ENV.fetch("PIPING_DRAIN_URI")) click to toggle source
# File lib/piping/client.rb, line 6
def initialize(base_uri: ENV.fetch("PIPING_DRAIN_URI"))
  @base_uri = base_uri
end

Public Instance Methods

create_events(events) click to toggle source
# File lib/piping/client.rb, line 10
def create_events(events)
  post("events", events)
end

Private Instance Methods

post(path, data) click to toggle source
# File lib/piping/client.rb, line 18
def post(path, data)
  response = HTTParty.post(
    uri(path),
    body: JSON.dump(data),
    headers: {
      "Content-Type" => "application/json",
    }
  )
  response.response.value
  response
end
uri(path) click to toggle source
# File lib/piping/client.rb, line 30
def uri(path)
  "#{base_uri}/#{path}"
end