<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def create_sprint(self, name, board_id, startDate=None, endDate=None):
 """Create a new sprint for the ``board_id``. :param name: Name of the sprint :type name: str :param board_id: Which board the sprint should be assigned. :type board_id: int :param startDate: Start date for the sprint. :type startDate: Optional[Any] :param endDate: End date for the sprint. :type endDate: Optional[Any] :return: The newly created Sprint :rtype: Sprint """

        payload = {'name': name}
        if startDate:
            payload["startDate"] = startDate
        if endDate:
            payload["endDate"] = endDate

        if self._options['agile_rest_path'] == GreenHopperResource.GREENHOPPER_REST_PATH:
            url = self._get_url('sprint/%s' % board_id, base=self.AGILE_BASE_URL)
            r = self._session.post(url)
            raw_issue_json = json_loads(r)
            """ now r contains something like:
            {
                  "id": 742,
                  "name": "Sprint 89",
                  "state": "FUTURE",
                  "linkedPagesCount": 0,
                  "startDate": "None",
                  "endDate": "None",
                  "completeDate": "None",
                  "remoteLinks": []
            }"""

            url = self._get_url(
                'sprint/%s' % raw_issue_json['id'], base=self.AGILE_BASE_URL)
            r = self._session.put(
                url, data=json.dumps(payload))
            raw_issue_json = json_loads(r)
        else:
            url = self._get_url('sprint', base=self.AGILE_BASE_URL)
            payload['originBoardId'] = board_id
            r = self._session.post(url, data=json.dumps(payload))
            raw_issue_json = json_loads(r)

        return Sprint(self._options, self._session, raw=raw_issue_json)