Sha256: 7b210ebb16ead0d2f0d5f7cb5e661bdb782930401181c6b34f9bb74f10acb4a0

Contents?: true

Size: 726 Bytes

Versions: 5

Compression:

Stored size: 726 Bytes

Contents

require 'faraday'

module Typetalk

  module Connection
    private

    def endpoint
      Typetalk.config.endpoint
    end

    def connection_options
      {
        :headers => {'Accept' => 'application/json; charset=utf-8', 'User-Agent' => Typetalk.config.user_agent},
        :proxy => Typetalk.config.proxy,
      }
    end

    def connection(options={})
      options = {multipart:nil}.merge(options)

      Faraday.new(connection_options) do |conn|
        conn.request :multipart if options[:multipart]
        conn.use Faraday::Request::UrlEncoded
        conn.use Faraday::Adapter::NetHttp
        # conn.use Faraday::Response::ParseJson
        # conn.use Faraday::Response::Logger
      end
    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
typetalk-0.1.0 lib/typetalk/connection.rb
typetalk-0.0.6 lib/typetalk/connection.rb
typetalk-0.0.5 lib/typetalk/connection.rb
typetalk-0.0.4 lib/typetalk/connection.rb
typetalk-0.0.3 lib/typetalk/connection.rb