private function validate($apiRawResponse)
    {
        $response = json_decode($apiRawResponse);

        if (null === $response) {
            throw new InvalidApiResponseException('Wechat response is probably mal-formed because cannot be json-decoded.');
        }

        if (!property_exists($response, 'errcode')) {
            throw new InvalidApiResponseException('Property "errcode" does not exist within Wechat response.');
        }

        if (0 !== $response->errcode) {
            throw new InvalidApiResponseException(sprintf('Wechat returned status code "%s" with message "%s"',
                $response->errcode,
                property_exists($response, 'errmsg') ? $response->errmsg : ''
            ));
        }

        return $response;
    }