From 14f2b4b53708569dbf70b5d79c2521a817e4127c Mon Sep 17 00:00:00 2001 From: Mark Friedrich Date: Sun, 25 Feb 2018 01:51:49 +0100 Subject: [PATCH 01/13] - added endpoint "getRouteData()" --- app/ApiInterface.php | 8 ++++++++ app/Config/ESIConf.php | 3 +++ app/ESI.php | 22 ++++++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/app/ApiInterface.php b/app/ApiInterface.php index 72f2572..63ac054 100644 --- a/app/ApiInterface.php +++ b/app/ApiInterface.php @@ -153,6 +153,14 @@ public function getUniverseTypesData(int $typeId, array $additionalOptions = []) */ public function openWindow(int $targetId, string $accessToken): array; + /** + * @param int $sourceId + * @param int $targetId + * @param array $options + * @return array + */ + public function getRouteData(int $sourceId, int $targetId, array $options = []): array; + /** * @param int $corporationId * @return bool diff --git a/app/Config/ESIConf.php b/app/Config/ESIConf.php index 7b743eb..babebd2 100644 --- a/app/Config/ESIConf.php +++ b/app/Config/ESIConf.php @@ -71,6 +71,9 @@ class ESIConf extends \Prefab { 'GET' => '/v3/universe/types/{x}/' ] ], + 'routes' => [ + 'GET' => '/v1/route/{x}/{x}/' + ], 'ui' => [ 'autopilot' => [ 'waypoint' => [ diff --git a/app/ESI.php b/app/ESI.php index 085fc9a..98ccc37 100644 --- a/app/ESI.php +++ b/app/ESI.php @@ -511,6 +511,28 @@ public function openWindow(int $targetId, string $accessToken): array{ return $return; } + /** + * @param int $sourceId + * @param int $targetId + * @param array $options + * @return array + */ + public function getRouteData(int $sourceId, int $targetId, array $options = []): array { + $urlParams = []; + + if( !empty($options['flag']) ){ + $urlParams['flag'] = $options['flag']; + } + + $url = $this->getEndpointURL(['routes', 'GET'], [$sourceId, $targetId], $urlParams); + $routeData = []; + + $response = $this->request($url, 'GET'); +var_dump($response); + + return $routeData; + } + /** * @param int $corporationId * @return bool From 59b1a5b01a267a88207d754f603c99dc2d83a4f0 Mon Sep 17 00:00:00 2001 From: Mark Friedrich Date: Sun, 25 Feb 2018 14:05:04 +0100 Subject: [PATCH 02/13] - added endpoint "getRouteData()" --- app/ESI.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/ESI.php b/app/ESI.php index 98ccc37..16ff8b4 100644 --- a/app/ESI.php +++ b/app/ESI.php @@ -519,12 +519,18 @@ public function openWindow(int $targetId, string $accessToken): array{ */ public function getRouteData(int $sourceId, int $targetId, array $options = []): array { $urlParams = []; - if( !empty($options['flag']) ){ $urlParams['flag'] = $options['flag']; } + if( !empty($options['connections']) ){ + $urlParams['connections'] = $options['connections']; + } + // if( !empty($options['avoid']) ){ + // $urlParams['avoid'] = $options['avoid']; + // } $url = $this->getEndpointURL(['routes', 'GET'], [$sourceId, $targetId], $urlParams); + var_dump($url); $routeData = []; $response = $this->request($url, 'GET'); From 7f5462d7a4538fceba1a61782be18cd5e90008f3 Mon Sep 17 00:00:00 2001 From: Mark Friedrich Date: Sun, 25 Feb 2018 16:09:44 +0100 Subject: [PATCH 03/13] - added endpoint "getRouteData()" --- app/ESI.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/ESI.php b/app/ESI.php index 16ff8b4..b8215b4 100644 --- a/app/ESI.php +++ b/app/ESI.php @@ -532,9 +532,12 @@ public function getRouteData(int $sourceId, int $targetId, array $options = []): $url = $this->getEndpointURL(['routes', 'GET'], [$sourceId, $targetId], $urlParams); var_dump($url); $routeData = []; - $response = $this->request($url, 'GET'); -var_dump($response); + + var_dump($response); + if( !empty($response) ){ + $routeData = array_unique( array_map('intval', $response) ); + } return $routeData; } From 4fcaae37c8ca45be9e0a060b33c20ed6931098af Mon Sep 17 00:00:00 2001 From: Mark Friedrich Date: Sun, 25 Feb 2018 16:15:18 +0100 Subject: [PATCH 04/13] - added endpoint "getRouteData()" --- app/ESI.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/ESI.php b/app/ESI.php index b8215b4..440da4e 100644 --- a/app/ESI.php +++ b/app/ESI.php @@ -519,22 +519,20 @@ public function openWindow(int $targetId, string $accessToken): array{ */ public function getRouteData(int $sourceId, int $targetId, array $options = []): array { $urlParams = []; - if( !empty($options['flag']) ){ - $urlParams['flag'] = $options['flag']; + if( !empty($options['avoid']) ){ + $urlParams['avoid'] = $options['avoid']; } if( !empty($options['connections']) ){ $urlParams['connections'] = $options['connections']; } - // if( !empty($options['avoid']) ){ - // $urlParams['avoid'] = $options['avoid']; - // } + if( !empty($options['flag']) ){ + $urlParams['flag'] = $options['flag']; + } $url = $this->getEndpointURL(['routes', 'GET'], [$sourceId, $targetId], $urlParams); - var_dump($url); $routeData = []; $response = $this->request($url, 'GET'); - var_dump($response); if( !empty($response) ){ $routeData = array_unique( array_map('intval', $response) ); } From f9cd34d6461251cd599cac993744e3073b4c430c Mon Sep 17 00:00:00 2001 From: Mark Friedrich Date: Sun, 25 Feb 2018 16:17:37 +0100 Subject: [PATCH 05/13] - added endpoint "getRouteData()" --- app/ESI.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/ESI.php b/app/ESI.php index 440da4e..241cd94 100644 --- a/app/ESI.php +++ b/app/ESI.php @@ -532,7 +532,8 @@ public function getRouteData(int $sourceId, int $targetId, array $options = []): $url = $this->getEndpointURL(['routes', 'GET'], [$sourceId, $targetId], $urlParams); $routeData = []; $response = $this->request($url, 'GET'); - +var_dump('ress '); +var_dump($response); if( !empty($response) ){ $routeData = array_unique( array_map('intval', $response) ); } From 16b6557a09a01a19a532d51188df924a5a96cd17 Mon Sep 17 00:00:00 2001 From: Mark Friedrich Date: Sun, 25 Feb 2018 16:43:09 +0100 Subject: [PATCH 06/13] - added endpoint "getRouteData()" --- app/Lib/WebClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Lib/WebClient.php b/app/Lib/WebClient.php index 355665d..2241e87 100644 --- a/app/Lib/WebClient.php +++ b/app/Lib/WebClient.php @@ -349,7 +349,7 @@ public function request( $url, array $options = null, $additionalOptions = [], $ $parsedResponseHeaders = $this->parseHeaders($responseHeaders); // check response headers $this->checkResponseHeaders($parsedResponseHeaders, $url); - $statusCode = $this->getStatusCodeFromHeaders($responseHeaders); + $statusCode = $this->getStatusCodeFromHeaders($parsedResponseHeaders); $statusType = $this->getStatusType($statusCode); switch($statusType){ From 9f284ae4dfc1d0d8f210cca49470e2c8cb2c3ea0 Mon Sep 17 00:00:00 2001 From: Mark Friedrich Date: Sun, 25 Feb 2018 16:49:36 +0100 Subject: [PATCH 07/13] - added endpoint "getRouteData()" --- app/ESI.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/ESI.php b/app/ESI.php index 241cd94..fca0ef8 100644 --- a/app/ESI.php +++ b/app/ESI.php @@ -534,8 +534,11 @@ public function getRouteData(int $sourceId, int $targetId, array $options = []): $response = $this->request($url, 'GET'); var_dump('ress '); var_dump($response); - if( !empty($response) ){ + if( !isset($response['error']) ){ $routeData = array_unique( array_map('intval', $response) ); + }else{ + $return['error'] = $response['error']; + } return $routeData; From 491461409019e348d2bd396597d5ad487e0dd43c Mon Sep 17 00:00:00 2001 From: Mark Friedrich Date: Sun, 25 Feb 2018 16:56:04 +0100 Subject: [PATCH 08/13] - added endpoint "getRouteData()" --- app/ESI.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/ESI.php b/app/ESI.php index fca0ef8..8a3221b 100644 --- a/app/ESI.php +++ b/app/ESI.php @@ -534,12 +534,19 @@ public function getRouteData(int $sourceId, int $targetId, array $options = []): $response = $this->request($url, 'GET'); var_dump('ress '); var_dump($response); + + if($response->error){ + $return['error'] = $response->error; + }else{ + $routeData = array_unique( array_map('intval', $response) ); + } + /* if( !isset($response['error']) ){ $routeData = array_unique( array_map('intval', $response) ); }else{ $return['error'] = $response['error']; - } + }*/ return $routeData; } From 60c9c57f7df6bf9980dfc43192666c40c8648f6b Mon Sep 17 00:00:00 2001 From: Mark Friedrich Date: Sun, 25 Feb 2018 16:59:02 +0100 Subject: [PATCH 09/13] - added endpoint "getRouteData()" --- app/ESI.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/ESI.php b/app/ESI.php index 8a3221b..096510d 100644 --- a/app/ESI.php +++ b/app/ESI.php @@ -536,9 +536,9 @@ public function getRouteData(int $sourceId, int $targetId, array $options = []): var_dump($response); if($response->error){ - $return['error'] = $response->error; + $routeData['error'] = $response->error; }else{ - $routeData = array_unique( array_map('intval', $response) ); + $routeData['route'] = array_unique( array_map('intval', $response) ); } /* if( !isset($response['error']) ){ From 984bbdbf8d4f9ec61696e1d8616d3c3ddb2f7c34 Mon Sep 17 00:00:00 2001 From: Mark Friedrich Date: Sun, 25 Feb 2018 17:11:01 +0100 Subject: [PATCH 10/13] - added endpoint "getRouteData()" --- app/ESI.php | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/app/ESI.php b/app/ESI.php index 096510d..a5b3d1c 100644 --- a/app/ESI.php +++ b/app/ESI.php @@ -528,7 +528,14 @@ public function getRouteData(int $sourceId, int $targetId, array $options = []): if( !empty($options['flag']) ){ $urlParams['flag'] = $options['flag']; } - + var_dump('1: $urlParams : '); + var_dump($urlParams); + $urlParams = $this->formatUrlParams($urlParams, [ + 'connections' => [',', '|'], + 'test' => ['&&', '-'] + ]); + var_dump('2: $urlParams : '); + var_dump($urlParams); $url = $this->getEndpointURL(['routes', 'GET'], [$sourceId, $targetId], $urlParams); $routeData = []; $response = $this->request($url, 'GET'); @@ -575,6 +582,25 @@ protected function getNpcCorporations(): array{ return $npcCorporations; } + protected function formatUrlParams(array $urlParams = [], array $format = []) : array { + + $formatter = function(&$item, $key, $params) use (&$formatter) { + $params['depth'] = isset($params['depth']) ? ++$params['depth'] : 0; + $params['firstKey'] = isset($params['firstKey']) ? $params['firstKey'] : $key; + + if(is_array($item)){ + if($delimiter = $params[$params['firstKey']][$params['depth']]){ + array_walk($item, $formatter, $params); + $item = implode($delimiter, $item); + } + } + }; + + array_walk($urlParams, $formatter, $format); + + return $urlParams; + } + /** * get/build endpoint URL * @param array $path From 517d035be6eb8bf97f1b0a799d1dec17eeea97a9 Mon Sep 17 00:00:00 2001 From: Mark Friedrich Date: Sun, 25 Feb 2018 17:15:54 +0100 Subject: [PATCH 11/13] - added endpoint "getRouteData()" --- app/ESI.php | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/app/ESI.php b/app/ESI.php index a5b3d1c..1636830 100644 --- a/app/ESI.php +++ b/app/ESI.php @@ -528,32 +528,20 @@ public function getRouteData(int $sourceId, int $targetId, array $options = []): if( !empty($options['flag']) ){ $urlParams['flag'] = $options['flag']; } - var_dump('1: $urlParams : '); - var_dump($urlParams); + $urlParams = $this->formatUrlParams($urlParams, [ - 'connections' => [',', '|'], - 'test' => ['&&', '-'] + 'connections' => [',', '|'] ]); - var_dump('2: $urlParams : '); - var_dump($urlParams); + $url = $this->getEndpointURL(['routes', 'GET'], [$sourceId, $targetId], $urlParams); $routeData = []; $response = $this->request($url, 'GET'); -var_dump('ress '); -var_dump($response); if($response->error){ $routeData['error'] = $response->error; }else{ $routeData['route'] = array_unique( array_map('intval', $response) ); } - /* - if( !isset($response['error']) ){ - $routeData = array_unique( array_map('intval', $response) ); - }else{ - $return['error'] = $response['error']; - - }*/ return $routeData; } From bebc33c12420107076f1a4c37dd46b58ec6ecb8a Mon Sep 17 00:00:00 2001 From: Mark Friedrich Date: Sun, 25 Feb 2018 17:25:41 +0100 Subject: [PATCH 12/13] - added endpoint "getRouteData()" --- app/ESI.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/ESI.php b/app/ESI.php index 1636830..b737bd5 100644 --- a/app/ESI.php +++ b/app/ESI.php @@ -530,7 +530,8 @@ public function getRouteData(int $sourceId, int $targetId, array $options = []): } $urlParams = $this->formatUrlParams($urlParams, [ - 'connections' => [',', '|'] + 'connections' => [',', '|'], + 'avoid' => [','] ]); $url = $this->getEndpointURL(['routes', 'GET'], [$sourceId, $targetId], $urlParams); From 73273778be5530c75e1eb6d5e38682caa3d27860 Mon Sep 17 00:00:00 2001 From: Mark Friedrich Date: Sat, 7 Apr 2018 16:37:05 +0200 Subject: [PATCH 13/13] - updated README.md --- README.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a9c9dbf..478a079 100644 --- a/README.md +++ b/README.md @@ -1 +1,25 @@ -# pathfinder_esi \ No newline at end of file +### [_EVE-Online_](https://www.eveonline.com) - [_ESI_ API](https://esi.tech.ccp.is) client library for [_Pathfinder_](https://github.com/exodus4d/pathfinder) + +This ESI API client handles all _ESI_ API calls within _Pathfinder_ (`>= v.1.2.3`) and implements all required endpoints. + +#### Installation +This _ESI_ client is automatically installed through [_Composer_](https://getcomposer.org/) with all dependencies from your _Pathfinder_ project root. (see [composer.json](https://github.com/exodus4d/pathfinder/blob/master/composer.json)). + +A newer version of _Pathfinder_ **may** require a newer version of this client as well. So running `composer install` **after** a _Pathfinder_ update will upgrade/install a newer _ESI_ client. +Check the _Pathfinder_ [release](https://github.com/exodus4d/pathfinder/releases) notes for further information. + +#### Bug report +Issues can be tracked here: https://github.com/exodus4d/pathfinder/issues + +#### Development +If you are a developer you might have **both** repositories ([exodus4d/pathfinder](https://github.com/exodus4d/pathfinder), [exodus4d/pathfinder_esi](https://github.com/exodus4d/pathfinder_esi) ) checked out locally. + +In this case you probably want to _test_ changes in your **local** [exodus4d/pathfinder_esi](https://github.com/exodus4d/pathfinder_esi) repo using your **local** [exodus4d/pathfinder](https://github.com/exodus4d/pathfinder) installation. + +1. Clone/Checkout **both** repositories local next to each other +2. Make your changes in your pathfinder_esi repo and **commit** changes (no push!) +3. Switch to your pathfinder repo +4. Run _Composer_ with [`composer-dev.json`](https://github.com/exodus4d/pathfinder/blob/master/composer-dev.json), which installs pathfinder_esi from your **local** repository. + - Unix: `$set COMPOSER=composer-dev.json && composer update` + - Windows (PowerShell): `$env:COMPOSER="composer-dev.json"; composer update --no-suggest` +