0.1.3 • Published 7 months ago

@cinemataztic/dch-tcp-helpers v0.1.3

Weekly downloads
-
License
ISC
Repository
-
Last release
7 months ago

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:

PropertyTypeDescription
statusstringThe result of the request. Either success or error.
deviceIdstringThe ID of the DCH-P.
screenIdstringThe ID of the screen connected to the DCH-P.
accessTokenstringThe access token for interacting with Cinemataztic's APIs.
networkNamestringThe name of the advertising network.
marketstringThe market the DCH-P is in.
countryCodestringThe country code of the market.
clusterNamestringThe 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.

ParameterType
message*string
severitynotice , warning , error , critical ,debug default:debug
targetcloud, sentry, winston default:winston
typeunity,general,internal,unknown,block default:general

postLog returns the following properties.

PropertyTypeDescription
statusstringThe result of the request. Either success or failed.
messagestringThe status message.

Example

const { postLog } = require("@cinemataztic/dch-tcp-helpers");

const { status, message } = await postLog(
  "test",
  "error",
  "[winston,cloud]",
  "general"
);