package com.atlassian.bitbucket.rest.pull;

import com.atlassian.bitbucket.rest.RestMapEntity;
import org.codehaus.jackson.map.annotate.JsonSerialize;

import javax.annotation.Nullable;

@JsonSerialize
public class RestPullRequestDeclineRequest extends RestMapEntity {

    private static final String COMMENT = "comment";
    private static final String VERSION = "version";

    public RestPullRequestDeclineRequest() {
    }

    /**
     * @return a comment explaining why the pull request is being declined, which may be {@code null}
     */
    @Nullable
    public String getComment() {
        return getStringProperty(COMMENT);
    }

    public int getVersion() {
        return getIntProperty(VERSION);
    }

    public boolean hasVersion() {
        return containsKey(VERSION);
    }

    // REST Documentation Examples

    public static final RestPullRequestDeclineRequest DECLINE_REQUEST_EXAMPLE = new RestPullRequestDeclineRequest() { {
        put(COMMENT, "An optional comment explaining why the pull request is being declined");
        put(VERSION, 1);
    } };
}
