Class: Youtrack::Client
- Inherits:
-
Object
- Object
- Youtrack::Client
- Defined in:
- lib/youtrack/client.rb
Instance Attribute Summary collapse
-
#admin ⇒ Object
stores the scope of all subsequent api calls.
-
#connection ⇒ Object
stores the response object.
-
#cookies ⇒ Object
stores the auth_headers.
-
#debug ⇒ Object
Sets debugging mode.
-
#login ⇒ Object
stores the Server login credential defaults to nil.
-
#password ⇒ Object
stores the Server password credential defaulst to nil.
-
#url ⇒ Object
holds the youTrack Server url defaults to nil.
Instance Method Summary collapse
- #admin? ⇒ Boolean
-
#connect! ⇒ Object
Makes a login call and sets the Cookie headers.
- #connected? ⇒ Boolean
- #credentials_hash ⇒ Object
-
#endpoint ⇒ Object
the server endpoint.
-
#initialize(options = {}) {|_self| ... } ⇒ Client
constructor
A new instance of Client.
- #issues ⇒ Object
- #projects ⇒ Object
- #tags ⇒ Object
- #users ⇒ Object
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ Client
Returns a new instance of Client.
32 33 34 35 36 37 38 |
# File 'lib/youtrack/client.rb', line 32 def initialize(={}, &block) @cookies = {} @admin = false @debug = false yield(self) if block_given? end |
Instance Attribute Details
#admin ⇒ Object
stores the scope of all subsequent api calls
23 24 25 |
# File 'lib/youtrack/client.rb', line 23 def admin @admin end |
#connection ⇒ Object
stores the response object
17 18 19 |
# File 'lib/youtrack/client.rb', line 17 def connection @connection end |
#cookies ⇒ Object
stores the auth_headers
20 21 22 |
# File 'lib/youtrack/client.rb', line 20 def @cookies end |
#debug ⇒ Object
Sets debugging mode
30 31 32 |
# File 'lib/youtrack/client.rb', line 30 def debug @debug end |
#login ⇒ Object
stores the Server login credential defaults to nil
10 11 12 |
# File 'lib/youtrack/client.rb', line 10 def login @login end |
#password ⇒ Object
stores the Server password credential defaulst to nil
14 15 16 |
# File 'lib/youtrack/client.rb', line 14 def password @password end |
#url ⇒ Object
holds the youTrack Server url defaults to nil
6 7 8 |
# File 'lib/youtrack/client.rb', line 6 def url @url end |
Instance Method Details
#admin? ⇒ Boolean
25 26 27 |
# File 'lib/youtrack/client.rb', line 25 def admin? true == @admin end |
#connect! ⇒ Object
Makes a login call and sets the Cookie headers
Returns the status code of the connection call
53 54 55 56 57 58 |
# File 'lib/youtrack/client.rb', line 53 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 |
#connected? ⇒ Boolean
60 61 62 |
# File 'lib/youtrack/client.rb', line 60 def connected? !!(connection && connection.headers['set-cookie'] && connection.code == 200) end |
#credentials_hash ⇒ Object
45 46 47 |
# File 'lib/youtrack/client.rb', line 45 def credentials_hash { login: login, password: password } end |
#endpoint ⇒ Object
the server endpoint
41 42 43 |
# File 'lib/youtrack/client.rb', line 41 def endpoint @endpoint = File.join(url, 'rest') end |
#issues ⇒ Object
72 73 74 |
# File 'lib/youtrack/client.rb', line 72 def issues resource(:issue).new(self) end |
#projects ⇒ Object
68 69 70 |
# File 'lib/youtrack/client.rb', line 68 def projects resource(:project).new(self) end |
#tags ⇒ Object
76 77 78 |
# File 'lib/youtrack/client.rb', line 76 def resource(:tag).new(self) end |
#users ⇒ Object
64 65 66 |
# File 'lib/youtrack/client.rb', line 64 def users resource(:user).new(self) end |