Trndi supports multiple backends via its API specification.
Location:
units/trndi/api/trndi.api.pp
TrndiAPI is the base class that API drivers inherit. Each API driver must implement:
constructor create(user, pass, extra: string);
Trndi always passes user and pass. extra defaults to empty unless needed.
function connect: boolean;
Establish connectivity and perform any initial probing.
function getReadings(minNum, maxNum: integer; extras: string = ''): BGResults;
Advanced overload (used by the base class and some drivers):
function getReadings(minNum, maxNum: integer; extras: string; out res: string): BGResults;
This variant also returns the raw response via res.
If these three functions are provided, the API driver will work.
TrndiNative provides platform-specific features under a common API. It’s often used for HTTP(S) so requests run via native APIs (WinHTTP, NS, etc.) instead of third-party libs.
Call inherited; in your constructor. You’ll have access to the native field.
Set a user agent and base URL in your constructor:
baseUrl := 'https://service.net/API/';
ua := 'Uploader/3.0.2.11 Darwin/14.0.0';
request makes an HTTP/S request.
function request(const post: boolean; const endpoint: string;
const params: array of string; const jsondata: string = '';
const header: string = ''): string;
baseUrl)key=value pairsKey=ValueYou should set these thresholds (see CGMCore):
Helpers:
Utility functions:
TDateTimeInherit TrndiAPI, implement create, connect, and getReadings. Use the native helper for HTTP.