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

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

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

    private final UpdateInfo updateInfo;

    public Update(UpdateInfo updateInfo) {
        this.updateInfo = updateInfo;
    }

    public String method() {
        return "UPDATE";
    }

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

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