Class: Useless::Doc::Core::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/useless/doc/core/request.rb

Overview

Documentation for an HTTP request.

Defined Under Namespace

Modules: Method Classes: Parameter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Request

Returns a new instance of Request.

Parameters:

  • attrs (Hash) (defaults to: {})

    corresponds to the class’s instance attributes.



53
54
55
56
57
58
59
60
61
# File 'lib/useless/doc/core/request.rb', line 53

def initialize(attrs = {})
  @method                   = attrs[:method]
  @description              = attrs[:description]
  @authentication_required  = attrs[:authentication_required]
  @parameters               = attrs[:parameters] || []
  @headers                  = attrs[:headers] || []
  @body                     = attrs[:body]
  @responses                = attrs[:responses] || []
end

Instance Attribute Details

#authentication_requiredBoolean

Returns whether or not the user needs to authenticate in order to perform this request.

Returns:

  • (Boolean)

    whether or not the user needs to authenticate in order to perform this request.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/useless/doc/core/request.rb', line 35

class Request

  module Method
    GET     = 'GET'
    HEAD    = 'HEAD'
    POST    = 'POST'
    PUT     = 'PUT'
    PATCH   = 'PATCH'
    DELETE  = 'DELETE'
    TRACE   = 'TRACE'
    CONNECT = 'CONNECT'
  end

  attr_accessor :method, :description, :authentication_required,
    :parameters, :headers, :body, :responses

  # @param [Hash] attrs corresponds to the class's instance attributes.
  #
  def initialize(attrs = {})
    @method                   = attrs[:method]
    @description              = attrs[:description]
    @authentication_required  = attrs[:authentication_required]
    @parameters               = attrs[:parameters] || []
    @headers                  = attrs[:headers] || []
    @body                     = attrs[:body]
    @responses                = attrs[:responses] || []
  end

  # Documentation for a request parameter for an API action.
  #
  # @!attribute [r] type
  #   @return [String] either "path" if it's part of the URL path, or
  #     "query" if it's part of the query string.
  #
  # @!attribute [r] key
  #   @return [String] the key of the parameter.
  #
  # @!attribute [r] required
  #   @return [Boolean] whether or not the parameter is required. If it is
  #     required, and the attribute is omitted, the response should have a
  #     4xx code.
  #
  # @!attribute [r] default
  #   @return [String, Numeric] the value used if the parameter is omitted
  #     and is not required.
  #
  # @!attribute [r] description
  #   @return [String] a description of the parameter.
  #
  class Parameter

    module Type
      PATH = 'path'
      QUERY = 'query'
    end

    attr_reader :type, :key, :required, :default, :description

    # @param [Hash] attrs corresponds to the class's instance attributes.
    #
    def initialize(attrs = {})
      @type         = attrs[:type]
      @key          = attrs[:key]
      @required     = attrs[:required]
      @default      = attrs[:default]
      @description  = attrs[:description]
    end
  end
end

#bodyBody

Returns the body of the request.

Returns:

  • (Body)

    the body of the request.

See Also:



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/useless/doc/core/request.rb', line 35

class Request

  module Method
    GET     = 'GET'
    HEAD    = 'HEAD'
    POST    = 'POST'
    PUT     = 'PUT'
    PATCH   = 'PATCH'
    DELETE  = 'DELETE'
    TRACE   = 'TRACE'
    CONNECT = 'CONNECT'
  end

  attr_accessor :method, :description, :authentication_required,
    :parameters, :headers, :body, :responses

  # @param [Hash] attrs corresponds to the class's instance attributes.
  #
  def initialize(attrs = {})
    @method                   = attrs[:method]
    @description              = attrs[:description]
    @authentication_required  = attrs[:authentication_required]
    @parameters               = attrs[:parameters] || []
    @headers                  = attrs[:headers] || []
    @body                     = attrs[:body]
    @responses                = attrs[:responses] || []
  end

  # Documentation for a request parameter for an API action.
  #
  # @!attribute [r] type
  #   @return [String] either "path" if it's part of the URL path, or
  #     "query" if it's part of the query string.
  #
  # @!attribute [r] key
  #   @return [String] the key of the parameter.
  #
  # @!attribute [r] required
  #   @return [Boolean] whether or not the parameter is required. If it is
  #     required, and the attribute is omitted, the response should have a
  #     4xx code.
  #
  # @!attribute [r] default
  #   @return [String, Numeric] the value used if the parameter is omitted
  #     and is not required.
  #
  # @!attribute [r] description
  #   @return [String] a description of the parameter.
  #
  class Parameter

    module Type
      PATH = 'path'
      QUERY = 'query'
    end

    attr_reader :type, :key, :required, :default, :description

    # @param [Hash] attrs corresponds to the class's instance attributes.
    #
    def initialize(attrs = {})
      @type         = attrs[:type]
      @key          = attrs[:key]
      @required     = attrs[:required]
      @default      = attrs[:default]
      @description  = attrs[:description]
    end
  end
end

#descriptionString

Returns a description of the request.

Returns:

  • (String)

    a description of the request.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/useless/doc/core/request.rb', line 35

class Request

  module Method
    GET     = 'GET'
    HEAD    = 'HEAD'
    POST    = 'POST'
    PUT     = 'PUT'
    PATCH   = 'PATCH'
    DELETE  = 'DELETE'
    TRACE   = 'TRACE'
    CONNECT = 'CONNECT'
  end

  attr_accessor :method, :description, :authentication_required,
    :parameters, :headers, :body, :responses

  # @param [Hash] attrs corresponds to the class's instance attributes.
  #
  def initialize(attrs = {})
    @method                   = attrs[:method]
    @description              = attrs[:description]
    @authentication_required  = attrs[:authentication_required]
    @parameters               = attrs[:parameters] || []
    @headers                  = attrs[:headers] || []
    @body                     = attrs[:body]
    @responses                = attrs[:responses] || []
  end

  # Documentation for a request parameter for an API action.
  #
  # @!attribute [r] type
  #   @return [String] either "path" if it's part of the URL path, or
  #     "query" if it's part of the query string.
  #
  # @!attribute [r] key
  #   @return [String] the key of the parameter.
  #
  # @!attribute [r] required
  #   @return [Boolean] whether or not the parameter is required. If it is
  #     required, and the attribute is omitted, the response should have a
  #     4xx code.
  #
  # @!attribute [r] default
  #   @return [String, Numeric] the value used if the parameter is omitted
  #     and is not required.
  #
  # @!attribute [r] description
  #   @return [String] a description of the parameter.
  #
  class Parameter

    module Type
      PATH = 'path'
      QUERY = 'query'
    end

    attr_reader :type, :key, :required, :default, :description

    # @param [Hash] attrs corresponds to the class's instance attributes.
    #
    def initialize(attrs = {})
      @type         = attrs[:type]
      @key          = attrs[:key]
      @required     = attrs[:required]
      @default      = attrs[:default]
      @description  = attrs[:description]
    end
  end
end

#headersArray<Header>

Returns possible headers for the request.

Returns:

  • (Array<Header>)

    possible headers for the request.

See Also:

  • Heaader


35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/useless/doc/core/request.rb', line 35

class Request

  module Method
    GET     = 'GET'
    HEAD    = 'HEAD'
    POST    = 'POST'
    PUT     = 'PUT'
    PATCH   = 'PATCH'
    DELETE  = 'DELETE'
    TRACE   = 'TRACE'
    CONNECT = 'CONNECT'
  end

  attr_accessor :method, :description, :authentication_required,
    :parameters, :headers, :body, :responses

  # @param [Hash] attrs corresponds to the class's instance attributes.
  #
  def initialize(attrs = {})
    @method                   = attrs[:method]
    @description              = attrs[:description]
    @authentication_required  = attrs[:authentication_required]
    @parameters               = attrs[:parameters] || []
    @headers                  = attrs[:headers] || []
    @body                     = attrs[:body]
    @responses                = attrs[:responses] || []
  end

  # Documentation for a request parameter for an API action.
  #
  # @!attribute [r] type
  #   @return [String] either "path" if it's part of the URL path, or
  #     "query" if it's part of the query string.
  #
  # @!attribute [r] key
  #   @return [String] the key of the parameter.
  #
  # @!attribute [r] required
  #   @return [Boolean] whether or not the parameter is required. If it is
  #     required, and the attribute is omitted, the response should have a
  #     4xx code.
  #
  # @!attribute [r] default
  #   @return [String, Numeric] the value used if the parameter is omitted
  #     and is not required.
  #
  # @!attribute [r] description
  #   @return [String] a description of the parameter.
  #
  class Parameter

    module Type
      PATH = 'path'
      QUERY = 'query'
    end

    attr_reader :type, :key, :required, :default, :description

    # @param [Hash] attrs corresponds to the class's instance attributes.
    #
    def initialize(attrs = {})
      @type         = attrs[:type]
      @key          = attrs[:key]
      @required     = attrs[:required]
      @default      = attrs[:default]
      @description  = attrs[:description]
    end
  end
end

#methodString

Returns the request’s HTTP method.

Returns:

  • (String)

    the request’s HTTP method.

See Also:



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/useless/doc/core/request.rb', line 35

class Request

  module Method
    GET     = 'GET'
    HEAD    = 'HEAD'
    POST    = 'POST'
    PUT     = 'PUT'
    PATCH   = 'PATCH'
    DELETE  = 'DELETE'
    TRACE   = 'TRACE'
    CONNECT = 'CONNECT'
  end

  attr_accessor :method, :description, :authentication_required,
    :parameters, :headers, :body, :responses

  # @param [Hash] attrs corresponds to the class's instance attributes.
  #
  def initialize(attrs = {})
    @method                   = attrs[:method]
    @description              = attrs[:description]
    @authentication_required  = attrs[:authentication_required]
    @parameters               = attrs[:parameters] || []
    @headers                  = attrs[:headers] || []
    @body                     = attrs[:body]
    @responses                = attrs[:responses] || []
  end

  # Documentation for a request parameter for an API action.
  #
  # @!attribute [r] type
  #   @return [String] either "path" if it's part of the URL path, or
  #     "query" if it's part of the query string.
  #
  # @!attribute [r] key
  #   @return [String] the key of the parameter.
  #
  # @!attribute [r] required
  #   @return [Boolean] whether or not the parameter is required. If it is
  #     required, and the attribute is omitted, the response should have a
  #     4xx code.
  #
  # @!attribute [r] default
  #   @return [String, Numeric] the value used if the parameter is omitted
  #     and is not required.
  #
  # @!attribute [r] description
  #   @return [String] a description of the parameter.
  #
  class Parameter

    module Type
      PATH = 'path'
      QUERY = 'query'
    end

    attr_reader :type, :key, :required, :default, :description

    # @param [Hash] attrs corresponds to the class's instance attributes.
    #
    def initialize(attrs = {})
      @type         = attrs[:type]
      @key          = attrs[:key]
      @required     = attrs[:required]
      @default      = attrs[:default]
      @description  = attrs[:description]
    end
  end
end

#parametersArray<Request::Parameter>

Returns possible parameters for the request.

Returns:

See Also:



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/useless/doc/core/request.rb', line 35

class Request

  module Method
    GET     = 'GET'
    HEAD    = 'HEAD'
    POST    = 'POST'
    PUT     = 'PUT'
    PATCH   = 'PATCH'
    DELETE  = 'DELETE'
    TRACE   = 'TRACE'
    CONNECT = 'CONNECT'
  end

  attr_accessor :method, :description, :authentication_required,
    :parameters, :headers, :body, :responses

  # @param [Hash] attrs corresponds to the class's instance attributes.
  #
  def initialize(attrs = {})
    @method                   = attrs[:method]
    @description              = attrs[:description]
    @authentication_required  = attrs[:authentication_required]
    @parameters               = attrs[:parameters] || []
    @headers                  = attrs[:headers] || []
    @body                     = attrs[:body]
    @responses                = attrs[:responses] || []
  end

  # Documentation for a request parameter for an API action.
  #
  # @!attribute [r] type
  #   @return [String] either "path" if it's part of the URL path, or
  #     "query" if it's part of the query string.
  #
  # @!attribute [r] key
  #   @return [String] the key of the parameter.
  #
  # @!attribute [r] required
  #   @return [Boolean] whether or not the parameter is required. If it is
  #     required, and the attribute is omitted, the response should have a
  #     4xx code.
  #
  # @!attribute [r] default
  #   @return [String, Numeric] the value used if the parameter is omitted
  #     and is not required.
  #
  # @!attribute [r] description
  #   @return [String] a description of the parameter.
  #
  class Parameter

    module Type
      PATH = 'path'
      QUERY = 'query'
    end

    attr_reader :type, :key, :required, :default, :description

    # @param [Hash] attrs corresponds to the class's instance attributes.
    #
    def initialize(attrs = {})
      @type         = attrs[:type]
      @key          = attrs[:key]
      @required     = attrs[:required]
      @default      = attrs[:default]
      @description  = attrs[:description]
    end
  end
end

#responsesArray<Response>

Returns possible responses to the request.

Returns:

  • (Array<Response>)

    possible responses to the request.

See Also:



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/useless/doc/core/request.rb', line 35

class Request

  module Method
    GET     = 'GET'
    HEAD    = 'HEAD'
    POST    = 'POST'
    PUT     = 'PUT'
    PATCH   = 'PATCH'
    DELETE  = 'DELETE'
    TRACE   = 'TRACE'
    CONNECT = 'CONNECT'
  end

  attr_accessor :method, :description, :authentication_required,
    :parameters, :headers, :body, :responses

  # @param [Hash] attrs corresponds to the class's instance attributes.
  #
  def initialize(attrs = {})
    @method                   = attrs[:method]
    @description              = attrs[:description]
    @authentication_required  = attrs[:authentication_required]
    @parameters               = attrs[:parameters] || []
    @headers                  = attrs[:headers] || []
    @body                     = attrs[:body]
    @responses                = attrs[:responses] || []
  end

  # Documentation for a request parameter for an API action.
  #
  # @!attribute [r] type
  #   @return [String] either "path" if it's part of the URL path, or
  #     "query" if it's part of the query string.
  #
  # @!attribute [r] key
  #   @return [String] the key of the parameter.
  #
  # @!attribute [r] required
  #   @return [Boolean] whether or not the parameter is required. If it is
  #     required, and the attribute is omitted, the response should have a
  #     4xx code.
  #
  # @!attribute [r] default
  #   @return [String, Numeric] the value used if the parameter is omitted
  #     and is not required.
  #
  # @!attribute [r] description
  #   @return [String] a description of the parameter.
  #
  class Parameter

    module Type
      PATH = 'path'
      QUERY = 'query'
    end

    attr_reader :type, :key, :required, :default, :description

    # @param [Hash] attrs corresponds to the class's instance attributes.
    #
    def initialize(attrs = {})
      @type         = attrs[:type]
      @key          = attrs[:key]
      @required     = attrs[:required]
      @default      = attrs[:default]
      @description  = attrs[:description]
    end
  end
end