[go: nahoru, domu]

Skip to content

Commit

Permalink
Updated README, fixed missing defaultLocale for the location sample
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Falconer committed Oct 29, 2020
1 parent ea4a824 commit a3f6af3
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 47 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

.DS_Store
*.iml
target/
bc-agent-service-account-credentials.json
112 changes: 65 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,91 +1,109 @@
# BUSINESS COMMUNICATIONS: Command-Line Sample

This sample demonstrates how to use the Java SDK for performing operations
with the [Business Communications API](https://businesscommunications.googleapis.com)
This sample demonstrates how to use the [Business Communications Java client library](https://github.com/google-business-communications/java-businesscommunications) for performing operations
with the [Business Communications API](https://businesscommunications.googleapis.com).

This application assumes that you're signed up with
[Business Messages](https://developers.google.com/business-communications/business-messages/guides/set-up/register).

## PREREQUISITES
## Documentation

The documentation for the Business Commmunications API can be found [here](https://developers.google.com/business-communications/business-messages/reference/business-communications/rest).

## Prerequisite

You must have the following software installed on your machine:

* [Apache Maven](http://maven.apache.org) 3.3.9 or greater
* [Java 8](http://www.oracle.com/technetwork/java/javase/downloads/index.html)

## SETUP

Register with Business Messages:
## Before you begin

1. Open [Google Cloud Console](https://console.cloud.google.com) with your
Business Messages Google account and create a new project for your agent.
1. [Register with Business Messages](https://developers.google.com/business-communications/business-messages/guides/set-up/register).
1. Once registered, follow the instructions to [enable the APIs for your project](https://developers.google.com/business-communications/business-messages/guides/set-up/register#enable-api).

Note the **Project ID** and **Project number** values.
### Setup your API authentication credentials

2. Open the
[Business Communications API](https://console.developers.google.com/apis/library/businesscommunications.googleapis.com)
in the API Library.
This sample application uses a service account key file to authenticate the Business Communication API calls for your registered Google Cloud project. You must download a service account key and configure it for the sample.

3. Click **Enable**.
To download a service account key and configure it for the sample, follow the instructions below.

4. [Register your project](https://developers.google.com/business-communications/business-messages/guides/set-up/register)
with Business Messages.
1. Open [Google Cloud Console](https://console.cloud.google.com) with your
Business Messages Google account and make sure you select the project that you registered for Business Messages with.

5. Create a service account.
1. Create a service account.

1. Navigate to [Credentials](https://console.cloud.google.com/apis/credentials).
1. Navigate to [Credentials](https://console.cloud.google.com/apis/credentials).

2. Click **Create service account**.
2. Click **Create service account**.

3. For **Service account name**, enter your agent's name, then click **Create**.
3. For **Service account name**, enter your agent's name, then click **Create**.

4. For **Select a role**, choose **Project** > **Editor**, the click **Continue**.
4. For **Select a role**, choose **Project** > **Editor**, then click **Continue**.

5. Under **Create key**, choose **JSON**, then click **Create**.
5. Under **Create key**, choose **JSON**, then click **Create**.

Your browser downloads the service account key. Store it in a secure location.
Your browser downloads the service account key. Store it in a secure location.

6. Click **Done**.

7. Copy the JSON credentials file into this sample's /src/main/resources
7. Copy the JSON credentials file into this sample's /resources
folder and rename it to "bc-agent-service-account-credentials.json".

## RUN THE SAMPLE
## Samples

### Brand CRUD operations

This sample demonstrates how to create a new brand, get brand details, update a brand, list all brands, and remove the created brand.

View the [source code](https://github.com/google-business-communications/bc-bm-java-command-line-examples/blob/master/src/main/java/com/google/businesscommunications/businessmessages/samples/BrandSample.java).

Usage:

```bash
mvn compile && mvn exec:java -Dexec.mainClass="com.google.businesscommunications.businessmessages.samples.BrandSample"
```

Alternative usage:

```bash
mvn compile && mvn exec:java -Dexec.mainClass="com.google.businesscommunications.businessmessages.samples.BrandSample" -Dexec.args="NO-DELETE"
```

If the NO-DELETE argument exists, the brand that gets created by the sample will not be deleted.

1. In a terminal, navigate to this sample's root directory.
### Agent CRUD operations

2. Run the methods:
* Brand API example:
This sample demonstrates how to create a new agent, get agent details, update the agent, list all agent, and remove the created agent.

mvn compile && mvn exec:java -Dexec.mainClass="com.google.businesscommunications.businessmessages.samples.BrandSample"
View the [source code](https://github.com/google-business-communications/bc-bm-java-command-line-examples/blob/master/src/main/java/com/google/businesscommunications/businessmessages/samples/AgentSample.java).

* Brand API example without brand deletion:
Usage:

mvn compile && mvn exec:java -Dexec.mainClass="com.google.businesscommunications.businessmessages.samples.BrandSample" -Dexec.args="NO-DELETE"
```bash
mvn compile && mvn exec:java -Dexec.mainClass="com.google.businesscommunications.businessmessages.samples.AgentSample" -Dexec.args="BRAND_NAME"
```

If the NO-DELETE argument exists, the brand that gets created by the
sample will not be deleted.
Replace BRAND_NAME with a valid brand ID in "brands/BRAND_ID" format. If you haven't created a brand, run the brand sample with the NO-DELETE argument to create a brand to reference.

* Agent API example:
Alternative usage:

mvn compile && mvn exec:java -Dexec.mainClass="com.google.businesscommunications.businessmessages.samples.AgentSample" -Dexec.args="BRAND_NAME"
```bash
mvn compile && mvn exec:java -Dexec.mainClass="com.google.businesscommunications.businessmessages.samples.AgentSample" -Dexec.args="BRAND_NAME NO-DELETE"
```

Replace BRAND_NAME with a valid brand ID in "brands/BRAND_ID" format.
If you haven't created a brand, run the brand sample with the NO-DELETE
argument to create a brand to reference.
Replace BRAND_NAME with a valid brand ID in "brands/BRAND_ID" format. If you haven't created a brand, run the brand sample with the NO-DELETE argument to create a brand to reference.

* Agent API example without agent deletion:
### Location CRUD operations

mvn compile && mvn exec:java -Dexec.mainClass="com.google.businesscommunications.businessmessages.samples.AgentSample" -Dexec.args="BRAND_NAME NO-DELETE"
This sample demonstrates how to create a new location, get location details, update the location, list all location, and remove the created location.

Replace BRAND_NAME with a valid brand ID in "brands/BRAND_ID" format.
If you haven't created a brand, run the brand sample with the NO-DELETE
argument to create a brand to reference.
View the [source code](https://github.com/google-business-communications/bc-bm-java-command-line-examples/blob/master/src/main/java/com/google/businesscommunications/businessmessages/samples/LocationSample.java).

* Location API example:
Usage:

mvn compile && mvn exec:java -Dexec.mainClass="com.google.businesscommunications.businessmessages.samples.LocationSample" -Dexec.args="AGENT_NAME"
```bash
mvn compile && mvn exec:java -Dexec.mainClass="com.google.businesscommunications.businessmessages.samples.LocationSample" -Dexec.args="AGENT_NAME"
```

Replace AGENT_NAME with a valid agent ID in "brands/BRAND_ID/agents/AGENT_ID" format.
If you haven't created an agent, run the agent sample with the NO-DELETE
argument to create an agent to reference.
Replace AGENT_NAME with a valid agent ID in "brands/BRAND_ID/agents/AGENT_ID" format. If you haven't created an agent, run the agent sample with the NO-DELETE argument to create an agent to reference.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ private static Location createLocation(String brandName, String agentName) {
BusinessCommunications.Brands.Locations.Create request = builder
.build().brands().locations().create(brandName,
new Location()
.setDefaultLocale("en")
.setAgent(agentName)
.setPlaceId("ChIJj61dQgK6j4AR4GeTYWZsKWw")
.setConversationalSettings(conversationalSettings)
Expand Down

0 comments on commit a3f6af3

Please sign in to comment.