package com.atlassian.bitbucket.test.rest.repository.sync;

import com.atlassian.bitbucket.test.rest.AbstractRestRequest;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Map;

public class RestGetRefSyncStatusRequest extends AbstractRestRequest {

    private final String refId;

    private RestGetRefSyncStatusRequest(Builder builder) {
        super(builder);

        refId = builder.refId;
    }

    public String getRefId() {
        return refId;
    }

    public boolean hasRefId() {
        return refId != null;
    }

    @Nonnull
    @Override
    public Map<String, Object> toQueryParams() {
        Map<String, Object> params = super.toQueryParams();
        if (hasRefId()) {
            params.put("at", getRefId());
        }

        return params;
    }

    public static class Builder extends AbstractBuilder<Builder, RestGetRefSyncStatusRequest> {

        private String refId;

        @Nonnull
        @Override
        public RestGetRefSyncStatusRequest build() {
            return new RestGetRefSyncStatusRequest(this);
        }

        @Nonnull
        public Builder refId(@Nullable String value) {
            refId = value;

            return self();
        }

        @Nonnull
        @Override
        protected Builder self() {
            return this;
        }
    }
}
