API Docs for: 4.0.6
Show:

ZipsceneRPCClient Class

Available since v0.0.1

This class passes jsonrpc requests to a server. It will authenticate with a username and password. It will refresh an accessToken when it expires.

Constructor

ZipsceneRPCClient

(
  • settings
)

Defined in lib/zipscene-rpc-client.js:24

Available since v0.0.1

Parameters:

  • settings Object
    • settings object for authentication and sever set up
    • server String
      • the server location to make requests
    • authServer String
      • the server to authenticate with when different from the server to make requests on.
    • email String
      • The email address to authenticate with.
    • username String
      • Alias for 'email'
    • password String
      • the password to authenticate with
    • userNamespaceId String
      • The user namespace the authenticated user belongs to.
    • accessToken String
      • the accessToken to use to make requests
    • routeVersion Number
      • Version of RPC endpoint to use
    • logRequests Boolean
      • If true, log requests and responses to stderr

Methods

authenticate

(
  • expired
)

Defined in lib/zipscene-rpc-client.js:90

Available since v0.0.1

This function tries to set the access token before making requests.

Parameters:

  • expired Boolean
    • If this is called because of an expired access token, set this flag.

createBearerHeader

(
  • accessToken
)

Defined in lib/zipscene-rpc-client.js:207

Available since v0.0.1

This takes the current accessToken and turns it in to the Bearer Authorization token

Parameters:

  • accessToken String
    • the access token

getUrl

(
  • [options={}]
)

Defined in lib/zipscene-rpc-client.js:187

Available since v0.0.1

Construct the URL to which JSONRPC requests will be placed.

Parameters:

  • [options={}] Object optional
    • [auth=false] Boolean optional
      • Returns the auth server URL instead of the main server.

request

(
  • method
  • params
  • [opts]
  • [id=requestCounter++]
)
Promise

Defined in lib/zipscene-rpc-client.js:219

Available since v0.0.1

Makes a request to the json-rpc service, handling authentication if necessary

Parameters:

  • method String
    • the api method to call, in dot notation
  • params Object
    • the params for this api method
  • [opts] Object optional
    • [exHeaders] Object optional
      • Object containing additional headers to use for the request.
    • [maxRetries] Number optional
      • Number of times to retry the req
    • [noReauth] Boolean optional
      • Throw token_expired errors instead of reauthenticating.
  • [id=requestCounter++] Number optional
    • the id to use for the request

Returns:

Promise:
  • resolves with the response that contains an object { error, result, id }

requestRaw

(
  • method
  • params
  • opts
  • [id=requestCounter++]
)
Readable

Make a request to an endpoint that returns streaming data rather than the standard JSONRPC format. Data will be returned as a plain data stream.

Parameters:

  • method String
    • the api method to call
  • params Object
    • the params for this api method
  • opts Object
  • [id=requestCounter++] Number optional
    • the id to use for the request

Returns:

Readable:

requestStream

(
  • method
  • params
  • opts
  • [id=requestCounter++]
)
zstreams.PassThrough

Defined in lib/zipscene-rpc-client.js:304

Available since v0.0.1

Make a request to an endpoint that returns streaming data rather than the standard JSONRPC format. Data will be returned as a readable zstream of parsed objects.

Parameters:

  • method String
    • the api method to call
  • params Object
    • the params for this api method
  • opts Object
  • [id=requestCounter++] Number optional
    • the id to use for the request

Returns:

zstreams.PassThrough:
  • returns a passthrough stream that will recieve data when the request comes back.