Sha256: e8c88358dd6dea246cf4a756d3998c8306dc21f2f90e86ed27301c8eaa73a887

Contents?: true

Size: 739 Bytes

Versions: 1

Compression:

Stored size: 739 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 Rubygem #{Typetalk::VERSION}"},
        :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

1 entries across 1 versions & 1 rubygems

Version Path
typetalk-0.0.2 lib/typetalk/connection.rb