Skip to content

Commit 400e458

Browse files
committed
MBS-10621: Use constants for default endpoints in googlesynthesize tool
1 parent dc387cf commit 400e458

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

tools/googlesynthesize/classes/connector.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@
3535
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3636
*/
3737
class connector extends \local_ai_manager\base_connector {
38+
public const DEFAULT_GOOGLE_SYNTHESIZE_ENDPOINT = 'https://texttospeech.googleapis.com/v1/text:synthesize';
39+
3840
#[\Override]
3941
protected function get_endpoint_url(): string {
40-
return $this->instance->get_endpoint() ?: 'https://texttospeech.googleapis.com/v1/text:synthesize';
42+
return $this->instance->get_endpoint() ?: self::DEFAULT_GOOGLE_SYNTHESIZE_ENDPOINT;
4143
}
4244

4345
#[\Override]

tools/googlesynthesize/classes/instance.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
class instance extends base_instance {
3232
#[\Override]
3333
protected function extend_form_definition(\MoodleQuickForm $mform): void {
34-
$defaultendpoint = 'https://texttospeech.googleapis.com/v1/text:synthesize';
34+
$defaultendpoint = connector::DEFAULT_GOOGLE_SYNTHESIZE_ENDPOINT;
3535
$insertat = $mform->elementExists('useglobalapikey') ? 'useglobalapikey' : 'apikey';
3636
$mform->insertElementBefore(
3737
$mform->createElement(

tools/googlesynthesize/tests/connector_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ private function make_connector(string $endpoint): connector {
4646

4747
public function test_get_endpoint_url_returns_default_when_empty(): void {
4848
$this->assertEquals(
49-
'https://texttospeech.googleapis.com/v1/text:synthesize',
49+
connector::DEFAULT_GOOGLE_SYNTHESIZE_ENDPOINT,
5050
$this->call_get_endpoint_url($this->make_connector(''))
5151
);
5252
}

0 commit comments

Comments
 (0)