diff --git a/README.md b/README.md index 02f948d..b944f1f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# AccuRanker for Laravel 5.1 +# AccuRanker for Laravel 5+ **THIS PACKAGE IS UNDER DEVELOPMENT** diff --git a/src/SpotOnLive/AccuRanker/Services/AccuRankerService.php b/src/SpotOnLive/AccuRanker/Services/AccuRankerService.php index b084359..1afe91d 100644 --- a/src/SpotOnLive/AccuRanker/Services/AccuRankerService.php +++ b/src/SpotOnLive/AccuRanker/Services/AccuRankerService.php @@ -131,6 +131,18 @@ public function createKeywordForDomain($domainId, $keyword, $searchType, $search return $this->convertResponseToKeyword($response); } + /** + * @param $domainId + * @param $id + * @return null + */ + public function deleteKeywordsForDomain($domainId, $id) + { + $response = $this->delete('domains/' . $domainId . '/keywords/' . $id . '/'); + + return null; + } + /** * Call the CURL get service * @@ -169,6 +181,22 @@ public function post($url, $body) return $this->parse($result); } + /** + * Call the CURL delete service + * + * @param $url + * @return array + */ + public function delete($url) + { + $result = $this->curlService->delete( + $this->getUrl() . $url, + $this->getToken() + ); + + return $this->parse($result); + } + /** * Parse result * diff --git a/src/SpotOnLive/AccuRanker/Services/AccuRankerServiceInterface.php b/src/SpotOnLive/AccuRanker/Services/AccuRankerServiceInterface.php index 2014238..a757a71 100644 --- a/src/SpotOnLive/AccuRanker/Services/AccuRankerServiceInterface.php +++ b/src/SpotOnLive/AccuRanker/Services/AccuRankerServiceInterface.php @@ -19,4 +19,22 @@ public function listKeywordsForDomain($id); * @return array */ public function listKeywordHistory($keywordId); + + /** + * @param $domainId + * @param $keyword + * @param $searchType + * @param $searchEngine + * @param array $optional + * @return mixed + */ + public function createKeywordForDomain($domainId, $keyword, $searchType, $searchEngine, $optional = []); + + /** + * @param $domainId + * @param $id + * @return mixed + */ + public function deleteKeywordsForDomain($domainId, $id); + } diff --git a/src/SpotOnLive/AccuRanker/Services/CurlService.php b/src/SpotOnLive/AccuRanker/Services/CurlService.php index c810401..2676059 100644 --- a/src/SpotOnLive/AccuRanker/Services/CurlService.php +++ b/src/SpotOnLive/AccuRanker/Services/CurlService.php @@ -4,6 +4,7 @@ use SpotOnLive\AccuRanker\Options\ApiOptions; + class CurlService implements CurlServiceInterface { /** @var ApiOptions */ @@ -30,7 +31,7 @@ public function get($url, $token, $params = []) curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); - curl_setopt($curl, CURLOPT_TIMEOUT, $this->config->get('curl_timeout')); + curl_setopt($curl,CURLOPT_TIMEOUT, $this->config->get('curl_timeout')); curl_setopt($curl, CURLOPT_HTTPHEADER, ['Authorization:' . $token]); $result = curl_exec($curl); @@ -52,9 +53,31 @@ public function post($url, $token, $body = []) $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); - curl_setopt($curl, CURLOPT_POST, 1); - curl_setopt($curl, CURLOPT_POSTFIELDS, $body); - curl_setopt($curl, CURLOPT_TIMEOUT, $this->config->get('curl_timeout')); + curl_setopt($curl,CURLOPT_POST, 1); + curl_setopt($curl,CURLOPT_POSTFIELDS,$body); + curl_setopt($curl,CURLOPT_TIMEOUT, $this->config->get('curl_timeout')); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_HTTPHEADER, ['Authorization:' . $token]); + + $result = curl_exec($curl); + + curl_close($curl); + + return $result; + } + + + /** + * @param $url + * @param $token + * @return mixed + */ + public function delete($url, $token) + { + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE"); + curl_setopt($curl,CURLOPT_TIMEOUT, $this->config->get('curl_timeout')); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, ['Authorization:' . $token]); diff --git a/src/SpotOnLive/AccuRanker/Services/CurlServiceInterface.php b/src/SpotOnLive/AccuRanker/Services/CurlServiceInterface.php index a5686a9..719e7c5 100644 --- a/src/SpotOnLive/AccuRanker/Services/CurlServiceInterface.php +++ b/src/SpotOnLive/AccuRanker/Services/CurlServiceInterface.php @@ -18,4 +18,11 @@ public function get($url, $token); * @return string */ public function post($url, $token, $body); + + /** + * @param $url + * @param $token + * @return mixed + */ + public function delete($url, $token); }