Skip to content

Commit f0d514a

Browse files
authored
fix: dialogflow tests and namespaces (GoogleCloudPlatform#1105)
1 parent 76bb7c5 commit f0d514a

File tree

7 files changed

+38
-38
lines changed

7 files changed

+38
-38
lines changed

dialogflow/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"require": {
3-
"google/cloud-dialogflow": "~0.3",
3+
"google/cloud-dialogflow": "^0.15",
44
"symfony/console": "^3.1"
55
},
66
"autoload": {

dialogflow/dialogflow.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
use Symfony\Component\Console\Command\Command;
2222
use Symfony\Component\Console\Input\InputArgument;
2323
use Symfony\Component\Console\Input\InputOption;
24-
use Google\Cloud\Dialogflow\V2\EntityType_Kind;
25-
use Google\Cloud\Dialogflow\V2\SessionEntityType_EntityOverrideMode;
24+
use Google\Cloud\Dialogflow\V2\EntityType\Kind;
25+
use Google\Cloud\Dialogflow\V2\SessionEntityType\EntityOverrideMode;
2626

2727
# includes the autoloader for libraries installed with composer
2828
require __DIR__ . '/vendor/autoload.php';
@@ -199,7 +199,7 @@
199199
->addArgument('display-name', InputArgument::REQUIRED,
200200
'Display name of the entity.')
201201
->addOption('kind', 'k', InputOption::VALUE_REQUIRED,
202-
'Kind of entity. KIND_MAP (default) or KIND_LIST', EntityType_Kind::KIND_MAP)
202+
'Kind of entity. KIND_MAP (default) or KIND_LIST', Kind::KIND_MAP)
203203
->setDescription('Create entity types with provided display name.')
204204
->setHelp(<<<EOF
205205
The <info>%command.name%</info> command creates entity type with provided name.
@@ -398,7 +398,7 @@
398398
InputArgument::REQUIRED, 'Entity values of the session entity type.')
399399
->addOption('entity-override-mode', 'o', InputOption::VALUE_REQUIRED,
400400
'ENTITY_OVERRIDE_MODE_OVERRIDE (default) or ENTITY_OVERRIDE_MODE_SUPPLEMENT',
401-
SessionEntityType_EntityOverrideMode::ENTITY_OVERRIDE_MODE_OVERRIDE)
401+
EntityOverrideMode::ENTITY_OVERRIDE_MODE_OVERRIDE)
402402
->setDescription('Create session entity type.')
403403
->setHelp(<<<EOF
404404
The <info>%command.name%</info> command creates session entity type with

dialogflow/src/entity_type_create.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@
2020

2121
use Google\Cloud\Dialogflow\V2\EntityTypesClient;
2222
use Google\Cloud\Dialogflow\V2\EntityType;
23-
use Google\Cloud\Dialogflow\V2\EntityType_Kind;
23+
use Google\Cloud\Dialogflow\V2\EntityType\Kind;
2424

2525
/**
2626
* Create an entity type with the given display name.
2727
*/
28-
function entity_type_create($projectId, $displayName, $kind = EntityType_Kind::KIND_MAP)
28+
function entity_type_create($projectId, $displayName, $kind = Kind::KIND_MAP)
2929
{
3030
$entityTypesClient = new EntityTypesClient();
3131

3232
// prepare entity type
33-
$parent = $entityTypesClient->projectAgentName($projectId);
33+
$parent = $entityTypesClient->agentName($projectId);
3434
$entityType = new EntityType();
3535
$entityType->setDisplayName($displayName);
3636
$entityType->setKind($kind);

dialogflow/src/entity_type_list.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function entity_type_list($projectId)
2424
{
2525
// get entity types
2626
$entityTypesClient = new EntityTypesClient();
27-
$parent = $entityTypesClient->projectAgentName($projectId);
27+
$parent = $entityTypesClient->agentName($projectId);
2828
$entityTypes = $entityTypesClient->listEntityTypes($parent);
2929

3030
foreach ($entityTypes->iterateAllElements() as $entityType) {

dialogflow/src/intent_create.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
namespace Google\Cloud\Samples\Dialogflow;
2020

2121
use Google\Cloud\Dialogflow\V2\IntentsClient;
22-
use Google\Cloud\Dialogflow\V2\Intent_TrainingPhrase_Part;
23-
use Google\Cloud\Dialogflow\V2\Intent_TrainingPhrase;
24-
use Google\Cloud\Dialogflow\V2\Intent_Message_Text;
25-
use Google\Cloud\Dialogflow\V2\Intent_Message;
22+
use Google\Cloud\Dialogflow\V2\Intent\TrainingPhrase\Part;
23+
use Google\Cloud\Dialogflow\V2\Intent\TrainingPhrase;
24+
use Google\Cloud\Dialogflow\V2\Intent\Message\Text;
25+
use Google\Cloud\Dialogflow\V2\Intent\Message;
2626
use Google\Cloud\Dialogflow\V2\Intent;
2727

2828
/**
@@ -34,31 +34,31 @@ function intent_create($projectId, $displayName, $trainingPhraseParts = [],
3434
$intentsClient = new IntentsClient();
3535

3636
// prepare parent
37-
$parent = $intentsClient->projectAgentName($projectId);
37+
$parent = $intentsClient->agentName($projectId);
3838

3939
// prepare training phrases for intent
4040
$trainingPhrases = [];
4141
foreach ($trainingPhraseParts as $trainingPhrasePart) {
42-
$part = new Intent_TrainingPhrase_Part;
43-
$part->setText($trainingPhrasePart);
42+
$part = (new Part())
43+
->setText($trainingPhrasePart);
4444

4545
// create new training phrase for each provided part
46-
$trainingPhrase = new Intent_TrainingPhrase();
47-
$trainingPhrase->setParts([$part]);
46+
$trainingPhrase = (new TrainingPhrase())
47+
->setParts([$part]);
4848
$trainingPhrases[] = $trainingPhrase;
4949
}
5050

5151
// prepare messages for intent
52-
$text = new Intent_Message_Text();
53-
$text->setText($messageTexts);
54-
$message = new Intent_Message();
55-
$message->setText($text);
52+
$text = (new Text())
53+
->setText($messageTexts);
54+
$message = (new Message())
55+
->setText($text);
5656

5757
// prepare intent
58-
$intent = new Intent();
59-
$intent->setDisplayName($displayName);
60-
$intent->setTrainingPhrases($trainingPhrases);
61-
$intent->setMessages([$message]);
58+
$intent = (new Intent())
59+
->setDisplayName($displayName)
60+
->setTrainingPhrases($trainingPhrases)
61+
->setMessages([$message]);
6262

6363
// create intent
6464
$response = $intentsClient->createIntent($parent, $intent);

dialogflow/src/intent_list.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function intent_list($projectId)
2424
{
2525
// get intents
2626
$intentsClient = new IntentsClient();
27-
$parent = $intentsClient->projectAgentName($projectId);
27+
$parent = $intentsClient->agentName($projectId);
2828
$intents = $intentsClient->listIntents($parent);
2929

3030
foreach ($intents->iterateAllElements() as $intent) {

dialogflow/src/session_entity_type_create.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,38 +18,38 @@
1818
// [START dialogflow_create_session_entity_type]
1919
namespace Google\Cloud\Samples\Dialogflow;
2020

21-
use Google\Cloud\Dialogflow\V2\SessionEntityType_EntityOverrideMode;
21+
use Google\Cloud\Dialogflow\V2\SessionEntityType\EntityOverrideMode;
2222
use Google\Cloud\Dialogflow\V2\SessionEntityTypesClient;
2323
use Google\Cloud\Dialogflow\V2\SessionEntityType;
24-
use Google\Cloud\Dialogflow\V2\EntityType_Entity;
24+
use Google\Cloud\Dialogflow\V2\EntityType\Entity;
2525

2626
/**
2727
* Create a session entity type with the given display name.
2828
*/
2929
function session_entity_type_create($projectId, $displayName, $values,
30-
$sessionId, $overrideMode = SessionEntityType_EntityOverrideMode::ENTITY_OVERRIDE_MODE_OVERRIDE)
30+
$sessionId, $overrideMode = EntityOverrideMode::ENTITY_OVERRIDE_MODE_OVERRIDE)
3131
{
3232
$sessionEntityTypesClient = new SessionEntityTypesClient();
3333
$parent = $sessionEntityTypesClient->sessionName($projectId, $sessionId);
3434

3535
// prepare name
3636
$sessionEntityTypeName = $sessionEntityTypesClient
37-
->sessionEntityTypeName($projectId, $sessionId, $displayName);
37+
->sessionEntityTypeName($projectId, $sessionId, $displayName);
3838

3939
// prepare entities
4040
$entities = [];
4141
foreach ($values as $value) {
42-
$entity = new EntityType_Entity();
43-
$entity->setValue($value);
44-
$entity->setSynonyms([$value]);
42+
$entity = (new Entity())
43+
->setValue($value)
44+
->setSynonyms([$value]);
4545
$entities[] = $entity;
4646
}
4747

4848
// prepare session entity type
49-
$sessionEntityType = new SessionEntityType();
50-
$sessionEntityType->setName($sessionEntityTypeName);
51-
$sessionEntityType->setEntityOverrideMode($overrideMode);
52-
$sessionEntityType->setEntities($entities);
49+
$sessionEntityType = (new SessionEntityType())
50+
->setName($sessionEntityTypeName)
51+
->setEntityOverrideMode($overrideMode)
52+
->setEntities($entities);
5353

5454
// create session entity type
5555
$response = $sessionEntityTypesClient->createSessionEntityType($parent,

0 commit comments

Comments
 (0)