Skip to content

Commit

Permalink
refactor (Mailgun/Java): Updated generated files for Form parameters …
Browse files Browse the repository at this point in the history
…serialization
  • Loading branch information
JPPortier committed Nov 26, 2024
1 parent 7ac54d7 commit 7b57bcb
Show file tree
Hide file tree
Showing 5 changed files with 273 additions and 707 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
import com.sinch.sdk.core.http.URLPathUtils;
import com.sinch.sdk.core.models.ServerConfiguration;
import com.sinch.sdk.domains.mailgun.models.v1.emails.request.SendEmailRequest;
import com.sinch.sdk.domains.mailgun.models.v1.emails.request.SendEmailRequestImpl;
import com.sinch.sdk.domains.mailgun.models.v1.emails.request.SendMimeEmailRequest;
import com.sinch.sdk.domains.mailgun.models.v1.emails.request.SendMimeEmailRequestImpl;
import com.sinch.sdk.domains.mailgun.models.v1.emails.response.GetStoredEmailResponse;
import com.sinch.sdk.domains.mailgun.models.v1.emails.response.SendEmailResponse;
import com.sinch.sdk.domains.mailgun.models.v1.emails.response.SendingQueuesStatusResponse;
Expand Down Expand Up @@ -324,8 +322,8 @@ public SendEmailResponse sendEmail(String domainName, SendEmailRequest requestPa
mapper.deserialize(response, new TypeReference<HashMap<String, ?>>() {}));
}

private HttpRequest sendEmailRequestBuilder(
String domainName, SendEmailRequest _requestParameters) throws ApiException {
private HttpRequest sendEmailRequestBuilder(String domainName, SendEmailRequest requestParameters)
throws ApiException {
// verify the required parameter 'domainName' is set
if (domainName == null) {
throw new ApiException(
Expand All @@ -338,79 +336,15 @@ private HttpRequest sendEmailRequestBuilder(
"\\{" + "domain_name" + "\\}",
URLPathUtils.encodePathSegment(domainName.toString()));

SendEmailRequestImpl requestParameters = (SendEmailRequestImpl) _requestParameters;
List<URLParameter> localVarQueryParams = new ArrayList<>();

Map<String, String> localVarHeaderParams = new HashMap<>();

final Collection<String> localVarAccepts = Arrays.asList("application/json");

final Collection<String> localVarContentTypes = Arrays.asList("multipart/form-data");

final Collection<String> localVarAuthNames = Arrays.asList("basicAuth");

HashMap<String, Object> localFormParams = new HashMap<>();
requestParameters.from().ifPresent(value -> localFormParams.put("from", value));
requestParameters.to().ifPresent(value -> localFormParams.put("to", value));
requestParameters.cc().ifPresent(value -> localFormParams.put("cc", value));
requestParameters.bcc().ifPresent(value -> localFormParams.put("bcc", value));
requestParameters.subject().ifPresent(value -> localFormParams.put("subject", value));
requestParameters.text().ifPresent(value -> localFormParams.put("text", value));
requestParameters.html().ifPresent(value -> localFormParams.put("html", value));
requestParameters.ampHtml().ifPresent(value -> localFormParams.put("amp-html", value));
requestParameters.attachment().ifPresent(value -> localFormParams.put("attachment", value));
requestParameters.inline().ifPresent(value -> localFormParams.put("inline", value));
requestParameters.template().ifPresent(value -> localFormParams.put("template", value));
requestParameters.templateVersion().ifPresent(value -> localFormParams.put("t:version", value));
requestParameters.templateText().ifPresent(value -> localFormParams.put("t:text", value));
requestParameters
.templateVariables()
.ifPresent(value -> localFormParams.put("t:variables", value));
requestParameters.tag().ifPresent(value -> localFormParams.put("o:tag", value));
requestParameters
.enableDkimSignature()
.ifPresent(value -> localFormParams.put("o:dkim", value));
requestParameters
.secondaryDkim()
.ifPresent(value -> localFormParams.put("o:secondary-dkim", value));
requestParameters
.secondaryDkimPublic()
.ifPresent(value -> localFormParams.put("o:secondary-dkim-public", value));
requestParameters
.deliveryTime()
.ifPresent(value -> localFormParams.put("o:deliverytime", value));
requestParameters
.deliveryTimeOptimizePeriod()
.ifPresent(value -> localFormParams.put("o:deliverytime-optimize-period", value));
requestParameters
.timezoneLocalize()
.ifPresent(value -> localFormParams.put("o:time-zone-localize", value));
requestParameters.testMode().ifPresent(value -> localFormParams.put("o:testmode", value));
requestParameters.tracking().ifPresent(value -> localFormParams.put("o:tracking", value));
requestParameters
.trackingClicks()
.ifPresent(value -> localFormParams.put("o:tracking-clicks", value));
requestParameters
.trackingOpens()
.ifPresent(value -> localFormParams.put("o:tracking-opens", value));
requestParameters.requireTls().ifPresent(value -> localFormParams.put("o:require-tls", value));
requestParameters
.skipVerification()
.ifPresent(value -> localFormParams.put("o:skip-verification", value));
requestParameters.sendingIp().ifPresent(value -> localFormParams.put("o:sending-ip", value));
requestParameters
.sendingIpPool()
.ifPresent(value -> localFormParams.put("o:sending-ip-pool", value));
requestParameters
.trackingPixelLocationTop()
.ifPresent(value -> localFormParams.put("o:tracking-pixel-location-top", value));
requestParameters
.hColonXMyHeader()
.ifPresent(value -> localFormParams.put("h:X-My-Header", value));
requestParameters.vColonMyVar().ifPresent(value -> localFormParams.put("v:my-var", value));
requestParameters
.recipientVariables()
.ifPresent(value -> localFormParams.put("recipient-variables", value));
final Map<String, Object> localFormParams =
mapper.serializeFormParameters(localVarContentTypes, requestParameters);

return new HttpRequest(
localVarPath,
Expand Down Expand Up @@ -457,7 +391,7 @@ public SendEmailResponse sendMimeEmail(String domainName, SendMimeEmailRequest r
}

private HttpRequest sendMimeEmailRequestBuilder(
String domainName, SendMimeEmailRequest _requestParameters) throws ApiException {
String domainName, SendMimeEmailRequest requestParameters) throws ApiException {
// verify the required parameter 'domainName' is set
if (domainName == null) {
throw new ApiException(
Expand All @@ -470,71 +404,15 @@ private HttpRequest sendMimeEmailRequestBuilder(
"\\{" + "domain_name" + "\\}",
URLPathUtils.encodePathSegment(domainName.toString()));

SendMimeEmailRequestImpl requestParameters = (SendMimeEmailRequestImpl) _requestParameters;
List<URLParameter> localVarQueryParams = new ArrayList<>();

Map<String, String> localVarHeaderParams = new HashMap<>();

final Collection<String> localVarAccepts = Arrays.asList("application/json");

final Collection<String> localVarContentTypes = Arrays.asList("multipart/form-data");

final Collection<String> localVarAuthNames = Arrays.asList("basicAuth");

HashMap<String, Object> localFormParams = new HashMap<>();
requestParameters.to().ifPresent(value -> localFormParams.put("to", value));
requestParameters.message().ifPresent(value -> localFormParams.put("message", value));
requestParameters.template().ifPresent(value -> localFormParams.put("template", value));
requestParameters.templateVersion().ifPresent(value -> localFormParams.put("t:version", value));
requestParameters.templateText().ifPresent(value -> localFormParams.put("t:text", value));
requestParameters
.templateVariables()
.ifPresent(value -> localFormParams.put("t:variables", value));
requestParameters.tag().ifPresent(value -> localFormParams.put("o:tag", value));
requestParameters
.enableDkimSignature()
.ifPresent(value -> localFormParams.put("o:dkim", value));
requestParameters
.secondaryDkim()
.ifPresent(value -> localFormParams.put("o:secondary-dkim", value));
requestParameters
.secondaryDkimPublic()
.ifPresent(value -> localFormParams.put("o:secondary-dkim-public", value));
requestParameters
.deliveryTime()
.ifPresent(value -> localFormParams.put("o:deliverytime", value));
requestParameters
.deliveryTimeOptimizePeriod()
.ifPresent(value -> localFormParams.put("o:deliverytime-optimize-period", value));
requestParameters
.timezoneLocalize()
.ifPresent(value -> localFormParams.put("o:time-zone-localize", value));
requestParameters.isTestMode().ifPresent(value -> localFormParams.put("o:testmode", value));
requestParameters.tracking().ifPresent(value -> localFormParams.put("o:tracking", value));
requestParameters
.trackingClicks()
.ifPresent(value -> localFormParams.put("o:tracking-clicks", value));
requestParameters
.trackingOpens()
.ifPresent(value -> localFormParams.put("o:tracking-opens", value));
requestParameters.requireTls().ifPresent(value -> localFormParams.put("o:require-tls", value));
requestParameters
.skipVerification()
.ifPresent(value -> localFormParams.put("o:skip-verification", value));
requestParameters.sendingIp().ifPresent(value -> localFormParams.put("o:sending-ip", value));
requestParameters
.sendingIpPool()
.ifPresent(value -> localFormParams.put("o:sending-ip-pool", value));
requestParameters
.trackingPixelLocationTop()
.ifPresent(value -> localFormParams.put("o:tracking-pixel-location-top", value));
requestParameters
.hColonXMyHeader()
.ifPresent(value -> localFormParams.put("h:X-My-Header", value));
requestParameters.vColonMyVar().ifPresent(value -> localFormParams.put("v:my-var", value));
requestParameters
.recipientVariables()
.ifPresent(value -> localFormParams.put("recipient-variables", value));
final Map<String, Object> localFormParams =
mapper.serializeFormParameters(localVarContentTypes, requestParameters);

return new HttpRequest(
localVarPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.sinch.sdk.core.utils.EnumDynamic;
import com.sinch.sdk.core.utils.EnumSupportDynamic;
import java.io.File;
import java.time.Instant;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;
Expand Down Expand Up @@ -226,7 +227,7 @@ public static String valueOf(DkimSignatureEnum e) {
*
* @return deliveryTime
*/
String getDeliveryTime();
Instant getDeliveryTime();

/**
* Toggles Send Time Optimization (STO) on a per-message basis. String should be set to the number
Expand All @@ -238,7 +239,7 @@ public static String valueOf(DkimSignatureEnum e) {
*
* @return deliveryTimeOptimizePeriod
*/
String getDeliveryTimeOptimizePeriod();
Integer getDeliveryTimeOptimizePeriod();

/**
* Toggles Timezone Optimization (TZO) on a per message basis. String should be set to preferred
Expand Down Expand Up @@ -530,22 +531,6 @@ public static String valueOf(SkipVerificationEnum e) {
*/
String getTrackingPixelLocationTop();

/**
* h: prefix followed by a Header/Value pair. For example:
* h:X-Mailgun-Sending-Ip-Pool=xx.xx.xxx.x.
*
* @return hColonXMyHeader
*/
String gethColonXMyHeader();

/**
* <code>v:</code> prefix followed by an arbitrary name allows to attach a custom JSON data to the
* message. See <strong>Attaching Data to Messages</strong> for more information
*
* @return vColonMyVar
*/
String getvColonMyVar();

/**
* A valid JSON-encoded dictionary, where key is a plain recipient address and value is a
* dictionary with variables that can be referenced in the message body. See <strong>Batch
Expand Down Expand Up @@ -744,7 +729,7 @@ interface Builder {
* @return Current builder
* @see #getDeliveryTime
*/
Builder setDeliveryTime(String deliveryTime);
Builder setDeliveryTime(Instant deliveryTime);

/**
* see getter
Expand All @@ -753,7 +738,7 @@ interface Builder {
* @return Current builder
* @see #getDeliveryTimeOptimizePeriod
*/
Builder setDeliveryTimeOptimizePeriod(String deliveryTimeOptimizePeriod);
Builder setDeliveryTimeOptimizePeriod(Integer deliveryTimeOptimizePeriod);

/**
* see getter
Expand Down Expand Up @@ -845,24 +830,6 @@ interface Builder {
*/
Builder setTrackingPixelLocationTop(String trackingPixelLocationTop);

/**
* see getter
*
* @param hColonXMyHeader see getter
* @return Current builder
* @see #gethColonXMyHeader
*/
Builder sethColonXMyHeader(String hColonXMyHeader);

/**
* see getter
*
* @param vColonMyVar see getter
* @return Current builder
* @see #getvColonMyVar
*/
Builder setvColonMyVar(String vColonMyVar);

/**
* see getter
*
Expand Down
Loading

0 comments on commit 7b57bcb

Please sign in to comment.