Class: JIRAClient
- Inherits:
-
Object
- Object
- JIRAClient
- Defined in:
- lib/jira_fix_version_release/jira_client.rb
Instance Method Summary collapse
- #getResponseBody(response) ⇒ Object
- #getResponseHeaders(response) ⇒ Object
-
#initialize(username, password, jira_domain) ⇒ JIRAClient
constructor
A new instance of JIRAClient.
- #run(method = nil, url = nil, headers = nil, payload = nil, username = @username, password = @password) ⇒ Object
Constructor Details
#initialize(username, password, jira_domain) ⇒ JIRAClient
Returns a new instance of JIRAClient.
7 8 9 10 11 |
# File 'lib/jira_fix_version_release/jira_client.rb', line 7 def initialize(username, password, jira_domain) @username = username @password = password @jira_domain = jira_domain end |
Instance Method Details
#getResponseBody(response) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/jira_fix_version_release/jira_client.rb', line 32 def getResponseBody(response) begin data = JSON.parse(response.body) rescue data = nil end return data end |
#getResponseHeaders(response) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/jira_fix_version_release/jira_client.rb', line 41 def getResponseHeaders(response) begin data = JSON.parse(response.headers) rescue data = nil end return data end |
#run(method = nil, url = nil, headers = nil, payload = nil, username = @username, password = @password) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/jira_fix_version_release/jira_client.rb', line 13 def run(method=nil, url=nil, headers=nil, payload=nil, username=@username, password=@password) raise ArgumentError, "Missing required parameters" if (method==nil or url==nil or username==nil or password==nil) raise ArgumentError, "Payload required for post/put request" if ((method=="post" or method=="put") and payload==nil) = Hash.new [:method] = method.to_sym [:url] = @jira_domain + url [:user] = username [:password] = password [:headers] = headers if headers != nil [:payload] = payload if payload !=nil and method != "get" response = RestClient::Request.execute() if(response.code < 200 or response.code > 299) raise "Error with the http request!" end return response end |