Class: FinchAPI::RequestOptions

Inherits:
BaseModel 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

Methods inherited from BaseModel

==, #==, #[], coerce, #deconstruct_keys, dump, fields, #inspect, known_fields, optional, required, #to_h

Methods included from Converter

#coerce, coerce, #dump, dump, type_info

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)


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

#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)


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

#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)


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

#idempotency_keyString?

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

sent for write requests.

Returns:

  • (String, nil)


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

optional :idempotency_key, String

#max_retriesInteger?

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

Returns:

  • (Integer, nil)


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

optional :max_retries, Integer

#timeoutFloat?

Request timeout in seconds.

Returns:

  • (Float, nil)


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

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)


48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/finch-api/request_options.rb', line 48

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