# Wishlist

The WISHLIST engagement allows users to send an email to all customers awaiting certain event (e.g. the customer receives a notification that the shoe size he is waiting for is now available). In order to use it, the eCommerce platform needs to send two additional events.

# TOPIC OBSERVE

Url: https://api.edrone.me/topic_observe

Sent when the customer observes an event (e.g. shoe size availability)

Field Description
app_id See Trace API below
email See Trace API below
topic_id Topic identifier is used to match topic_observe event with topic_publish event.
topic_campaign_id Campaign identifier of the observed topic. It is mapped to the email design. The default setup is the same design for all wishlist topics. If you would like to create more designs please contact our support.
<script>
    const subscribeButton = document.querySelector('#__subscribe-button');
    
    if (subscribeButton) {
        subscribeButton.addEventListener('click', function() {
            const email = document.querySelector('#email')?.value ?? '';
            const productId = document.querySelector('#product-box')?.getAttribute('data-product-id') ?? '';
            const xhr = new XMLHttpRequest();

            xhr.open("POST", "https://api.edrone.me/topic_observe", true);
            xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
            xhr.onreadystatechange = () => {
                if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
                    // Request finished - handle this part based on your needs.
                }
            };
            xhr.send(JSON.stringify({
                app_id: '[YOUR_APP_ID]',
                email: email,
                topic_id: productId, //unique per topic
                topic_campaign_id: 0 // 0 - default email design
            }));
        });
    }
</script>

Example https://api.edrone.me/topic_observe?app_id=bdag3h3563u&email=przykladowyemail@gmail.com&topic_id=dg623be63bbs&topic_campaign_id=0&action_type=topic_observe

# TOPIC PUBLISH

Trigger notification for all the customers observing the topic. Url: https://api.edrone.me/topic_publish

Value Description
app_id See Trace API below
topic_id Topic identifier is used to match topic_observe event with topic_publish event.
product_ids See Trace API below
product_urls CSee Trace API below
product_skus See Trace API below
product_titles See Trace API below
product_images See Trace API below
product_category_ids See Trace API below
product_category_names See Trace API below
product_brand_ids See Trace API below
product_brand_names See Trace API below
<script>
    const notifyAvailability = document.querySelector('#notify-availability');

    if (notifyAvailability) {
        notifyAvailability.addEventListener('click', function() {
            const productId = document.querySelector('#product-id-input')?.value ?? '';
            const xhr = new XMLHttpRequest();

            xhr.open("POST", "https://api.edrone.me/topic_publish", true);
            xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
            xhr.onreadystatechange = () => {
                if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
                    // Request finished - handle this part based on your needs.
                }
            };
            xhr.send(JSON.stringify({
                app_id: '[YOUR_APP_ID]',
                topic_id: productId,
                product_ids: 'example value',
                product_urls: 'example value',
                product_skus: 'example value',
                product_titles: 'example value',
                product_images: 'example value',
                product_category_ids: 'example value',
                product_category_names: 'example value',
                product_brand_ids: 'example value',
                product_brand_names: 'example value'
            }));
        });
    }
</script>

# GET SUBSCRIBERS COUNT

Returns the number of currently subscribed customers for a specific productId.
Url https://api.edrone.me/wishlist_get_subscribers_count?app_id=XX&product_id=XX

Field Description
app_id See Trace API below
product_id Id of product we ask for