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

com.arm.mbed.cloud.sdk.connect.adapters.WebhookAdapter Maven / Gradle / Ivy

Go to download

The Pelion Cloud SDK (formerly known as Mbed Cloud SDK) provides a simplified interface to the Pelion Cloud APIs by exposing functionality using conventions and paradigms familiar to Java developers.

There is a newer version: 2.5.0
Show newest version
package com.arm.mbed.cloud.sdk.connect.adapters;

import com.arm.mbed.cloud.sdk.annotations.Preamble;
import com.arm.mbed.cloud.sdk.common.GenericAdapter.Mapper;
import com.arm.mbed.cloud.sdk.common.TranslationUtils;
import com.arm.mbed.cloud.sdk.connect.model.Webhook;

@Preamble(description = "Adapter for webhook model")
public final class WebhookAdapter {

    private WebhookAdapter() {
        super();
    }

    /**
     * Maps a webhook.
     * 
     * @param apiWebhook
     *            webhook to map
     * @return a webhook
     */
    public static Webhook map(com.arm.mbed.cloud.sdk.lowlevel.pelionclouddevicemanagement.model.Webhook apiWebhook) {
        if (apiWebhook == null) {
            return null;
        }
        final Webhook webhook = new Webhook();
        webhook.setUrl(TranslationUtils.toUrl(apiWebhook.getUrl()));
        webhook.setHeaders(apiWebhook.getHeaders());
        return webhook;
    }

    /**
     * Gets a mapper.
     * 
     * @return mapper
     */
    public static Mapper
           getMapper() {
        return new Mapper() {

            @Override
            public Webhook map(com.arm.mbed.cloud.sdk.lowlevel.pelionclouddevicemanagement.model.Webhook toBeMapped) {
                return WebhookAdapter.map(toBeMapped);
            }

        };
    }

    /**
     * Reverses mapping of a new webhook.
     * 
     * @param webhook
     *            new webhook
     * @return a new webhook request
     */
    public static com.arm.mbed.cloud.sdk.lowlevel.pelionclouddevicemanagement.model.Webhook
           reverseMap(Webhook webhook) {
        if (webhook == null) {
            return null;
        }
        final com.arm.mbed.cloud.sdk.lowlevel.pelionclouddevicemanagement.model.Webhook internalWebhook = new com.arm.mbed.cloud.sdk.lowlevel.pelionclouddevicemanagement.model.Webhook();
        internalWebhook.setUrl(TranslationUtils.toString(webhook.getUrl()));
        internalWebhook.setHeaders(webhook.getHeaders());
        return internalWebhook;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy