-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
363 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
src/main/java/com/google/businesscommunications/businessmessages/samples/CreateGreeting.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Copyright (C) 2020 Google Inc. 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. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* 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 com.google.businesscommunications.businessmessages.samples; | ||
|
||
import com.google.api.services.businesscommunications.v1.BusinessCommunications; | ||
import com.google.api.services.businesscommunications.v1.model.*; | ||
|
||
import java.util.*; | ||
|
||
|
||
/** | ||
* This code snippet creates a new greeting. | ||
* | ||
* Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.agents.greetings | ||
* | ||
* This code is based on the https://github.com/google-business-communications/java-businesscommunications Java | ||
* Business Communications client library. | ||
*/ | ||
|
||
public class CreateGreeting { | ||
|
||
private static BusinessCommunications.Builder builder; | ||
|
||
public static void main(String[] args) { | ||
|
||
builder = BusinessCommunicationsApi.getBusinessCommunicationsBuilder(); | ||
|
||
String brandId = "EDIT_HERE"; | ||
String agentId = "EDIT_HERE"; | ||
|
||
String agentName = "brands/" + brandId + "/agents/" + agentId; | ||
|
||
// Create a list of conversation starters for the greeting | ||
List<ConversationStarters> conversationStarters = new ArrayList<ConversationStarters>() {{ | ||
add(new ConversationStarters().setSuggestion(new Suggestion() | ||
.setReply(new SuggestedReply().setText("Click me").setPostbackData("postback_option_1")))); | ||
add(new ConversationStarters().setSuggestion(new Suggestion() | ||
.setReply(new SuggestedReply().setText("Chip #2").setPostbackData("postback_option_2")))); | ||
}}; | ||
|
||
// Create a list of welcome messages for the greeting | ||
List<WelcomeMessage> welcomeMessages = new ArrayList<WelcomeMessage>() {{ | ||
add(new WelcomeMessage().setText("Hello there!")); | ||
add(new WelcomeMessage().setText("How may I help you?")); | ||
}}; | ||
|
||
// Actually create the greeting object | ||
Greeting greeting = new Greeting(); | ||
greeting | ||
.setLocale("en") | ||
.setCustomId("My first greeting") | ||
.setWelcomeMessages(welcomeMessages) | ||
.setConversationStarters(conversationStarters); | ||
|
||
// Build the request to create the greeting and execute it | ||
try { | ||
BusinessCommunications.Brands.Agents.Greetings.Create request = builder | ||
.build().brands().agents().greetings().create(agentName, greeting); | ||
|
||
greeting = request.execute(); | ||
|
||
// Print the response and display the contents of the greeting | ||
System.out.println(greeting.toPrettyString()); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
src/main/java/com/google/businesscommunications/businessmessages/samples/GetAgent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (C) 2020 Google Inc. 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. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* 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 com.google.businesscommunications.businessmessages.samples; | ||
|
||
import com.google.api.services.businesscommunications.v1.BusinessCommunications; | ||
import com.google.api.services.businesscommunications.v1.model.*; | ||
|
||
import java.io.IOException; | ||
import java.util.*; | ||
|
||
/** | ||
* This code snippet gets an agent. | ||
* Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.agents/get | ||
* | ||
* This code is based on the https://github.com/google-business-communications/java-businesscommunications Java | ||
* Business Communications client library. | ||
*/ | ||
|
||
public class GetAgent { | ||
|
||
private static BusinessCommunications.Builder builder; | ||
|
||
public static void main(String[] args) { | ||
|
||
builder = BusinessCommunicationsApi.getBusinessCommunicationsBuilder(); | ||
|
||
String brandId = "EDIT_HERE"; | ||
String agentId = "EDIT_HERE"; | ||
|
||
String agentName = "brands/" + brandId + "/agents/" + agentId; | ||
|
||
// Get agent details | ||
System.out.println("Get Agent Details:"); | ||
Agent agent = null; | ||
|
||
try { | ||
BusinessCommunications.Brands.Agents.Get request = builder | ||
.build().brands().agents().get(agentName); | ||
|
||
agent = request.execute(); | ||
System.out.println(agent.toPrettyString()); | ||
|
||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
src/main/java/com/google/businesscommunications/businessmessages/samples/GetGreeting.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (C) 2020 Google Inc. 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. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* 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 com.google.businesscommunications.businessmessages.samples; | ||
|
||
import com.google.api.services.businesscommunications.v1.BusinessCommunications; | ||
import com.google.api.services.businesscommunications.v1.model.*; | ||
|
||
import java.util.*; | ||
|
||
|
||
/** | ||
* This code snippet gets a greeting. | ||
* | ||
* Read more: https://developers.devsite.corp.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.agents.greetings#get | ||
* | ||
* This code is based on the https://github.com/google-business-communications/java-businesscommunications Java | ||
* Business Communications client library. | ||
*/ | ||
|
||
public class GetGreeting { | ||
|
||
private static BusinessCommunications.Builder builder; | ||
|
||
public static void main(String[] args) { | ||
|
||
builder = BusinessCommunicationsApi.getBusinessCommunicationsBuilder(); | ||
|
||
String brandId = "EDIT_HERE"; | ||
String agentId = "EDIT_HERE"; | ||
String greetingId = "EDIT_HERE"; | ||
|
||
String greetingName = "brands/" + brandId + "/agents/" + agentId + | ||
"/greetings/" + greetingId; | ||
|
||
// Build the request to get the greeting object and execute it | ||
try { | ||
BusinessCommunications.Brands.Agents.Greetings.Get request = builder | ||
.build().brands().agents().greetings().get(greetingName); | ||
|
||
Greeting greeting = request.execute(); | ||
|
||
// Print the response and display the contents of the greeting | ||
System.out.println(greeting.toPrettyString()); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
src/main/java/com/google/businesscommunications/businessmessages/samples/ListGreetings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (C) 2020 Google Inc. 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. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* 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 com.google.businesscommunications.businessmessages.samples; | ||
|
||
import com.google.api.services.businesscommunications.v1.BusinessCommunications; | ||
import com.google.api.services.businesscommunications.v1.model.*; | ||
|
||
import java.util.*; | ||
|
||
/** | ||
* This code snippet lists all greetings associated with an agent | ||
* Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/brands.agents.greetings/list | ||
* | ||
* This code is based on the https://github.com/google-business-communications/java-businesscommunications Java | ||
* Business Communications client library. | ||
*/ | ||
|
||
|
||
public class ListGreetings { | ||
|
||
private static BusinessCommunications.Builder builder; | ||
|
||
public static void main(String[] args) { | ||
|
||
builder = BusinessCommunicationsApi.getBusinessCommunicationsBuilder(); | ||
|
||
String brandId = "EDIT_HERE"; | ||
String agentId = "EDIT_HERE"; | ||
|
||
String agentName = "brands/" + brandId + "/agents/" + agentId; | ||
|
||
// Build the request to get the greeting object and execute it | ||
try { | ||
BusinessCommunications.Brands.Agents.Greetings.List request = builder | ||
.build().brands().agents().greetings().list(agentName); | ||
|
||
ListGreetingsResponse greetings = request.execute(); | ||
|
||
// Print the response and display the contents of the greeting | ||
System.out.println(greetings.toPrettyString()); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
Oops, something went wrong.