package org.gitlab4j.api.models;

import java.util.Date;

import org.gitlab4j.api.Constants;
import org.gitlab4j.api.GitLabApiForm;
import org.gitlab4j.api.Constants.DeploymentOrderBy;
import org.gitlab4j.api.Constants.DeploymentStatus;
import org.gitlab4j.api.Constants.SortOrder;
import org.gitlab4j.api.utils.ISO8601;

import com.fasterxml.jackson.annotation.JsonIgnore;

public class DeploymentFilter {

	/**
	 * Return deployments ordered by either one of id, iid, created_at, updated_at or ref fields. Default is id.
	 */
	private DeploymentOrderBy orderBy;

	/**
	 * Return deployments sorted in asc or desc order. Default is asc.
	 */
	private SortOrder sortOrder;

	/**
     * Return deployments updated after the specified date. Expected in ISO 8601 format (2019-03-15T08:00:00Z).
     */
    private Date updatedAfter;

    /**
     * Return deployments updated before the specified date. Expected in ISO 8601 format (2019-03-15T08:00:00Z).
     */
    private Date updatedBefore;

    /**
     * The name of the environment to filter deployments by.
     */
    private String environment;

    /**
     * The status to filter deployments by.
     */
    private DeploymentStatus status;

	public DeploymentOrderBy getOrderBy() {
		return orderBy;
	}

	public void setOrderBy(DeploymentOrderBy orderBy) {
		this.orderBy = orderBy;
	}

	public SortOrder getSortOrder() {
		return sortOrder;
	}

	public void setSortOrder(SortOrder sortOrder) {
		this.sortOrder = sortOrder;
	}

	public Date getUpdatedAfter() {
		return updatedAfter;
	}

	public void setUpdatedAfter(Date updatedAfter) {
		this.updatedAfter = updatedAfter;
	}

	public Date getUpdatedBefore() {
		return updatedBefore;
	}

	public void setUpdatedBefore(Date updatedBefore) {
		this.updatedBefore = updatedBefore;
	}

	public String getEnvironment() {
		return environment;
	}

	public void setEnvironment(String environment) {
		this.environment = environment;
	}

	public DeploymentStatus getStatus() {
		return status;
	}

	public void setStatus(DeploymentStatus status) {
		this.status = status;
	}

    public DeploymentFilter withOrderBy(DeploymentOrderBy orderBy) {
        this.orderBy = orderBy;
        return (this);
    }

    public DeploymentFilter withSortOrder(SortOrder sortOrder) {
        this.sortOrder = sortOrder;
        return (this);
    }

    public DeploymentFilter withUpdatedAfter(Date updatedAfter) {
        this.updatedAfter = updatedAfter;
        return (this);
    }

    public DeploymentFilter withUpdatedBefore(Date updatedBefore) {
        this.updatedBefore = updatedBefore;
        return (this);
    }

    public DeploymentFilter withEnvironment(String environment) {
        this.environment = environment;
        return (this);
    }

    public DeploymentFilter withStatus(DeploymentStatus status) {
        this.status = status;
        return (this);
    }

    @JsonIgnore
    public GitLabApiForm getQueryParams(int page, int perPage) {
        return (getQueryParams()
                .withParam(Constants.PAGE_PARAM, page)
                .withParam(Constants.PER_PAGE_PARAM, perPage));
    }

    @JsonIgnore
    public GitLabApiForm getQueryParams() {
        return (new GitLabApiForm()
                .withParam("order_by", orderBy)
                .withParam("sort", sortOrder)
                .withParam("updated_after", ISO8601.toString(updatedAfter, false))
                .withParam("updated_before", ISO8601.toString(updatedBefore, false))
                .withParam("environment", environment)
                .withParam("status", status));
    }

}

@@ -1780,32 +1780,636 @@
 atedBefore;%0A%09%7D%0A%0A
+%09/**%0A%09 * @deprecated use %7B@link #getUpdatedAfter()%7D%0A%09 */%0A%09@Deprecated%0A%09public Date getFinishedAfter() %7B%0A%09%09return updatedAfter;%0A%09%7D%0A%0A%09/**%0A%09 * @deprecated use %7B@link #setUpdatedAfter(Date)%7D%0A%09 */%0A%09@Deprecated%0A%09public void setFinishedAfter(Date finishedAfter) %7B%0A%09%09this.updatedAfter = finishedAfter;%0A%09%7D%0A%0A%09/**%0A%09 * @deprecated use %7B@link #getUpdatedBefore()%7D%0A%09 */%0A%09@Deprecated%0A%09public Date getFinishedBefore() %7B%0A%09%09return updatedBefore;%0A%09%7D%0A%0A%09/**%0A%09 * @deprecated use %7B@link #setUpdatedBefore(Date)%7D%0A%09 */%0A%09@Deprecated%0A%09public void setFinishedBefore(Date finishedBefore) %7B%0A%09%09this.updatedBefore = finishedBefore;%0A%09%7D%0A%0A
 %09public String g
@@ -3212,32 +3212,469 @@
  (this);%0A    %7D%0A%0A
+%09/**%0A%09 * @deprecated use %7B@link #withUpdatedAfter(Date)%7D%0A%09 */%0A%09@Deprecated%0A    public DeploymentFilter withFinishedAfter(Date finishedAfter) %7B%0A        this.updatedAfter = finishedAfter;%0A        return (this);%0A    %7D%0A%0A%09/**%0A%09 * @deprecated use %7B@link #withUpdatedBefore(Date)%7D%0A%09 */%0A%09@Deprecated%0A    public DeploymentFilter withFinishedBefore(Date finishedBefore) %7B%0A        this.updatedBefore = finishedBefore;%0A        return (this);%0A    %7D%0A%0A
     public Deplo

Add backward compatibility in DeploymetFilter