Sha256: 7f861d3816bc5db9391ae9a8b6eb5518e6bde72547d7b2ab70734932ad8a3534
Contents?: true
Size: 797 Bytes
Versions: 1
Compression:
Stored size: 797 Bytes
Contents
# frozen_string_literal: true module Tinybird class HttpClient attr_reader :uri def initialize(uri) @uri = uri end def get(headers = {}) request = Net::HTTP::Get.new(uri, headers) make_request(request) end def post(body, headers = {}) request = Net::HTTP::Post.new(uri, headers) request.body = body.to_json make_request(request) end private def make_request(request) request["Authorization"] = "Bearer #{Tinybird.config.auth_token}" request["User-Agent"] = "tinybird-ruby/#{Tinybird::VERSION}" Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http| http.request(request).then do |response| Response.new(response) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tinybird-0.1.1 | lib/tinybird/http_client.rb |