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

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

package it.auties.whatsapp.model.response;

import com.fasterxml.jackson.annotation.JsonCreator;
import it.auties.whatsapp.model.newsletter.Newsletter;
import it.auties.whatsapp.util.Json;

import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Optional;

public record SubscribedNewslettersResponse(List newsletters) {
    @JsonCreator
    SubscribedNewslettersResponse(Map> json) {
        this(json.values()
                .stream()
                .findFirst()
                .orElseThrow(() -> new NoSuchElementException("Missing newsletters")));
    }

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

    private record JsonResponse(Optional data) {

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy