def _createUploadData(self, activity, auto_pause=False):
        ''' create data dict for posting to RK API '''
        record = {}

        record["type"] = [key for key in self._activityMappings if self._activityMappings[key] == activity.Type][0]
        record["start_time"] = activity.StartTime.strftime("%a, %d %b %Y %H:%M:%S")
        if activity.Stats.MovingTime.Value is not None:
            record["duration"] = activity.Stats.MovingTime.asUnits(ActivityStatisticUnit.Seconds).Value
        elif activity.Stats.TimerTime.Value is not None:
            record["duration"] = activity.Stats.TimerTime.asUnits(ActivityStatisticUnit.Seconds).Value
        else:
            record["duration"] = (activity.EndTime - activity.StartTime).total_seconds()

        if activity.Stats.HR.Average is not None:
            record["average_heart_rate"] = int(activity.Stats.HR.Average)
        if activity.Stats.Energy.Value is not None:
            record["total_calories"] = activity.Stats.Energy.asUnits(ActivityStatisticUnit.Kilocalories).Value
        if activity.Stats.Distance.Value is not None:
            record["total_distance"] = activity.Stats.Distance.asUnits(ActivityStatisticUnit.Meters).Value

        if activity.Name and activity.Notes and activity.Name != activity.Notes:
            record["notes"] = activity.Name + " - " + activity.Notes
        elif activity.Notes:
            record["notes"] = activity.Notes
        elif activity.Name:
            record["notes"] = activity.Name

        if activity.Private:
            record["share"] = "Just Me"

        if activity.CountTotalWaypoints() > 1:
            flat_wps = activity.GetFlatWaypoints()

            anchor_ts = flat_wps[0].Timestamp

            # By default, use the provided waypoint types
            wp_type_iter = (wp.Type for wp in flat_wps)
            # Unless those types don't include pause/resume, in which case use our auto-pause calculation
            if auto_pause and not any(wp.Type == WaypointType.Pause for wp in flat_wps):
                # ...but not if we don't know the intended moving time
                if activity.Stats.MovingTime.Value:
                    wp_type_iter = AutoPauseCalculator.calculate(flat_wps, activity.Stats.MovingTime.asUnits(ActivityStatisticUnit.Seconds).Value)

            inPause = False
            for waypoint, waypoint_type in zip(flat_wps, wp_type_iter):
                timestamp = (waypoint.Timestamp - anchor_ts).total_seconds()

                if waypoint_type in self._wayptTypeMappings.values():
                    wpType = [key for key, value in self._wayptTypeMappings.items() if value == waypoint_type][0]
                else:
                    wpType = "gps"  # meh

                if not inPause and waypoint_type == WaypointType.Pause:
                    inPause = True
                elif inPause and waypoint_type == WaypointType.Pause:
                    continue # RK gets all crazy when you send it multiple pause waypoints in a row.
                elif inPause and waypoint_type != WaypointType.Pause:
                    inPause = False

                if waypoint.Location is not None and waypoint.Location.Latitude is not None and waypoint.Location.Longitude is not None:
                    if "path" not in record:
                        record["path"] = []
                    pathPt = {"timestamp": timestamp,
                              "latitude": waypoint.Location.Latitude,
                              "longitude": waypoint.Location.Longitude,
                              "type": wpType}
                    pathPt["altitude"] = waypoint.Location.Altitude if waypoint.Location.Altitude is not None else 0  # this is straight of of their "example calls" page
                    record["path"].append(pathPt)

                if waypoint.HR is not None:
                    if "heart_rate" not in record:
                        record["heart_rate"] = []
                    record["heart_rate"].append({"timestamp": timestamp, "heart_rate": round(waypoint.HR)})

                if waypoint.Calories is not None:
                    if "calories" not in record:
                        record["calories"] = []
                    record["calories"].append({"timestamp": timestamp, "calories": waypoint.Calories})

                if waypoint.Distance is not None:
                    if "distance" not in record:
                        record["distance"] = []
                    record["distance"].append({"timestamp": timestamp, "distance": waypoint.Distance})

        return record
 create data dict for posting to RK API 
tapiriik/services/RunKeeper/runkeeper.py