Ejemplo n.º 1
0
        /// <summary>
        /// View the details of all the outcomes associated with your app
        /// </summary>
        /// <param name="outcomeNames">List of names and the value (sum/count) for the returned outcome data. For out-of-the-box OneSignal outcomes such as click and session duration, please use the “os” prefix with two underscores. For other outcomes, please use the name specified by the user.</param>
        /// <param name="outcomeTimeRange">Time range for the returned data. The values can be 1h (for the last 1 hour data), 1d (for the last 1 day data), or 1mo (for the last 1 month data).</param>
        /// <param name="outcomePlatforms">Default is data from all platforms if the parameter is omitted.</param>
        /// <param name="outcomeAttribution">Attribution type for the outcomes. The values can be direct or influenced.</param>
        /// <param name="appId">Optional app id if you want an app id different than what is defined in OneSignalConfiguration</param>
        /// <returns>App outcomes</returns>
        public NotificationOutcomeResponse ViewOutcomes(List <string> outcomeNames, OutcomeTimeRange outcomeTimeRange = OutcomeTimeRange.OneHour, List <DeviceType> outcomePlatforms = null, OutcomeAttribution outcomeAttribution = OutcomeAttribution.Total, string appId = null)
        {
            var url = $"apps/{appId ?? OneSignalConfiguration.GetAppId()}/outcomes{BuildOutcomes(true, outcomeNames, outcomeTimeRange, outcomePlatforms, outcomeAttribution)}";

            return(Get <NotificationOutcomeResponse>(url));
        }
Ejemplo n.º 2
0
        private static string BuildOutcomes(bool includeUrlStart, List <string> outcomeNames, OutcomeTimeRange outcomeTimeRange = OutcomeTimeRange.OneHour, List <DeviceType> outcomePlatforms = null, OutcomeAttribution outcomeAttribution = OutcomeAttribution.Total)
        {
            var url                   = string.Empty;
            var urlStart              = includeUrlStart ? "?" : "";
            var rawOutcomeNames       = string.Join("&outcome_names[]=", outcomeNames);
            var outcomeNamesFormatted = includeUrlStart ? rawOutcomeNames : rawOutcomeNames.Trim('&');

            url += $"{urlStart}{outcomeNamesFormatted}";
            url += $"&outcome_time_range={outcomeTimeRange.ToEnumMemberAttrValue()}";
            if (outcomePlatforms != null && outcomePlatforms.Any())
            {
                url += $"&outcome_platforms={string.Join(",", outcomePlatforms)}";
            }
            url += $"&outcome_attribution={outcomeAttribution.ToString().ToLower()}";

            return(url);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// View the details of a single notification and outcomes associated with it
        /// </summary>
        /// <param name="notificationId">The id of the notification</param>
        /// <param name="outcomeNames">List of names and the value (sum/count) for the returned outcome data. For out-of-the-box OneSignal outcomes such as click and session duration, please use the “os” prefix with two underscores. For other outcomes, please use the name specified by the user.</param>
        /// <param name="outcomeTimeRange">Time range for the returned data. The values can be 1h (for the last 1 hour data), 1d (for the last 1 day data), or 1mo (for the last 1 month data).</param>
        /// <param name="outcomePlatforms">Default is data from all platforms if the parameter is omitted.</param>
        /// <param name="outcomeAttribution">Attribution type for the outcomes. The values can be direct or influenced.</param>
        /// <param name="appId">Optional app id if you want an app id different than what is defined in OneSignalConfiguration</param>
        /// <returns>Notification details</returns>
        public NotificationResponse ViewNotification(string notificationId, List <string> outcomeNames = null, OutcomeTimeRange outcomeTimeRange = OutcomeTimeRange.OneHour, List <DeviceType> outcomePlatforms = null, OutcomeAttribution outcomeAttribution = OutcomeAttribution.Total, string appId = null)
        {
            var url = $"notifications/{notificationId}?app_id={appId ?? OneSignalConfiguration.GetAppId()}";

            if (outcomeNames != null && outcomeNames.Any())
            {
                url += BuildOutcomes(false, outcomeNames, outcomeTimeRange, outcomePlatforms, outcomeAttribution);
            }

            return(Get <NotificationResponse>(url));
        }