protected function preparePostRequest(RequestInterface $request, $data)
    {
        if ($data !== null) {
            // Add the POST data to the request.
            $request->setOption(CURLOPT_POST, true);
            $request->setOption(CURLOPT_POSTFIELDS, $data);
        } else {
            $request->setOption(CURLOPT_CUSTOMREQUEST, 'POST');
        }
    }