All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.auties.whatsapp.model.response.NewsletterMuteResponse Maven / Gradle / Ivy

package it.auties.whatsapp.model.response;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import it.auties.whatsapp.model.jid.Jid;
import it.auties.whatsapp.util.Json;

import java.util.Map;
import java.util.Objects;
import java.util.Optional;

public record NewsletterMuteResponse(@JsonProperty("id") Jid jid, @JsonProperty("mute") boolean mute) {
    @JsonCreator
    NewsletterMuteResponse(Map json) {
        this(Jid.of(json.get("id")), Objects.equals(json.get("mute"), "ON"));
    }

    public static Optional ofJson(String json) {
        return Json.readValue(json, JsonData.class)
                .data()
                .map(JsonResponse::response);
    }

    private record JsonData(Optional data) {

    }

    private record JsonResponse(
            @JsonProperty("xwa2_notify_newsletter_on_mute_change") NewsletterMuteResponse response) {

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy