diff --git a/lib/API/Endpoints/v1/Services.php b/lib/API/Endpoints/v1/Services.php index 47b29154da..996248ccf4 100644 --- a/lib/API/Endpoints/v1/Services.php +++ b/lib/API/Endpoints/v1/Services.php @@ -19,7 +19,7 @@ class Services extends APIEndpoint { $this->date_time = new DateTime(); } - function verifyMailPoetKey($data = array()) { + function checkMSSKey($data = array()) { $key = isset($data['key']) ? trim($data['key']) : null; if(!$key) { @@ -69,7 +69,7 @@ class Services extends APIEndpoint { return $this->errorResponse(array(APIError::BAD_REQUEST => $error)); } - function verifyPremiumKey($data = array()) { + function checkPremiumKey($data = array()) { $key = isset($data['key']) ? trim($data['key']) : null; if(!$key) { diff --git a/tests/unit/API/Endpoints/v1/ServicesTest.php b/tests/unit/API/Endpoints/v1/ServicesTest.php index 9ad506dbc8..9975eab3b2 100644 --- a/tests/unit/API/Endpoints/v1/ServicesTest.php +++ b/tests/unit/API/Endpoints/v1/ServicesTest.php @@ -12,7 +12,7 @@ class ServicesTest extends MailPoetTest { } function testItRespondsWithErrorIfNoMSSKeyIsGiven() { - $response = $this->services_endpoint->verifyMailPoetKey(array('key' => '')); + $response = $this->services_endpoint->checkMSSKey(array('key' => '')); expect($response->status)->equals(APIResponse::STATUS_BAD_REQUEST); expect($response->errors[0]['message'])->equals('Please specify a key.'); } @@ -23,7 +23,7 @@ class ServicesTest extends MailPoetTest { array('checkMSSKey' => array('state' => Bridge::MAILPOET_KEY_VALID)), $this ); - $response = $this->services_endpoint->verifyMailPoetKey($this->data); + $response = $this->services_endpoint->checkMSSKey($this->data); expect($response->status)->equals(APIResponse::STATUS_OK); } @@ -33,7 +33,7 @@ class ServicesTest extends MailPoetTest { array('checkMSSKey' => array('state' => Bridge::MAILPOET_KEY_INVALID)), $this ); - $response = $this->services_endpoint->verifyMailPoetKey($this->data); + $response = $this->services_endpoint->checkMSSKey($this->data); expect($response->status)->equals(APIResponse::STATUS_NOT_FOUND); } @@ -47,7 +47,7 @@ class ServicesTest extends MailPoetTest { )), $this ); - $response = $this->services_endpoint->verifyMailPoetKey($this->data); + $response = $this->services_endpoint->checkMSSKey($this->data); expect($response->status)->equals(APIResponse::STATUS_OK); expect($response->data['message']) ->contains($date->format($this->services_endpoint->date_time->getDateFormat())); @@ -59,7 +59,7 @@ class ServicesTest extends MailPoetTest { array('checkMSSKey' => array('code' => Bridge::CHECK_ERROR_UNAVAILABLE)), $this ); - $response = $this->services_endpoint->verifyMailPoetKey($this->data); + $response = $this->services_endpoint->checkMSSKey($this->data); expect($response->status)->equals(APIResponse::STATUS_NOT_FOUND); expect($response->errors[0]['message'])->contains((string)Bridge::CHECK_ERROR_UNAVAILABLE); } @@ -70,13 +70,13 @@ class ServicesTest extends MailPoetTest { array('checkMSSKey' => function() { throw new \Exception('test'); }), $this ); - $response = $this->services_endpoint->verifyMailPoetKey($this->data); + $response = $this->services_endpoint->checkMSSKey($this->data); expect($response->status)->equals(APIResponse::STATUS_NOT_FOUND); expect($response->errors[0]['message'])->equals('test'); } function testItRespondsWithErrorIfNoPremiumKeyIsGiven() { - $response = $this->services_endpoint->verifyPremiumKey(array('key' => '')); + $response = $this->services_endpoint->checkPremiumKey(array('key' => '')); expect($response->status)->equals(APIResponse::STATUS_BAD_REQUEST); expect($response->errors[0]['message'])->equals('Please specify a key.'); } @@ -87,7 +87,7 @@ class ServicesTest extends MailPoetTest { array('checkPremiumKey' => array('state' => Bridge::PREMIUM_KEY_VALID)), $this ); - $response = $this->services_endpoint->verifyPremiumKey($this->data); + $response = $this->services_endpoint->checkPremiumKey($this->data); expect($response->status)->equals(APIResponse::STATUS_OK); } @@ -97,7 +97,7 @@ class ServicesTest extends MailPoetTest { array('checkPremiumKey' => array('state' => Bridge::PREMIUM_KEY_INVALID)), $this ); - $response = $this->services_endpoint->verifyPremiumKey($this->data); + $response = $this->services_endpoint->checkPremiumKey($this->data); expect($response->status)->equals(APIResponse::STATUS_NOT_FOUND); } @@ -107,7 +107,7 @@ class ServicesTest extends MailPoetTest { array('checkPremiumKey' => array('state' => Bridge::PREMIUM_KEY_ALREADY_USED)), $this ); - $response = $this->services_endpoint->verifyPremiumKey($this->data); + $response = $this->services_endpoint->checkPremiumKey($this->data); expect($response->status)->equals(APIResponse::STATUS_NOT_FOUND); } @@ -121,7 +121,7 @@ class ServicesTest extends MailPoetTest { )), $this ); - $response = $this->services_endpoint->verifyPremiumKey($this->data); + $response = $this->services_endpoint->checkPremiumKey($this->data); expect($response->status)->equals(APIResponse::STATUS_OK); expect($response->data['message']) ->contains($date->format($this->services_endpoint->date_time->getDateFormat())); @@ -133,7 +133,7 @@ class ServicesTest extends MailPoetTest { array('checkPremiumKey' => array('code' => Bridge::CHECK_ERROR_UNAVAILABLE)), $this ); - $response = $this->services_endpoint->verifyPremiumKey($this->data); + $response = $this->services_endpoint->checkPremiumKey($this->data); expect($response->status)->equals(APIResponse::STATUS_NOT_FOUND); expect($response->errors[0]['message'])->contains((string)Bridge::CHECK_ERROR_UNAVAILABLE); } @@ -144,7 +144,7 @@ class ServicesTest extends MailPoetTest { array('checkPremiumKey' => function() { throw new \Exception('test'); }), $this ); - $response = $this->services_endpoint->verifyPremiumKey($this->data); + $response = $this->services_endpoint->checkPremiumKey($this->data); expect($response->status)->equals(APIResponse::STATUS_NOT_FOUND); expect($response->errors[0]['message'])->equals('test'); } diff --git a/views/settings/mta.html b/views/settings/mta.html index 1ed9a8e999..778a734187 100644 --- a/views/settings/mta.html +++ b/views/settings/mta.html @@ -754,7 +754,7 @@ MailPoet.Ajax.post({ api_version: window.mailpoet_api_version, endpoint: 'services', - action: 'verifyMailPoetKey', + action: 'checkMSSKey', data: { key: key } diff --git a/views/settings/premium.html b/views/settings/premium.html index 0d412485d0..4a57345d80 100644 --- a/views/settings/premium.html +++ b/views/settings/premium.html @@ -86,7 +86,7 @@ MailPoet.Ajax.post({ api_version: window.mailpoet_api_version, endpoint: 'services', - action: 'verifyPremiumKey', + action: 'checkPremiumKey', data: { key: key }