/**
   * Deletes a single Event Item.<br>
   * Implements the delete Event Item operation of the EventSpot API by calling the ConstantContact
   * server side.
   *
   * @param accessToken Constant Contact OAuth2 access token.
   * @param eventId The id of the event.
   * @param itemId The id of the event item to delete.
   * @return true on success; <br>
   *     An exception is thrown otherwise.
   * @throws ConstantContactServiceException When something went wrong in the Constant Contact flow
   *     or an error is returned from server.
   */
  @Override
  public boolean deleteEventItem(String accessToken, String eventId, String itemId)
      throws ConstantContactServiceException {
    try {
      String url =
          String.format(
              "%1$s%2$s",
              Config.Endpoints.BASE_URL,
              String.format(Config.Endpoints.EVENT_ITEM_ID, eventId, itemId));

      CUrlResponse response = getRestClient().delete(url, accessToken);
      if (response.isError()) {
        ConstantContactServiceException constantContactException =
            new ConstantContactServiceException(
                ConstantContactServiceException.RESPONSE_ERR_SERVICE);
        response.getInfo().add(new CUrlRequestError("url", url));
        constantContactException.setErrorInfo(response.getInfo());
        throw constantContactException;
      }
      return response.getStatusCode() == HttpURLConnection.HTTP_NO_CONTENT;
    } catch (ConstantContactServiceException e) {
      throw new ConstantContactServiceException(e);
    } catch (Exception e) {
      throw new ConstantContactServiceException(e);
    }
  }
  /**
   * Updates the Event status.<br>
   * Implements the update Event Status operation of the EventSpot API by calling the
   * ConstantContact server side.
   *
   * @param accessToken Constant Contact OAuth2 access token.
   * @param eventId The id of the event to update.
   * @param status The status of the event.
   * @return true on success;<br>
   *     An exception is thrown otherwise.
   * @throws ConstantContactServiceException When something went wrong in the Constant Contact flow
   *     or an error is returned from server.
   */
  @Override
  public boolean updateEventStatus(String accessToken, String eventId, String status)
      throws ConstantContactServiceException {
    try {
      String url =
          String.format(
              "%1$s%2$s",
              Config.Endpoints.BASE_URL, String.format(Config.Endpoints.EVENT_ID, eventId));

      EventUpdateStatus eventUpdateStatus = new EventUpdateStatus(status);
      List<EventUpdateStatus> eventUpdateStatusRequestList = new ArrayList<EventUpdateStatus>();
      eventUpdateStatusRequestList.add(eventUpdateStatus);
      EventUpdateStatusRequest eventUpdateStatusRequest =
          new EventUpdateStatusRequest(eventUpdateStatusRequestList);
      String json = eventUpdateStatusRequest.toJSON();

      CUrlResponse response = getRestClient().patch(url, accessToken, json);
      if (response.isError()) {
        ConstantContactServiceException constantContactException =
            new ConstantContactServiceException(
                ConstantContactServiceException.RESPONSE_ERR_SERVICE);
        response.getInfo().add(new CUrlRequestError("url", url));
        constantContactException.setErrorInfo(response.getInfo());
        throw constantContactException;
      }
      return response.getStatusCode() == HttpURLConnection.HTTP_NO_CONTENT;
    } catch (ConstantContactServiceException e) {
      throw new ConstantContactServiceException(e);
    } catch (Exception e) {
      throw new ConstantContactServiceException(e);
    }
  }