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

it.auties.whatsapp.model.privacy.GdprAccountReport Maven / Gradle / Ivy

There is a newer version: 3.5.1
Show newest version
package it.auties.whatsapp.model.privacy;

import it.auties.whatsapp.api.Whatsapp;
import it.auties.whatsapp.util.Clock;
import lombok.NonNull;

import java.time.ZonedDateTime;

/**
 * A model interface that represents a gdpr account report. This can be queried using
 * {@link Whatsapp#getGdprAccountInfoStatus()}
 */
public sealed interface GdprAccountReport {
    /**
     * Constructs a pending gdpr report from a timestamp
     *
     * @param timestamp the timestamp in seconds
     * @return a non-null gdpr request
     */
    static Pending ofPending(long timestamp) {
        return new Pending(timestamp <= 0 ? ZonedDateTime.now().plusDays(3) : Clock.parseSeconds(timestamp));
    }

    /**
     * Constructs a successful gdpr report
     *
     * @return a non-null gdpr request
     */
    static Ready ofReady() {
        return new Ready();
    }

    /**
     * Constructs an erroneous gdpr report
     *
     * @return a non-null gdpr request
     */
    static Error ofError() {
        return new Error();
    }

    /**
     * Returns the type of this report
     *
     * @return a non-null type
     */
    Type type();

    /**
     * The constants of this enumerated type describe the status of a gdpr request
     */
    enum Type {
        /**
         * Pending, should be ready in about three business days
         */
        PENDING,
        /**
         * An error occurred and the report could not be delivered
         */
        ERROR,
        /**
         * The report is ready to be downloaded
         */
        READY
    }

    /**
     * A pending gdpr request
     *
     * @param dateTime the eta for the result of the request
     */
    record Pending(@NonNull ZonedDateTime dateTime) implements GdprAccountReport {
        @Override
        public Type type() {
            return Type.PENDING;
        }
    }

    /**
     * A successful gdpr request
     */
    record Ready() implements GdprAccountReport {
        @Override
        public Type type() {
            return Type.READY;
        }
    }

    /**
     * An erroneous gdpr request
     */
    record Error() implements GdprAccountReport {
        @Override
        public Type type() {
            return Type.ERROR;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy