software.amazon.awssdk.services.pinpoint.model.EndpointMessageResult Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pinpoint Show documentation
Show all versions of pinpoint Show documentation
The AWS Java SDK for Amazon Pinpoint module holds the client classes that are used for communicating
with Amazon Pinpoint Service
/*
* Copyright 2014-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package software.amazon.awssdk.services.pinpoint.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
* The result from sending a message to an endpoint.
*/
@Generated("software.amazon.awssdk:codegen")
public final class EndpointMessageResult implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField ADDRESS_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(EndpointMessageResult::address)).setter(setter(Builder::address))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Address").build()).build();
private static final SdkField DELIVERY_STATUS_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(EndpointMessageResult::deliveryStatusAsString)).setter(setter(Builder::deliveryStatus))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DeliveryStatus").build()).build();
private static final SdkField MESSAGE_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(EndpointMessageResult::messageId)).setter(setter(Builder::messageId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MessageId").build()).build();
private static final SdkField STATUS_CODE_FIELD = SdkField. builder(MarshallingType.INTEGER)
.getter(getter(EndpointMessageResult::statusCode)).setter(setter(Builder::statusCode))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StatusCode").build()).build();
private static final SdkField STATUS_MESSAGE_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(EndpointMessageResult::statusMessage)).setter(setter(Builder::statusMessage))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StatusMessage").build()).build();
private static final SdkField UPDATED_TOKEN_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(EndpointMessageResult::updatedToken)).setter(setter(Builder::updatedToken))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("UpdatedToken").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ADDRESS_FIELD,
DELIVERY_STATUS_FIELD, MESSAGE_ID_FIELD, STATUS_CODE_FIELD, STATUS_MESSAGE_FIELD, UPDATED_TOKEN_FIELD));
private static final long serialVersionUID = 1L;
private final String address;
private final String deliveryStatus;
private final String messageId;
private final Integer statusCode;
private final String statusMessage;
private final String updatedToken;
private EndpointMessageResult(BuilderImpl builder) {
this.address = builder.address;
this.deliveryStatus = builder.deliveryStatus;
this.messageId = builder.messageId;
this.statusCode = builder.statusCode;
this.statusMessage = builder.statusMessage;
this.updatedToken = builder.updatedToken;
}
/**
* Address that endpoint message was delivered to.
*
* @return Address that endpoint message was delivered to.
*/
public String address() {
return address;
}
/**
* The delivery status of the message. Possible values:
*
* SUCCESS - The message was successfully delivered to the endpoint.
*
* TRANSIENT_FAILURE - A temporary error occurred. Amazon Pinpoint will attempt to deliver the message again later.
*
* FAILURE_PERMANENT - An error occurred when delivering the message to the endpoint. Amazon Pinpoint won't attempt
* to send the message again.
*
* TIMEOUT - The message couldn't be sent within the timeout period.
*
* QUIET_TIME - The local time for the endpoint was within the QuietTime for the campaign or app.
*
* DAILY_CAP - The endpoint has received the maximum number of messages it can receive within a 24-hour period.
*
* HOLDOUT - The endpoint was in a hold out treatment for the campaign.
*
* THROTTLED - Amazon Pinpoint throttled sending to this endpoint.
*
* EXPIRED - The endpoint address is expired.
*
* CAMPAIGN_CAP - The endpoint received the maximum number of messages allowed by the campaign.
*
* SERVICE_FAILURE - A service-level failure prevented Amazon Pinpoint from delivering the message.
*
* UNKNOWN - An unknown error occurred.
*
* If the service returns an enum value that is not available in the current SDK version, {@link #deliveryStatus}
* will return {@link DeliveryStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #deliveryStatusAsString}.
*
*
* @return The delivery status of the message. Possible values:
*
* SUCCESS - The message was successfully delivered to the endpoint.
*
* TRANSIENT_FAILURE - A temporary error occurred. Amazon Pinpoint will attempt to deliver the message again
* later.
*
* FAILURE_PERMANENT - An error occurred when delivering the message to the endpoint. Amazon Pinpoint won't
* attempt to send the message again.
*
* TIMEOUT - The message couldn't be sent within the timeout period.
*
* QUIET_TIME - The local time for the endpoint was within the QuietTime for the campaign or app.
*
* DAILY_CAP - The endpoint has received the maximum number of messages it can receive within a 24-hour
* period.
*
* HOLDOUT - The endpoint was in a hold out treatment for the campaign.
*
* THROTTLED - Amazon Pinpoint throttled sending to this endpoint.
*
* EXPIRED - The endpoint address is expired.
*
* CAMPAIGN_CAP - The endpoint received the maximum number of messages allowed by the campaign.
*
* SERVICE_FAILURE - A service-level failure prevented Amazon Pinpoint from delivering the message.
*
* UNKNOWN - An unknown error occurred.
* @see DeliveryStatus
*/
public DeliveryStatus deliveryStatus() {
return DeliveryStatus.fromValue(deliveryStatus);
}
/**
* The delivery status of the message. Possible values:
*
* SUCCESS - The message was successfully delivered to the endpoint.
*
* TRANSIENT_FAILURE - A temporary error occurred. Amazon Pinpoint will attempt to deliver the message again later.
*
* FAILURE_PERMANENT - An error occurred when delivering the message to the endpoint. Amazon Pinpoint won't attempt
* to send the message again.
*
* TIMEOUT - The message couldn't be sent within the timeout period.
*
* QUIET_TIME - The local time for the endpoint was within the QuietTime for the campaign or app.
*
* DAILY_CAP - The endpoint has received the maximum number of messages it can receive within a 24-hour period.
*
* HOLDOUT - The endpoint was in a hold out treatment for the campaign.
*
* THROTTLED - Amazon Pinpoint throttled sending to this endpoint.
*
* EXPIRED - The endpoint address is expired.
*
* CAMPAIGN_CAP - The endpoint received the maximum number of messages allowed by the campaign.
*
* SERVICE_FAILURE - A service-level failure prevented Amazon Pinpoint from delivering the message.
*
* UNKNOWN - An unknown error occurred.
*
* If the service returns an enum value that is not available in the current SDK version, {@link #deliveryStatus}
* will return {@link DeliveryStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #deliveryStatusAsString}.
*
*
* @return The delivery status of the message. Possible values:
*
* SUCCESS - The message was successfully delivered to the endpoint.
*
* TRANSIENT_FAILURE - A temporary error occurred. Amazon Pinpoint will attempt to deliver the message again
* later.
*
* FAILURE_PERMANENT - An error occurred when delivering the message to the endpoint. Amazon Pinpoint won't
* attempt to send the message again.
*
* TIMEOUT - The message couldn't be sent within the timeout period.
*
* QUIET_TIME - The local time for the endpoint was within the QuietTime for the campaign or app.
*
* DAILY_CAP - The endpoint has received the maximum number of messages it can receive within a 24-hour
* period.
*
* HOLDOUT - The endpoint was in a hold out treatment for the campaign.
*
* THROTTLED - Amazon Pinpoint throttled sending to this endpoint.
*
* EXPIRED - The endpoint address is expired.
*
* CAMPAIGN_CAP - The endpoint received the maximum number of messages allowed by the campaign.
*
* SERVICE_FAILURE - A service-level failure prevented Amazon Pinpoint from delivering the message.
*
* UNKNOWN - An unknown error occurred.
* @see DeliveryStatus
*/
public String deliveryStatusAsString() {
return deliveryStatus;
}
/**
* Unique message identifier associated with the message that was sent.
*
* @return Unique message identifier associated with the message that was sent.
*/
public String messageId() {
return messageId;
}
/**
* Downstream service status code.
*
* @return Downstream service status code.
*/
public Integer statusCode() {
return statusCode;
}
/**
* Status message for message delivery.
*
* @return Status message for message delivery.
*/
public String statusMessage() {
return statusMessage;
}
/**
* If token was updated as part of delivery. (This is GCM Specific)
*
* @return If token was updated as part of delivery. (This is GCM Specific)
*/
public String updatedToken() {
return updatedToken;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(address());
hashCode = 31 * hashCode + Objects.hashCode(deliveryStatusAsString());
hashCode = 31 * hashCode + Objects.hashCode(messageId());
hashCode = 31 * hashCode + Objects.hashCode(statusCode());
hashCode = 31 * hashCode + Objects.hashCode(statusMessage());
hashCode = 31 * hashCode + Objects.hashCode(updatedToken());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof EndpointMessageResult)) {
return false;
}
EndpointMessageResult other = (EndpointMessageResult) obj;
return Objects.equals(address(), other.address())
&& Objects.equals(deliveryStatusAsString(), other.deliveryStatusAsString())
&& Objects.equals(messageId(), other.messageId()) && Objects.equals(statusCode(), other.statusCode())
&& Objects.equals(statusMessage(), other.statusMessage()) && Objects.equals(updatedToken(), other.updatedToken());
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*/
@Override
public String toString() {
return ToString.builder("EndpointMessageResult").add("Address", address())
.add("DeliveryStatus", deliveryStatusAsString()).add("MessageId", messageId()).add("StatusCode", statusCode())
.add("StatusMessage", statusMessage()).add("UpdatedToken", updatedToken()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Address":
return Optional.ofNullable(clazz.cast(address()));
case "DeliveryStatus":
return Optional.ofNullable(clazz.cast(deliveryStatusAsString()));
case "MessageId":
return Optional.ofNullable(clazz.cast(messageId()));
case "StatusCode":
return Optional.ofNullable(clazz.cast(statusCode()));
case "StatusMessage":
return Optional.ofNullable(clazz.cast(statusMessage()));
case "UpdatedToken":
return Optional.ofNullable(clazz.cast(updatedToken()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function