(close-client {:com.adgoji.vistarmedia/keys [http-client executor]})Close the internal HTTP connection pool and executor.
NOTE: if custom executor was provided during client initialization, it won't be closed.
Close the internal HTTP connection pool and executor. NOTE: if custom executor was provided during client initialization, it won't be closed.
(invoke client
{:com.adgoji.vistarmedia/keys [op payload wrap-request wrap-opts]})Invoke the op operation and return the response body as Clojure map.
The request is sent to the base URL selected by the operation's
url-key in [ops]: ::base-url for DSP API operations,
::reporting-url for Reporting API operations.
Authentication is handled automatically, if operation itself returns 403 error, login operation is called on the same host as the operation and the requested operation is retried once. If login operation fails, an exception is thrown.
payload can optionally include :query-params, :body or named
path parameters. If requested operation is a :get operation, only
:query-params is passed to the request, otherwise, only :body.
If operation's path contains any named parameters, those parameters
must be present in the payload with the same name, for example if
path is '/advertisers/{id}' then payload must contain :id keys
with a valid advertiser ID. Inspect the [ops] map to figure out
operation's method and presence of named path parameters.
Optionally wrap-opts can be provided: any value, passed unchanged
to the client's wrapper in the thunk's metadata under ::wrap-opts
(see [new-client]), both for the operation and for the re-login it
may trigger. The library never reads it. Use it to tell the
wrapper about the call site, e.g. whether to wait for a rate limit
permit or fail fast. After a re-login the operation is sent again
as a new wrapper call with the same metadata.
DEPRECATED: the per-call wrap-request override. Pass wrap-opts
and branch on it in the client's wrapper instead. Until it is
removed, wrap-request replaces the client's wrapper for the
requested operation only and receives the same thunk with request
metadata. It bypasses the client's wrapper (and any rate limiter
in it) and has no effect on the login call, which always goes
through the client's wrapper.
Invoke the `op` operation and return the response body as Clojure map.
The request is sent to the base URL selected by the operation's
`url-key` in [ops]: `::base-url` for DSP API operations,
`::reporting-url` for Reporting API operations.
Authentication is handled automatically, if operation itself returns
403 error, login operation is called on the same host as the
operation and the requested operation is retried once. If login
operation fails, an exception is thrown.
`payload` can optionally include `:query-params`, `:body` or named
path parameters. If requested operation is a `:get` operation, only
`:query-params` is passed to the request, otherwise, only `:body`.
If operation's path contains any named parameters, those parameters
must be present in the `payload` with the same name, for example if
path is '/advertisers/{id}' then payload must contain `:id` keys
with a valid advertiser ID. Inspect the [ops] map to figure out
operation's method and presence of named path parameters.
Optionally `wrap-opts` can be provided: any value, passed unchanged
to the client's wrapper in the thunk's metadata under `::wrap-opts`
(see [new-client]), both for the operation and for the re-login it
may trigger. The library never reads it. Use it to tell the
wrapper about the call site, e.g. whether to wait for a rate limit
permit or fail fast. After a re-login the operation is sent again
as a new wrapper call with the same metadata.
DEPRECATED: the per-call `wrap-request` override. Pass `wrap-opts`
and branch on it in the client's wrapper instead. Until it is
removed, `wrap-request` replaces the client's wrapper for the
requested operation only and receives the same thunk with request
metadata. It bypasses the client's wrapper (and any rate limiter
in it) and has no effect on the login call, which always goes
through the client's wrapper.(new-client {:com.adgoji.vistarmedia/keys [credential http-opts base-url
reporting-url wrap-request]})Returns new VistarMedia DSP API client.
The only mandatory parameter is credential which is a map with
:email and :password keys. The user must have API access.
Optional parameters:
base-url - base URL of the DSP API, in case you want to
override it and use another environment. Defaults to
https://platform-api.vistarmedia.com/api.
reporting-url - base URL of the DSP Reporting API, which lives
on a separate host. Override it to use another environment (e.g.
staging). Defaults to https://trafficking.vistarmedia.com.
http-opts - overrides for the internal hato HTTP client. The
options are merged with the default options map, but
:cookie-policy is always set to :all (it's necessary for
authentication to work).
wrap-request - a function (fn [thunk] ...) that wraps every
HTTP call made by the client, including login calls. Useful to
set up retry or rate limiter policies. thunk takes no args and
returns the full hato response map (status, headers, decoded
body). Status checks happen after the wrapper returns, so the
wrapper also sees error responses.
The thunk's metadata describes the request:
::op - the operation keyword from [ops], or ::login for the
authentication call;::method - HTTP method keyword, e.g. :get;::path - request path with path parameters substituted, e.g.
/dsp/v1/advertisers/123;::url-key - client key of the base URL the path is appended
to: ::base-url or ::reporting-url;::wrap-opts - the ::wrap-opts value passed to [invoke], as
given; also set on the re-login that the call triggers. The
library never reads it. Absent when not provided.The metadata never includes the request payload or credentials. Read it from the thunk the wrapper receives: wrapping the thunk in another fn (e.g. when composing wrappers) drops it.
Returns new VistarMedia DSP API client.
The only mandatory parameter is `credential` which is a map with
`:email` and `:password` keys. The user must have API access.
Optional parameters:
- `base-url` - base URL of the DSP API, in case you want to
override it and use another environment. Defaults to
`https://platform-api.vistarmedia.com/api`.
- `reporting-url` - base URL of the DSP Reporting API, which lives
on a separate host. Override it to use another environment (e.g.
staging). Defaults to `https://trafficking.vistarmedia.com`.
- `http-opts` - overrides for the internal hato HTTP client. The
options are merged with the default options map, but
`:cookie-policy` is always set to `:all` (it's necessary for
authentication to work).
- `wrap-request` - a function `(fn [thunk] ...)` that wraps every
HTTP call made by the client, including login calls. Useful to
set up retry or rate limiter policies. `thunk` takes no args and
returns the full hato response map (status, headers, decoded
body). Status checks happen after the wrapper returns, so the
wrapper also sees error responses.
The thunk's metadata describes the request:
- `::op` - the operation keyword from [ops], or `::login` for the
authentication call;
- `::method` - HTTP method keyword, e.g. `:get`;
- `::path` - request path with path parameters substituted, e.g.
`/dsp/v1/advertisers/123`;
- `::url-key` - client key of the base URL the path is appended
to: `::base-url` or `::reporting-url`;
- `::wrap-opts` - the `::wrap-opts` value passed to [invoke], as
given; also set on the re-login that the call triggers. The
library never reads it. Absent when not provided.
The metadata never includes the request payload or credentials.
Read it from the thunk the wrapper receives: wrapping the thunk in
another fn (e.g. when composing wrappers) drops it.Map of all supported operations to [method path] or
[method path url-key].
url-key is the client key holding the base URL the path is
appended to: ::base-url (DSP API) when omitted, ::reporting-url
for the Reporting API operations.
Map of all supported operations to `[method path]` or `[method path url-key]`. `url-key` is the client key holding the base URL the path is appended to: `::base-url` (DSP API) when omitted, `::reporting-url` for the Reporting API operations.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |