Liking cljdoc? Tell your friends :D

com.adgoji.vistarmedia


close-clientclj

(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.
sourceraw docstring

default-middlewareclj

source

invokeclj

(invoke client {:com.adgoji.vistarmedia/keys [op payload wrap-request]})

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-request can be provided for the requested operation, it temporarily overrides the client's wrapper (see [new-client]) and receives the same thunk with request metadata. This should be used carefully, especially with rate limiters, since it bypasses the client's wrapper. The provided wrapper has no effect on the login call, which always goes through the client's wrapper. After a re-login the operation is sent again as a new wrapper call with the same metadata.

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-request` can be provided for the requested
operation, it temporarily overrides the client's wrapper (see
[new-client]) and receives the same thunk with request metadata.
This should be used carefully, especially with rate limiters, since
it bypasses the client's wrapper.  The provided wrapper has no
effect on the login call, which always goes through the client's
wrapper.  After a re-login the operation is sent again as a new
wrapper call with the same metadata.
sourceraw docstring

new-clientclj

(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.

    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`.

  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.
sourceraw docstring

opsclj

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.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close