示例#1
0
        /// <summary>
        /// Update an event
        /// </summary>
        /// <param name="eventId">Event id to be updated</param>
        /// <param name="eventSpot">The new values for event</param>
        /// <returns>The updated event</returns>
        public IndividualEvent PutEventSpot(string eventId, IndividualEvent eventSpot)
        {
            if (string.IsNullOrWhiteSpace(eventId))
            {
                throw new IllegalArgumentException(CTCT.Resources.Errors.InvalidId);
            }
            if (eventSpot == null)
            {
                throw new IllegalArgumentException(CTCT.Resources.Errors.ObjectNull);
            }

            string         url      = String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.EventSpots, "/", eventId);
            string         json     = eventSpot.ToJSON();
            RawApiResponse response = RestClient.Put(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey, json);

            try
            {
                var individualEvent = response.Get <IndividualEvent>();
                return(individualEvent);
            }
            catch (Exception ex)
            {
                throw new CtctException(ex.Message, ex);
            }
        }
示例#2
0
        /// <summary>
        /// Publish an event
        /// </summary>
        /// <param name="accessToken">Constant Contact OAuth2 access token</param>
        /// <param name="apiKey">The API key for the application</param>
        /// <param name="eventSpot">The event to publish</param>
        /// <returns>The published event</returns>
        public IndividualEvent PostEventSpot(string accessToken, string apiKey, IndividualEvent eventSpot)
        {
            string       url      = String.Concat(Config.Endpoints.BaseUrl, Config.Endpoints.EventSpots);
            string       json     = eventSpot.ToJSON();
            CUrlResponse response = RestClient.Post(url, accessToken, apiKey, json);

            if (response.HasData)
            {
                return(response.Get <IndividualEvent>());
            }
            else if (response.IsError)
            {
                throw new CtctException(response.GetErrorMessage());
            }
            return(new IndividualEvent());
        }
示例#3
0
        /// <summary>
        /// Publish an event
        /// </summary>
        /// <param name="eventSpot">The event to publish</param>
        /// <returns>The published event</returns>
        public IndividualEvent PostEventSpot(IndividualEvent eventSpot)
        {
            if (eventSpot == null)
            {
                throw new IllegalArgumentException(ConstantContactClient.Resources.Errors.ObjectNull);
            }

            string         url      = String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.EventSpots);
            string         json     = eventSpot.ToJSON();
            RawApiResponse response = RestClient.Post(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey, json);

            try
            {
                var individualEvent = response.Get <IndividualEvent>();
                return(individualEvent);
            }
            catch (Exception ex)
            {
                throw new ConstantContactClientException(ex.Message, ex);
            }
        }