package com.ticketmaster.api.discovery.operation;

import java.util.Arrays;
import java.util.List;

import com.ticketmaster.api.discovery.util.Preconditions;

import lombok.EqualsAndHashCode;
import lombok.ToString;

@ToString
@EqualsAndHashCode(callSuper = true)
public class SearchEventsOperation extends PagedOperation<SearchEventsOperation> {

  private static final List<String> UNITS = Arrays.asList("miles", "km");

  public SearchEventsOperation keyword(String keyword) {
    return withParam("keyword", keyword);
  }

  public SearchEventsOperation attractionId(String attractionId) {
    return withParam("attractionId", attractionId);
  }

  public SearchEventsOperation attractionId(String... attractionIds) {
    return withCommaSeparatedParam("attractionId", attractionIds);
  }

  public SearchEventsOperation venueId(String venueId) {
    return withParam("venueId", venueId);
  }

  public SearchEventsOperation venueId(String... venueIds) {
    return withCommaSeparatedParam("venueId", venueIds);
  }

  public SearchEventsOperation promoterId(String promoterId) {
    return withParam("promoterId", promoterId);
  }

  public SearchEventsOperation promoterId(String... promoterIds) {
    return withCommaSeparatedParam("promoterId", promoterIds);
  }

  public SearchEventsOperation postalCode(String postalCode) {
    return withParam("postalCode", postalCode);
  }

  public SearchEventsOperation latlong(String latitude, String longitude) {
    return withParam("latlong", String.format("%s,%s", latitude, longitude));
  }

  public SearchEventsOperation radius(Integer radius) {
    return withParam("radius", radius);
  }

  public SearchEventsOperation unit(String unit) {
    Preconditions.checkArgument(UNITS.contains(unit),
        String.format("Invalid unit, supported units: %s", UNITS.toString()));
    return withParam("unit", unit);
  }

  public SearchEventsOperation marketId(Integer marketId) {
    return withParam("marketId", marketId);
  }

  @Override
  protected SearchEventsOperation getThis() {
    return this;
  }
}

@@ -1975,16 +1975,1771 @@
 );%0A  %7D%0A%0A
+  public SearchEventsOperation marketIds(Integer... marketIds) %7B%0A    return withCommaSeparatedParam(%22marketId%22, marketIds);%0A  %7D%0A%0A  public SearchEventsOperation endDateTime(String endDateTime) %7B%0A    return withParam(%22endDateTime%22, endDateTime);%0A  %7D%0A%0A  public SearchEventsOperation startDateTime(String startDateTime) %7B%0A    return withParam(%22startDateTime%22, startDateTime);%0A  %7D%0A%0A  public SearchEventsOperation city( String city) %7B%0A    return withParam(%22city%22, city);%0A  %7D%0A%0A  public SearchEventsOperation countryCode( String countryCode) %7B return withParam(%22countryCode%22, countryCode); %7D%0A%0A  public SearchEventsOperation countryCode( String... countryCodes) %7B return withCommaSeparatedParam(%22countryCode%22, countryCodes); %7D%0A%0A  public SearchEventsOperation stateCode( String stateCode) %7B%0A    return withParam(%22stateCode%22, stateCode);%0A  %7D%0A%0A  public SearchEventsOperation stateCode( String... stateCodes) %7B return withCommaSeparatedParam(%22stateCode%22, stateCodes); %7D%0A%0A  public SearchEventsOperation dmaId( String dmaId) %7B return withParam(%22dmaId%22, dmaId); %7D%0A%0A  public SearchEventsOperation dmaId( String... dmaIds) %7B return withCommaSeparatedParam(%22dmaIds%22, dmaIds); %7D%0A%0A  public SearchEventsOperation includeTBA( String includeTBA) %7B return withParam(%22includeTBA%22, includeTBA); %7D%0A%0A  public SearchEventsOperation includeTBD( String includeTBD) %7B return withParam(%22includeTBD%22, includeTBD); %7D%0A%0A  public SearchEventsOperation sort( String sort) %7B return withParam(%22sort%22, sort); %7D%0A%0A  public SearchEventsOperation onsaleEndDateTime( String onsaleEndDateTime) %7B return withParam(%22onsaleEndDateTime%22, onsaleEndDateTime); %7D%0A%0A  public SearchEventsOperation onsaleStartDateTime( String onsaleStartDateTime) %7B return withParam(%22onsaleStartDateTime%22, onsaleStartDateTime); %7D%0A%0A
   @Overr
@@ -3809,10 +3809,11 @@
 is;%0A  %7D%0A
+%0A
 %7D%0A

Add Event search parameters