* @copyright 2021 DIGITAL RETAIL TECHNOLOGIES SL * @license https://opensource.org/licenses/MIT The MIT License * * Don't forget to prefix your containers with your own identifier * to avoid any conflicts with others containers. */ if (!defined('_PS_VERSION_')) { exit; } /** * Class RetailcrmLogger * * @author DIGITAL RETAIL TECHNOLOGIES SL * @license GPL * * @see https://retailcrm.ru */ class RetailcrmJsonResponse { private static function jsonResponse($response) { return json_encode($response); } public static function invalidResponse($msg, $status = 404) { http_response_code($status); return [ 'success' => false, 'errorMsg' => $msg, ]; } public static function successfullResponse($data = null, $key = null) { $response = [ 'success' => true, ]; if (null !== $data) { if (is_array($key)) { foreach ($key as $i => $value) { if (isset($data[$i])) { $response[$value] = $data[$i]; } } } elseif (is_string($key)) { $response[$key] = $data; } else { $response['response'] = $data; } } return $response; } }