Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit f71b037

Browse files
use API v2 as default
"Version 1 (v1) of the DeepL API is not supported by the DeepL API plan available from October 2018. Please use version 2 for all new products other than CAT tool integrations." from https://www.deepl.com/docs-api/accessing-the-api/api-versions/
1 parent 64c4a0f commit f71b037

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/DeepL.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class DeepL
132132
* @param string $authKey
133133
* @param integer $apiVersion
134134
*/
135-
public function __construct($authKey, $apiVersion = 1)
135+
public function __construct($authKey, $apiVersion = 2)
136136
{
137137
$this->authKey = $authKey;
138138
$this->apiVersion = $apiVersion;
@@ -251,7 +251,7 @@ protected function buildUrl(
251251
$url = DeepL::API_URL_V2;
252252
break;
253253
default:
254-
$url = DeepL::API_URL_V1;
254+
$url = DeepL::API_URL_V2;
255255
}
256256

257257
$url .= '?' . sprintf(DeepL::API_URL_AUTH_KEY, $this->authKey);

tests/DeepLTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function testBuildUrl()
106106
{
107107
$authKey = '123456';
108108

109-
$expectedString = 'https://api.deepl.com/v1/translate?' . http_build_query(array(
109+
$expectedString = 'https://api.deepl.com/v2/translate?' . http_build_query(array(
110110
'auth_key' => $authKey,
111111
'source_lang' => 'de',
112112
'target_lang' => 'en',
@@ -128,7 +128,7 @@ public function testBuildUrl()
128128
public function testBuildUrlWithTags()
129129
{
130130
$authKey = '123456';
131-
$expectedString = 'https://api.deepl.com/v1/translate?' . http_build_query(array(
131+
$expectedString = 'https://api.deepl.com/v2/translate?' . http_build_query(array(
132132
'auth_key' => $authKey,
133133
'source_lang' => 'de',
134134
'target_lang' => 'en',
@@ -164,7 +164,7 @@ public function testBuildBody()
164164
}
165165

166166
/**
167-
* Test translate() success
167+
* Test translate() success with v2 API
168168
*
169169
* TEST REQUIRES VALID DEEPL AUTH KEY!!
170170
*/
@@ -185,17 +185,17 @@ public function testTranslateSuccess()
185185
}
186186

187187
/**
188-
* Test translate() success with v2 API
188+
* Test translate() success with v1 API
189189
*
190190
* TEST REQUIRES VALID DEEPL AUTH KEY!!
191191
*/
192-
public function testTranslateV2Success()
192+
public function testTranslateV1Success()
193193
{
194194
if (self::$authKey === false) {
195195
$this->markTestSkipped('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured.');
196196
}
197197

198-
$deepl = new DeepL(self::$authKey, 2);
198+
$deepl = new DeepL(self::$authKey, 1);
199199

200200
$germanText = 'Hallo Welt';
201201
$expectedText = 'Hello World';

0 commit comments

Comments
 (0)