예제 #1
0
        public void PushbulletPushListTest()
        {
            try
            {
                var devices = Client.CurrentUsersDevices();
                Assert.IsNotNull(devices);

                var device = devices.Devices.Where(o => o.manufacturer == "Apple").FirstOrDefault();
                Assert.IsNotNull(device, "Could not find the device specified.");

                PushListRequest reqeust = new PushListRequest()
                {
                    device_iden = device.iden,
                    title       = "Shopping List"
                };

                reqeust.items.Add("Milk");
                reqeust.items.Add("Bread");
                reqeust.items.Add("Chicken");

                var response = Client.PushList(reqeust);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
예제 #2
0
        /// <summary>
        /// Pushes the list.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <param name="ignoreEmptyFields">if set to <c>true</c> [ignore empty fields].</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">list request</exception>
        /// <exception cref="System.Exception">
        /// </exception>
        public PushResponse PushList(PushListRequest request, bool ignoreEmptyFields = false)
        {
            try
            {
                #region pre-processing

                if (request == null)
                {
                    throw new ArgumentNullException("list request");
                }

                if (string.IsNullOrWhiteSpace(request.DeviceIden) && string.IsNullOrWhiteSpace(request.Email))
                {
                    throw new Exception(PushbulletConstants.PushRequestErrorMessages.EmptyEmailProperty);
                }

                if (string.IsNullOrWhiteSpace(request.Type))
                {
                    throw new Exception(PushbulletConstants.PushRequestErrorMessages.EmptyTypeProperty);
                }

                if (!ignoreEmptyFields)
                {
                    if (string.IsNullOrWhiteSpace(request.Title))
                    {
                        throw new Exception(PushbulletConstants.PushListErrorMessages.EmptyTitleProperty);
                    }
                }

                #endregion pre-processing


                #region processing

                return(PostPushRequest <PushListRequest>(request));

                #endregion processing
            }
            catch (Exception)
            {
                throw;
            }
        }