Sha256: c6c15a02364b8fb271fa163c6f799e4da2e2c4f7870a575abf9c907afbe89e33

Contents?: true

Size: 794 Bytes

Versions: 22

Compression:

Stored size: 794 Bytes

Contents

require "faraday_middleware"
require "faraday/response/decode_tradevan"

module Einvoice
  module Connection
    private

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

      ::Faraday::Connection.new(connection_options) do |connection|
        case self.class.to_s
        when "Einvoice::Tradevan::Provider"
          connection.response :decode_tradevan, encryption_keys[:key1]
        end
        connection.request :url_encoded

        case format.to_s.downcase
        when "xml" then connection.response :xml
        when "json" then connection.response :json
        end

        connection.adapter Faraday.default_adapter
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
einvoice-1.2.22 lib/einvoice/connection.rb
einvoice-1.2.21 lib/einvoice/connection.rb
einvoice-1.2.20 lib/einvoice/connection.rb
einvoice-1.2.19 lib/einvoice/connection.rb
einvoice-1.2.18 lib/einvoice/connection.rb
einvoice-1.2.17 lib/einvoice/connection.rb
einvoice-1.2.16 lib/einvoice/connection.rb
einvoice-1.2.15 lib/einvoice/connection.rb
einvoice-1.2.14 lib/einvoice/connection.rb
einvoice-1.2.13 lib/einvoice/connection.rb
einvoice-1.2.12 lib/einvoice/connection.rb
einvoice-1.2.11 lib/einvoice/connection.rb
einvoice-1.2.10 lib/einvoice/connection.rb
einvoice-1.2.9 lib/einvoice/connection.rb
einvoice-1.2.8 lib/einvoice/connection.rb
einvoice-1.2.7 lib/einvoice/connection.rb
einvoice-1.2.6 lib/einvoice/connection.rb
einvoice-1.2.5 lib/einvoice/connection.rb
einvoice-1.2.4 lib/einvoice/connection.rb
einvoice-1.2.3 lib/einvoice/connection.rb