Sha256: 212399580c8ecdcb1742beee1bc2aa9306f9f77b7d59525eea9b581dc1d507e9
Contents?: true
Size: 1.75 KB
Versions: 2
Compression:
Stored size: 1.75 KB
Contents
module Youtrack class Client # holds the youTrack Server url # defaults to nil attr_accessor :url # stores the Server login credential # defaults to nil attr_accessor :login # stores the Server password credential # defaulst to nil attr_accessor :password # stores the response object attr_accessor :connection # stores the auth_headers attr_accessor :cookies # stores the scope of all subsequent api calls attr_accessor :admin def admin? true == @admin end # Sets debugging mode attr_accessor :debug def initialize(options={}, &block) @cookies = {} @admin = false @debug = false yield(self) if block_given? end # the server endpoint def endpoint @endpoint = File.join(url, 'rest') end def credentials_hash { login: login, password: password } end # Makes a login call and sets the Cookie headers # # Returns the status code of the connection call def connect! @connection = HTTParty.post(File.join(url, "rest/user/login"), body: credentials_hash ) #@connection = HTTParty.post(File.join(url, "hub/auth/login"), body: credentials_hash ) @cookies['Cookie'] = @connection.headers['set-cookie'] @connection.code end def connected? !!(connection && connection.headers['set-cookie'] && connection.code == 200) end def users resource(:user).new(self) end def projects resource(:project).new(self) end def issues resource(:issue).new(self) end def tags resource(:tag).new(self) end private def resource(resource_name) Youtrack.const_get(resource_name.to_s.capitalize) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rutrack-0.0.12 | lib/youtrack/client.rb |
rutrack-0.0.11.1 | lib/youtrack/client.rb |