Skip to content

Commit

Permalink
fix: Naming conventions for classes (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
kewynakshlley committed Dec 29, 2023
1 parent 1f6c130 commit a3ed5a5
Show file tree
Hide file tree
Showing 21 changed files with 100 additions and 105 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ import com.resend.services.emails.ResendEmails;
public class Main {
public static void main(String[] args) {
Resend resend = new Resend("re_123");
SendEmailRequest sendEmailRequest = SendEmailRequest.builder()

CreateEmailOptions params = CreateEmailOptions.builder()
.from("Me <me@exemple.io>")
.to("to@example", "you@example.com")
.cc("carbon@example.com", "copy@example.com")
Expand All @@ -53,7 +53,7 @@ public class Main {
.build();

try {
SendEmailResponse data = resend.emails().send(sendEmailRequest);
CreateEmailResponse data = resend.emails().send(params);
System.out.println(data.getId());
} catch (ResendException e) {
e.printStackTrace();
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/resend/services/apikeys/ApiKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.resend.core.net.HttpMethod;
import com.resend.core.service.BaseService;
import com.resend.services.apikeys.model.CreateApiKeyResponse;
import com.resend.services.apikeys.model.CreateApiKeyRequest;
import com.resend.services.apikeys.model.CreateApiKeyOptions;
import com.resend.services.apikeys.model.ListApiKeysResponse;
import okhttp3.MediaType;

Expand All @@ -26,12 +26,12 @@ public ApiKeys(final String apiKey) {
/**
* Creates an API key.
*
* @param createApiKeyRequest The request the API key details.
* @param createApiKeyOptions The request the API key details.
* @return The response indicating the state of the api key.
* @throws ResendException If an error occurs during the API key creation process.
*/
public CreateApiKeyResponse create(CreateApiKeyRequest createApiKeyRequest) throws ResendException {
String payload = super.resendMapper.writeValue(createApiKeyRequest);
public CreateApiKeyResponse create(CreateApiKeyOptions createApiKeyOptions) throws ResendException {
String payload = super.resendMapper.writeValue(createApiKeyOptions);
AbstractHttpResponse<String> response = httpClient.perform("/api-keys", super.apiKey, HttpMethod.POST, payload, MediaType.get("application/json"));

if (!response.isSuccessful()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* Represents an API key item.
*/
public class ApiKeyItem {
public class ApiKey {

@JsonProperty("id")
private String id;
Expand All @@ -24,19 +24,19 @@ public class ApiKeyItem {
private OffsetDateTime createdAt;

/**
* Default constructor. Creates an instance of ApiKeyItem with default values.
* Default constructor. Creates an instance of ApiKey with default values.
*/
public ApiKeyItem() {
public ApiKey() {
}

/**
* Creates an instance of ApiKeyItem with the specified attributes.
* Creates an instance of ApiKey with the specified attributes.
*
* @param id The ID of the API key item.
* @param name The name of the API key item.
* @param createdAt The creation timestamp of the API key item.
*/
public ApiKeyItem(String id, String name, OffsetDateTime createdAt) {
public ApiKey(String id, String name, OffsetDateTime createdAt) {
this.id = id;
this.name = name;
this.createdAt = createdAt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* Represents a request to create an api key.
*/
public class CreateApiKeyRequest {
public class CreateApiKeyOptions {

@JsonProperty("name")
private final String name;
Expand All @@ -21,7 +21,7 @@ public class CreateApiKeyRequest {
*
* @param builder The builder to construct the API Key.
*/
public CreateApiKeyRequest(Builder builder) {
public CreateApiKeyOptions(Builder builder) {
this.name = builder.name;
this.permission = builder.permission;
this.domainId = builder.domainId;
Expand Down Expand Up @@ -109,8 +109,8 @@ public Builder domainId(String domainId) {
*
* @return A new CreateApiKeyRequest object.
*/
public CreateApiKeyRequest build() {
return new CreateApiKeyRequest(this);
public CreateApiKeyOptions build() {
return new CreateApiKeyOptions(this);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public class ListApiKeysResponse {

@JsonProperty("data")
private List<ApiKeyItem> data;
private List<ApiKey> data;

/**
* Default constructor. Creates an instance of ListApiKeysResponse with an empty data list.
Expand All @@ -23,7 +23,7 @@ public ListApiKeysResponse() {
*
* @param data The list of API key items.
*/
public ListApiKeysResponse(List<ApiKeyItem> data) {
public ListApiKeysResponse(List<ApiKey> data) {
this.data = data;
}

Expand All @@ -32,7 +32,7 @@ public ListApiKeysResponse(List<ApiKeyItem> data) {
*
* @return The list of API key items.
*/
public List<ApiKeyItem> getData() {
public List<ApiKey> getData() {
return data;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/resend/services/audiences/Audiences.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ public Audiences(final String apiKey) {
/**
* Creates an Audience.
*
* @param createAudienceRequestOptions The Audience details.
* @param createAudienceOptions The Audience details.
* @return The details of the created audience.
* @throws ResendException If an error occurs during the Audience creation process.
*/
public CreateAudienceResponseSuccess create(CreateAudienceRequestOptions createAudienceRequestOptions) throws ResendException {
String payload = super.resendMapper.writeValue(createAudienceRequestOptions);
public CreateAudienceResponseSuccess create(CreateAudienceOptions createAudienceOptions) throws ResendException {
String payload = super.resendMapper.writeValue(createAudienceOptions);
AbstractHttpResponse<String> response = httpClient.perform("/audiences", super.apiKey, HttpMethod.POST, payload, MediaType.get("application/json"));

if (!response.isSuccessful()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* Represents a request to create an audience with options.
*/
public class CreateAudienceRequestOptions {
public class CreateAudienceOptions {

@JsonProperty("name")
private final String name;
Expand All @@ -15,7 +15,7 @@ public class CreateAudienceRequestOptions {
*
* @param builder The builder to construct the Audience Options.
*/
public CreateAudienceRequestOptions(Builder builder) {
public CreateAudienceOptions(Builder builder) {
this.name = builder.name;
}

Expand All @@ -29,7 +29,7 @@ public String getName() {
}

/**
* Create a new builder instance for constructing CreateAudienceRequestOptions objects.
* Create a new builder instance for constructing CreateAudienceOptions objects.
*
* @return A new builder instance.
*/
Expand All @@ -38,7 +38,7 @@ public static Builder builder() {
}

/**
* Builder class for constructing CreateAudienceRequestOptions objects.
* Builder class for constructing CreateAudienceOptions objects.
*/
public static class Builder {
private String name;
Expand All @@ -55,12 +55,12 @@ public Builder name(String name) {
}

/**
* Build a new CreateAudienceRequestOptions object.
* Build a new CreateAudienceOptions object.
*
* @return A new CreateAudienceRequestOptions object.
* @return A new CreateAudienceOptions object.
*/
public CreateAudienceRequestOptions build() {
return new CreateAudienceRequestOptions(this);
public CreateAudienceOptions build() {
return new CreateAudienceOptions(this);
}
}
}
8 changes: 4 additions & 4 deletions src/main/java/com/resend/services/batch/Batch.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.resend.core.service.BaseService;

import com.resend.services.batch.model.CreateBatchEmailsResponse;
import com.resend.services.emails.model.SendEmailRequest;
import com.resend.services.emails.model.CreateEmailOptions;
import okhttp3.MediaType;

import java.util.List;
Expand All @@ -31,7 +31,7 @@ public Batch(final String apiKey) {
* @return The emails ids.
* @throws ResendException If an error occurs while sending batch emails.
*/
public CreateBatchEmailsResponse send(List<SendEmailRequest> emails) throws ResendException {
public CreateBatchEmailsResponse send(List<CreateEmailOptions> emails) throws ResendException {

String payload = super.resendMapper.writeValue(emails);
AbstractHttpResponse<String> response = super.httpClient.perform("/emails/batch", super.apiKey, HttpMethod.POST, payload, MediaType.get("application/json"));
Expand All @@ -50,11 +50,11 @@ public CreateBatchEmailsResponse send(List<SendEmailRequest> emails) throws Rese
/**
* Creates and sends a batch of email messages based on the provided list of email requests.
*
* @param emails A list of {@link SendEmailRequest} objects representing the email messages to be sent.
* @param emails A list of {@link CreateEmailOptions} objects representing the email messages to be sent.
* @return A {@link CreateBatchEmailsResponse} containing information about the created batch of emails.
* @throws ResendException if an error occurs during the creation and sending of the emails.
*/
public CreateBatchEmailsResponse create(List<SendEmailRequest> emails) throws ResendException {
public CreateBatchEmailsResponse create(List<CreateEmailOptions> emails) throws ResendException {
return this.send(emails);
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/resend/services/domains/Domains.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ public Domains(final String apiKey) {
}

/**
* Creates a domain based on the provided CreateDomainRequest and returns a CreateDomainResponse.
* Creates a domain based on the provided CreateDomainOptions and returns a CreateDomainResponse.
*
* @param createDomainRequest The request object containing the domain creation details.
* @param createDomainOptions The request object containing the domain creation details.
* @return A CreateDomainResponse representing the result of the domain creation operation.
* @throws ResendException If an error occurs during the domain creation process.
*/
public CreateDomainResponse create(CreateDomainRequest createDomainRequest) throws ResendException {
String payload = super.resendMapper.writeValue(createDomainRequest);
public CreateDomainResponse create(CreateDomainOptions createDomainOptions) throws ResendException {
String payload = super.resendMapper.writeValue(createDomainOptions);
AbstractHttpResponse<String> response = httpClient.perform("/domains", super.apiKey, HttpMethod.POST, payload, MediaType.get("application/json"));

if (!response.isSuccessful()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* Represents a request to create a domain.
*/
public class CreateDomainRequest {
public class CreateDomainOptions {

@JsonProperty("name")
private final String name;
Expand All @@ -14,11 +14,11 @@ public class CreateDomainRequest {
private final String region;

/**
* Constructs a CreateDomainRequest object using the provided builder.
* Constructs a CreateDomainOptions object using the provided builder.
*
* @param builder The builder to construct the CreateDomainRequest from.
* @param builder The builder to construct the CreateDomainOptions from.
*/
public CreateDomainRequest(Builder builder) {
public CreateDomainOptions(Builder builder) {
this.name = builder.name;
this.region = builder.region;
}
Expand All @@ -42,7 +42,7 @@ public String getRegion() {
}

/**
* Create a new builder instance for constructing CreateDomainRequest objects.
* Create a new builder instance for constructing CreateDomainOptions objects.
*
* @return A new builder instance.
*/
Expand All @@ -51,7 +51,7 @@ public static Builder builder() {
}

/**
* Builder class for constructing CreateDomainRequest objects.
* Builder class for constructing CreateDomainOptions objects.
*/
public static class Builder {
private String name;
Expand Down Expand Up @@ -80,12 +80,12 @@ public Builder region(String region) {
}

/**
* Build a new CreateDomainRequest object.
* Build a new CreateDomainOptions object.
*
* @return A new CreateDomainRequest object.
* @return A new CreateDomainOptions object.
*/
public CreateDomainRequest build() {
return new CreateDomainRequest(this);
public CreateDomainOptions build() {
return new CreateDomainOptions(this);
}
}
}
17 changes: 7 additions & 10 deletions src/main/java/com/resend/services/emails/Emails.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
import com.resend.core.net.AbstractHttpResponse;
import com.resend.core.net.HttpMethod;
import com.resend.core.service.BaseService;
import com.resend.services.batch.model.CreateBatchEmailsResponse;
import com.resend.services.emails.model.CreateEmailOptions;
import com.resend.services.emails.model.CreateEmailResponse;
import com.resend.services.emails.model.Email;
import com.resend.services.emails.model.SendEmailRequest;
import com.resend.services.emails.model.SendEmailResponse;
import okhttp3.MediaType;

import java.util.List;

/**
* Represents the Resend Emails module.
*/
Expand All @@ -29,13 +26,13 @@ public Emails(final String apiKey) {
/**
* Sends an email based on the provided email request.
*
* @param sendEmailRequest The request containing email details.
* @param createEmailOptions The request containing email details.
* @return The response indicating the status of the email sending.
* @throws ResendException If an error occurs while sending the email.
*/
public SendEmailResponse send(SendEmailRequest sendEmailRequest) throws ResendException {
public CreateEmailResponse send(CreateEmailOptions createEmailOptions) throws ResendException {

String payload = super.resendMapper.writeValue(sendEmailRequest);
String payload = super.resendMapper.writeValue(createEmailOptions);
AbstractHttpResponse<String> response = super.httpClient.perform("/emails", super.apiKey, HttpMethod.POST, payload, MediaType.get("application/json"));

if (!response.isSuccessful()) {
Expand All @@ -44,9 +41,9 @@ public SendEmailResponse send(SendEmailRequest sendEmailRequest) throws ResendEx

String responseBody = response.getBody();

SendEmailResponse sendEmailResponse = resendMapper.readValue(responseBody, SendEmailResponse.class);
CreateEmailResponse createEmailResponse = resendMapper.readValue(responseBody, CreateEmailResponse.class);

return sendEmailResponse;
return createEmailResponse;
}

/**
Expand Down
Loading

0 comments on commit a3ed5a5

Please sign in to comment.