Class

ScenidCloudService

ScenidCloudService(tokenSource, serviceUrl)

Base class for all Scenid service clients.

Handles token acquisition, request building, and response parsing. All service-specific classes extend this class and call this.get, this.post, this.put, and this.delete to communicate with their respective backend service.

Constructor

# new ScenidCloudService(tokenSource, serviceUrl)

Parameters:
Name Type Description
tokenSource string | function

Either a static token string or an async function that resolves to a Bearer token. The function form is used in production — the SDK calls it before every request so tokens are always fresh.

serviceUrl string

Base URL of the target service (e.g. https://crm-service.example.com).

View Source services/ScenidCloudService.class.js, line 26

Methods

# delete(call, bodyopt) → {Promise.<ServiceResponse>}

Sends an authenticated DELETE request.

Parameters:
Name Type Attributes Description
call string

Path relative to serviceUrl.

body * <optional>

Optional request body, serialised to JSON.

View Source services/ScenidCloudService.class.js, line 152

Promise.<ServiceResponse>

# get(call) → {Promise.<ServiceResponse>}

Sends an authenticated GET request.

Parameters:
Name Type Description
call string

Path relative to serviceUrl.

View Source services/ScenidCloudService.class.js, line 122

Promise.<ServiceResponse>

# async makeRequest(method, call, bodyopt) → {Promise.<ServiceResponse>}

Makes an authenticated HTTP request to the service and returns the parsed response.

Acquires a token, constructs the full endpoint URL, serialises the body as JSON when provided, and parses the JSON response. Throws a typed error on network failure or non-JSON responses.

Parameters:
Name Type Attributes Description
method string

HTTP method (GET, POST, PUT, or DELETE).

call string

Path to call relative to serviceUrl (leading / optional).

body * <optional>

Request body. Serialised to JSON unless already a string.

View Source services/ScenidCloudService.class.js, line 66

sdk/fetch-failed – network-level failure.

Error

sdk/endpoint-invalid – service returned 404 with non-JSON body.

Error

sdk/non-json-response – response body could not be parsed.

Error
Promise.<ServiceResponse>

# post(call, bodyopt) → {Promise.<ServiceResponse>}

Sends an authenticated POST request.

Parameters:
Name Type Attributes Description
call string

Path relative to serviceUrl.

body * <optional>

Request body, serialised to JSON.

View Source services/ScenidCloudService.class.js, line 142

Promise.<ServiceResponse>

# put(call, body) → {Promise.<ServiceResponse>}

Sends an authenticated PUT request.

Parameters:
Name Type Description
call string

Path relative to serviceUrl.

body *

Request body, serialised to JSON.

View Source services/ScenidCloudService.class.js, line 132

Promise.<ServiceResponse>