ResponseTranslator
in package
CNR ResponseTranslator
Table of Contents
Properties
- $descriptionRegexMap : array<string|int, mixed>
- hidden class var of API description regex mappings for translation
Methods
- translate() : string
- translate a raw api response
- findMatch() : bool
- Finds a match in the given text and performs replacements based on patterns and placeholders.
Properties
$descriptionRegexMap
hidden class var of API description regex mappings for translation
private
static array<string|int, mixed>
$descriptionRegexMap
= [
// HX - just for future reference, can be cleaned up if we have something similar in place for CNR
"Authorization failed; Operation forbidden by ACL" => "Authorization failed; Used Command `{COMMAND}` not white-listed by your Access Control List",
// CNR
"Missing required attribute; premium domain name. please provide required parameters" => "Confirm the Premium pricing by providing the necessary premium domain price data.",
"SkipPregQuote" => [
// HX - just for future reference
//"Invalid attribute value syntax; resource record \[(.+)\]" => "Invalid Syntax for DNSZone Resource Record: $1",
//"Missing required attribute; CLASS(?:=| \[MUST BE )PREMIUM_([\w\+]+)[\s\]]" => "Confirm the Premium pricing by providing the parameter CLASS with the value PREMIUM_$1.",
//"Syntax error in Parameter DOMAIN \((.+)\)" => "The Domain Name $1 is invalid.",
// CNR
"Authorization failed.*(?:\\[.*(authori[sz]ation (information|code|password)|authinfo).*\\]|wrong auth code)" => "The provided Authorization Code (EPP Code) is incorrect. Please verify the correct Authorization Code with the current registrar and try again.",
],
]
Methods
translate()
translate a raw api response
public
static translate(string $raw, array<string|int, string> $cmd[, array<string|int, string> $ph = [] ]) : string
Parameters
- $raw : string
-
API raw response
- $cmd : array<string|int, string>
-
requested API command
- $ph : array<string|int, string> = []
-
list of place holder vars
Return values
stringfindMatch()
Finds a match in the given text and performs replacements based on patterns and placeholders.
protected
static findMatch(string $regex, string &$newraw, string $val, array<string|int, string> $cmd, array<string|int, string> $ph) : bool
This function searches for a specified regular expression pattern in the provided text and performs replacements based on the matched pattern, command data, and placeholder values.
Parameters
- $regex : string
-
The regular expression pattern to search for.
- $newraw : string
-
The input text where the match will be searched for and replacements applied.
- $val : string
-
The value to be used in replacement if a match is found.
- $cmd : array<string|int, string>
-
The command data containing replacements, if applicable.
- $ph : array<string|int, string>
-
An array of placeholder values for further replacements.