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

it.auties.whatsapp.model.newsletter.NewsletterMetadata Maven / Gradle / Ivy

package it.auties.whatsapp.model.newsletter;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import it.auties.protobuf.annotation.ProtobufMessage;
import it.auties.protobuf.annotation.ProtobufProperty;
import it.auties.protobuf.model.ProtobufType;
import it.auties.whatsapp.util.Clock;

import java.time.ZonedDateTime;
import java.util.Optional;
import java.util.OptionalLong;

@ProtobufMessage
public record NewsletterMetadata(
        @ProtobufProperty(index = 1, type = ProtobufType.OBJECT)
        Optional name,
        @ProtobufProperty(index = 2, type = ProtobufType.OBJECT)
        Optional description,
        @ProtobufProperty(index = 3, type = ProtobufType.OBJECT)
        Optional picture,
        @ProtobufProperty(index = 4, type = ProtobufType.STRING)
        Optional handle,
        @ProtobufProperty(index = 5, type = ProtobufType.OBJECT)
        Optional settings,
        @ProtobufProperty(index = 6, type = ProtobufType.STRING)
        Optional invite,
        @ProtobufProperty(index = 7, type = ProtobufType.BOOL)
        Optional verification,
        @ProtobufProperty(index = 8, type = ProtobufType.UINT64)
        OptionalLong creationTimestampSeconds
) {
    @JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
    NewsletterMetadata(
            NewsletterName name,
            NewsletterDescription description,
            NewsletterPicture picture,
            String handle,
            NewsletterSettings settings,
            String invite,
            String verification,
            @JsonProperty("creation_time")
            Long creationTimestampSeconds
    ) {
        this(
                Optional.ofNullable(name),
                Optional.ofNullable(description),
                Optional.ofNullable(picture),
                Optional.ofNullable(handle),
                Optional.ofNullable(settings),
                Optional.ofNullable(invite),
                verification == null ? Optional.empty() : Optional.of(verification.equals("VERIFIED")),
                creationTimestampSeconds == null ? OptionalLong.empty() : OptionalLong.of(creationTimestampSeconds)
        );
    }

    public Optional creationTimestamp() {
        return Clock.parseSeconds(creationTimestampSeconds.orElse(0L));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy