All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.pinpoint.model.APNSPushNotificationTemplate Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Amazon Pinpoint module holds the client classes that are used for communicating with Amazon Pinpoint Service

There is a newer version: 2.28.4
Show newest version
/*
 * Copyright 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;

/**
 * 

* Specifies channel-specific content and settings for a message template that can be used in push notifications that * are sent through the APNs (Apple Push Notification service) channel. *

*/ @Generated("software.amazon.awssdk:codegen") public final class APNSPushNotificationTemplate implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField ACTION_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Action") .getter(getter(APNSPushNotificationTemplate::actionAsString)).setter(setter(Builder::action)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Action").build()).build(); private static final SdkField BODY_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Body") .getter(getter(APNSPushNotificationTemplate::body)).setter(setter(Builder::body)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Body").build()).build(); private static final SdkField MEDIA_URL_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("MediaUrl").getter(getter(APNSPushNotificationTemplate::mediaUrl)).setter(setter(Builder::mediaUrl)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MediaUrl").build()).build(); private static final SdkField RAW_CONTENT_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("RawContent").getter(getter(APNSPushNotificationTemplate::rawContent)) .setter(setter(Builder::rawContent)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RawContent").build()).build(); private static final SdkField SOUND_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Sound") .getter(getter(APNSPushNotificationTemplate::sound)).setter(setter(Builder::sound)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Sound").build()).build(); private static final SdkField TITLE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Title") .getter(getter(APNSPushNotificationTemplate::title)).setter(setter(Builder::title)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Title").build()).build(); private static final SdkField URL_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Url") .getter(getter(APNSPushNotificationTemplate::url)).setter(setter(Builder::url)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Url").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ACTION_FIELD, BODY_FIELD, MEDIA_URL_FIELD, RAW_CONTENT_FIELD, SOUND_FIELD, TITLE_FIELD, URL_FIELD)); private static final long serialVersionUID = 1L; private final String action; private final String body; private final String mediaUrl; private final String rawContent; private final String sound; private final String title; private final String url; private APNSPushNotificationTemplate(BuilderImpl builder) { this.action = builder.action; this.body = builder.body; this.mediaUrl = builder.mediaUrl; this.rawContent = builder.rawContent; this.sound = builder.sound; this.title = builder.title; this.url = builder.url; } /** *

* The action to occur if a recipient taps a push notification that's based on the message template. Valid values * are: *

*
    *
  • *

    * OPEN_APP - Your app opens or it becomes the foreground app if it was sent to the background. This is the default * action. *

    *
  • *
  • *

    * DEEP_LINK - Your app opens and displays a designated user interface in the app. This setting uses the * deep-linking features of the iOS platform. *

    *
  • *
  • *

    * URL - The default mobile browser on the recipient's device opens and loads the web page at a URL that you * specify. *

    *
  • *
*

* If the service returns an enum value that is not available in the current SDK version, {@link #action} will * return {@link Action#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #actionAsString}. *

* * @return The action to occur if a recipient taps a push notification that's based on the message template. Valid * values are:

*
    *
  • *

    * OPEN_APP - Your app opens or it becomes the foreground app if it was sent to the background. This is the * default action. *

    *
  • *
  • *

    * DEEP_LINK - Your app opens and displays a designated user interface in the app. This setting uses the * deep-linking features of the iOS platform. *

    *
  • *
  • *

    * URL - The default mobile browser on the recipient's device opens and loads the web page at a URL that you * specify. *

    *
  • * @see Action */ public final Action action() { return Action.fromValue(action); } /** *

    * The action to occur if a recipient taps a push notification that's based on the message template. Valid values * are: *

    *
      *
    • *

      * OPEN_APP - Your app opens or it becomes the foreground app if it was sent to the background. This is the default * action. *

      *
    • *
    • *

      * DEEP_LINK - Your app opens and displays a designated user interface in the app. This setting uses the * deep-linking features of the iOS platform. *

      *
    • *
    • *

      * URL - The default mobile browser on the recipient's device opens and loads the web page at a URL that you * specify. *

      *
    • *
    *

    * If the service returns an enum value that is not available in the current SDK version, {@link #action} will * return {@link Action#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #actionAsString}. *

    * * @return The action to occur if a recipient taps a push notification that's based on the message template. Valid * values are:

    *
      *
    • *

      * OPEN_APP - Your app opens or it becomes the foreground app if it was sent to the background. This is the * default action. *

      *
    • *
    • *

      * DEEP_LINK - Your app opens and displays a designated user interface in the app. This setting uses the * deep-linking features of the iOS platform. *

      *
    • *
    • *

      * URL - The default mobile browser on the recipient's device opens and loads the web page at a URL that you * specify. *

      *
    • * @see Action */ public final String actionAsString() { return action; } /** *

      * The message body to use in push notifications that are based on the message template. *

      * * @return The message body to use in push notifications that are based on the message template. */ public final String body() { return body; } /** *

      * The URL of an image or video to display in push notifications that are based on the message template. *

      * * @return The URL of an image or video to display in push notifications that are based on the message template. */ public final String mediaUrl() { return mediaUrl; } /** *

      * The raw, JSON-formatted string to use as the payload for push notifications that are based on the message * template. If specified, this value overrides all other content for the message template. *

      * * @return The raw, JSON-formatted string to use as the payload for push notifications that are based on the message * template. If specified, this value overrides all other content for the message template. */ public final String rawContent() { return rawContent; } /** *

      * The key for the sound to play when the recipient receives a push notification that's based on the message * template. The value for this key is the name of a sound file in your app's main bundle or the Library/Sounds * folder in your app's data container. If the sound file can't be found or you specify default for the value, the * system plays the default alert sound. *

      * * @return The key for the sound to play when the recipient receives a push notification that's based on the message * template. The value for this key is the name of a sound file in your app's main bundle or the * Library/Sounds folder in your app's data container. If the sound file can't be found or you specify * default for the value, the system plays the default alert sound. */ public final String sound() { return sound; } /** *

      * The title to use in push notifications that are based on the message template. This title appears above the * notification message on a recipient's device. *

      * * @return The title to use in push notifications that are based on the message template. This title appears above * the notification message on a recipient's device. */ public final String title() { return title; } /** *

      * The URL to open in the recipient's default mobile browser, if a recipient taps a push notification that's based * on the message template and the value of the Action property is URL. *

      * * @return The URL to open in the recipient's default mobile browser, if a recipient taps a push notification that's * based on the message template and the value of the Action property is URL. */ public final String url() { return url; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(actionAsString()); hashCode = 31 * hashCode + Objects.hashCode(body()); hashCode = 31 * hashCode + Objects.hashCode(mediaUrl()); hashCode = 31 * hashCode + Objects.hashCode(rawContent()); hashCode = 31 * hashCode + Objects.hashCode(sound()); hashCode = 31 * hashCode + Objects.hashCode(title()); hashCode = 31 * hashCode + Objects.hashCode(url()); return hashCode; } @Override public final boolean equals(Object obj) { return equalsBySdkFields(obj); } @Override public final boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof APNSPushNotificationTemplate)) { return false; } APNSPushNotificationTemplate other = (APNSPushNotificationTemplate) obj; return Objects.equals(actionAsString(), other.actionAsString()) && Objects.equals(body(), other.body()) && Objects.equals(mediaUrl(), other.mediaUrl()) && Objects.equals(rawContent(), other.rawContent()) && Objects.equals(sound(), other.sound()) && Objects.equals(title(), other.title()) && Objects.equals(url(), other.url()); } /** * 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 final String toString() { return ToString.builder("APNSPushNotificationTemplate").add("Action", actionAsString()).add("Body", body()) .add("MediaUrl", mediaUrl()).add("RawContent", rawContent()).add("Sound", sound()).add("Title", title()) .add("Url", url()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "Action": return Optional.ofNullable(clazz.cast(actionAsString())); case "Body": return Optional.ofNullable(clazz.cast(body())); case "MediaUrl": return Optional.ofNullable(clazz.cast(mediaUrl())); case "RawContent": return Optional.ofNullable(clazz.cast(rawContent())); case "Sound": return Optional.ofNullable(clazz.cast(sound())); case "Title": return Optional.ofNullable(clazz.cast(title())); case "Url": return Optional.ofNullable(clazz.cast(url())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((APNSPushNotificationTemplate) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

      * The action to occur if a recipient taps a push notification that's based on the message template. Valid * values are: *

      *
        *
      • *

        * OPEN_APP - Your app opens or it becomes the foreground app if it was sent to the background. This is the * default action. *

        *
      • *
      • *

        * DEEP_LINK - Your app opens and displays a designated user interface in the app. This setting uses the * deep-linking features of the iOS platform. *

        *
      • *
      • *

        * URL - The default mobile browser on the recipient's device opens and loads the web page at a URL that you * specify. *

        *
      • *
      * * @param action * The action to occur if a recipient taps a push notification that's based on the message template. * Valid values are:

      *
        *
      • *

        * OPEN_APP - Your app opens or it becomes the foreground app if it was sent to the background. This is * the default action. *

        *
      • *
      • *

        * DEEP_LINK - Your app opens and displays a designated user interface in the app. This setting uses the * deep-linking features of the iOS platform. *

        *
      • *
      • *

        * URL - The default mobile browser on the recipient's device opens and loads the web page at a URL that * you specify. *

        *
      • * @see Action * @return Returns a reference to this object so that method calls can be chained together. * @see Action */ Builder action(String action); /** *

        * The action to occur if a recipient taps a push notification that's based on the message template. Valid * values are: *

        *
          *
        • *

          * OPEN_APP - Your app opens or it becomes the foreground app if it was sent to the background. This is the * default action. *

          *
        • *
        • *

          * DEEP_LINK - Your app opens and displays a designated user interface in the app. This setting uses the * deep-linking features of the iOS platform. *

          *
        • *
        • *

          * URL - The default mobile browser on the recipient's device opens and loads the web page at a URL that you * specify. *

          *
        • *
        * * @param action * The action to occur if a recipient taps a push notification that's based on the message template. * Valid values are:

        *
          *
        • *

          * OPEN_APP - Your app opens or it becomes the foreground app if it was sent to the background. This is * the default action. *

          *
        • *
        • *

          * DEEP_LINK - Your app opens and displays a designated user interface in the app. This setting uses the * deep-linking features of the iOS platform. *

          *
        • *
        • *

          * URL - The default mobile browser on the recipient's device opens and loads the web page at a URL that * you specify. *

          *
        • * @see Action * @return Returns a reference to this object so that method calls can be chained together. * @see Action */ Builder action(Action action); /** *

          * The message body to use in push notifications that are based on the message template. *

          * * @param body * The message body to use in push notifications that are based on the message template. * @return Returns a reference to this object so that method calls can be chained together. */ Builder body(String body); /** *

          * The URL of an image or video to display in push notifications that are based on the message template. *

          * * @param mediaUrl * The URL of an image or video to display in push notifications that are based on the message template. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mediaUrl(String mediaUrl); /** *

          * The raw, JSON-formatted string to use as the payload for push notifications that are based on the message * template. If specified, this value overrides all other content for the message template. *

          * * @param rawContent * The raw, JSON-formatted string to use as the payload for push notifications that are based on the * message template. If specified, this value overrides all other content for the message template. * @return Returns a reference to this object so that method calls can be chained together. */ Builder rawContent(String rawContent); /** *

          * The key for the sound to play when the recipient receives a push notification that's based on the message * template. The value for this key is the name of a sound file in your app's main bundle or the Library/Sounds * folder in your app's data container. If the sound file can't be found or you specify default for the value, * the system plays the default alert sound. *

          * * @param sound * The key for the sound to play when the recipient receives a push notification that's based on the * message template. The value for this key is the name of a sound file in your app's main bundle or the * Library/Sounds folder in your app's data container. If the sound file can't be found or you specify * default for the value, the system plays the default alert sound. * @return Returns a reference to this object so that method calls can be chained together. */ Builder sound(String sound); /** *

          * The title to use in push notifications that are based on the message template. This title appears above the * notification message on a recipient's device. *

          * * @param title * The title to use in push notifications that are based on the message template. This title appears * above the notification message on a recipient's device. * @return Returns a reference to this object so that method calls can be chained together. */ Builder title(String title); /** *

          * The URL to open in the recipient's default mobile browser, if a recipient taps a push notification that's * based on the message template and the value of the Action property is URL. *

          * * @param url * The URL to open in the recipient's default mobile browser, if a recipient taps a push notification * that's based on the message template and the value of the Action property is URL. * @return Returns a reference to this object so that method calls can be chained together. */ Builder url(String url); } static final class BuilderImpl implements Builder { private String action; private String body; private String mediaUrl; private String rawContent; private String sound; private String title; private String url; private BuilderImpl() { } private BuilderImpl(APNSPushNotificationTemplate model) { action(model.action); body(model.body); mediaUrl(model.mediaUrl); rawContent(model.rawContent); sound(model.sound); title(model.title); url(model.url); } public final String getAction() { return action; } public final void setAction(String action) { this.action = action; } @Override public final Builder action(String action) { this.action = action; return this; } @Override public final Builder action(Action action) { this.action(action == null ? null : action.toString()); return this; } public final String getBody() { return body; } public final void setBody(String body) { this.body = body; } @Override public final Builder body(String body) { this.body = body; return this; } public final String getMediaUrl() { return mediaUrl; } public final void setMediaUrl(String mediaUrl) { this.mediaUrl = mediaUrl; } @Override public final Builder mediaUrl(String mediaUrl) { this.mediaUrl = mediaUrl; return this; } public final String getRawContent() { return rawContent; } public final void setRawContent(String rawContent) { this.rawContent = rawContent; } @Override public final Builder rawContent(String rawContent) { this.rawContent = rawContent; return this; } public final String getSound() { return sound; } public final void setSound(String sound) { this.sound = sound; } @Override public final Builder sound(String sound) { this.sound = sound; return this; } public final String getTitle() { return title; } public final void setTitle(String title) { this.title = title; } @Override public final Builder title(String title) { this.title = title; return this; } public final String getUrl() { return url; } public final void setUrl(String url) { this.url = url; } @Override public final Builder url(String url) { this.url = url; return this; } @Override public APNSPushNotificationTemplate build() { return new APNSPushNotificationTemplate(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy