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:



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

def initialize(options={}, &block)
  @cookies = {}
  @admin   = 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

#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



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

Returns:

  • (Boolean)


55
56
57
# File 'lib/youtrack/client.rb', line 55

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

#credentials_hashObject



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

def credentials_hash
  { login: , password: password }
end

#endpointObject

the server endpoint



37
38
39
# File 'lib/youtrack/client.rb', line 37

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

#issuesObject



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

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

#projectsObject



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

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

#usersObject



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

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