Sha256: 585dd7e4516c2a19f18e7b4c67ace1f4b868639d7a6964302ff2952b53c9cddc

Contents?: true

Size: 532 Bytes

Versions: 7

Compression:

Stored size: 532 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).tap { |h| h.use_ssl = uri.scheme == "https" }
      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

7 entries across 7 versions & 1 rubygems

Version Path
breezy_pdf_lite-0.1.0 lib/breezy_pdf_lite/client.rb
breezy_pdf_lite-0.0.7 lib/breezy_pdf_lite/client.rb
breezy_pdf_lite-0.0.6 lib/breezy_pdf_lite/client.rb
breezy_pdf_lite-0.0.4 lib/breezy_pdf_lite/client.rb
breezy_pdf_lite-0.0.3 lib/breezy_pdf_lite/client.rb
breezy_pdf_lite-0.0.2 lib/breezy_pdf_lite/client.rb
breezy_pdf_lite-0.0.1 lib/breezy_pdf_lite/client.rb