|
| 1 | +package com.mailgun.api.v1; |
| 2 | + |
| 3 | +import com.mailgun.api.MailgunApi; |
| 4 | +import com.mailgun.enums.ApiVersion; |
| 5 | +import com.mailgun.model.webhooks.AccountWebhook; |
| 6 | +import com.mailgun.model.webhooks.AccountWebhookCreatedResult; |
| 7 | +import com.mailgun.model.webhooks.AccountWebhookListResult; |
| 8 | +import com.mailgun.model.webhooks.AccountWebhookRequest; |
| 9 | +import com.mailgun.model.webhooks.AccountWebhooksDeleteQuery; |
| 10 | +import com.mailgun.model.webhooks.AccountWebhooksListQuery; |
| 11 | +import feign.Headers; |
| 12 | +import feign.Param; |
| 13 | +import feign.QueryMap; |
| 14 | +import feign.RequestLine; |
| 15 | +import feign.Response; |
| 16 | + |
| 17 | +/** |
| 18 | + * Account Webhooks API (v1): create, retrieve, update, and delete account-level webhooks. |
| 19 | + * Account-level webhooks are configured independently for US and EU regions. |
| 20 | + * When triggered, webhook URLs are deduplicated by event type across account and domain levels. |
| 21 | + * Note: Webhook changes can take up to 10 minutes to become effective due to caching. |
| 22 | + * |
| 23 | + * @see <a href="https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/account-webhooks/get-v1-webhooks.md">List account-level webhooks</a> |
| 24 | + * @see <a href="https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/account-webhooks/post-v1-webhooks.md">Create an account-level webhook</a> |
| 25 | + * @see <a href="https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/account-webhooks/put-v1-webhooks--webhook-id-.md">Update an account-level webhook</a> |
| 26 | + * @see <a href="https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/account-webhooks/delete-v1-webhooks.md">Delete account-level webhooks</a> |
| 27 | + * @see <a href="https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/account-webhooks/get-v1-webhooks--webhook-id-.md">Get account-level webhook by ID</a> |
| 28 | + * @see <a href="https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/account-webhooks/delete-v1-webhooks--webhook-id-.md">Delete account-level webhook by ID</a> |
| 29 | + */ |
| 30 | +@Headers("Accept: application/json") |
| 31 | +public interface MailgunAccountWebhooksApi extends MailgunApi { |
| 32 | + |
| 33 | + static ApiVersion getApiVersion() { |
| 34 | + return ApiVersion.V_1; |
| 35 | + } |
| 36 | + |
| 37 | + /** |
| 38 | + * Retrieve all account-level webhooks. |
| 39 | + * |
| 40 | + * @return {@link AccountWebhookListResult} |
| 41 | + */ |
| 42 | + @RequestLine("GET /webhooks") |
| 43 | + AccountWebhookListResult getAllWebhooks(); |
| 44 | + |
| 45 | + /** |
| 46 | + * Retrieve all account-level webhooks (raw response). |
| 47 | + * |
| 48 | + * @return {@link Response} |
| 49 | + */ |
| 50 | + @RequestLine("GET /webhooks") |
| 51 | + Response getAllWebhooksFeignResponse(); |
| 52 | + |
| 53 | + /** |
| 54 | + * Retrieve account-level webhooks filtered by specific webhook IDs. |
| 55 | + * |
| 56 | + * @param query {@link AccountWebhooksListQuery} optional filter by comma-separated webhook IDs |
| 57 | + * @return {@link AccountWebhookListResult} |
| 58 | + */ |
| 59 | + @RequestLine("GET /webhooks") |
| 60 | + AccountWebhookListResult getAllWebhooks(@QueryMap AccountWebhooksListQuery query); |
| 61 | + |
| 62 | + /** |
| 63 | + * Retrieve account-level webhooks filtered by specific webhook IDs (raw response). |
| 64 | + * |
| 65 | + * @param query {@link AccountWebhooksListQuery} optional filter by comma-separated webhook IDs |
| 66 | + * @return {@link Response} |
| 67 | + */ |
| 68 | + @RequestLine("GET /webhooks") |
| 69 | + Response getAllWebhooksFeignResponse(@QueryMap AccountWebhooksListQuery query); |
| 70 | + |
| 71 | + /** |
| 72 | + * Retrieve a specific account-level webhook by its ID. |
| 73 | + * |
| 74 | + * @param webhookId the webhook ID to retrieve |
| 75 | + * @return {@link AccountWebhook} |
| 76 | + */ |
| 77 | + @RequestLine("GET /webhooks/{webhook_id}") |
| 78 | + AccountWebhook getWebhook(@Param("webhook_id") String webhookId); |
| 79 | + |
| 80 | + /** |
| 81 | + * Retrieve a specific account-level webhook by its ID (raw response). |
| 82 | + * |
| 83 | + * @param webhookId the webhook ID to retrieve |
| 84 | + * @return {@link Response} |
| 85 | + */ |
| 86 | + @RequestLine("GET /webhooks/{webhook_id}") |
| 87 | + Response getWebhookFeignResponse(@Param("webhook_id") String webhookId); |
| 88 | + |
| 89 | + /** |
| 90 | + * Create an account-level webhook. |
| 91 | + * |
| 92 | + * @param request {@link AccountWebhookRequest} with url, event_types, and optional description |
| 93 | + * @return {@link AccountWebhookCreatedResult} containing the new webhook ID |
| 94 | + */ |
| 95 | + @Headers("Content-Type: multipart/form-data") |
| 96 | + @RequestLine("POST /webhooks") |
| 97 | + AccountWebhookCreatedResult createWebhook(AccountWebhookRequest request); |
| 98 | + |
| 99 | + /** |
| 100 | + * Create an account-level webhook (raw response). |
| 101 | + * |
| 102 | + * @param request {@link AccountWebhookRequest} with url, event_types, and optional description |
| 103 | + * @return {@link Response} |
| 104 | + */ |
| 105 | + @Headers("Content-Type: multipart/form-data") |
| 106 | + @RequestLine("POST /webhooks") |
| 107 | + Response createWebhookFeignResponse(AccountWebhookRequest request); |
| 108 | + |
| 109 | + /** |
| 110 | + * Update an existing account-level webhook by replacing its URL, description, and event types. |
| 111 | + * |
| 112 | + * @param webhookId the webhook ID to update |
| 113 | + * @param request {@link AccountWebhookRequest} with the replacement configuration |
| 114 | + * @return {@link AccountWebhookCreatedResult} containing the webhook ID |
| 115 | + */ |
| 116 | + @Headers("Content-Type: multipart/form-data") |
| 117 | + @RequestLine("PUT /webhooks/{webhook_id}") |
| 118 | + AccountWebhookCreatedResult updateWebhook(@Param("webhook_id") String webhookId, AccountWebhookRequest request); |
| 119 | + |
| 120 | + /** |
| 121 | + * Update an existing account-level webhook (raw response). |
| 122 | + * |
| 123 | + * @param webhookId the webhook ID to update |
| 124 | + * @param request {@link AccountWebhookRequest} with the replacement configuration |
| 125 | + * @return {@link Response} |
| 126 | + */ |
| 127 | + @Headers("Content-Type: multipart/form-data") |
| 128 | + @RequestLine("PUT /webhooks/{webhook_id}") |
| 129 | + Response updateWebhookFeignResponse(@Param("webhook_id") String webhookId, AccountWebhookRequest request); |
| 130 | + |
| 131 | + /** |
| 132 | + * Delete account-level webhooks. Either set {@code all=true} to remove all webhooks, |
| 133 | + * or provide {@code webhook_ids} to delete specific ones. |
| 134 | + * |
| 135 | + * @param query {@link AccountWebhooksDeleteQuery} specifying which webhooks to delete |
| 136 | + */ |
| 137 | + @RequestLine("DELETE /webhooks") |
| 138 | + void deleteWebhooks(@QueryMap AccountWebhooksDeleteQuery query); |
| 139 | + |
| 140 | + /** |
| 141 | + * Delete account-level webhooks (raw response). |
| 142 | + * |
| 143 | + * @param query {@link AccountWebhooksDeleteQuery} specifying which webhooks to delete |
| 144 | + * @return {@link Response} |
| 145 | + */ |
| 146 | + @RequestLine("DELETE /webhooks") |
| 147 | + Response deleteWebhooksFeignResponse(@QueryMap AccountWebhooksDeleteQuery query); |
| 148 | + |
| 149 | + /** |
| 150 | + * Delete a specific account-level webhook by its ID. |
| 151 | + * |
| 152 | + * @param webhookId the webhook ID to delete |
| 153 | + */ |
| 154 | + @RequestLine("DELETE /webhooks/{webhook_id}") |
| 155 | + void deleteWebhook(@Param("webhook_id") String webhookId); |
| 156 | + |
| 157 | + /** |
| 158 | + * Delete a specific account-level webhook by its ID (raw response). |
| 159 | + * |
| 160 | + * @param webhookId the webhook ID to delete |
| 161 | + * @return {@link Response} |
| 162 | + */ |
| 163 | + @RequestLine("DELETE /webhooks/{webhook_id}") |
| 164 | + Response deleteWebhookFeignResponse(@Param("webhook_id") String webhookId); |
| 165 | + |
| 166 | +} |
0 commit comments