diff --git a/README.md b/README.md index b82fb5a..c79cddc 100644 --- a/README.md +++ b/README.md @@ -908,6 +908,8 @@ public void getInboundRoute() { ### Create an inbound route +Call `includeAttachments(false)` to drop attachments before the message is forwarded. It defaults to `true`. Inline (CID) parts count as attachments, so images embedded in an HTML body are dropped too. + ```java import com.mailersend.sdk.MailerSend; import com.mailersend.sdk.exceptions.MailerSendException; @@ -932,6 +934,7 @@ public void createInboundRoute() { .domainEnabled(false) .matchFilter("match_all") .forwards(new Forward[] { forward }) + .includeAttachments(false) .addRoute(); } catch (MailerSendException e) { @@ -944,6 +947,8 @@ public void createInboundRoute() { ### Update an inbound route +Leaving `includeAttachments()` unset keeps the route's stored value; the API does not reset it to `true`. Pass `false` explicitly to drop attachments. + ```java import com.mailersend.sdk.MailerSend; import com.mailersend.sdk.exceptions.MailerSendException; @@ -969,6 +974,7 @@ public void updateInboundRoute() { .domainEnabled(false) .matchFilter("match_all") .forwards(new Forward[] { forward }) + .includeAttachments(true) .updateRoute("inbound route id"); System.out.println(route.id); diff --git a/src/main/java/com/mailersend/sdk/inboundroutes/InboundRoute.java b/src/main/java/com/mailersend/sdk/inboundroutes/InboundRoute.java index d5a90a4..b28e733 100644 --- a/src/main/java/com/mailersend/sdk/inboundroutes/InboundRoute.java +++ b/src/main/java/com/mailersend/sdk/inboundroutes/InboundRoute.java @@ -47,6 +47,9 @@ public class InboundRoute { @SerializedName("priority") public int priority; + @SerializedName("include_attachments") + public boolean includeAttachments; + /** *

postDeserialize.

diff --git a/src/main/java/com/mailersend/sdk/inboundroutes/InboundRouteBuilder.java b/src/main/java/com/mailersend/sdk/inboundroutes/InboundRouteBuilder.java index ea8ce01..4c3b095 100644 --- a/src/main/java/com/mailersend/sdk/inboundroutes/InboundRouteBuilder.java +++ b/src/main/java/com/mailersend/sdk/inboundroutes/InboundRouteBuilder.java @@ -189,6 +189,22 @@ public InboundRouteBuilder forwards(Forward[] forwards) { builderBody.forwards = forwards; return this; } + + /** + *

includeAttachments.

+ * + *

Forwards attachments with the message. Defaults to {@code true}. Set it to + * {@code false} to drop them before the message is forwarded; inline (CID) parts count as + * attachments, so images embedded in an HTML body are dropped too. Leaving this unset on + * an update keeps the route's stored value.

+ * + * @param includeAttachments a boolean. + * @return a {@link com.mailersend.sdk.inboundroutes.InboundRouteBuilder} object. + */ + public InboundRouteBuilder includeAttachments(boolean includeAttachments) { + builderBody.includeAttachments = includeAttachments; + return this; + } private static final String[] VALID_CATCH_FILTER_TYPES = {"catch_all", "catch_recipient"}; diff --git a/src/main/java/com/mailersend/sdk/inboundroutes/InboundRouteBuilderBody.java b/src/main/java/com/mailersend/sdk/inboundroutes/InboundRouteBuilderBody.java index 82df048..150f1aa 100644 --- a/src/main/java/com/mailersend/sdk/inboundroutes/InboundRouteBuilderBody.java +++ b/src/main/java/com/mailersend/sdk/inboundroutes/InboundRouteBuilderBody.java @@ -55,6 +55,13 @@ public class InboundRouteBuilderBody { @SerializedName("forwards") public Forward[] forwards; + /** + * Optional. Boxed so an unset value is omitted from the request body: the API keeps + * the route's stored value when the key is absent, and rejects an explicit null. + */ + @SerializedName("include_attachments") + public Boolean includeAttachments; + /** *

reset.

*/ @@ -71,5 +78,6 @@ public void reset() { matchFilter = null; matchType = null; forwards = null; + includeAttachments = null; } } diff --git a/src/test/resources/fixtures/InboundRoutesTest_AddInboundRouteTest().json b/src/test/resources/fixtures/InboundRoutesTest_AddInboundRouteTest().json index b8aec1f..afd487f 100644 --- a/src/test/resources/fixtures/InboundRoutesTest_AddInboundRouteTest().json +++ b/src/test/resources/fixtures/InboundRoutesTest_AddInboundRouteTest().json @@ -1 +1 @@ -{"b8a0377fe05e24ddd4159a4076934d0e3fb8dad1":{"body":"{\"data\":{\"id\":\"jpr9084z9xlw63dn\",\"name\":\"Test inbound name\",\"address\":\"emcbcwyz41fdrr7uuiz1@inbound.mailersend.net\",\"domain\":null,\"dns_checked_at\":null,\"enabled\":true,\"filters\":[{\"type\":\"match_all\",\"key\":null,\"comparer\":null,\"value\":null}],\"forwards\":[{\"type\":\"webhook\",\"value\":\"https:\\/\\/example-domain.com\",\"secret\":\"FRwZFJCkf7nbydrn0oq9uLc76USD4iaI\"}],\"mxValues\":{\"priority\":\"10\",\"target\":\"inbound.mailersend.net\"}}}","headers":{":status":["201"],"cache-control":["no-cache, private"],"cf-cache-status":["DYNAMIC"],"cf-ray":["73d3b22358826f68-ATH"],"content-type":["application/json"],"date":["Fri, 19 Aug 2022 14:49:26 GMT"],"expect-ct":["max-age\u003d604800, report-uri\u003d\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\""],"server":["cloudflare"],"strict-transport-security":["max-age\u003d15724800; includeSubDomains"],"x-apiquota-remaining":["-1"],"x-apiquota-reset":["2022-08-20T00:00:00Z"],"x-ratelimit-limit":["60"],"x-ratelimit-remaining":["57"]},"statusCode":201}} \ No newline at end of file +{"b8a0377fe05e24ddd4159a4076934d0e3fb8dad1":{"body":"{\"data\":{\"id\":\"jpr9084z9xlw63dn\",\"name\":\"Test inbound name\",\"address\":\"emcbcwyz41fdrr7uuiz1@inbound.mailersend.net\",\"domain\":null,\"dns_checked_at\":null,\"enabled\":true,\"filters\":[{\"type\":\"match_all\",\"key\":null,\"comparer\":null,\"value\":null}],\"forwards\":[{\"type\":\"webhook\",\"value\":\"https:\\/\\/example-domain.com\",\"secret\":\"FRwZFJCkf7nbydrn0oq9uLc76USD4iaI\"}],\"mxValues\":{\"priority\":\"10\",\"target\":\"inbound.mailersend.net\"},\"include_attachments\":true}}","headers":{":status":["201"],"cache-control":["no-cache, private"],"cf-cache-status":["DYNAMIC"],"cf-ray":["73d3b22358826f68-ATH"],"content-type":["application/json"],"date":["Fri, 19 Aug 2022 14:49:26 GMT"],"expect-ct":["max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\""],"server":["cloudflare"],"strict-transport-security":["max-age=15724800; includeSubDomains"],"x-apiquota-remaining":["-1"],"x-apiquota-reset":["2022-08-20T00:00:00Z"],"x-ratelimit-limit":["60"],"x-ratelimit-remaining":["57"]},"statusCode":201}} \ No newline at end of file diff --git a/src/test/resources/fixtures/InboundRoutesTest_InboundRoutesListTest().json b/src/test/resources/fixtures/InboundRoutesTest_InboundRoutesListTest().json index b369c97..6050d75 100644 --- a/src/test/resources/fixtures/InboundRoutesTest_InboundRoutesListTest().json +++ b/src/test/resources/fixtures/InboundRoutesTest_InboundRoutesListTest().json @@ -1 +1 @@ -{"da3edc8bde57193e98e999a2ac1899738b69b5b5":{"body":"{\"data\":[{\"id\":\"x3vz9dleq7lkj50y\",\"name\":\"test\",\"address\":\"fqs5shof9gvwsxs7hwaz@inbound.mailersend.net\",\"domain\":null,\"dns_checked_at\":null,\"enabled\":true,\"filters\":[{\"type\":\"match_all\",\"key\":null,\"comparer\":null,\"value\":null}],\"forwards\":[{\"type\":\"webhook\",\"value\":\"https:\\/\\/api-003.mailerlite.dev\",\"secret\":\"yAI5fwx9hR0K4gzeOxW6YBrMcoHtLtoc\"}],\"mxValues\":{\"priority\":\"10\",\"target\":\"inbound.mailersend.net\"}},{\"id\":\"83yxj6ljoq4do2rm\",\"name\":\"Test inbound name\",\"address\":\"vxlarh7vthhnagf3zved@inbound.mailersend.net\",\"domain\":null,\"dns_checked_at\":null,\"enabled\":true,\"filters\":[{\"type\":\"match_all\",\"key\":null,\"comparer\":null,\"value\":null}],\"forwards\":[{\"type\":\"webhook\",\"value\":\"https:\\/\\/example.com\",\"secret\":\"9IAyXyE6eAg2pre8QQfvcs3VPJSS8iaW\"}],\"mxValues\":{\"priority\":\"10\",\"target\":\"inbound.mailersend.net\"}},{\"id\":\"jpr9084z9xlw63dn\",\"name\":\"Test inbound name\",\"address\":\"emcbcwyz41fdrr7uuiz1@inbound.mailersend.net\",\"domain\":null,\"dns_checked_at\":null,\"enabled\":true,\"filters\":[{\"type\":\"match_all\",\"key\":null,\"comparer\":null,\"value\":null}],\"forwards\":[{\"type\":\"webhook\",\"value\":\"https:\\/\\/example-domain.com\",\"secret\":\"FRwZFJCkf7nbydrn0oq9uLc76USD4iaI\"}],\"mxValues\":{\"priority\":\"10\",\"target\":\"inbound.mailersend.net\"}}],\"links\":{\"first\":\"https:\\/\\/api.mailersend.com\\/v1\\/inbound?page\u003d1\",\"last\":\"https:\\/\\/api.mailersend.com\\/v1\\/inbound?page\u003d1\",\"prev\":null,\"next\":null},\"meta\":{\"current_page\":1,\"from\":1,\"last_page\":1,\"links\":[{\"url\":null,\"label\":\"\u0026laquo; Previous\",\"active\":false},{\"url\":\"https:\\/\\/api.mailersend.com\\/v1\\/inbound?page\u003d1\",\"label\":\"1\",\"active\":true},{\"url\":null,\"label\":\"Next \u0026raquo;\",\"active\":false}],\"path\":\"https:\\/\\/api.mailersend.com\\/v1\\/inbound\",\"per_page\":25,\"to\":3,\"total\":3}}","headers":{":status":["200"],"cache-control":["no-cache, private"],"cf-cache-status":["DYNAMIC"],"cf-ray":["73d3b63a9a016f5f-ATH"],"content-type":["application/json"],"date":["Fri, 19 Aug 2022 14:52:14 GMT"],"expect-ct":["max-age\u003d604800, report-uri\u003d\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\""],"server":["cloudflare"],"strict-transport-security":["max-age\u003d15724800; includeSubDomains"],"x-apiquota-remaining":["-1"],"x-apiquota-reset":["2022-08-20T00:00:00Z"],"x-ratelimit-limit":["60"],"x-ratelimit-remaining":["59"]},"statusCode":200}} \ No newline at end of file +{"da3edc8bde57193e98e999a2ac1899738b69b5b5":{"body":"{\"data\":[{\"id\":\"x3vz9dleq7lkj50y\",\"name\":\"test\",\"address\":\"fqs5shof9gvwsxs7hwaz@inbound.mailersend.net\",\"domain\":null,\"dns_checked_at\":null,\"enabled\":true,\"filters\":[{\"type\":\"match_all\",\"key\":null,\"comparer\":null,\"value\":null}],\"forwards\":[{\"type\":\"webhook\",\"value\":\"https:\\/\\/api-003.mailerlite.dev\",\"secret\":\"yAI5fwx9hR0K4gzeOxW6YBrMcoHtLtoc\"}],\"mxValues\":{\"priority\":\"10\",\"target\":\"inbound.mailersend.net\"},\"include_attachments\":true},{\"id\":\"83yxj6ljoq4do2rm\",\"name\":\"Test inbound name\",\"address\":\"vxlarh7vthhnagf3zved@inbound.mailersend.net\",\"domain\":null,\"dns_checked_at\":null,\"enabled\":true,\"filters\":[{\"type\":\"match_all\",\"key\":null,\"comparer\":null,\"value\":null}],\"forwards\":[{\"type\":\"webhook\",\"value\":\"https:\\/\\/example.com\",\"secret\":\"9IAyXyE6eAg2pre8QQfvcs3VPJSS8iaW\"}],\"mxValues\":{\"priority\":\"10\",\"target\":\"inbound.mailersend.net\"},\"include_attachments\":true},{\"id\":\"jpr9084z9xlw63dn\",\"name\":\"Test inbound name\",\"address\":\"emcbcwyz41fdrr7uuiz1@inbound.mailersend.net\",\"domain\":null,\"dns_checked_at\":null,\"enabled\":true,\"filters\":[{\"type\":\"match_all\",\"key\":null,\"comparer\":null,\"value\":null}],\"forwards\":[{\"type\":\"webhook\",\"value\":\"https:\\/\\/example-domain.com\",\"secret\":\"FRwZFJCkf7nbydrn0oq9uLc76USD4iaI\"}],\"mxValues\":{\"priority\":\"10\",\"target\":\"inbound.mailersend.net\"},\"include_attachments\":true}],\"links\":{\"first\":\"https:\\/\\/api.mailersend.com\\/v1\\/inbound?page=1\",\"last\":\"https:\\/\\/api.mailersend.com\\/v1\\/inbound?page=1\",\"prev\":null,\"next\":null},\"meta\":{\"current_page\":1,\"from\":1,\"last_page\":1,\"links\":[{\"url\":null,\"label\":\"« Previous\",\"active\":false},{\"url\":\"https:\\/\\/api.mailersend.com\\/v1\\/inbound?page=1\",\"label\":\"1\",\"active\":true},{\"url\":null,\"label\":\"Next »\",\"active\":false}],\"path\":\"https:\\/\\/api.mailersend.com\\/v1\\/inbound\",\"per_page\":25,\"to\":3,\"total\":3}}","headers":{":status":["200"],"cache-control":["no-cache, private"],"cf-cache-status":["DYNAMIC"],"cf-ray":["73d3b63a9a016f5f-ATH"],"content-type":["application/json"],"date":["Fri, 19 Aug 2022 14:52:14 GMT"],"expect-ct":["max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\""],"server":["cloudflare"],"strict-transport-security":["max-age=15724800; includeSubDomains"],"x-apiquota-remaining":["-1"],"x-apiquota-reset":["2022-08-20T00:00:00Z"],"x-ratelimit-limit":["60"],"x-ratelimit-remaining":["59"]},"statusCode":200}} \ No newline at end of file diff --git a/src/test/resources/fixtures/InboundRoutesTest_SingleInboundRouteTest().json b/src/test/resources/fixtures/InboundRoutesTest_SingleInboundRouteTest().json index 13f8104..58e48c7 100644 --- a/src/test/resources/fixtures/InboundRoutesTest_SingleInboundRouteTest().json +++ b/src/test/resources/fixtures/InboundRoutesTest_SingleInboundRouteTest().json @@ -1 +1 @@ -{"981d4a16b72bd8c0fba5563dabfb4f5498c48ae9":{"body":"{\"data\":{\"id\":\"83yxj6ljoq4do2rm\",\"name\":\"Test inbound name\",\"address\":\"vxlarh7vthhnagf3zved@inbound.mailersend.net\",\"domain\":null,\"dns_checked_at\":null,\"enabled\":true,\"filters\":[{\"type\":\"match_all\",\"key\":null,\"comparer\":null,\"value\":null}],\"forwards\":[{\"type\":\"webhook\",\"value\":\"https:\\/\\/example.com\",\"secret\":\"9IAyXyE6eAg2pre8QQfvcs3VPJSS8iaW\"}],\"mxValues\":{\"priority\":\"10\",\"target\":\"inbound.mailersend.net\"}}}","headers":{":status":["200"],"cache-control":["no-cache, private"],"cf-cache-status":["DYNAMIC"],"cf-ray":["73d3ba6eded638c9-ATH"],"content-type":["application/json"],"date":["Fri, 19 Aug 2022 14:55:06 GMT"],"expect-ct":["max-age\u003d604800, report-uri\u003d\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\""],"server":["cloudflare"],"strict-transport-security":["max-age\u003d15724800; includeSubDomains"],"x-apiquota-remaining":["-1"],"x-apiquota-reset":["2022-08-20T00:00:00Z"],"x-ratelimit-limit":["60"],"x-ratelimit-remaining":["59"]},"statusCode":200}} \ No newline at end of file +{"981d4a16b72bd8c0fba5563dabfb4f5498c48ae9":{"body":"{\"data\":{\"id\":\"83yxj6ljoq4do2rm\",\"name\":\"Test inbound name\",\"address\":\"vxlarh7vthhnagf3zved@inbound.mailersend.net\",\"domain\":null,\"dns_checked_at\":null,\"enabled\":true,\"filters\":[{\"type\":\"match_all\",\"key\":null,\"comparer\":null,\"value\":null}],\"forwards\":[{\"type\":\"webhook\",\"value\":\"https:\\/\\/example.com\",\"secret\":\"9IAyXyE6eAg2pre8QQfvcs3VPJSS8iaW\"}],\"mxValues\":{\"priority\":\"10\",\"target\":\"inbound.mailersend.net\"},\"include_attachments\":true}}","headers":{":status":["200"],"cache-control":["no-cache, private"],"cf-cache-status":["DYNAMIC"],"cf-ray":["73d3ba6eded638c9-ATH"],"content-type":["application/json"],"date":["Fri, 19 Aug 2022 14:55:06 GMT"],"expect-ct":["max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\""],"server":["cloudflare"],"strict-transport-security":["max-age=15724800; includeSubDomains"],"x-apiquota-remaining":["-1"],"x-apiquota-reset":["2022-08-20T00:00:00Z"],"x-ratelimit-limit":["60"],"x-ratelimit-remaining":["59"]},"statusCode":200}} \ No newline at end of file diff --git a/src/test/resources/fixtures/InboundRoutesTest_UpdateInboundRouteTest().json b/src/test/resources/fixtures/InboundRoutesTest_UpdateInboundRouteTest().json index fe90a6c..0699ce9 100644 --- a/src/test/resources/fixtures/InboundRoutesTest_UpdateInboundRouteTest().json +++ b/src/test/resources/fixtures/InboundRoutesTest_UpdateInboundRouteTest().json @@ -1 +1 @@ -{"1aff61f4d4446105b742718ccb14f912cd075602":{"body":"{\"data\":{\"id\":\"83yxj6ljoq4do2rm\",\"name\":\"Updated route name\",\"address\":\"vxlarh7vthhnagf3zved@inbound.mailersend.net\",\"domain\":null,\"dns_checked_at\":null,\"enabled\":true,\"filters\":[{\"type\":\"match_all\",\"key\":null,\"comparer\":null,\"value\":null}],\"forwards\":[{\"type\":\"webhook\",\"value\":\"https:\\/\\/example.com\",\"secret\":\"9IAyXyE6eAg2pre8QQfvcs3VPJSS8iaW\"}],\"mxValues\":{\"priority\":\"10\",\"target\":\"inbound.mailersend.net\"}}}","headers":{":status":["200"],"cache-control":["no-cache, private"],"cf-cache-status":["DYNAMIC"],"cf-ray":["73d3bf27ad6238d6-ATH"],"content-type":["application/json"],"date":["Fri, 19 Aug 2022 14:58:19 GMT"],"expect-ct":["max-age\u003d604800, report-uri\u003d\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\""],"server":["cloudflare"],"strict-transport-security":["max-age\u003d15724800; includeSubDomains"],"x-apiquota-remaining":["-1"],"x-apiquota-reset":["2022-08-20T00:00:00Z"],"x-ratelimit-limit":["60"],"x-ratelimit-remaining":["59"]},"statusCode":200}} \ No newline at end of file +{"1aff61f4d4446105b742718ccb14f912cd075602":{"body":"{\"data\":{\"id\":\"83yxj6ljoq4do2rm\",\"name\":\"Updated route name\",\"address\":\"vxlarh7vthhnagf3zved@inbound.mailersend.net\",\"domain\":null,\"dns_checked_at\":null,\"enabled\":true,\"filters\":[{\"type\":\"match_all\",\"key\":null,\"comparer\":null,\"value\":null}],\"forwards\":[{\"type\":\"webhook\",\"value\":\"https:\\/\\/example.com\",\"secret\":\"9IAyXyE6eAg2pre8QQfvcs3VPJSS8iaW\"}],\"mxValues\":{\"priority\":\"10\",\"target\":\"inbound.mailersend.net\"},\"include_attachments\":true}}","headers":{":status":["200"],"cache-control":["no-cache, private"],"cf-cache-status":["DYNAMIC"],"cf-ray":["73d3bf27ad6238d6-ATH"],"content-type":["application/json"],"date":["Fri, 19 Aug 2022 14:58:19 GMT"],"expect-ct":["max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\""],"server":["cloudflare"],"strict-transport-security":["max-age=15724800; includeSubDomains"],"x-apiquota-remaining":["-1"],"x-apiquota-reset":["2022-08-20T00:00:00Z"],"x-ratelimit-limit":["60"],"x-ratelimit-remaining":["59"]},"statusCode":200}} \ No newline at end of file diff --git a/src/test/resources/fixtures/InboundRoutesTest_inbound_domain_not_required_when_domain_enabled_is_false().json b/src/test/resources/fixtures/InboundRoutesTest_inbound_domain_not_required_when_domain_enabled_is_false().json index 2408b87..d3eccf8 100644 --- a/src/test/resources/fixtures/InboundRoutesTest_inbound_domain_not_required_when_domain_enabled_is_false().json +++ b/src/test/resources/fixtures/InboundRoutesTest_inbound_domain_not_required_when_domain_enabled_is_false().json @@ -1 +1 @@ -{"ad464b3b9851abf34d634bda2b845511b51fad7e":{"body":"{\"data\":{\"id\":\"jpr9084z9xlw63dn\",\"name\":\"Test inbound name\",\"address\":\"emcbcwyz41fdrr7uuiz1@inbound.mailersend.net\",\"domain\":null,\"dns_checked_at\":null,\"enabled\":true,\"filters\":[{\"type\":\"match_all\",\"key\":null,\"comparer\":null,\"value\":null}],\"forwards\":[],\"mxValues\":{\"priority\":\"10\",\"target\":\"inbound.mailersend.net\"}}}","headers":{":status":["201"],"cache-control":["no-cache, private"],"content-type":["application/json"],"date":["Fri, 19 Aug 2022 14:49:26 GMT"],"server":["cloudflare"]},"statusCode":201}} \ No newline at end of file +{"ad464b3b9851abf34d634bda2b845511b51fad7e":{"body":"{\"data\":{\"id\":\"jpr9084z9xlw63dn\",\"name\":\"Test inbound name\",\"address\":\"emcbcwyz41fdrr7uuiz1@inbound.mailersend.net\",\"domain\":null,\"dns_checked_at\":null,\"enabled\":true,\"filters\":[{\"type\":\"match_all\",\"key\":null,\"comparer\":null,\"value\":null}],\"forwards\":[],\"mxValues\":{\"priority\":\"10\",\"target\":\"inbound.mailersend.net\"},\"include_attachments\":true}}","headers":{":status":["201"],"cache-control":["no-cache, private"],"content-type":["application/json"],"date":["Fri, 19 Aug 2022 14:49:26 GMT"],"server":["cloudflare"]},"statusCode":201}} \ No newline at end of file