Class: JIRA::RequestClient

Inherits:
Object
  • Object
show all
Defined in:
lib/jira/request_client.rb

Overview

Base class for request clients specific to a particular authentication method.

Direct Known Subclasses

HttpClient, OauthClient

Instance Method Summary collapse

Instance Method Details

#make_multipart_request(*args) ⇒ Object

This method is abstract.

Abstract method to make a request to the JIRA server with a file upload.

Raises:

Parameters:

  • Arguments to pass to the request method



56
57
58
# File 'lib/jira/request_client.rb', line 56

def make_multipart_request(*args)
  raise NotImplementedError
end

#make_request(*args) ⇒ Object

This method is abstract.

Abstract method to make a request to the JIRA server.

Raises:

Parameters:

  • Arguments to pass to the request method



49
50
51
# File 'lib/jira/request_client.rb', line 49

def make_request(*args)
  raise NotImplementedError
end

#request(*args) ⇒ Net::HTTPResponse

Makes the JIRA REST API call.

Returns the response if the request was successful (HTTP::2xx) and raises a JIRA::HTTPError if it was not successful, with the response attached.

Generally you should not call this method directly, but use derived classes.

File uploads are not supported with this method. Use request_multipart instead.

Raises:

  • if it was not successful

Parameters:

  • Arguments to pass to the request method

Returns:

  • The response from the server



23
24
25
26
27
28
# File 'lib/jira/request_client.rb', line 23

def request(*args)
  response = make_request(*args)
  raise HTTPError, response unless response.is_a?(Net::HTTPSuccess)

  response
end

#request_multipart(*args) ⇒ Net::HTTPResponse

Makes a multipart request to the JIRA server.

This is used for file uploads.

Generally you should not call this method directly, but use derived classes.

Raises:

  • if it was not successful

Parameters:

  • Arguments to pass to the request method

Returns:

  • The response from the server



39
40
41
42
43
44
# File 'lib/jira/request_client.rb', line 39

def request_multipart(*args)
  response = make_multipart_request(*args)
  raise HTTPError, response unless response.is_a?(Net::HTTPSuccess)

  response
end