0.1.3 • Published 7 months ago
@cinemataztic/dch-tcp-helpers v0.1.3
DCH TCP Helpers
This is a collection of helper functions for interacting with the DCH through TCP.
Installation
It is available as an npm package.
npm install @cinemataztic/dch-tcp-helpers
Usage
The package will by default contact the DCH on 127.0.0.1
with the port specified by the INTERNAL_TCP_SERVER
environment variable. If this is not set, it will default to port 4455.
API
getDeviceInfo
The getDeviceInfo
function takes no parameters and returns an object with the following properties:
Property | Type | Description |
---|---|---|
status | string | The result of the request. Either success or error . |
deviceId | string | The ID of the DCH-P. |
screenId | string | The ID of the screen connected to the DCH-P. |
accessToken | string | The access token for interacting with Cinemataztic's APIs. |
networkName | string | The name of the advertising network. |
market | string | The market the DCH-P is in. |
countryCode | string | The country code of the market. |
clusterName | string | The name of the cluster the DCH-P is in. |
Example
const { getDeviceInfo } = require("@cinemataztic/dch-tcp-helpers");
const {
status,
deviceId,
screenId,
accessToken,
networkName,
market,
countryCode,
clusterName,
} = await getDeviceInfo();
postLog
The postLog
function takes four parameters and returns an object:
postLog
accepts the following parameters.
Parameter | Type |
---|---|
message* | string |
severity | notice , warning , error , critical ,debug default:debug |
target | cloud , sentry , winston default:winston |
type | unity ,general ,internal ,unknown ,block default:general |
postLog
returns the following properties.
Property | Type | Description |
---|---|---|
status | string | The result of the request. Either success or failed . |
message | string | The status message. |
Example
const { postLog } = require("@cinemataztic/dch-tcp-helpers");
const { status, message } = await postLog(
"test",
"error",
"[winston,cloud]",
"general"
);