コード例 #1
0
ファイル: EventSpotService.cs プロジェクト: WCGPR0/parsers
        /// <summary>
        /// Updates an existing attributes for an item
        /// </summary>
        /// <param name="eventId">Event id</param>
        /// <param name="itemId">EventItem id</param>
        /// <param name="attributeId">Attribute id</param>
        /// <param name="attribute">Attribute new values</param>
        /// <returns>The newly updated attribute</returns>
        public CTCT.Components.EventSpot.Attribute PutEventItemAttribute(string eventId, string itemId, string attributeId, CTCT.Components.EventSpot.Attribute attribute)
        {
            if (string.IsNullOrWhiteSpace(eventId))
            {
                throw new IllegalArgumentException(CTCT.Resources.Errors.InvalidId);
            }
            if (string.IsNullOrWhiteSpace(itemId))
            {
                throw new IllegalArgumentException(CTCT.Resources.Errors.InvalidId);
            }
            if (string.IsNullOrWhiteSpace(attributeId))
            {
                throw new IllegalArgumentException(CTCT.Resources.Errors.InvalidId);
            }
            if (attribute == null)
            {
                throw new IllegalArgumentException(CTCT.Resources.Errors.ObjectNull);
            }

            string url  = String.Format(String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.ItemAttribute), eventId, itemId, attributeId);
            string json = attribute.ToJSON();

            RawApiResponse response = RestClient.Put(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey, json);

            try
            {
                var attrib = response.Get <CTCT.Components.EventSpot.Attribute>();
                return(attrib);
            }
            catch (Exception ex)
            {
                throw new CtctException(ex.Message, ex);
            }
        }
コード例 #2
0
        /// <summary>
        /// Updates an existing attributes for an item
        /// </summary>
        /// <param name="accessToken">Constant Contact OAuth2 access token</param>
        /// <param name="apiKey">The API key for the application</param>
        /// <param name="eventId">Event id</param>
        /// <param name="itemId">EventItem id</param>
        /// <param name="attributeId">Attribute id</param>
        /// <param name="attribute">Attribute new values</param>
        /// <returns>The newly updated attribute</returns>
        public CTCT.Components.EventSpot.Attribute PutEventItemAttribute(string accessToken, string apiKey, string eventId, string itemId, string attributeId, CTCT.Components.EventSpot.Attribute attribute)
        {
            string url  = String.Format(String.Concat(Config.Endpoints.BaseUrl, Config.Endpoints.ItemAttribute), eventId, itemId, attributeId);
            string json = attribute.ToJSON();

            CUrlResponse response = RestClient.Put(url, accessToken, apiKey, json);

            if (response.HasData)
            {
                return(response.Get <CTCT.Components.EventSpot.Attribute>());
            }
            else if (response.IsError)
            {
                throw new CtctException(response.GetErrorMessage());
            }
            return(new CTCT.Components.EventSpot.Attribute());
        }