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

        record["Basic"] = {
            "Name" : activity.Name,
            "Duration" : self._getDuration(activity),
            "Distance" : activity.Stats.Distance.asUnits(ActivityStatisticUnit.Meters).Value,
            "StartTime": activity.StartTime.strftime("%Y-%m-%d %H:%M:%S"),
            "Type": activity.Type,
            "Energy": activity.Stats.Energy.asUnits(ActivityStatisticUnit.Kilocalories).Value,
            "Notes" : activity.Notes,
            "Private" : activity.Private,
            }

        waypoints = {
            "AvgHR" : activity.Stats.HR.Average,
            "HeartRateValue" : [],
            "HeartRateTime" : [],
            "CadenceValue" : [],
            "CadenceTime" : [],
            "LongitudePathValue" : [],
            "LatitudePathValue" : [],
            "AltitudePathValue" : [],
            "PathTime" : [],
            "SpeedValue" : [],
            "SpeedTime" : [],
            "PowerValue" : [],
            "PowerTime" : [],
            }
        record["Waypoints"] = waypoints;

        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)

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

                if not inPause and waypoint_type == WaypointType.Pause:
                    inPause = True
                elif inPause and waypoint_type == WaypointType.Pause:
                    continue
                elif inPause and waypoint_type != WaypointType.Pause:
                    inPause = False

                if waypoint.HR is not None:
                    waypoints["HeartRateTime"].append(timestamp)
                    waypoints["HeartRateValue"].append(round(waypoint.HR))

                if waypoint.Power is not None:
                    waypoints["PowerTime"].append(timestamp)
                    waypoints["PowerValue"].append(waypoint.Power)

                if waypoint.Speed is not None:
                    waypoints["SpeedTime"].append(timestamp)
                    waypoints["SpeedValue"].append(waypoint.Speed)

                if waypoint.Cadence is not None:
                    waypoints["CadenceTime"].append(timestamp)
                    waypoints["CadenceValue"].append(waypoint.Cadence)

                if waypoint.Location is not None:
                    waypoints["PathTime"].append(timestamp)

                    if waypoint.Location.Longitude is not None and waypoint.Location.Latitude is not None:         
                        waypoints["LongitudePathValue"].append(waypoint.Location.Longitude)
                        waypoints["LatitudePathValue"].append(waypoint.Location.Latitude)
                    else:
                        waypoints["LongitudePathValue"].append(None)
                        waypoints["LatitudePathValue"].append(None)

                    waypoints["AltitudePathValue"].append(waypoint.Location.Altitude)

        return record
 create data dict for posting to pulsstory API 
tapiriik/services/Pulsstory/pulsstory.py