-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add emails.share() method #127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/main/java/com/resend/services/emails/model/ShareEmailOptions.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| package com.resend.services.emails.model; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
|
||
| /** | ||
| * Represents a request to create a shareable link for an email. | ||
| */ | ||
| public class ShareEmailOptions { | ||
|
|
||
| @JsonProperty("expires_in") | ||
| private final String expiresIn; | ||
|
|
||
| private ShareEmailOptions(Builder builder) { | ||
|
|
||
| this.expiresIn = builder.expiresIn; | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| * Retrieves how long the shareable link stays valid for. | ||
| * | ||
| * @return The expiration duration of the shareable link. | ||
| */ | ||
| public String getExpiresIn() { | ||
| return expiresIn; | ||
| } | ||
|
|
||
| /** | ||
| * Creates a new builder instance to construct ShareEmailOptions. | ||
| * | ||
| * @return A new builder instance. | ||
| */ | ||
| public static Builder builder() { | ||
| return new Builder(); | ||
| } | ||
|
|
||
| /** | ||
| * Builder class for constructing ShareEmailOptions instances. | ||
| */ | ||
| public static class Builder { | ||
| /** | ||
| * Creates a new Builder instance. | ||
| */ | ||
| public Builder() { | ||
| } | ||
|
|
||
| private String expiresIn; | ||
|
|
||
| /** | ||
| * Set how long the shareable link stays valid for. | ||
| * | ||
| * @param expiresIn A human-readable duration (e.g., "10m", "2 hours", "1 day", "1h 30m"). Defaults to "48h" and is capped at 48 hours. | ||
| * @return This builder instance for method chaining. | ||
| */ | ||
| public Builder expiresIn(String expiresIn) { | ||
| this.expiresIn = expiresIn; | ||
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * Builds and returns a {@code ShareEmailOptions} based on the configured properties. | ||
| * | ||
| * @return A {@code ShareEmailOptions} instance. | ||
| */ | ||
| public ShareEmailOptions build() { | ||
| return new ShareEmailOptions(this); | ||
| } | ||
| } | ||
| } |
51 changes: 51 additions & 0 deletions
51
src/main/java/com/resend/services/emails/model/ShareEmailResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| package com.resend.services.emails.model; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
|
||
| /** | ||
| * Represents the share email response. | ||
| */ | ||
| public class ShareEmailResponse extends EmailResponse { | ||
|
|
||
| /** | ||
| * The shareable link URL for the email. | ||
| */ | ||
| @JsonProperty("url") | ||
| private String url; | ||
|
|
||
| /** | ||
| * Constructs a new instance of {@code ShareEmailResponse}. | ||
| */ | ||
| public ShareEmailResponse() { | ||
| } | ||
|
|
||
| /** | ||
| * Constructs a ShareEmailResponse with the provided ID, object and URL. | ||
| * | ||
| * @param id The ID associated with the email. | ||
| * @param object The resource object. | ||
| * @param url The shareable link URL for the email. | ||
| */ | ||
| public ShareEmailResponse(String id, String object, String url) { | ||
| super(id, object); | ||
| this.url = url; | ||
| } | ||
|
|
||
| /** | ||
| * Retrieves the shareable link URL for the email. | ||
| * | ||
| * @return The shareable link URL. | ||
| */ | ||
| public String getUrl() { | ||
| return url; | ||
| } | ||
|
|
||
| /** | ||
| * Sets the shareable link URL for the email. | ||
| * | ||
| * @param url The shareable link URL to be set. | ||
| */ | ||
| public void setUrl(String url) { | ||
| this.url = url; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.