diff --git a/app/ApiInterface.php b/app/ApiInterface.php index d8884e1..72f2572 100644 --- a/app/ApiInterface.php +++ b/app/ApiInterface.php @@ -131,6 +131,14 @@ public function getUniverseJumps(): array; */ public function getUniverseKills(): array; + /** + * @param int $structureId + * @param string $accessToken + * @param array $additionalOptions + * @return array + */ + public function getUniverseStructureData(int $structureId, string $accessToken, array $additionalOptions = []): array; + /** * @param int $typeId * @param array $additionalOptions diff --git a/app/Config/ESIConf.php b/app/Config/ESIConf.php index 1dfec90..def42b0 100644 --- a/app/Config/ESIConf.php +++ b/app/Config/ESIConf.php @@ -64,6 +64,9 @@ class ESIConf extends \Prefab { 'GET' => '/v1/universe/constellations/' ] ], + 'structures' => [ + 'GET' => '/v1/universe/structures/{x}/', + ], 'types' => [ 'GET' => '/v3/universe/types/{x}/' ] diff --git a/app/ESI.php b/app/ESI.php index a5c165d..711a2b4 100644 --- a/app/ESI.php +++ b/app/ESI.php @@ -157,7 +157,9 @@ public function getCharacterData(int $characterId): array{ if( !empty($response) ){ $characterData = (new namespace\Mapper\Character($response))->getData(); - $characterData['id'] = $characterId; + if( !empty($characterData) ){ + $characterData['id'] = $characterId; + } } return $characterData; @@ -234,7 +236,9 @@ public function getCorporationData(int $corporationId): array{ if( !empty($response) ){ $corporationData = (new namespace\Mapper\Corporation($response))->getData(); - $corporationData['id'] = $corporationId; + if( !empty($corporationData) ){ + $corporationData['id'] = $corporationId; + } } return $corporationData; @@ -251,7 +255,9 @@ public function getAllianceData(int $allianceId): array{ if( !empty($response) ){ $allianceData = (new namespace\Mapper\Alliance($response))->getData(); - $allianceData['id'] = $allianceId; + if( !empty($allianceData) ){ + $allianceData['id'] = $allianceId; + } } return $allianceData; @@ -444,6 +450,28 @@ public function getUniverseKills(): array{ return $systemKills; } + /** + * @param int $structureId + * @param string $accessToken + * @param array $additionalOptions + * @return array + */ + public function getUniverseStructureData(int $structureId, string $accessToken, array $additionalOptions = []): array { + $url = $this->getEndpointURL(['universe', 'structures', 'GET'], [$structureId]); + $structureData = []; + + $response = $this->request($url, 'GET', $accessToken, $additionalOptions); + + if( !empty($response) ){ + $structureData = (new namespace\Mapper\Universe\Structure($response))->getData(); + if( !empty($structureData) ){ + $structureData['id'] = $structureId; + } + } + + return $structureData; + } + /** * @param int $typeId * @param array $additionalOptions diff --git a/app/Mapper/InventoryType.php b/app/Mapper/InventoryType.php index a55bc9e..114fb68 100644 --- a/app/Mapper/InventoryType.php +++ b/app/Mapper/InventoryType.php @@ -13,8 +13,7 @@ class InventoryType extends mapper\AbstractIterator { protected static $map = [ - 'id' => ['ship' => 'typeId'], - - 'name' => ['ship' => 'typeName'] + 'id' => ['ship' => 'typeId'], + 'name' => ['ship' => 'typeName'] ]; } \ No newline at end of file diff --git a/app/Mapper/Location.php b/app/Mapper/Location.php index 6886140..b689161 100644 --- a/app/Mapper/Location.php +++ b/app/Mapper/Location.php @@ -13,10 +13,10 @@ class Location extends mapper\AbstractIterator { protected static $map = [ - 'solar_system_id' => ['system' => 'id'], + 'solar_system_id' => ['system' => 'id'], - 'station_id' => ['station' => 'id'], + 'station_id' => ['station' => 'id'], - 'structure_id' => ['structure' => 'id'] + 'structure_id' => ['structure' => 'id'] ]; } \ No newline at end of file diff --git a/app/Mapper/Station.php b/app/Mapper/Station.php index 4783904..13c4fee 100644 --- a/app/Mapper/Station.php +++ b/app/Mapper/Station.php @@ -14,7 +14,6 @@ class Station extends mapper\AbstractIterator { protected static $map = [ 'id' => ['station' => 'id'], - 'name' => ['station' => 'name'] ]; } \ No newline at end of file diff --git a/app/Mapper/Universe/Structure.php b/app/Mapper/Universe/Structure.php new file mode 100644 index 0000000..0476fe0 --- /dev/null +++ b/app/Mapper/Universe/Structure.php @@ -0,0 +1,24 @@ + 'name', + 'solar_system_id' => 'systemId', + 'type_id' => 'typeId', + 'position' => 'position', + 'x' => 'x', + 'y' => 'y', + 'z' => 'z', + ]; +} \ No newline at end of file