Class: Youtrack::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/youtrack/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) {|_self| ... } ⇒ Client

Returns a new instance of Client.

Yields:

  • (_self)

Yield Parameters:



32
33
34
35
36
37
38
# File 'lib/youtrack/client.rb', line 32

def initialize(options={}, &block)
  @cookies  = {}
  @admin    = false
  @debug    = false

  yield(self) if block_given?
end

Instance Attribute Details

#adminObject

stores the scope of all subsequent api calls



23
24
25
# File 'lib/youtrack/client.rb', line 23

def admin
  @admin
end

#connectionObject

stores the response object



17
18
19
# File 'lib/youtrack/client.rb', line 17

def connection
  @connection
end

#cookiesObject

stores the auth_headers



20
21
22
# File 'lib/youtrack/client.rb', line 20

def cookies
  @cookies
end

#debugObject

Sets debugging mode



30
31
32
# File 'lib/youtrack/client.rb', line 30

def debug
  @debug
end

#loginObject

stores the Server login credential defaults to nil



10
11
12
# File 'lib/youtrack/client.rb', line 10

def 
  @login
end

#passwordObject

stores the Server password credential defaulst to nil



14
15
16
# File 'lib/youtrack/client.rb', line 14

def password
  @password
end

#urlObject

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

Returns:

  • (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
# File 'lib/youtrack/client.rb', line 53

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

Returns:

  • (Boolean)


59
60
61
# File 'lib/youtrack/client.rb', line 59

def connected?
  !!(connection && connection.headers['set-cookie'] && connection.code == 200)
end

#credentials_hashObject



45
46
47
# File 'lib/youtrack/client.rb', line 45

def credentials_hash
  { login: , password: password }
end

#endpointObject

the server endpoint



41
42
43
# File 'lib/youtrack/client.rb', line 41

def endpoint
  @endpoint = File.join(url, 'rest')
end

#issuesObject



71
72
73
# File 'lib/youtrack/client.rb', line 71

def issues
  resource(:issue).new(self)
end

#projectsObject



67
68
69
# File 'lib/youtrack/client.rb', line 67

def projects
  resource(:project).new(self)
end

#tagsObject



75
76
77
# File 'lib/youtrack/client.rb', line 75

def tags
  resource(:tag).new(self)
end

#usersObject



63
64
65
# File 'lib/youtrack/client.rb', line 63

def users
  resource(:user).new(self)
end