Skip to content

Commit f7de919

Browse files
authored
refactor (Conversation): Enhance comments (#27)
* refactor (Conversation): Enhance comments
1 parent e31b3b3 commit f7de919

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+164
-84
lines changed

snippets/src/main/java/conversation/application/Create.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ public static void main(String[] args) {
3232
String keySecret = Settings.getKeySecret().orElse("MY_KEY_SECRET");
3333
String conversationRegion = Settings.getConversationRegion().orElse("MY_CONVERSATION_REGION");
3434

35-
String smsServicePlanId = Settings.getServicePlanId().orElse("MY_SERVICE_PLAN_ID");
36-
String smsApiToken = ("AN_SMS_API_TOKEN");
35+
// The service plan ID and API token for the SMS channel
36+
String smsServicePlanId = Settings.getServicePlanId().orElse("SMS_SERVICE_PLAN_ID");
37+
String smsApiToken = ("SMS_API_TOKEN");
3738

3839
Configuration configuration =
3940
Configuration.builder()

snippets/src/main/java/conversation/application/Delete.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ public static void main(String[] args) {
2525
String keySecret = Settings.getKeySecret().orElse("MY_KEY_SECRET");
2626
String conversationRegion = Settings.getConversationRegion().orElse("MY_CONVERSATION_REGION");
2727

28-
String conversationApplicationId = "AN_APPLICATION_ID";
28+
// The ID of the Conversation App to delete
29+
String conversationApplicationId = "CONVERSATION_APP_ID";
2930

3031
Configuration configuration =
3132
Configuration.builder()

snippets/src/main/java/conversation/application/Get.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ public static void main(String[] args) {
2626
String keySecret = Settings.getKeySecret().orElse("MY_KEY_SECRET");
2727
String conversationRegion = Settings.getConversationRegion().orElse("MY_CONVERSATION_REGION");
2828

29-
String conversationApplicationId = "AN_APPLICATION_ID";
29+
// The ID of the Conversation App to retrieve
30+
String conversationApplicationId = "CONVERSATION_APP_ID";
3031

3132
Configuration configuration =
3233
Configuration.builder()

snippets/src/main/java/conversation/application/List.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ public static void main(String[] args) {
2727
String keySecret = Settings.getKeySecret().orElse("MY_KEY_SECRET");
2828
String conversationRegion = Settings.getConversationRegion().orElse("MY_CONVERSATION_REGION");
2929

30-
String servicePlanId = Settings.getServicePlanId().orElse("MY_SERVICE_PLAN_ID");
31-
32-
String smsApiToken = "MY_SMS_API_TOEKN";
33-
3430
Configuration configuration =
3531
Configuration.builder()
3632
.setProjectId(projectId)

snippets/src/main/java/conversation/application/Update.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ public static void main(String[] args) {
2727
String keySecret = Settings.getKeySecret().orElse("MY_KEY_SECRET");
2828
String conversationRegion = Settings.getConversationRegion().orElse("MY_CONVERSATION_REGION");
2929

30-
String conversationApplicationId = "AN_APPLICATION_ID";
30+
// The ID of the Conversation App to update
31+
String conversationApplicationId = "CONVERSATION_APP_ID";
32+
// New name for the Conversation App
33+
String updatedAppName = "Updated from Java SDK snippet";
3134

3235
Configuration configuration =
3336
Configuration.builder()
@@ -43,8 +46,7 @@ public static void main(String[] args) {
4346

4447
LOGGER.info(String.format("Update application with ID '%s'", conversationApplicationId));
4548

46-
AppUpdateRequest parameters =
47-
AppUpdateRequest.builder().setDisplayName("Updated from Java SDK snippet").build();
49+
AppUpdateRequest parameters = AppUpdateRequest.builder().setDisplayName(updatedAppName).build();
4850

4951
AppResponse result = appService.update(conversationApplicationId, parameters);
5052

snippets/src/main/java/conversation/capability/Capability.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@ public static void main(String[] args) {
3131
String keySecret = Settings.getKeySecret().orElse("MY_KEY_SECRET");
3232
String conversationRegion = Settings.getConversationRegion().orElse("MY_CONVERSATION_REGION");
3333

34-
String conversationApplicationId = "AN_APPLICATION_ID";
35-
String smsRecipientPhoneNumber = "AN_SMS_RECIPIENT_PHONE_NUMBER";
34+
// The ID of the Conversation App where the recipient channel is configured
35+
String conversationApplicationId = "CONVERSATION_APP_ID";
36+
// The channel to look up the capabilities for
37+
ConversationChannel recipientChannel = ConversationChannel.SMS;
38+
// The phone number of the recipient to look up the capabilities for
39+
String recipientPhoneNumber = "RECIPIENT_PHONE_NUMBER";
3640

3741
Configuration configuration =
3842
Configuration.builder()
@@ -49,8 +53,8 @@ public static void main(String[] args) {
4953
Recipient channelRecipients =
5054
ChannelRecipientIdentities.of(
5155
ChannelRecipientIdentity.builder()
52-
.setChannel(ConversationChannel.SMS)
53-
.setIdentity(smsRecipientPhoneNumber)
56+
.setChannel(recipientChannel)
57+
.setIdentity(recipientPhoneNumber)
5458
.build());
5559

5660
QueryCapabilityRequest request =
@@ -60,7 +64,7 @@ public static void main(String[] args) {
6064
.build();
6165

6266
LOGGER.info(
63-
String.format("Trigger capability lookup for phone number '%s'", smsRecipientPhoneNumber));
67+
String.format("Trigger capability lookup for phone number '%s'", recipientPhoneNumber));
6468

6569
QueryCapabilityResponse response = capabilityService.lookup(request);
6670

snippets/src/main/java/conversation/contact/Create.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,14 @@ public static void main(String[] args) {
3131
String keySecret = Settings.getKeySecret().orElse("MY_KEY_SECRET");
3232
String conversationRegion = Settings.getConversationRegion().orElse("MY_CONVERSATION_REGION");
3333

34-
String smsRecipientPhoneNumber = "AN_SMS_RECIPIENT_PHONE_NUMBER";
34+
// The channel to use for the contact
35+
ConversationChannel recipientChannel = ConversationChannel.SMS;
36+
// The phone number of the contact to create
37+
String recipientPhoneNumber = "RECIPIENT_PHONE_NUMBER";
38+
// The display name of the contact to create
39+
String contactDisplayName = "Created from Java SDK snippet";
40+
// The language of the contact to create
41+
ContactLanguage contactLanguage = ContactLanguage.FR;
3542

3643
Configuration configuration =
3744
Configuration.builder()
@@ -52,11 +59,11 @@ public static void main(String[] args) {
5259
.setChannelIdentities(
5360
Arrays.asList(
5461
ChannelIdentity.builder()
55-
.setChannel(ConversationChannel.SMS)
56-
.setIdentity(smsRecipientPhoneNumber)
62+
.setChannel(recipientChannel)
63+
.setIdentity(recipientPhoneNumber)
5764
.build()))
58-
.setDisplayName("created from Java SDK snippet")
59-
.setLanguage(ContactLanguage.FR)
65+
.setDisplayName(contactDisplayName)
66+
.setLanguage(contactLanguage)
6067
.build();
6168

6269
Contact result = contactService.create(contact);

snippets/src/main/java/conversation/contact/Delete.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ public static void main(String[] args) {
2525
String keySecret = Settings.getKeySecret().orElse("MY_KEY_SECRET");
2626
String conversationRegion = Settings.getConversationRegion().orElse("MY_CONVERSATION_REGION");
2727

28-
String conversationContactId = "A_CONTACT_ID";
28+
// The ID of the contact to delete
29+
String conversationContactId = "CONTACT_ID";
2930

3031
Configuration configuration =
3132
Configuration.builder()

snippets/src/main/java/conversation/contact/Get.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ public static void main(String[] args) {
2626
String keySecret = Settings.getKeySecret().orElse("MY_KEY_SECRET");
2727
String conversationRegion = Settings.getConversationRegion().orElse("MY_CONVERSATION_REGION");
2828

29-
String conversationContactId = "A_CONTACT_ID";
29+
// The ID of the contact to retrieve
30+
String conversationContactId = "CONTACT_ID";
3031

3132
Configuration configuration =
3233
Configuration.builder()

snippets/src/main/java/conversation/contact/GetChannelProfile.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,13 @@ public static void main(String[] args) {
2727
String keySecret = Settings.getKeySecret().orElse("MY_KEY_SECRET");
2828
String conversationRegion = Settings.getConversationRegion().orElse("MY_CONVERSATION_REGION");
2929

30-
String conversationApplicationId = "AN_APPLICATION_ID";
31-
String conversationContactId = "A_CONTACT_ID";
30+
// The ID of the Conversation application the contact belongs to
31+
String conversationApplicationId = "APPLICATION_ID";
32+
// The ID of the contact to retrieve the channel profile for
33+
String conversationContactId = "CONTACT_ID";
34+
// The channel associated with the contact
35+
GetChannelProfileConversationChannel conversationChannel =
36+
GetChannelProfileConversationChannel.MESSENGER;
3237

3338
Configuration configuration =
3439
Configuration.builder()
@@ -45,7 +50,7 @@ public static void main(String[] args) {
4550
ContactGetChannelProfileByContactIdRequest parametersByContactId =
4651
ContactGetChannelProfileByContactIdRequest.builder()
4752
.setAppId(conversationApplicationId)
48-
.setChannel(GetChannelProfileConversationChannel.MESSENGER)
53+
.setChannel(conversationChannel)
4954
.setContactId(conversationContactId)
5055
.build();
5156

0 commit comments

Comments
 (0)