com.mailgun.model.webhooks.WebhookUpdateRequest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mailgun-java Show documentation
Show all versions of mailgun-java Show documentation
The Mailgun SDK for Java enables Java developers to work with Mailgun API
efficiently.
The newest version!
package com.mailgun.model.webhooks;
import feign.form.FormProperty;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Singular;
import lombok.ToString;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.Set;
import static com.mailgun.util.Constants.FIELD_CANNOT_BE_NULL_OR_EMPTY;
/**
*
* Webhook update request.
*
*
* @see Webhooks
*/
@Getter
@ToString
@EqualsAndHashCode
@Builder
public class WebhookUpdateRequest {
/**
*
* URLs for the webhook event.
* Only up to 3 URLs are supported.
*
*/
@Singular
@FormProperty("url")
Set urls;
public static WebhookUpdateRequestBuilder builder() {
return new CustomWebhookUpdateRequestBuilder();
}
private static class CustomWebhookUpdateRequestBuilder extends WebhookUpdateRequestBuilder {
public WebhookUpdateRequest build() {
if (CollectionUtils.isEmpty(super.urls)) {
throw new IllegalArgumentException(String.format(FIELD_CANNOT_BE_NULL_OR_EMPTY, "url(s)"));
}
super.urls.stream()
.filter(StringUtils::isNotBlank)
.findFirst()
.orElseThrow(() -> new IllegalArgumentException(String.format(FIELD_CANNOT_BE_NULL_OR_EMPTY, "url(s)")));
return super.build();
}
}
public static class WebhookUpdateRequestBuilder {
}
}