Created
August 13, 2019 16:30
-
-
Save pupca/29300e65e2f3b63b5c82ff936a68e405 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'savon' | |
class PolarionService | |
def initialize | |
@tracker_url = 'https://cns.net.plm.eds.com/polarion/ws/services/TrackerWebService?wsdl' | |
@session_url = 'https://cns.net.plm.eds.com/polarion/ws/services/SessionWebService?wsdl' | |
end | |
def tracker_client | |
cert = File.expand_path("/Users/pupca/Downloads/cns.pem1") | |
Savon.client(open_timeout: 5000, read_timeout: 5000, :ssl_verify_mode => :none, wsdl: @tracker_url, soap_header: { "ns1:sessionID" => get_session_id, :attributes! => { "ns1:sessionID" => {"env:actor" => "http://schemas.xmlsoap.org/soap/actor/next", "env:mustUnderstand" => "0", "xmlns:ns1" => "http://ws.polarion.com/session"}}}) | |
end | |
def get_session_id | |
session_client = Savon.client(wsdl: @session_url, :ssl_verify_mode => :none) | |
response = session_client.call(:log_in, message: {user_name: ENV["POLARION_LOGIN"], password: ENV["POLARION_PASSWORD"]}) | |
session_id = response.header[:session_id] | |
end | |
def query_workitems(query) | |
workitems = tracker_client.call(:query_work_items, message: {query: query, sort: "id", fields: ["id", "severity", "customFields.customer", "customFields.internalCustomers", "customFields.occurrence", "customFields.detection", "customFields.workaround", "customFields.priorityBooster"]}) | |
result = workitems.body[:query_work_items_response][:query_work_items_return] | |
result = [result] if result.class == Hash | |
result = [] if result.class == NilClass | |
puts "Quering '#{query}'' with result #{result.to_a.count}" | |
return result | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment