/** * @param array $response * @return TpDataApiResponse * @throws TpInvalidSignatureException */ public static function createFromResponse(array $response) { $keys = array('merchantId'); $data = \dlds\thepay\api\TpUtils::filterKeys($response, $keys); $instance = new static($data); return $instance; }
/** * TpAbstractModel constructor. * * @param array $data */ public function __construct(array $data = array()) { $keys = static::keys(); $filtered = \dlds\thepay\api\TpUtils::filterKeys($data, $keys); foreach ($filtered as $key => $value) { $this[$key] = $value; } unset($value); }
/** * @param string $operation * @param TpMerchantConfig $config * @param stdClass $data * @return TpDataApiResponse * @throws TpInvalidSignatureException */ public static function getResponse($operation, \dlds\thepay\api\TpMerchantConfig $config, \stdClass $data) { /** @var string|TpDataApiResponse $className Only class name. */ $className = '\\dlds\\thepay\\api\\dataApi\\responses\\' . preg_replace('/^get(.+)$/', 'TpDataApiGet$1Response', $operation); $fileName = $className . '.php'; $array = \dlds\thepay\api\TpUtils::toArrayRecursive($data); $listPaths = $className::listPaths(); $flattened = \dlds\thepay\api\dataApi\processors\TpDataApiSoapFlattener::processWithPaths($array, $listPaths); \dlds\thepay\api\dataApi\parameters\TpDataApiSignature::validate($flattened, $config->dataApiPassword); $dateTimePaths = $className::dateTimePaths(); $inflated = \dlds\thepay\api\dataApi\processors\TpDataApiDateTimeInflater::processWithPaths($flattened, $dateTimePaths); $response = $className::createFromResponse($inflated); return $response; }
/** * @param mixed $value * @param string[] $currentPath * @return mixed */ protected function processItem($value, array $currentPath) { if (is_array($value) || is_object($value)) { $value = (array) $value; $isList = \dlds\thepay\api\TpUtils::isList($value); if ($isList) { $processed = $this->processList($value, $currentPath); } else { $processed = $this->processHash($value, $currentPath); } } else { // Only arrays are treated specially. $processed = $value; } return $processed; }