Sha256: f4e88bb3c657a402aa125efcaf3ece5d4d43b15649c8ac78d9f0791dfc1c7205

Contents?: true

Size: 895 Bytes

Versions: 2

Compression:

Stored size: 895 Bytes

Contents

module Citrix
  module Training
    module Helpers
      module HttpClient
        def json_parser
          Aitch::ResponseParser::JSONParser.engine
        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.2 lib/citrix/training/helpers/http_client.rb
citrix-0.2.1 lib/citrix/training/helpers/http_client.rb