Beispiel #1
0
 /// <summary>
 ///  Create a specific event item
 /// </summary>
 /// <param name="eventId">Event id</param>
 /// <param name="eventItem">EventItem id</param>
 /// <returns>The newly created EventItem</returns>
 public EventItem PostEventItem(string eventId, EventItem eventItem)
 {
     if (string.IsNullOrWhiteSpace(eventId))
     {
         throw new IllegalArgumentException(Config.Errors.InvalidId);
     }
     if (eventItem == null)
     {
         throw new IllegalArgumentException(Config.Errors.ObjectNull);
     }
     return EventSpotService.PostEventItem(this.AccessToken, this.APIKey, eventId, eventItem);
 }
Beispiel #2
0
        /// <summary>
        ///  Create a specific event item
        /// </summary>
        /// <param name="eventId">Event id</param>
        /// <param name="eventItem">EventItem id</param>
        /// <returns>The newly created EventItem</returns>
        public EventItem PostEventItem(string eventId, EventItem eventItem)
        {
            if (string.IsNullOrWhiteSpace(eventId))
            {
                throw new IllegalArgumentException(CTCT.Resources.Errors.InvalidId);
            }
            if (eventItem == null)
            {
                throw new IllegalArgumentException(CTCT.Resources.Errors.ObjectNull);
            }

            string url = String.Format(String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.EventItem), eventId, null);
            string json = eventItem.ToJSON();

            RawApiResponse response = RestClient.Post(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey, json);
            try
            {
                var eventIt = response.Get<EventItem>();
                return eventIt;
            }
            catch (Exception ex)
            {
                throw new CtctException(ex.Message, ex);
            }
        }
Beispiel #3
0
        /// <summary>
        ///  Create a specific event 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="eventItem">EventItem id</param>
        /// <returns>The newly created EventItem</returns>
        public EventItem PostEventItem(string accessToken, string apiKey, string eventId, EventItem eventItem)
        {
            string url = String.Format(String.Concat(Config.Endpoints.BaseUrl, Config.Endpoints.EventItem), eventId, null);
            string json = eventItem.ToJSON();

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