Module: RemoteAPI

Included in:
JIRA::JIRAService
Defined in:
lib/jiraSOAP/remoteAPI.rb

Constant Summary collapse

RESPONSE_XPATH =
'/node()[1]/node()[1]/node()[1]/node()[2]'

Instance Method Summary collapse

Instance Method Details

#create_issue_with_issue(issue) ⇒ Object



143
144
145
146
147
148
149
150
151
152
# File 'lib/jiraSOAP/remoteAPI.rb', line 143

def create_issue_with_issue(issue)
  response = invoke('soap:createIssue') { |msg|
    msg.add 'soap:in0', @auth_token
    msg.add 'soap:in1' do |submsg|
      issue.soapify_for submsg
    end
  }
  frag = response.document.xpath '//createIssueReturn'
  JIRA::Issue.issue_with_xml_fragment frag
end

#get_custom_fieldsObject



43
44
45
46
47
48
49
50
51
# File 'lib/jiraSOAP/remoteAPI.rb', line 43

def get_custom_fields
  response = invoke('soap:getCustomFields') { |msg|
    msg.add 'soap:in0', @auth_token
  }
  response.document.xpath("#{RESPONSE_XPATH}/getCustomFieldsReturn").map {
    |frag|
    JIRA::Field.field_with_xml_fragment frag
  }
end

#get_issue_typesObject



53
54
55
56
57
58
59
60
61
# File 'lib/jiraSOAP/remoteAPI.rb', line 53

def get_issue_types
  response = invoke('soap:getIssueTypes') { |msg|
    msg.add 'soap:in0', @auth_token
  }
  response.document.xpath("#{RESPONSE_XPATH}/getIssueTypesReturn").map {
    |frag|
    JIRA::IssueType.issue_type_with_xml_fragment frag
  }
end

#get_issues_from_jql_search(jql_query, max_results = 500) ⇒ Object



119
120
121
122
123
124
125
126
127
128
129
# File 'lib/jiraSOAP/remoteAPI.rb', line 119

def get_issues_from_jql_search(jql_query, max_results = 500)
  response = invoke('soap:getIssuesFromJqlSearch') { |msg|
    msg.add 'soap:in0', @auth_token
    msg.add 'soap:in1', jql_query
    msg.add 'soap:in2', max_results
  }
  response.document.xpath("#{RESPONSE_XPATH}/getIssuesFromJqlSearchReturn").map {
    |frag|
    JIRA::Issue.issue_with_xml_fragment frag
  }
end

#get_notification_schemesObject



73
74
75
76
77
78
79
80
81
# File 'lib/jiraSOAP/remoteAPI.rb', line 73

def get_notification_schemes
  response = invoke('soap:getNotificationSchemes') { |msg|
    msg.add 'soap:in0', @auth_token
  }
  response.document.xpath("#{RESPONSE_XPATH}/getNotificationSchemesReturn").map {
    |frag|
    JIRA::Scheme.scheme_with_xml_fragment frag
  }
end

#get_prioritiesObject



23
24
25
26
27
28
29
30
31
# File 'lib/jiraSOAP/remoteAPI.rb', line 23

def get_priorities
  response = invoke('soap:getPriorities') { |msg|
    msg.add 'soap:in0', @auth_token
  }
  response.document.xpath("#{RESPONSE_XPATH}/getPrioritiesReturn").map {
    |frag|
    JIRA::Priority.priority_with_xml_fragment frag
  }
end

#get_project_avatar_for_key(project_key) ⇒ Object



111
112
113
114
115
116
117
# File 'lib/jiraSOAP/remoteAPI.rb', line 111

def get_project_avatar_for_key(project_key)
  response = invoke('soap:getProjectAvatar') { |msg|
    msg.add 'soap:in0', @auth_token
    msg.add 'soap:in1', project_key
  }
  JIRA::Avatar.avatar_with_xml_fragment response.document.xpath '//getProjectAvatarReturn'
end

#get_project_with_key(project_key) ⇒ Object



94
95
96
97
98
99
100
101
# File 'lib/jiraSOAP/remoteAPI.rb', line 94

def get_project_with_key(project_key)
  response = invoke('soap:getProjectByKey') { |msg|
    msg.add 'soap:in0', @auth_token
    msg.add 'soap:in1', project_key
  }
  frag = response.document.xpath '//getProjectByKeyReturn'
  JIRA::Project.project_with_xml_fragment frag
end

#get_resolutionsObject



33
34
35
36
37
38
39
40
41
# File 'lib/jiraSOAP/remoteAPI.rb', line 33

def get_resolutions
  response = invoke('soap:getResolutions') { |msg|
    msg.add 'soap:in0', @auth_token
  }
  response.document.xpath("#{RESPONSE_XPATH}/getResolutionsReturn").map {
    |frag|
    JIRA::Resolution.resolution_with_xml_fragment frag
  }
end

#get_statusesObject



63
64
65
66
67
68
69
70
71
# File 'lib/jiraSOAP/remoteAPI.rb', line 63

def get_statuses
  response = invoke('soap:getStatuses') { |msg|
    msg.add 'soap:in0', @auth_token
  }
  response.document.xpath("#{RESPONSE_XPATH}/getStatusesReturn").map {
    |frag|
    JIRA::Status.status_with_xml_fragment frag
  }
end

#get_user_with_name(user_name) ⇒ Object



103
104
105
106
107
108
109
# File 'lib/jiraSOAP/remoteAPI.rb', line 103

def get_user_with_name(user_name)
  response = invoke('soap:getUser') { |msg|
    msg.add 'soap:in0', @auth_token
    msg.add 'soap:in1', user_name
  }
  JIRA::User.user_with_xml_fragment response.document.xpath '//getUserReturn'
end

#get_versions_for_project(project_key) ⇒ Object



83
84
85
86
87
88
89
90
91
92
# File 'lib/jiraSOAP/remoteAPI.rb', line 83

def get_versions_for_project(project_key)
  response = invoke('soap:getVersions') { |msg|
    msg.add 'soap:in0', @auth_token
    msg.add 'soap:in1', project_key
  }
  response.document.xpath("#{RESPONSE_XPATH}/getVersionsReturn").map {
    |frag|
    JIRA::Version.version_with_xml_fragment frag
  }
end

#login(user, password) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/jiraSOAP/remoteAPI.rb', line 4

def (user, password)
  response = invoke('soap:login') { |msg|
    msg.add 'soap:in0', user
    msg.add 'soap:in1', password
  }
  #TODO: error handling (catch the exception and look at the Response node?)
  #cache now that we know it is safe to do so
  @user       = user
  @auth_token = response.document.xpath('//loginReturn').first.to_s
  true
end

#logoutObject



16
17
18
19
20
21
# File 'lib/jiraSOAP/remoteAPI.rb', line 16

def logout
  response = invoke('soap:logout') { |msg|
    msg.add 'soap:in0', @auth_token
  }
  response.document.xpath('//logoutReturn').first.to_s == 'true'
end

#update_issue(issue_key, *field_values) ⇒ Object



131
132
133
134
135
136
137
138
139
140
141
# File 'lib/jiraSOAP/remoteAPI.rb', line 131

def update_issue(issue_key, *field_values)
  response = invoke('soap:updateIssue') { |msg|
    msg.add 'soap:in0', @auth_token
    msg.add 'soap:in1', issue_key
    msg.add 'soap:in2'  do |submsg|
      field_values.each { |fv| fv.soapify_for submsg }
    end
  }
  frag = response.document.xpath '//updateIssueReturn'
  JIRA::Issue.issue_with_xml_fragment frag
end