Skip to content

Commit

Permalink
Merge pull request #8 from exodus4d/develop
Browse files Browse the repository at this point in the history
v1.2.1
  • Loading branch information
exodus4d authored Oct 31, 2017
2 parents 96cdc75 + 8d3b369 commit 57210c2
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 10 deletions.
8 changes: 8 additions & 0 deletions app/ApiInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions app/Config/ESIConf.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ class ESIConf extends \Prefab {
'GET' => '/v1/universe/constellations/'
]
],
'structures' => [
'GET' => '/v1/universe/structures/{x}/',
],
'types' => [
'GET' => '/v3/universe/types/{x}/'
]
Expand Down
34 changes: 31 additions & 3 deletions app/ESI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions app/Mapper/InventoryType.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
class InventoryType extends mapper\AbstractIterator {

protected static $map = [
'id' => ['ship' => 'typeId'],

'name' => ['ship' => 'typeName']
'id' => ['ship' => 'typeId'],
'name' => ['ship' => 'typeName']
];
}
6 changes: 3 additions & 3 deletions app/Mapper/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']
];
}
1 change: 0 additions & 1 deletion app/Mapper/Station.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class Station extends mapper\AbstractIterator {

protected static $map = [
'id' => ['station' => 'id'],

'name' => ['station' => 'name']
];
}
24 changes: 24 additions & 0 deletions app/Mapper/Universe/Structure.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* Created by PhpStorm.
* User: exodu
* Date: 14.10.2017
* Time: 15:40
*/

namespace Exodus4D\ESI\Mapper\Universe;

use data\mapper;

class Structure extends mapper\AbstractIterator {

protected static $map = [
'name' => 'name',
'solar_system_id' => 'systemId',
'type_id' => 'typeId',
'position' => 'position',
'x' => 'x',
'y' => 'y',
'z' => 'z',
];
}

0 comments on commit 57210c2

Please sign in to comment.