Class: GroqRuby::Request

Inherits:
Data
  • Object
show all
Defined in:
lib/groq_ruby/request.rb

Overview

Value object describing a single HTTP request. Built by resources, consumed by Transport. Immutable.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method:, path:, query: nil, body: nil, headers: {}, content_type: nil) ⇒ Request

Returns a new instance of Request.



5
6
7
# File 'lib/groq_ruby/request.rb', line 5

def initialize(method:, path:, query: nil, body: nil, headers: {}, content_type: nil)
  super
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body

Returns:

  • (Object)

    the current value of body



4
5
6
# File 'lib/groq_ruby/request.rb', line 4

def body
  @body
end

#content_typeObject (readonly)

Returns the value of attribute content_type

Returns:

  • (Object)

    the current value of content_type



4
5
6
# File 'lib/groq_ruby/request.rb', line 4

def content_type
  @content_type
end

#headersObject (readonly)

Returns the value of attribute headers

Returns:

  • (Object)

    the current value of headers



4
5
6
# File 'lib/groq_ruby/request.rb', line 4

def headers
  @headers
end

#methodObject (readonly)

Returns the value of attribute method

Returns:

  • (Object)

    the current value of method



4
5
6
# File 'lib/groq_ruby/request.rb', line 4

def method
  @method
end

#pathObject (readonly)

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



4
5
6
# File 'lib/groq_ruby/request.rb', line 4

def path
  @path
end

#queryObject (readonly)

Returns the value of attribute query

Returns:

  • (Object)

    the current value of query



4
5
6
# File 'lib/groq_ruby/request.rb', line 4

def query
  @query
end

Instance Method Details

#with_headers(extra) ⇒ Object



9
10
11
# File 'lib/groq_ruby/request.rb', line 9

def with_headers(extra)
  with(headers: headers.merge(extra))
end