Base class for service clients. Unlike Client
does not
provide any public methods so subclasses can declare them as they like,
without having to override say a get()
method.
Throws TypeError
instances if illegal options are provided.
Configure a client when it's instantiated. If provided it must be an object. Only own-properties are considered.
Sets the pathname
property. If given it must be a non-empty string.
Cannot contain a ?
search component, use the query
option instead.
Updates the query
parameter list. Optional, but if given it must be an
object. Only own-properties are considered as parameters.
Parameter names must not be empty strings. Values can be strings, finite numbers, and booleans. They'll be cast to strings if necessary.
Updates the headers
list. Optional, but if given it must be an object.
Only own-properties are considered as headers.
Header names are downcased and may not be the same as other downcased names. They must not be empty strings either.
Values can be strings, finite numbers, and booleans. They'll be cast to strings if necessary. Values may be arrays, in which case each item will still need to be a string, finite number, or boolean. Again they'll be cast to strings if necessary. Array values are not allowed to include other arrays.
Sets the auth
property. If provided will override any existing default.
Sets the transport
property. Optional only if the client class provides
a default transport. Must be an object, but other methods are not
checked.
The remote path. Subclasses can set a default value on the prototype or
instance before the base constructor is called. Such values must not
include a query component. Defaults to /
.
Flat list of parameters and values, e.g. ['foo', 'bar', 'baz', 'thud']
would correspond to foo=bar&baz=thud
.
Subclasses can set an initial value on the prototype or instances before
the base constructor is called. The query
option is then added to this
initial value. This can lead to duplicate parameters. Exactly how these
are sent to the service depends on the behavior of the Request
class.
When setting the initial value make sure the parameter names are non-empty strings and the values are strings.
To be safe, the initial query
list is never used directly.
Flat list of headers and values, e.g. ['content-type', 'text/plain']
would correspond to a content-type: text/plain
header.
Subclasses can set an initial value on the prototype or instance before the
base constructor is called. The headers
option is then added to this
initial value. This can lead to duplicate headers. Exactly how these
are sent to the service depends on the behavior of the Request
class.
When setting the initial value make sure the header names are non-empty, downcased strings and the values are strings, or flat arrays containing just strings.
To be safe, the initial headers
list is never used directly.
Credential for authenticating with the service. Its format depends on the
behavior of the Request
class, which is responsible for including it in
the request issued against the service.
Subclasses can set a default value on the prototype or instance before the
base constructor is called. The auth
option will override this default
value.
An instance of a transport class, e.g.
SslTransport
, responsible for issuing the
request against the service.
Class used to describe requests that are to be issued against the service.
Defaults to Request
.
Promise subclass for a service response. Defaults to
Response
.
Converts query
's own-properties and values into a flat list of alternating
property names and values. Validates that the the names are not empty;
validates the values and casts them to strings if necessary.
Throws TypeError
instances for validation errors.
Converts headers
' own-properties and values into a flat list of alternating
property names and values. First downcases the property names and checks
against other names in the same headers
object in case there are
case-insensitive duplicates. Validates that the the names are not empty;
validates the values and casts them to strings if necessary.
Throws TypeError
instances for validation errors.
Constructs and issues a request using the .transport
.
For documentation on options
see the Request
class.
BaseClient([options])