Class: FinchAPI::RequestOptions

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/finch-api/request_options.rb

Overview

Specify HTTP behaviour to use for a specific request. These options supplement

or override those provided at the client level.

When making a request, you can pass an actual {RequestOptions} instance, or
simply pass a Hash with symbol keys matching the attributes on this class.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(values = {}) ⇒ RequestOptions

Returns a new instance of RequestOptions.

Parameters:

  • values (Hash{Symbol=>Object}) (defaults to: {})


5
# File 'lib/finch-api/request_options.rb', line 5

def initialize(values = {}) = super

Instance Attribute Details

#extra_bodyObject?

Extra data to send with the request. These are deep merged into any data

generated as part of the normal request.

Returns:

  • (Object, nil)


54
# File 'lib/finch-api/request_options.rb', line 54

optional :extra_body, FinchAPI::HashOf[FinchAPI::Unknown]

#extra_headersHash{String=>String, nil}?

Extra headers to send with the request. These are ‘.merged`’d into any

`extra_headers` given at the client level.

Returns:

  • (Hash{String=>String, nil}, nil)


47
# File 'lib/finch-api/request_options.rb', line 47

optional :extra_headers, FinchAPI::HashOf[String, nil?: true]

#extra_queryHash{String=>Array<String>, String, nil}?

Extra query params to send with the request. These are ‘.merge`’d into any

`query` given at the client level.

Returns:

  • (Hash{String=>Array<String>, String, nil}, nil)


40
# File 'lib/finch-api/request_options.rb', line 40

optional :extra_query, FinchAPI::HashOf[FinchAPI::ArrayOf[String]]

#idempotency_keyString?

Idempotency key to send with request and all associated retries. Will only be

sent for write requests.

Returns:

  • (String, nil)


33
# File 'lib/finch-api/request_options.rb', line 33

optional :idempotency_key, String

#max_retriesInteger?

Maximum number of retries to attempt after a failed initial request.

Returns:

  • (Integer, nil)


60
# File 'lib/finch-api/request_options.rb', line 60

optional :max_retries, Integer

#timeoutFloat?

Request timeout in seconds.

Returns:

  • (Float, nil)


66
# File 'lib/finch-api/request_options.rb', line 66

optional :timeout, Float

Class Method Details

.validate!(opts) ⇒ 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.

Parameters:

Raises:

  • (ArgumentError)


15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/finch-api/request_options.rb', line 15

def self.validate!(opts)
  case opts
  in FinchAPI::RequestOptions | Hash
    opts.to_h.each_key do |k|
      unless fields.include?(k)
        raise ArgumentError.new("Request `opts` keys must be one of #{fields.keys}, got #{k.inspect}")
      end
    end
  else
    raise ArgumentError.new("Request `opts` must be a Hash or RequestOptions, got #{opts.inspect}")
  end
end