Class: Ezid::Request Abstract Private

Inherits:
SimpleDelegator
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/ezid/requests/request.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

This class is abstract.

A request to the EZID service.

Constant Summary collapse

CHARSET =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

"UTF-8"
CONTENT_TYPE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

"text/plain"
GET =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

HTTP methods

Net::HTTP::Get
PUT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Net::HTTP::Put
POST =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Net::HTTP::Post
DELETE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Net::HTTP::Delete

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, *args) ⇒ Request

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Request.

Parameters:



45
46
47
48
# File 'lib/ezid/requests/request.rb', line 45

def initialize(client, *args)
  @client = client
  super build_request
end

Class Attribute Details

.http_methodObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



28
29
30
# File 'lib/ezid/requests/request.rb', line 28

def http_method
  @http_method
end

.pathObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



28
29
30
# File 'lib/ezid/requests/request.rb', line 28

def path
  @path
end

.response_classObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



28
29
30
# File 'lib/ezid/requests/request.rb', line 28

def response_class
  @response_class
end

Instance Attribute Details

#clientObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



41
42
43
# File 'lib/ezid/requests/request.rb', line 41

def client
  @client
end

Class Method Details

.execute(client, *args) {|request| ... } ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Yields:

  • (request)


30
31
32
33
34
# File 'lib/ezid/requests/request.rb', line 30

def execute(client, *args)
  request = new(client, *args)
  yield request if block_given?
  request.execute
end

.short_nameObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



36
37
38
# File 'lib/ezid/requests/request.rb', line 36

def short_name
  name.split("::").last.sub("Request", "")
end

Instance Method Details

#authentication_required?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


78
79
80
# File 'lib/ezid/requests/request.rb', line 78

def authentication_required?
  true
end

#executeEzid::Response

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Executes the request and returns the response

Returns:



52
53
54
# File 'lib/ezid/requests/request.rb', line 52

def execute
  response_class.new(get_response_for_request)
end

#handle_response(http_response) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



86
87
88
89
90
# File 'lib/ezid/requests/request.rb', line 86

def handle_response(http_response)
  response_class.new(http_response).tap do |response|
    yield response if block_given?
  end
end

#has_metadata?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


82
83
84
# File 'lib/ezid/requests/request.rb', line 82

def has_metadata?
  !.empty? rescue false
end

#pathString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

HTTP request path

Returns:

  • (String)

    the path



64
65
66
# File 'lib/ezid/requests/request.rb', line 64

def path
  self.class.path
end

#queryString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

HTTP request query string

Returns:

  • (String)

    the query string



76
# File 'lib/ezid/requests/request.rb', line 76

def query; end

#response_classClass

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Class to wrap Net::HTTPResponse

Returns:

  • (Class)


70
71
72
# File 'lib/ezid/requests/request.rb', line 70

def response_class
  self.class.response_class || Response
end

#uriURI

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The request URI

Returns:

  • (URI)

    the URI



58
59
60
# File 'lib/ezid/requests/request.rb', line 58

def uri
  @uri ||= build_uri
end