static function parseWorkout($source)
    {
        $workout = new Workout();

        $workout
            ->setSource($source)
            ->setTypeId($source['sport'])
            ->setDuration($source['duration'])
            ->setStart(new \DateTime($source['start_time']))
            ->setMapPrivacy($source['privacy_map'])
            ->setWorkoutPrivacy($source['privacy_workout']);

        if ($source['id']) {
            $workout->setId($source['id']);
        }

        if ($source['calories']) {
            $workout->setCalories($source['calories']);
        }

        if ($source['distance']) {
            $workout->setDistance($source['distance']);
        }

        if (isset($source['points'])) {
            $points = [];
            foreach ($source['points'] as $point) {
                $points[] = OldApiParser::parsePoint($point);
            }
            $workout->setPoints($points);
        }

        if (isset($source['heart_rate_avg'])) {
            $workout->setAvgHeartRate($source['heart_rate_avg']);
        }

        if (isset($source['heart_rate_max'])) {
            $workout->setMaxHeartRate($source['heart_rate_max']);
        }

        if (isset($source['notes'])) {
            $workout->setNotes($source['notes']);
        }

        return $workout;
    }