execute($request, $accessToken); DebugData::add('pdd-api', [ 'accessToken' => $accessToken, 'apiMethod' => $request->getApiMethod(), 'apiParams' => json_decode($request->getApiParas(), true), 'apiResponse' => $response, ]); self::$lastResponse = $response; if (!self::isSuccessResponse($response)) { self::apiLog($request->getApiMethod(), $request, $response); } return $response; } protected static function handleResponse($response, $successDataBuilder = null) { return $response; } protected static function isSuccessResponse($response) { $response = ZcArrayHelper::objectToArray($response); if (isset($response['code']) && $response['code'] == 0) { return true; } $resultInfo = isset($response['code']) ? $response['resultInfo'] : $response; if (!isset($resultInfo['statusCode']) || $resultInfo['statusCode'] !== 0) { return false; } return true; } protected static function apiLog($apiName, $request, $response) { Zc::getLog('tool/pddApi/' . $apiName)->info('params: ' . print_r($request->getApiParas(), true) . 'response: ' . print_r($response, true)); } public static function getLastRequest() { return self::$lastRequest; } public static function getLastResponse() { return self::$lastResponse; } }