package org.xbib.io.webdav.client.methods;

import org.xbib.io.webdav.client.MergeInfo;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

/**
 * Represents an HTTP MERGE request.
 *
 * @see <a href="http://webdav.org/specs/rfc3253.html#rfc.section.11.2">RFC 3253, Section 11.2</a>
 */
public class Merge extends AbstractMethod {

    private final MergeInfo mergeInfo;

    public Merge(MergeInfo mergeInfo) {
        this.mergeInfo = mergeInfo;
    }

    @Override
    public String method() {
        return "MERGE";
    }

    @Override
    public HttpRequest.BodyPublisher bodyPublisher() {
        return publish(mergeInfo);
    }

    @Override
    public boolean succeeded(HttpResponse<?> response) {
        return response.statusCode() == 207;
    }
}
