Ejemplo n.º 1
0
        private object CreateArgs(string title, string message, string userKey, string device, Priority priority, DateTime timestamp, NotificationSound notificationSound)
        {
            // Try the passed user key or fall back to default
            var userGroupKey = string.IsNullOrEmpty(userKey) ? DefaultUserGroupSendKey : userKey;

            if (string.IsNullOrEmpty(userGroupKey))
            {
                throw new ArgumentException("User key must be supplied", nameof(userKey));
            }

            var args = new PushoverRequestArguments()
            {
                token     = AppKey,
                user      = userGroupKey,
                device    = device,
                title     = title,
                message   = message,
                timestamp = (int)timestamp.Subtract(new DateTime(1970, 1, 1)).TotalSeconds,
                priority  = (int)priority
            };

            if (notificationSound != NotificationSound.NotSet)
            {
                args.sound = notificationSound.ToString().ToLower();
            }

            return(args);
        }
Ejemplo n.º 2
0
        private object CreateArgs(string title, string message, string userKey, string device, Priority priority, NotificationSound notificationSound, MessageStyle messageStyle)
        {
            // Try the passed user key or fall back to default
            var userGroupKey = string.IsNullOrEmpty(userKey) ? DefaultUserGroupSendKey : userKey;

            if (string.IsNullOrEmpty(userGroupKey))
            {
                throw new ArgumentException("User key must be supplied", nameof(userKey));
            }

            var args = new PushoverRequestArguments()
            {
                token    = AppKey,
                user     = userGroupKey,
                device   = device,
                title    = title,
                message  = message,
                priority = (int)priority
            };

            if (notificationSound != NotificationSound.NotSet)
            {
                args.sound = notificationSound.ToString().ToLower();
            }

            if (messageStyle == MessageStyle.html)
            {
                args.html = "1";
            }
            if (messageStyle == MessageStyle.monospace)
            {
                args.monospace = "1";
            }

            return(args);
        }