Class: JenkinsTracker::TrackerClient

Inherits:
Object
  • Object
show all
Defined in:
lib/jenkins_tracker/tracker_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ TrackerClient

Returns a new instance of TrackerClient.



7
8
9
# File 'lib/jenkins_tracker/tracker_client.rb', line 7

def initialize(options = {})
  @token = options[:token]
end

Instance Attribute Details

#tokenObject (readonly)

Returns the value of attribute token.



5
6
7
# File 'lib/jenkins_tracker/tracker_client.rb', line 5

def token
  @token
end

#use_ssl=(value) ⇒ Object

Sets the attribute use_ssl

Parameters:

  • value

    the value to set the attribute use_ssl to.



4
5
6
# File 'lib/jenkins_tracker/tracker_client.rb', line 4

def use_ssl=(value)
  @use_ssl = value
end

Instance Method Details

#add_note_to_story(project_id, story_id, note) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/jenkins_tracker/tracker_client.rb', line 15

def add_note_to_story(project_id, story_id, note)
  begin
    connection["projects/#{project_id}/stories/#{story_id}/notes"].post("<note><text>#{note}</text></note>")
  rescue => e
    # if the post fails for whatever reason (e.g. invalid story id etc), just ignore it
    #puts ["An error occurred while trying add note to Story ##{story_id} in Project ##{project_id} ", e.message, e.backtrace] * "\n"
  end
end

#connection(options = {}) ⇒ Object



11
12
13
# File 'lib/jenkins_tracker/tracker_client.rb', line 11

def connection(options = {})
  @connection ||= RestClient::Resource.new(api_url, :headers => { 'X-TrackerToken' => token, 'Content-Type' => 'application/xml' })
end