/// <summary> /// Publish or cancel an event by changing the status of the event /// </summary> /// <param name="eventId">Event id</param> /// <param name="eventStatus">New status of the event. ACTIVE" and "CANCELLED are allowed</param> /// <returns>The updated event</returns> public IndividualEvent PatchEventSpotStatus(string eventId, EventStatus eventStatus) { if (string.IsNullOrWhiteSpace(eventId)) { throw new IllegalArgumentException(CTCT.Resources.Errors.InvalidId); } string url = String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.EventSpots, "/", eventId); var patchRequests = new List<PatchRequest>(); var patchRequest = new PatchRequest("REPLACE", "#/status", eventStatus.ToString()); patchRequests.Add(patchRequest); string json = patchRequests.ToJSON(); RawApiResponse response = RestClient.Patch(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey, json); try { var individualEvent = response.Get<IndividualEvent>(); return individualEvent; } catch (Exception ex) { throw new CtctException(ex.Message, ex); } }
/// <summary> /// Publish or cancel an event by changing the status of the 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="eventStatus">New status of the event. ACTIVE" and "CANCELLED are allowed</param> /// <returns>The updated event</returns> public IndividualEvent PatchEventSpotStatus(string accessToken, string apiKey, string eventId, EventStatus eventStatus) { string url = String.Concat(Config.Endpoints.BaseUrl, Config.Endpoints.EventSpots, "/", eventId); var patchRequests = new List<PatchRequest>(); var patchRequest = new PatchRequest("REPLACE", "#/status", eventStatus.ToString()); patchRequests.Add(patchRequest); string json = patchRequests.ToJSON(); CUrlResponse response = RestClient.Patch(url, accessToken, apiKey, json); if (response.HasData) { return response.Get<IndividualEvent>(); } else if (response.IsError) { throw new CtctException(response.GetErrorMessage()); } return new IndividualEvent(); }