package com.atlassian.stash.internal.build.rest;

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

import java.util.Map;

@JsonSerialize
public class RestMultipleBuildStats extends RestMapEntity {

    public RestMultipleBuildStats(Map<String, BuildSummary> statsByCommitId) {
        for (Map.Entry<String, BuildSummary> stats : statsByCommitId.entrySet()) {
            put(stats.getKey(), new RestBuildStats(stats.getValue()));
        }
    }

    private RestMultipleBuildStats() {
        // private no-arg constructor for the REST example
    }

    // REST Documentation Example

    public static final RestMultipleBuildStats EXAMPLE;

    static {
        EXAMPLE = new RestMultipleBuildStats();
        EXAMPLE.put("db0dd118fa6ccdf1d593fef00df839dd27702df7", new RestBuildStats(3, 0, 1));
        EXAMPLE.put("bde37280e62fcc2b1151b50fe91f387d1e84abee", new RestBuildStats(0, 1, 1));
        EXAMPLE.put("4d0cfc66f56e05cc86127a4e5e1a88c32c689af8", new RestBuildStats(2, 0, 0));
    }

}
