package com.atlassian.bitbucket.rest.repository;

import com.atlassian.bitbucket.repository.RefType;
import com.atlassian.bitbucket.rest.annotation.JsonSurrogate;
import com.atlassian.bitbucket.repository.Ref;
import org.codehaus.jackson.map.annotate.JsonSerialize;

@JsonSerialize
@JsonSurrogate(Ref.class)
public class RestRef extends RestMinimalRef {

    private static final String LATEST_COMMIT = "latestCommit";

    public RestRef() {
    }

    public RestRef(Ref ref) {
        this(ref.getId(), ref.getDisplayId(), ref.getType(), ref.getLatestCommit());
    }

    protected RestRef(String id, String displayId, RefType type, String latestCommit) {
        super(id, displayId, type);

        put(LATEST_COMMIT, latestCommit);
        put("latestChangeset", latestCommit); //Because Bamboo
    }
}
