package com.atlassian.bitbucket.rest.pull;

import com.atlassian.bitbucket.pull.PullRequest;
import com.atlassian.bitbucket.pull.PullRequestOutOfDateException;
import com.atlassian.bitbucket.rest.annotation.JsonSurrogate;
import com.atlassian.bitbucket.rest.RestEntityOutOfDateErrorMessage;
import org.codehaus.jackson.map.annotate.JsonSerialize;

@JsonSerialize
@JsonSurrogate(PullRequestOutOfDateException.class)
public class RestPullRequestOutOfDateErrorMessage extends RestEntityOutOfDateErrorMessage {

    public RestPullRequestOutOfDateErrorMessage(PullRequestOutOfDateException exception) {
        super(exception);

        PullRequest pullRequest = exception.getPullRequest();
        if (pullRequest != null) {
            put("pullRequest", new RestPullRequest(pullRequest));
        }
    }
}
