Sha256: e80811ea01b4673919bca0ad1bbc93d1fcc9671b1094d6feae947b9f42332efe

Contents?: true

Size: 539 Bytes

Versions: 1

Compression:

Stored size: 539 Bytes

Contents

require "faraday_middleware"

module Einvoice
  module Connection
    private

    def connection
      options = {
        headers: { "Accept" => "application/#{format}; charset=utf-8" },
        url: endpoint
      }

      ::Faraday::Connection.new(options) do |connection|
        case format.to_s.downcase
        when "xml" then connection.use Faraday::Response::ParseXml
        when "json" then connection.use Faraday::Response::ParseJson
        end

        connection.adapter Faraday.default_adapter
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
einvoice-0.1.0 lib/einvoice/connection.rb