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;
}
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;
}
Aggregations