Search in sources :

Example 1 with WebhookSubscriptionDTO

use of org.wso2.carbon.apimgt.rest.api.store.v1.dto.WebhookSubscriptionDTO in project carbon-apimgt by wso2.

the class AsyncAPIMappingUtil method fromSubscriptionToDTO.

/**
 * Converts a Subscription object to DTO.
 *
 * @param subscription Subscription object
 * @return WebhookSubscriptionDTO object
 */
public static WebhookSubscriptionDTO fromSubscriptionToDTO(Subscription subscription) {
    WebhookSubscriptionDTO webhookSubscriptionDTO = new WebhookSubscriptionDTO();
    webhookSubscriptionDTO.setTopic(subscription.getTopic());
    webhookSubscriptionDTO.setApiId(subscription.getApiUuid());
    webhookSubscriptionDTO.setAppId(subscription.getAppID());
    webhookSubscriptionDTO.setCallBackUrl(subscription.getCallback());
    webhookSubscriptionDTO.setDeliveryTime(getDateAsString(subscription.getLastDelivery()));
    webhookSubscriptionDTO.setDeliveryStatus(subscription.getLastDeliveryState());
    return webhookSubscriptionDTO;
}
Also used : WebhookSubscriptionDTO(org.wso2.carbon.apimgt.rest.api.store.v1.dto.WebhookSubscriptionDTO)

Example 2 with WebhookSubscriptionDTO

use of org.wso2.carbon.apimgt.rest.api.store.v1.dto.WebhookSubscriptionDTO in project carbon-apimgt by wso2.

the class AsyncAPIMappingUtil method fromSubscriptionListToDTO.

/**
 * Converts Set of Subscription objects to SubscriptionListDTO.
 *
 * @param subscriptions Set of Subscription objects
 * @return WebhookSubscriptionListDTO containing SubscriptionDTOs
 */
public static WebhookSubscriptionListDTO fromSubscriptionListToDTO(Set<Subscription> subscriptions) {
    WebhookSubscriptionListDTO webhookSubscriptionListDTO = new WebhookSubscriptionListDTO();
    List<WebhookSubscriptionDTO> subscriptionDTOs = webhookSubscriptionListDTO.getList();
    webhookSubscriptionListDTO.setCount(subscriptions.size());
    if (subscriptionDTOs == null) {
        subscriptionDTOs = new ArrayList<>();
        webhookSubscriptionListDTO.setList(subscriptionDTOs);
    }
    for (Subscription subscription : subscriptions) {
        subscriptionDTOs.add(fromSubscriptionToDTO(subscription));
    }
    return webhookSubscriptionListDTO;
}
Also used : WebhookSubscriptionListDTO(org.wso2.carbon.apimgt.rest.api.store.v1.dto.WebhookSubscriptionListDTO) WebhookSubscriptionDTO(org.wso2.carbon.apimgt.rest.api.store.v1.dto.WebhookSubscriptionDTO) Subscription(org.wso2.carbon.apimgt.api.model.webhooks.Subscription)

Aggregations

WebhookSubscriptionDTO (org.wso2.carbon.apimgt.rest.api.store.v1.dto.WebhookSubscriptionDTO)2 Subscription (org.wso2.carbon.apimgt.api.model.webhooks.Subscription)1 WebhookSubscriptionListDTO (org.wso2.carbon.apimgt.rest.api.store.v1.dto.WebhookSubscriptionListDTO)1