package com.atlassian.bitbucket.internal.mirroring.mirror.rest.webhook;

import com.atlassian.bitbucket.internal.mirroring.mirror.rest.RestUnknownEntity;
import com.atlassian.bitbucket.mirroring.mirror.UpstreamServerType;

import javax.annotation.Nonnull;
import java.util.Optional;

/**
 * Attempts to convert from an unknown REST entity to a known {@link BaseRestWebHookEvent}.
 */
public interface RestWebHookEventConverter {
    /**
     * @return a {@link BaseRestWebHookEvent web hook event} that best matches the entity or empty if one doesn't match
     */
    @Nonnull
    Optional<? extends BaseRestWebHookEvent> convert(@Nonnull UpstreamServerType upstreamType,
                                                     @Nonnull RestUnknownEntity unknownEntity);
}
