Skip to content

Commit

Permalink
lintered files
Browse files Browse the repository at this point in the history
  • Loading branch information
scmacdon committed Jun 10, 2024
1 parent 7849470 commit cfb38b3
Show file tree
Hide file tree
Showing 14 changed files with 1,055 additions and 1,005 deletions.
6 changes: 3 additions & 3 deletions kotlin/services/pinpoint/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ repositories {
}
apply(plugin = "org.jlleitschuh.gradle.ktlint")
dependencies {
implementation("aws.sdk.kotlin:pinpoint:1.0.30")
implementation("aws.sdk.kotlin:pinpointemail:1.0.30")
implementation("aws.sdk.kotlin:secretsmanager:1.0.30")
implementation("aws.sdk.kotlin:pinpoint:1.2.28")
implementation("aws.sdk.kotlin:pinpointemail:1.2.28")
implementation("aws.sdk.kotlin:secretsmanager:1.2.28")
implementation("aws.smithy.kotlin:http-client-engine-okhttp:0.30.0")
implementation("aws.smithy.kotlin:http-client-engine-crt:0.30.0")
implementation("com.google.code.gson:gson:2.10")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,86 +1,88 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package com.kotlin.pinpoint

// snippet-start:[pinpoint.kotlin.add_endpoint.import]
import aws.sdk.kotlin.services.pinpoint.PinpointClient
import aws.sdk.kotlin.services.pinpoint.model.ChannelType
import aws.sdk.kotlin.services.pinpoint.model.EndpointBatchItem
import aws.sdk.kotlin.services.pinpoint.model.EndpointBatchRequest
import aws.sdk.kotlin.services.pinpoint.model.EndpointUser
import aws.sdk.kotlin.services.pinpoint.model.UpdateEndpointsBatchRequest
import kotlin.system.exitProcess
// snippet-end:[pinpoint.kotlin.add_endpoint.import]

/**
Before running this Kotlin code example, set up your development environment,
including your credentials.
For more information, see the following documentation topic:
https://docs.aws.amazon.com/sdk-for-kotlin/latest/developer-guide/setup.html
*/

suspend fun main(args: Array<String>) {

val usage = """
Usage:
<appId>
Where:
appId - The Amazon Pinpoint project/application ID to use.
"""

if (args.size != 1) {
println(usage)
exitProcess(0)
}

val appId = args[0]
updateEndpointsViaBatch(appId)
}

// snippet-start:[pinpoint.kotlin.add_endpoint.main]
suspend fun updateEndpointsViaBatch(applicationIdVal: String?) {

val myNames = mutableListOf<String>()
myNames.add("Richard")
myNames.add("Roe")

val myMapRichard = mutableMapOf<String, List<String>>()
myMapRichard.put("name", myNames)

val richardRoe = EndpointUser {
userId = "example_user_1"
userAttributes = myMapRichard
}

// Create an EndpointBatchItem object for Richard Roe.
val richardRoesEmailEndpoint = EndpointBatchItem {
channelType = ChannelType.Email
address = "[email protected]"
id = "example_endpoint_1"
attributes = myMapRichard
user = richardRoe
}

val richardList: MutableList<EndpointBatchItem> = ArrayList()
richardList.add(richardRoesEmailEndpoint)

// Adds multiple endpoint definitions to a single request object.
val endpointList = EndpointBatchRequest {
item = richardList
}

// Updates the endpoints with Amazon Pinpoint.
PinpointClient { region = "us-west-2" }.use { pinpoint ->
val result = pinpoint.updateEndpointsBatch(
UpdateEndpointsBatchRequest {
applicationId = applicationIdVal
endpointBatchRequest = endpointList
}
)
println("Update endpoint result ${result.messageBody?.message}")
}
}
// snippet-end:[pinpoint.kotlin.add_endpoint.main]
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package com.kotlin.pinpoint

// snippet-start:[pinpoint.kotlin.add_endpoint.import]
import aws.sdk.kotlin.services.pinpoint.PinpointClient
import aws.sdk.kotlin.services.pinpoint.model.ChannelType
import aws.sdk.kotlin.services.pinpoint.model.EndpointBatchItem
import aws.sdk.kotlin.services.pinpoint.model.EndpointBatchRequest
import aws.sdk.kotlin.services.pinpoint.model.EndpointUser
import aws.sdk.kotlin.services.pinpoint.model.UpdateEndpointsBatchRequest
import kotlin.system.exitProcess
// snippet-end:[pinpoint.kotlin.add_endpoint.import]

/**
Before running this Kotlin code example, set up your development environment,
including your credentials.
For more information, see the following documentation topic:
https://docs.aws.amazon.com/sdk-for-kotlin/latest/developer-guide/setup.html
*/

suspend fun main(args: Array<String>) {
val usage = """
Usage:
<appId>
Where:
appId - The Amazon Pinpoint project/application ID to use.
"""

if (args.size != 1) {
println(usage)
exitProcess(0)
}

val appId = args[0]
updateEndpointsViaBatch(appId)
}

// snippet-start:[pinpoint.kotlin.add_endpoint.main]
suspend fun updateEndpointsViaBatch(applicationIdVal: String?) {
val myNames = mutableListOf<String>()
myNames.add("Richard")
myNames.add("Roe")

val myMapRichard = mutableMapOf<String, List<String>>()
myMapRichard.put("name", myNames)

val richardRoe =
EndpointUser {
userId = "example_user_1"
userAttributes = myMapRichard
}

// Create an EndpointBatchItem object for Richard Roe.
val richardRoesEmailEndpoint =
EndpointBatchItem {
channelType = ChannelType.Email
address = "[email protected]"
id = "example_endpoint_1"
attributes = myMapRichard
user = richardRoe
}

val richardList: MutableList<EndpointBatchItem> = ArrayList()
richardList.add(richardRoesEmailEndpoint)

// Adds multiple endpoint definitions to a single request object.
val endpointList =
EndpointBatchRequest {
item = richardList
}

// Updates the endpoints with Amazon Pinpoint.
PinpointClient { region = "us-west-2" }.use { pinpoint ->
val result =
pinpoint.updateEndpointsBatch(
UpdateEndpointsBatchRequest {
applicationId = applicationIdVal
endpointBatchRequest = endpointList
},
)
println("Update endpoint result ${result.messageBody?.message}")
}
}
// snippet-end:[pinpoint.kotlin.add_endpoint.main]
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package com.kotlin.pinpoint

// snippet-start:[pinpoint.kotlin.createapp.import]
import aws.sdk.kotlin.services.pinpoint.PinpointClient
import aws.sdk.kotlin.services.pinpoint.model.CreateAppRequest
import aws.sdk.kotlin.services.pinpoint.model.CreateApplicationRequest
import kotlin.system.exitProcess
// snippet-end:[pinpoint.kotlin.createapp.import]

/**
Before running this Kotlin code example, set up your development environment,
including your credentials.
For more information, see the following documentation topic:
https://docs.aws.amazon.com/sdk-for-kotlin/latest/developer-guide/setup.html
*/

suspend fun main(args: Array<String>) {

val usage = """
Usage: <appName>
Where:
appName - The name of the application to create.
"""

if (args.size != 1) {
println(usage)
exitProcess(0)
}

val appName = args[0]
val appId = createApplication(appName)
println("The app Id is: $appId")
}

// snippet-start:[pinpoint.kotlin.createapp.main]
suspend fun createApplication(applicationName: String?): String? {

val createApplicationRequestOb = CreateApplicationRequest {
name = applicationName
}

PinpointClient { region = "us-west-2" }.use { pinpoint ->
val result = pinpoint.createApp(
CreateAppRequest {
createApplicationRequest = createApplicationRequestOb
}
)
return result.applicationResponse?.id
}
}
// snippet-end:[pinpoint.kotlin.createapp.main]
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package com.kotlin.pinpoint

// snippet-start:[pinpoint.kotlin.createapp.import]
import aws.sdk.kotlin.services.pinpoint.PinpointClient
import aws.sdk.kotlin.services.pinpoint.model.CreateAppRequest
import aws.sdk.kotlin.services.pinpoint.model.CreateApplicationRequest
import kotlin.system.exitProcess
// snippet-end:[pinpoint.kotlin.createapp.import]

/**
Before running this Kotlin code example, set up your development environment,
including your credentials.
For more information, see the following documentation topic:
https://docs.aws.amazon.com/sdk-for-kotlin/latest/developer-guide/setup.html
*/

suspend fun main(args: Array<String>) {
val usage = """
Usage: <appName>
Where:
appName - The name of the application to create.
"""

if (args.size != 1) {
println(usage)
exitProcess(0)
}

val appName = args[0]
val appId = createApplication(appName)
println("The app Id is: $appId")
}

// snippet-start:[pinpoint.kotlin.createapp.main]
suspend fun createApplication(applicationName: String?): String? {
val createApplicationRequestOb =
CreateApplicationRequest {
name = applicationName
}

PinpointClient { region = "us-west-2" }.use { pinpoint ->
val result =
pinpoint.createApp(
CreateAppRequest {
createApplicationRequest = createApplicationRequestOb
},
)
return result.applicationResponse?.id
}
}
// snippet-end:[pinpoint.kotlin.createapp.main]
Loading

0 comments on commit cfb38b3

Please sign in to comment.