Sha256: 541ad654e1bad0627fa49c2c0c14304e143c41ae2410129313f0456088f4a80e

Contents?: true

Size: 892 Bytes

Versions: 2

Compression:

Stored size: 892 Bytes

Contents

module Citrix
  module Training
    module Helpers
      module HttpClient
        def json_parser
          http_client.configuration.json_parser
        end

        def url_for(*args)
          File.join(API_ENDPOINT, *args.map(&:to_s))
        end

        def http_client
          @http_client ||= Aitch::Namespace.new.tap do |ns|
            ns.configure do |config|
              if $DEBUG
                require 'logger'
                config.logger = Logger.new($stdout)
              end

              config.user_agent = "Citrix::Rubygems/#{Citrix::VERSION}"
              config.default_headers = {
                'Authorization' => -> { "OAuth oauth_token=#{credentials.oauth_token}" },
                'Accept' => 'application/json',
                'Content-Type' => 'application/json'
              }
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
citrix-0.2.0 lib/citrix/training/helpers/http_client.rb
citrix-0.1.0 lib/citrix/training/helpers/http_client.rb