/// <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(); }
/// <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(CTCT.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 CtctException(ex.Message, ex); } }