Sha256: 7ad294778c5f81f8ea89c2a3ee4defb9df268019da8b99bfa1087108625e368b

Contents?: true

Size: 741 Bytes

Versions: 1

Compression:

Stored size: 741 Bytes

Contents

# frozen_string_literal: true

require "faraday"
Dir[File.expand_path("faraday/*.rb", __dir__)].sort.each { |f| require f }

module Pocket
  # @private
  module Connection
    private

    def connection(_raw: false)
      Faraday::Connection.new(configure_options) do |conn|
        conn.use(FaradayMiddleware::PocketOAuth, consumer_key, access_token)

        conn.request :json
        conn.response :json

        conn.use(Faraday::Response::RaiseError)
        conn.adapter Faraday.default_adapter
      end
    end

    def configure_options
      {
        headers: {"User-Agent" => user_agent, "Content-Type" => "application/json"},
        proxy: proxy,
        ssl: {verify: false},
        url: endpoint
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pocket-ruby-0.6.0 lib/pocket/connection.rb