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.
-
#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
- #users ⇒ Object
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ Client
Returns a new instance of Client.
29 30 31 32 33 34 |
# File 'lib/youtrack/client.rb', line 29 def initialize(={}, &block) @cookies = {} @admin = 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 |
#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
49 50 51 52 53 |
# File 'lib/youtrack/client.rb', line 49 def connect! @connection = HTTParty.post(File.join(url, "rest/user/login"), body: credentials_hash ) @cookies['Cookie'] = @connection.headers['set-cookie'] @connection.code end |
#connected? ⇒ Boolean
55 56 57 |
# File 'lib/youtrack/client.rb', line 55 def connected? !!(connection && connection.headers['set-cookie'] && connection.code == 200) end |
#credentials_hash ⇒ Object
41 42 43 |
# File 'lib/youtrack/client.rb', line 41 def credentials_hash { login: login, password: password } end |
#endpoint ⇒ Object
the server endpoint
37 38 39 |
# File 'lib/youtrack/client.rb', line 37 def endpoint @endpoint = File.join(url, 'rest') end |
#issues ⇒ Object
67 68 69 |
# File 'lib/youtrack/client.rb', line 67 def issues resource(:issue).new(self) end |
#projects ⇒ Object
63 64 65 |
# File 'lib/youtrack/client.rb', line 63 def projects resource(:project).new(self) end |
#users ⇒ Object
59 60 61 |
# File 'lib/youtrack/client.rb', line 59 def users resource(:user).new(self) end |