Example #1
0
 /// <summary>
 /// Update a promo code for an event
 /// </summary>
 /// <param name="eventId">Event id</param>
 /// <param name="promocodeId">Promocode id</param>
 /// <param name="promocode">The new Promocode values</param>
 /// <returns>The newly updated Promocode</returns>
 public Promocode PutPromocode(string eventId, string promocodeId, Promocode promocode)
 {
     if (string.IsNullOrWhiteSpace(eventId))
     {
         throw new IllegalArgumentException(Config.Errors.InvalidId);
     }
     if (string.IsNullOrWhiteSpace(promocodeId))
     {
         throw new IllegalArgumentException(Config.Errors.InvalidId);
     }
     if (promocode == null)
     {
         throw new IllegalArgumentException(Config.Errors.ObjectNull);
     }
     return EventSpotService.PutPromocode(this.AccessToken, this.APIKey, eventId, promocodeId, promocode);
 }
Example #2
0
        /// <summary>
        /// Update a promo code for an event
        /// </summary>
        /// <param name="eventId">Event id</param>
        /// <param name="promocodeId">Promocode id</param>
        /// <param name="promocode">The new Promocode values</param>
        /// <returns>The newly updated Promocode</returns>
        public Promocode PutPromocode(string eventId, string promocodeId, Promocode promocode)
        {
            if (string.IsNullOrWhiteSpace(eventId))
            {
                throw new IllegalArgumentException(CTCT.Resources.Errors.InvalidId);
            }
            if (string.IsNullOrWhiteSpace(promocodeId))
            {
                throw new IllegalArgumentException(CTCT.Resources.Errors.InvalidId);
            }
            if (promocode == null)
            {
                throw new IllegalArgumentException(CTCT.Resources.Errors.ObjectNull);
            }

            string url = String.Format(String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.EventPromocode), eventId, promocodeId);

            string json = promocode.ToJSON();

            RawApiResponse response = RestClient.Put(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey, json);
            try
            {
                var promoc = response.Get<Promocode>();
                return promoc;
            }
            catch (Exception ex)
            {
                throw new CtctException(ex.Message, ex);
            }
        }
Example #3
0
        /// <summary>
        /// Update a promo code for an event
        /// </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="promocodeId">Promocode id</param>
        /// <param name="promocode">The new Promocode values</param>
        /// <returns>The newly updated Promocode</returns>
        public Promocode PutPromocode(string accessToken, string apiKey, string eventId, string promocodeId, Promocode promocode)
        {
            string url = String.Format(String.Concat(Config.Endpoints.BaseUrl, Config.Endpoints.EventPromocode), eventId, promocodeId);

            string json = promocode.ToJSON();

            CUrlResponse response = RestClient.Put(url, accessToken, apiKey, json);
            if (response.HasData)
            {
                return response.Get<Promocode>();
            }
            else if (response.IsError)
            {
                throw new CtctException(response.GetErrorMessage());
            }
            return new Promocode();
        }