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

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

/**
 * Represents an HTTP UNBIND request.
 *
 * @see <a href="http://webdav.org/specs/rfc5842.html#rfc.section.5">RFC 5842, Section 5</a>
 */
public class Unbind extends AbstractMethod {

    private final UnbindInfo info;

    public Unbind(UnbindInfo info) {
        this.info = info;
    }

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

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

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