package com.getbubblenow.android.resource;

import com.getbubblenow.android.api.enums.MFAuthType;
import com.getbubblenow.android.api.enums.Status;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public final class StatusResource<T> {

    @NonNull
    public final MFAuthType authType;

    @NonNull
    public final Status status;

    @Nullable
    public final String message;

    @Nullable
    public final T data;


    private StatusResource(
            @NonNull final Status status,
            @Nullable final String message,
            @Nullable final T data,
            @Nullable final MFAuthType authType) {
        this.status = status;
        this.message = message;
        this.data = data;
        this.authType = authType;
    }


    public static <T> StatusResource<T> success(final T data) {
        return new StatusResource<>(Status.SUCCESS, null, data, MFAuthType.NONE);
    }

    public static <T> StatusResource<T> auth(final MFAuthType type, final String msg) {
        return new StatusResource<>(Status.AUTH, msg, null, type);
    }

    public static <T> StatusResource<T> auth(final MFAuthType type) {
        return new StatusResource<>(Status.AUTH, null, null, type);
    }

    public static <T> StatusResource<T> error(final String msg) {
        return new StatusResource<>(Status.ERROR, msg, null, MFAuthType.NONE);
    }

    public static <T> StatusResource<T> loading() {
        return new StatusResource<>(Status.LOADING, null, null, MFAuthType.NONE);
    }

    public static <T> StatusResource<T> empty() {
        return new StatusResource<>(Status.EMPTY, null, null, MFAuthType.NONE);
    }

}
