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

Commit

Permalink
use API v2 as default
Browse files Browse the repository at this point in the history
"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/
  • Loading branch information
arkadiusjonczek committed Jul 19, 2020
1 parent 64c4a0f commit f71b037
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/DeepL.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class DeepL
* @param string $authKey
* @param integer $apiVersion
*/
public function __construct($authKey, $apiVersion = 1)
public function __construct($authKey, $apiVersion = 2)
{
$this->authKey = $authKey;
$this->apiVersion = $apiVersion;
Expand Down Expand Up @@ -251,7 +251,7 @@ protected function buildUrl(
$url = DeepL::API_URL_V2;
break;
default:
$url = DeepL::API_URL_V1;
$url = DeepL::API_URL_V2;
}

$url .= '?' . sprintf(DeepL::API_URL_AUTH_KEY, $this->authKey);
Expand Down
12 changes: 6 additions & 6 deletions tests/DeepLTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function testBuildUrl()
{
$authKey = '123456';

$expectedString = 'https://api.deepl.com/v1/translate?' . http_build_query(array(
$expectedString = 'https://api.deepl.com/v2/translate?' . http_build_query(array(
'auth_key' => $authKey,
'source_lang' => 'de',
'target_lang' => 'en',
Expand All @@ -128,7 +128,7 @@ public function testBuildUrl()
public function testBuildUrlWithTags()
{
$authKey = '123456';
$expectedString = 'https://api.deepl.com/v1/translate?' . http_build_query(array(
$expectedString = 'https://api.deepl.com/v2/translate?' . http_build_query(array(
'auth_key' => $authKey,
'source_lang' => 'de',
'target_lang' => 'en',
Expand Down Expand Up @@ -164,7 +164,7 @@ public function testBuildBody()
}

/**
* Test translate() success
* Test translate() success with v2 API
*
* TEST REQUIRES VALID DEEPL AUTH KEY!!
*/
Expand All @@ -185,17 +185,17 @@ public function testTranslateSuccess()
}

/**
* Test translate() success with v2 API
* Test translate() success with v1 API
*
* TEST REQUIRES VALID DEEPL AUTH KEY!!
*/
public function testTranslateV2Success()
public function testTranslateV1Success()
{
if (self::$authKey === false) {
$this->markTestSkipped('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured.');
}

$deepl = new DeepL(self::$authKey, 2);
$deepl = new DeepL(self::$authKey, 1);

$germanText = 'Hallo Welt';
$expectedText = 'Hello World';
Expand Down

0 comments on commit f71b037

Please sign in to comment.