Class: KiYoutrack::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/ki_youtrack/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = Kiseru::Config[:ki_youtrack]) ⇒ Api

Returns a new instance of Api.



7
8
9
# File 'lib/ki_youtrack/api.rb', line 7

def initialize(config=Kiseru::Config[:ki_youtrack])
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



5
6
7
# File 'lib/ki_youtrack/api.rb', line 5

def config
  @config
end

Instance Method Details

#issue(id, opts = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ki_youtrack/api.rb', line 11

def issue(id, opts = {})
  config.ensure_present('login', 'password', 'subdomain', 'ssl')

   = @config.read('login')
  password = @config.read('password')
  subdomain = @config.read('subdomain')
  ssl = @config.read('ssl')
  cookies = @config.read('cached_auth_cookies')

  session = Session.new(, password, subdomain, :ssl => ssl, :cookies => cookies)
  response = session.init

  issue = session.issue(id)

  @config.write('cached_auth_cookies', session.session_cookies.encode("UTF-8"))

  filtered_data = IssueFilter.filter(issue)
  MultiJson.dump(filtered_data, :pretty => opts[:pretty])
end