Sha256: 2f095985d66f181431aa82a2e58e0473c03507a7133e53fd7c8134c5d6d49e03

Contents?: true

Size: 637 Bytes

Versions: 1

Compression:

Stored size: 637 Bytes

Contents

# frozen_string_literal: true

module BreezyPDFLite
  # HTTP Client for BreezyPDFLite API
  class Client
    def post(path, body)
      uri = URI.parse(BreezyPDFLite.base_url + path)

      http = Net::HTTP.new(uri.host, uri.port)
      http.use_ssl = uri.scheme == "https"
      http.open_timeout = BreezyPDFLite.open_timeout
      http.read_timeout = BreezyPDFLite.read_timeout

      request = Net::HTTP::Post.new(uri.request_uri, headers)

      request.body = body

      http.request(request)
    end

    private

    def headers
      {
        "Authorization": "Bearer #{BreezyPDFLite.secret_api_key}"
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
breezy_pdf_lite-0.1.1 lib/breezy_pdf_lite/client.rb