Пример #1
0
        public void SetNotificationPreferences()
        {
            Assert.IsNotNull(TestData.NotificationPreferencesResponse);
            ApplicationDeliveryPreferencesType appPref = TestData.NotificationPreferencesResponse.ApplicationDeliveryPreferences;

            appPref.NotificationPayloadType = NotificationPayloadTypeCodeType.eBLSchemaSOAP;
            NotificationEnableTypeCollection userPref = TestData.NotificationPreferencesResponse.UserDeliveryPreferenceArray;
            SetNotificationPreferencesCall   api      = new SetNotificationPreferencesCall(this.apiContext);

            api.ApplicationDeliveryPreferences = appPref;
            api.UserDeliveryPreferenceList     = userPref;
            // Make API call.
            ApiException gotException = null;

            try
            {
                api.Execute();
            }
            catch (ApiException ex)
            {
                gotException = ex;
            }
            if (gotException != null)
            {
                Assert.IsTrue(appPref == null && userPref == null);
            }
        }
Пример #2
0
        /*
         * // Messages...
         * list.Add(});
         * list.Add(new NotificationEnableType { EventType = NotificationEventTypeCodeType.MyMessageseBayMessage, EventEnable = EnableCodeType.Enable });
         * list.Add(new NotificationEnableType { EventType = NotificationEventTypeCodeType.MyMessagesM2MMessage, EventEnable = EnableCodeType.Enable });
         *
         * // Feedback
         * list.Add(new NotificationEnableType { EventType = NotificationEventTypeCodeType.FeedbackReceived, EventEnable = EnableCodeType.Enable });
         * // FeedbackStarChanged
         *
         * // Sales
         *
         * list.Add(new NotificationEnableType { EventType = NotificationEventTypeCodeType.AuctionCheckoutComplete, EventEnable = EnableCodeType.Enable });
         * list.Add(new NotificationEnableType { EventType = NotificationEventTypeCodeType.BestOffer, EventEnable = EnableCodeType.Enable });
         * list.Add(new NotificationEnableType { EventType = NotificationEventTypeCodeType.BidReceived, EventEnable = EnableCodeType.Enable });
         * list.Add(new NotificationEnableType { EventType = NotificationEventTypeCodeType.FixedPriceTransaction, EventEnable = EnableCodeType.Enable });
         * // ItemSold == Only shown when a purchase happens and it ends the listing. The FixedPriceTransaction also occurs.
         * list.Add(new NotificationEnableType { EventType = NotificationEventTypeCodeType.ItemMarkedPaid, EventEnable = EnableCodeType.Enable });
         *
         *
         * // Listings Ended
         * list.Add(new NotificationEnableType { EventType = NotificationEventTypeCodeType.ItemSuspended, EventEnable = EnableCodeType.Enable });
         * list.Add(new NotificationEnableType { EventType = NotificationEventTypeCodeType.ItemClosed, EventEnable = EnableCodeType.Enable });
         * list.Add(new NotificationEnableType { EventType = NotificationEventTypeCodeType.ItemUnsold, EventEnable = EnableCodeType.Enable });
         *
         *
         * // Request Totals
         * list.Add(new NotificationEnableType { EventType = NotificationEventTypeCodeType.CheckoutBuyerRequestsTotal, EventEnable = EnableCodeType.Enable });
         *
         * // Disputes
         * list.Add(new NotificationEnableType { EventType = NotificationEventTypeCodeType.BuyerResponseDispute, EventEnable = EnableCodeType.Enable });
         * // INRBuyerClosedDispute
         * // INRBuyerOpenedDispute
         * // INRBuyerRespondedToDispute
         * //
         *
         * // WTF
         * list.Add(new NotificationEnableType { EventType = NotificationEventTypeCodeType.TokenRevocation, EventEnable = EnableCodeType.Enable });
         * list.Add(new NotificationEnableType { EventType = NotificationEventTypeCodeType.UserIDChanged, EventEnable = EnableCodeType.Enable });
         */

        protected override void ExecuteInternal()
        {
            ApiContext apiContext = this.ApiContext;
            SetNotificationPreferencesCall apiCall = new SetNotificationPreferencesCall(apiContext);

            // Application Delivery Preferences
            {
                ApplicationDeliveryPreferencesType applicationDeliveryPreferences = new ApplicationDeliveryPreferencesType();
                applicationDeliveryPreferences.ApplicationEnable = EnableCodeType.Enable;

                applicationDeliveryPreferences.DeviceType = DeviceTypeCodeType.ClientAlerts;

                applicationDeliveryPreferences.AlertEnable = EnableCodeType.Disable;

                apiCall.ApplicationDeliveryPreferences = applicationDeliveryPreferences;
            }

            // UserDeliveryPreferenceList
            {
                apiCall.UserDeliveryPreferenceList = new NotificationEnableTypeCollection();

                foreach (NotificationPreference item in this.NotificationPreferences)
                {
                    if (item.Dirty)
                    {
                        NotificationEnableType enableType = new NotificationEnableType()
                        {
                            EventType   = item.EventType,
                            EventEnable = item.Enabled ? EnableCodeType.Enable : EnableCodeType.Disable
                        };

                        apiCall.UserDeliveryPreferenceList.Add(enableType);
                    }
                }
            }

            apiCall.Execute();

            foreach (NotificationPreference item in this.NotificationPreferences)
            {
                item.Dirty = false;
            }
        }
Пример #3
0
        public IHttpActionResult Post(FormDataCollection data)
        {
            try
            {
                string notificationEvent  = data.Get("notificationEvent");
                string notificationEnable = data.Get("notificationEnable");

                SetNotificationPreferencesCall call = new SetNotificationPreferencesCall(context);
                call.UserDeliveryPreferenceList = new NotificationEnableTypeCollection();
                call.UserDeliveryPreferenceList.Add(new NotificationEnableType()
                {
                    EventType   = (NotificationEventTypeCodeType)Enum.Parse(typeof(NotificationEventTypeCodeType), notificationEvent, true),
                    EventEnable = (EnableCodeType)Enum.Parse(typeof(EnableCodeType), notificationEnable, true)
                });
                call.Execute();

                return(Ok());
            }
            catch
            {
                return(NotFound());
            }
        }