Sha256: 7696a9b79de5799cc34458b0b1b683fecf8604179434a5e87a311c57c1641483

Contents?: true

Size: 823 Bytes

Versions: 3

Compression:

Stored size: 823 Bytes

Contents

# frozen_string_literal: true

module Lokalise
  module Connection
    BASE_URL = 'https://api.lokalise.com/api2/'

    def connection(client)
      Faraday.new(options(client), request_params_for(client)) do |faraday|
        faraday.use(:gzip) if client.enable_compression
        faraday.adapter Faraday.default_adapter
      end
    end

    private

    def options(client)
      {
        headers: {
          accept: 'application/json',
          user_agent: "ruby-lokalise-api gem/#{Lokalise::VERSION}",
          client.token_header => client.token
        },
        url: BASE_URL
      }
    end

    # Allows to customize request params per-client
    def request_params_for(client)
      {request: {timeout: client.timeout, open_timeout: client.open_timeout}}
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-lokalise-api-4.5.1 lib/ruby-lokalise-api/connection.rb
ruby-lokalise-api-4.5.0 lib/ruby-lokalise-api/connection.rb
ruby-lokalise-api-4.4.0 lib/ruby-lokalise-api/connection.rb