KServer JSON Files: Difference between revisions
Jump to navigation
Jump to search
Line 407: | Line 407: | ||
| v1 formatted using parameters v2..vn | | v1 formatted using parameters v2..vn | ||
| format a string with parameters | | format a string with parameters | ||
|- | |||
| FormatCurr(v1, v2) | |||
| v1 (string) is the desired currency format<BR>v2 (currency) is the source value | |||
| v2 formatted using the format specified by v1 | |||
| format a currency value | |||
|- | |- | ||
| FormatDateTime(v1, v2) | | FormatDateTime(v1, v2) |
Revision as of 13:15, 4 September 2024
Introduction
KServer (Keystone REST Server) is a configurable REST/JSON server that uses JSON text files to define its functionality. This provides great flexibility and allows new functionality to be added easily, in most cases without requiring code changes to the server itself.
See: Keystone_REST_Server_(KServer) for more on KServer.
JSON File Contents
Sample File
(TBD)
Actions
NOTE: These Actions are preliminary and subject to change!
Syntax | Type | HTTP Method(s) | Parameters | Return Value | Description |
---|---|---|---|---|---|
Abort(v1) | before/after | GET,PUT,POST,PATCH | v1 is a Boolean expression | none | aborts endpoint processing if v1 is true |
ApiNegotiate(v1, v2) | before | GET | v1 is the minimum API level the client supports v2 is the desired API level for the client |
>0 is the negotiated API level <0 an error occurred |
negotiates API level between client and server |
ArrayAsValue(v1) | after | GET | v1 is the JSON array name | first array element value if length of array is exactly 1 | convert single element array into element value |
ClearCaches() | before | GET | none | none | clear all query caches for all DB connections |
FileKey(v1[, v2]) | before | GET | v1 is True to indicate a temporary file, False for existing file v2 is the name of the existing file |
JSONValue containing file key | obtain file key for server file |
JSON(v1) | before | GET | v1 is the JSON string to parse | JSONValue representing parsed string | parse JSON string |
Generator(v1, v2, v3[, v4]) | before | GET,PUT,POST,PATCH | v1 is the database name v2 is the generator name v3 is the generator increment v4 is the parameter name for the result |
JSONValue representing generator value (if v4 not specified) | obtain a database generator value (once per request) |
KBackupFileKey(v1, v2) | before | GET | v1 is the database suffix (ex: SYS, DOC, 001) v2 is the subfolder (can be empty) |
JSONValue containing file key | obtain file key for server database backup file |
KClearSessions() | before | GET | none | none | clear all existing Session IDs |
KCommitUpdate(v1, v2) | before | GET | v1 is the update version v2 is the update file key |
none | commit the update file to the system database |
KContactToCust(v1, v2) | before | GET | v1 is the contact key v2 is the customer id parameter name |
none customer id parameter set if customer found HTTP status 403 if no customer found |
lookup customer based on contact key |
KDBBackup(v1, v2, v3) | before | GET | v1 is the database suffix (ex: sys, doc, 001, 002, etc) v2 is the backup file key v3 is the backup info JSON field name PostData is the Base-64 encoded backup info |
JSON value containing the backup task Id | initiate a database backup task |
KDBRestore(v1, v2) | before | GET | v1 is the database suffix (ex: sys, doc, 001, 002, etc) v2 is the backup file key |
JSON value containing the restore task Id | initiate a database restore task |
KDBResume(v1) | before | GET | v1 is the database suffix (ex: sys, doc, 001, 002, etc) | none | resume KServer access to the database |
KDBSuspend(v1) | before | GET | v1 is the database suffix (ex: sys, doc, 001, 002, etc) | none | suspend KServer access to the database |
KDeviceCmd(v1, v2, v3 [,v4]) | after | GET, PUT | v1 is the Plant Id v2 is the command v3 is the JSON object reference v4 is a miscellaneous parameter |
none | send the command to one or more devices based on the device list for the plant |
KPPTranslate(v1[,v2]) | after | POST | v1 is the Payment Processor Trx Type (1=CardConnect Capture, 2=CardConnect Settlement) v2 is the content root |
none | translate the payment processor specific content to generic backoffice content |
KstqcPostResult(v1 [,v2]) | after | PUT, POST, PATCH | v1 is the result JSON object name v2 is the additional error information |
JSONObject representing post status | returns a formatted Stonemont QC post status result |
KstqcResult(v1, v2) | after | GET | v1 is the result JSON object name v2 is the JSON data object name |
JSONObject representing status | returns a formatted Stonemont QC status result |
KtrTruckStatus(v1, v2) | after | GET | v1 is the truck status JSON field name v2 is the ticket info JSON array name |
JSONObject representing truck status | returns a formatted truck status result |
KWriteDoc(v1[, v2]) | after | PUT, POST, PATCH | v1 is the JSON object/array reference v2 is the filename suffix |
none | writes a document to a file |
ListEndPoints(v1) | before | GET | v1 specifies whether to include all endpoints (False) or endpoints with queries (True) | JSONArray containing EndPoint names | return list of endpoints for current API root |
LoadData(v1[, v2, v3..v10]) | before | GET | v1 specifies the type of data to return: *azureblobs *azurecontainers *kscachestats *ksconfig *ksquerystats *ksserverstats v2 is the internal datatable name (v1 is default) v3..v10 are data-specific parameters |
JSONObject containing requested data | return requested data |
NextEndPoint(v1[, v2]) | after | PUT, POST, PATCH | v1 is the next Endpoint URI to process (absolute URI begins with /, relative does not) v2 is the Endpoint method (GET assumed) |
JSONObject representing result of Endpoint execution (for GET method) | executes the specified Endpoint |
PostFile(v1) | before | PUT, POST, PATCH | v1 is the filename to write to PostData is the Base-64 encoded file data |
none | writes PostData to file |
ReadFileChunk(v1, v2, v3) | before/after | GET | v1 is the file key to read from v2 is the start offset v3 is the number of bytes to read |
JSONObject representing file chunk ("filedata" contains Base-64 encoded file chunk) | reads file chunk |
RemoveFile(v1) | before | GET | v1 is the file key to delete | none | deletes a file on the server |
ResultAsCSV(v1[, v2]) | after | GET | v1 is the JSON object name (must include metadata) v2 indicates whether to include a header record (False assumed) |
JSONString representing result data converted to CSV | converts result data to CSV format |
ResultToFile(v1[, v2, v3]) | after | GET | v1 is the filename to write result data to (use .csv extension to convert to CSV) v2 is the JSON object name for CSV (must include metadata) v3 indicates whether to write a header record for CSV (False assumed) |
JSONValue representing result data with conversion applied | exports result data to a file |
TaskStatus(v1) | before | GET | v1 is the Task Id | JSONValue representing the status of the task | obtain status of a background task |
UserLogin(v1, v2, v3, v4) | before | GET | v1 is the company ID v2 is the user ID v3 is the encrypted password v4 is the client OS version |
JSONObject representing login session information | logs in a Keystone On-Demand user |
UserLogout(v1) | before | GET | v1 is the session key | Null | logs out a Keystone On-Demand user |
UserSessionExpired(v1) | before | GET | v1 is the user ID | Null | indicates that a Keystone On-Demand user is no longer logged in |
WriteFileChunk(v1) | before/after | PUT, POST, PATCH | v1 is the file key to write to PostData is the Base-64 encoded file data |
none | writes file chunk |
Functions
NOTE: These Functions are preliminary and subject to change!
Syntax | Parameters | Return Value | Description |
---|---|---|---|
Add(v1, v2 [, .. vn]) | v1 (any) is the first source value v2 (any) is the second source value ... vn (any) is the last source value |
sum of all the source values | calculate sum of a list of values |
AutoInc(v1, v2) | v1 (string) is the auto-increment ID v2 (integer) is the increment |
previous value of auto-increment v1 + v2 | increments last stored value of auto-increment by specified value |
Base64Decode(v1) | v1 (string) is the source base-64 encoded string | base-64 decoded string v1 | applies base-64 decoding to an input string |
Base64Encode(v1) | v1 (string) is the source string | base-64 encoded string v1 | applies base-64 encoding to an input string |
Ceil(v1) | v1 (any) is the source value | integer ceiling of v1 | returns the integer ceiling of a value |
ChangeFileExt(v1, v2) | v1 (string) is the source filename v2 (string) is the new file extension |
source filename with new file extension | change extension of filename |
Coalesce(v1, [, .. vn]) | v1 (any) is the first value ... vn (any) is the last value |
the first non-null value or Null | returns the first non-null value in a list of values |
CoalesceStr(v1, [, .. vn]) | v1 (any) is the first value ... vn (any) is the last value |
the first non-empty string value or Null | returns the first non-empty string value in a list of values |
CompareDatePart(v1, v2 [, v3, v4]) | v1 (datetime) is the source value v2 (integer) is the target year v3 (integer) is the target month v4 (integer) is the target day |
-1 if source value < target values 0 if source value matches target values 1 if source value > target values |
compares a source datetime with target year/month/day |
Concat(v1, v2 [, .. vn]) | v1 (string) is the first source string v2 (string) is the second source string ... vn (string) is the last source string |
all the source strings concatenated together | concatenate a list of strings |
Config(v1) | v1 (string) is the configuration parameter name | value of configuration parameter v1 | obtain value of configuration parameter |
Copy(v1,v2,v3) | v1 (string) is the source string v2 (integer) is the starting position v3 (integer) is the length to copy |
source string from starting position to starting position + length - 1 | copy a portion of a string |
DateOf(v1) | v1 (TDateTime) is the source value | v1 with time portion stripped | return date portion of TDateTime value |
DayOf(v1) | v1 (TDateTime) is the source value | day portion of v1 | return day portion of TDateTime value |
Distance(v1, v2, v3, v4 [,v5]) | v1 (double) is the first coordinate latitude v2 (double) is the first coordinate longitude v3 (double) is the second coordinate latitude v4 (double) is the second coordinate longitude v5 (boolean) is True for metric, False for imperial units |
straight-line distance between two coordinates | return straight-line distance in kilometers (metric) or miles (imperial) |
Div(v1, v2 [, .. vn]) | v1 (any) is the first source value v2 (any) is the second source value ... vn (any) is the last source value |
division of all the source values | calculate result of division of a list of values |
ElementOf(v1, v2 [, .. vn]) | v1 (integer) is the array index v2 (any) is the first array value... vn (any) is the last array value |
element v1 of the array or Null if v1 is outside the bounds of the array | returns a specified element of an array of values |
EncodeDateTime(v1, v2, v3 [, v4, v5, v6, v7]) | v1 (integer) is the year v2 (integer) is the month v3 (integer) is the day v4 (integer) is the hour v5 (integer) is the minute v6 (integer) is the second v7 (integer) is the millisecond |
input values encoded into a TDateTime | return TDateTime from input values |
EndOfTheDay(v1) | v1 (TDateTime) is the source value | last millisecond of v1 | return last millisecond of the day for a date |
EndOfTheMonth(v1) | v1 (TDateTime) is the source value | last millisecond of the last day of the month of v1 | return last millisecond of last day of month for a date |
EndOfTheWeek(v1) | v1 (TDateTime) is the source value | last millisecond of the last day of the week of v1 | return last millisecond of last day of week for a date |
EndOfTheYear(v1) | v1 (TDateTime) is the source value | last millisecond of the last day of the year of v1 | return last millisecond of last day of year for a date |
Eq(v1, v2) | v1 (any) is the first source value v2 (any) is the second source value |
True if v1 = v2 False if v1 <> v2 |
test equality of two values |
ExtractFileExt(v1) | v1 (string) is the source filename | source file extension (including leading '.') | extract extension from filename |
FileExists(v1) | v1 (string) is the source filename | True if the file v1 exists | determine if file exists |
FileKey(v1 [,v2]) | v1 (boolean) is True for a new (temporary) file, False for an existing file v2 (string) is the source filename |
file key | obtain file key for server file |
Format(v1 [,v2 [, .. vn]]) | v1 (string) is the format string v2 (any) is the first format parameter ... vn (any) is the last format parameter |
v1 formatted using parameters v2..vn | format a string with parameters |
FormatCurr(v1, v2) | v1 (string) is the desired currency format v2 (currency) is the source value |
v2 formatted using the format specified by v1 | format a currency value |
FormatDateTime(v1, v2) | v1 (string) is the desired date/time format v2 (TDateTime) is the source value |
v2 formatted using the format specified by v1 | format a date/time value |
Ge(v1, v2) | v1 (any) is the first source value v2 (any) is the second source value |
True if v1 >= v2 False if v1 < v2 |
test if first value is greater than or equal to the second value |
Generator(v1, v2, v3) | v1 (string) is the database name v2 (string) is the generator name v3 (integer) is the generator increment |
new generator value | obtain a database generator value |
Gt(v1, v2) | v1 (any) is the first source value v2 (any) is the second source value |
True if v1 > v2 False if v1 <= v2 |
test if first value is greater than the second value |
High(v1) | v1 (string) is one of the following data types: * Integer * TDateTime |
highest supported value for the data type | return the highest value for the data type |
If(v1, v2 [,v3]) | v1 (boolean) is the source condition v2 (any) is the True value v3 (any) is the False value |
v2 if v1 is True v3 (or unchanged) if v1 is False |
evaluate condition and return True or False value |
In(v1, v2 [, .. vn]) | v1 (any) is the input value v2 thru vn (any) are the test values |
True if v1 matches at least one of the test values | determine if an input value occurs in a list of test values |
IncDay(v1 [,v2]) | v1 (TDateTime) is the source value v2 (integer) is the offset |
v1 with day offset by v2 (1 assumed) | adjust day within a TDateTime value |
IncHour(v1 [,v2]) | v1 (TDateTime) is the source value v2 (integer) is the offset |
v1 with hours offset by v2 (1 assumed) | adjust hours within a TDateTime value |
IncMinute(v1 [,v2]) | v1 (TDateTime) is the source value v2 (integer) is the offset |
v1 with minutes offset by v2 (1 assumed) | adjust minutes within a TDateTime value |
IncMonth(v1, [,v2]) | v1 (TDateTime) is the source value v2 (integer) is the offset |
v1 with month offset by v2 (1 assumed) | adjust month within a TDateTime value |
IncSecond(v1 [,v2]) | v1 (TDateTime) is the source value v2 (integer) is the offset |
v1 with seconds offset by v2 (1 assumed) | adjust seconds within a TDateTime value |
IncWeek(v1, [,v2]) | v1 (TDateTime) is the source value v2 (integer) is the offset |
v1 with week offset by v2 (1 assumed) | adjust week within a TDateTime value |
IncYear(v1, [,v2]) | v1 (TDateTime) is the source value v2 (integer) is the offset |
v1 with year offset by v2 (1 assumed) | adjust year within a TDateTime value |
IsNull(v1) | v1 (any) is the source value | True if V1 is Null False if V1 is not Null |
test for a Null value |
IsNotNull(v1) | v1 (any) is the source value | True if V1 is not Null False if V1 is Null |
test for a Non-Null value |
IsStrEmpty(v1) | v1 (any) is the source value | True if V1 is Null or an empty string False otherwise |
test for a Null or empty string value |
IsStrNotEmpty(v1) | v1 (any) is the source value | True if V1 is not Null and not an empty string False otherwise |
test for a Non-Null, non-empty string value |
KDateTime(v1, v2) | v1 (TDateTime) is the source date v2 (integer-HHMM) is the source time |
date of v1 combined with time of v2 as TDateTime | combine Keystone date and time values into a single TDateTime value |
KeystoneVersion() | (string) Keystone version | return Keystone version | |
KMinutesToTime(v1) | v1 (integer) is the source minutes | v1 (minutes) converted to hours/minutes as HHMM | convert minutes to Keystone HHMM |
KProjectedTime(v1, v2, v3, v4, v5, v6 [,v7]) DEPRECATED a/o 4.1.5.1 - use KQueryProjectedTime |
v1 (integer) is the order session number v2 (integer) is the order trans number v3 (integer) is the order load number v4 (currency) is the load size v5 (integer) is the load status v6 (datetime) is the current dispatch time v7 (integer) is the status of the desired projected time |
TDateTime representing the requested projected time (On Job/Return Plant assumed based on load status) |
calculate a projected time based on order and ticket information obtained by querying the database |
KQueryProjectedTime(v1, v2, v3, v4 [,v5]) | v1 (string) is the name of an already active query containing the time fields v2 (currency) is the load size v3 (integer) is the load status v4 (datetime) is the current dispatch time v5 (integer) is the status of the desired projected time |
TDateTime representing the requested projected time (On Job/Return Plant assumed based on load status) |
calculate a projected time based on order and ticket information obtained from already active query |
KSessionNo() | none | Keystone session number | obtain the Keystone session number associated with SessionId |
KSystemOption(v1, v2 [,v3]) | v1 (string) is the section name v2 (string) is the option name v3 (string) is the default value |
Keystone system option for DEFAULT group | obtain the specified Keystone system option (or default value) |
KTimeOf(v1) | v1 (TDateTime) is the source value | v1 with date portion stripped as HHMM | return time extracted from source value as HHMM |
KTransNo([v1]) | v1 (integer) is the increment (default is 1) | Keystone trans number | obtain the next available Keystone trans number |
KUMConvert(v1, v2, v3 [, v4]) | v1 (number) is the source quantity v2 (string) is the source U/M v3 (string) is the target U/M v4 (string) is the product id |
(currency) target quantity | return source quantity converted to target U/M |
KUpdateFile() | (string) Keystone update filename | return Keystone update filename from system database | |
Le(v1, v2) | v1 (any) is the first source value v2 (any) is the second source value |
True if v1 <= v2 False if v1 > v2 |
test if first value is less than or equal to the second value |
LeftStr(v1, v2) | v1 (string) is the source value v2 (integer) is the count |
the first v2 characters of v1 | return first n characters of a string |
Lookup(v1, v2, v3, v4, v5 [, .. vn-1, vn]) | v1 (string) is the DataTable name v2 (string) is the DataTable result field name v3 (any) is the default result value v4 (string) is the DataTable lookup field #1 name v5 (any) is the DataTable lookup field #1 value ... vn-1 (string) is the DataTable lookup field #n name vn (any) is the DataTable lookup field #n value |
Value of DataTable result field if record lookup successful (default value otherwise) | lookup a value in a DataTable |
Low(v1) | v1 (string) is one of the following data types: * Integer * TDateTime |
lowest supported value for the data type | return the lowest value for the data type |
Lowercase(v1) | v1 (string) is the source value | v1 with all characters converted to lowercase | lowercase a string |
Lt(v1, v2) | v1 (any) is the first source value v2 (any) is the second source value |
True if v1 < v2 False if v1 >= v2 |
test if first value is less than the second value |
Max(v1, v2 [, .. vn]) | v1 (any) is the first source value v2 (any) is the second source value ... vn (any) is the last source value |
maximum of all the source values | find maximum of a list of values |
MidStr(v1, v2, v3) | v1 (string) is the source value v2 (integer) is the start position v3 (integer) is the count |
v3 characters of v1 beginning at position v2 | return a portion of a string |
Min(v1, v2 [, .. vn]) | v1 (any) is the first source value v2 (any) is the second source value ... vn (any) is the last source value |
minimum of all the source values | find minimum of a list of values |
MinuteDiff(v1, v2) | v1 (TDateTime) is the first source value v2 (TDateTime) is the second source value |
difference of v1 - v2 in minutes | return difference in minutes of two TDateTime values |
MinutesBetween(v1, v2) | v1 (TDateTime) is the first source value v2 (TDateTime) is the second source value |
minutes between v1 and v2 (always a positive integer) | return positive minutes between two TDateTime values |
MinuteSpan(v1, v2) | v1 (TDateTime) is the first source value v2 (TDateTime) is the second source value |
span of v1 - v2 in minutes (always positive) | return positive span in minutes of two TDateTime values |
MonthOf(v1) | v1 (TDateTime) is the source value | month portion of v1 | return month portion of TDateTime value |
Mul(v1, v2 [, .. vn]) | v1 (any) is the first source value v2 (any) is the second source value ... vn (any) is the last source value |
multiplication of all the source values | calculate result of multiplication of a list of values |
Ne(v1, v2) | v1 (any) is the first source value v2 (any) is the second source value |
True if v1 <> v2 False if v1 = v2 |
test inequality of two values |
Negate(v1) | v1 (any) is the source value | negative of v1 | negate a value |
Now() | current system date & time | return current system date & time | |
NullIf(v1, v2) | v1 (any) is the first source value v2 (any) is the second source value |
Null if v1 = v2 v1 if v1 <> v2 |
apply NullIf operation to two values |
PathCombine(v1, v2) | v1 (string) is the file path v2 (string) is the file name |
file path concatenated with path separator and file name | combine file path and file name |
RightStr(v1, v2) | v1 (string) is the source value v2 (integer) is the count |
the last v2 characters of v1 | return last n characters of a string |
Round(v1 [, v2]) | v1 (any) is the source value v2 (integer) is the number of decimal places (0 assumed) |
source value rounded to specified decimal places | round a value |
ServerName() | (string) server name | return KServer name | |
ServerVersion() | (string) server version | return KServer version | |
Split(v1,v2,v3) | v1 (string) is the source value v2 (string) is the delimiter v3 (integer) is the desired occurrence |
v3rd string delimited by v2 from v1 | extract a string element within a delimited string |
SplitFileLevels(v1,v2) | v1 (string) is the filename including path v2 (integer) is the number of file levels |
v1 | maintain several versions of a specified file |
StartOfTheDay(v1) | v1 (TDateTime) is the source value | first millisecond of v1 | return first millisecond of the day for a date |
StartOfTheMonth(v1) | v1 (TDateTime) is the source value | first millisecond of the first day of the month of v1 | return first millisecond of first day of month for a date |
StartOfTheWeek(v1) | v1 (TDateTime) is the source value | first millisecond of the first day of the week of v1 | return first millisecond of first day of week for a date |
StartOfTheYear(v1) | v1 (TDateTime) is the source value | first millisecond of the first day of the year of v1 | return first millisecond of first day of year for a date |
StringReplace(v1, v2, v3[, v4]) | v1 (string) is the source value v2 (string) is the search value v3 (string) is the replacement value v4 (boolean) is true to replace all occurrences |
v1 replacing first/all occurrences of v2 with v3 | replace a specific pattern within a string |
Sub(v1, v2 [, .. vn]) | v1 (any) is the first source value v2 (any) is the second source value ... vn (any) is the last source value |
subtraction of all the source values | calculate result of subtraction of a list of values |
TimeOf(v1) | v1 (TDateTime) is the source value | v1 with date portion stripped | return time portion of TDateTime value |
ToBool(v1 [,v2, v3]) | v1 (any) is the source value v2 (string) is the source string representing True v3 (string) is the source string representing False |
v1 converted to boolean (False if NULL) | return source value converted to boolean |
ToInteger(v1) | v1 (any) is the source value | v1 converted to integer (zero if NULL) | return source value converted to integer |
ToString(v1) | v1 (any) is the source value | v1 converted to string (empty string if NULL) | return source value converted to string |
Trunc(v1) | v1 (any) is the source value | integer truncation of v1 | returns the integer truncation of a value |
Uppercase(v1) | v1 (string) is the source value | v1 with all characters converted to uppercase | uppercase a string |
WeekOf(v1) | v1 (TDateTime) is the source value | week of the year of v1 | return week of the year of TDateTime value |
WorkDaysInMonth(v1,v2) | v1 (TDateTime) is the source value v2 (integer) is a control value: 0 = all days are work days 1 = Sat is not a work day 2 = Sun is not a work day 3 = Sat/Sun are not work days |
work days in the month up to and including v1 | return work days in the month up to and including the TDateTime value |
YearOf(v1) | v1 (TDateTime) is the source value | year portion of v1 | return year portion of TDateTime value |