Sha256: 57ee90963ab3a1d3a8aefb56d4f9ee18e1feaf283880234b4d8c686b72d33be0

Contents?: true

Size: 1.23 KB

Versions: 5

Compression:

Stored size: 1.23 KB

Contents

module Youtrack
  class Base
    include HTTParty

    # The base route URL
    attr_accessor :base_url

    # The Server Endpoint
    attr_accessor :service

    # Stores the response of the previous request
    attr_accessor :response


    def initialize(client)
      @service = client
      @base_url = @service.endpoint
      self.class.debug_output($stderr) if client.debug
    end

    protected

      def join(*args)
        File.join(*args)
      end

      def prepare_options(options={})
        options[:headers] ||= {}
        options[:headers]['Cookie'] = service.cookies['Cookie']
        options
      end
      
      def post(path, options={})
        options = prepare_options(options)
        @response = self.class.post( join(base_url, path), options )
      end

      def put(path, options={})
        options = prepare_options(options)
        @response = self.class.put( join(base_url, path), options )
      end

      def get(path, options={})
        options = prepare_options(options)
        @response = self.class.get( join(base_url, path), options )
      end

      def delete(path, options={})
        options = prepare_options(options)
        @response = self.class.delete( join(base_url, path), options )
      end

  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
rutrack-0.0.12 lib/youtrack/resources/base.rb
rutrack-0.0.11.1 lib/youtrack/resources/base.rb
youtrack-0.0.11 lib/youtrack/resources/base.rb
youtrack-0.0.10 lib/youtrack/resources/base.rb
youtrack-0.0.9 lib/youtrack/resources/base.rb