CoolCMS API

ExpressSmsParser
in package

FinalYes

Text of an express SMS: `<KEYWORD> <MODULE> <SERVICE> <ID>`.

Both directions live here so they cannot drift apart: compose() builds the text the Front section shows, parse() reads the text the aggregator forwards.

Tolerant on purpose — people type the SMS by hand: case, diacritics and runs of whitespace do not matter. Strict where it counts: the keyword must match the gateway keyword (it tells which web the SMS belongs to when several share one aggregator account) and the id must be a positive integer. The price is never read from the text; it comes from the shortcode.

Table of Contents

Constants

INVALID_KEYWORD_MISMATCH  : string = 'keywordMismatch'
INVALID_KEYWORD_NOT_CONFIGURED  : string = 'keywordNotConfigured'
INVALID_MALFORMED  : string = 'malformed'

Methods

compose()  : string
The exact text a visitor is asked to send.
normalizeToken()  : string
parse()  : ExpressSmsCommand
serviceCodeFromKeyword()  : string
Service word of a module quick price. The quick price `keyword` column historically holds the whole legacy text (`COOLSOFT TOP`), so the service is its last word; a single word works too.
tokenize()  : array<int, string>

Constants

INVALID_KEYWORD_MISMATCH

public string INVALID_KEYWORD_MISMATCH = 'keywordMismatch'

INVALID_KEYWORD_NOT_CONFIGURED

public string INVALID_KEYWORD_NOT_CONFIGURED = 'keywordNotConfigured'

Methods

compose()

The exact text a visitor is asked to send.

public static compose(string $gatewayKeyword, string $moduleCode, string $serviceCode, int $objectId) : string
Parameters
$gatewayKeyword : string
$moduleCode : string
$serviceCode : string
$objectId : int
Return values
string

normalizeToken()

public static normalizeToken(string $token) : string
Parameters
$token : string
Return values
string

serviceCodeFromKeyword()

Service word of a module quick price. The quick price `keyword` column historically holds the whole legacy text (`COOLSOFT TOP`), so the service is its last word; a single word works too.

public static serviceCodeFromKeyword(string $quickPriceKeyword) : string
Parameters
$quickPriceKeyword : string
Return values
string

tokenize()

private static tokenize(string $text) : array<int, string>
Parameters
$text : string
Return values
array<int, string>
On this page

Search results