diff --git a/app/Client/Ccp/Esi/Esi.php b/app/Client/Ccp/Esi/Esi.php index cb3ca02..b2a5fc2 100644 --- a/app/Client/Ccp/Esi/Esi.php +++ b/app/Client/Ccp/Esi/Esi.php @@ -212,6 +212,31 @@ function($body) : array { ); } + /** + * @param int $characterId + * @param string $accessToken + * @return RequestConfig + */ + protected function getCharacterRolesRequest(int $characterId, string $accessToken) : RequestConfig { + return new RequestConfig( + WebClient::newRequest('GET', $this->getEndpointURI(['characters', 'roles', 'GET'], [$characterId])), + $this->getRequestOptions($accessToken), + function($body) : array { + $rolesData = []; + if(!$body->error){ + $rolesData = (new Mapper\Character\Roles($body))->getData(); + array_walk($rolesData, function(&$roles){ + $roles = array_map('strtolower', (array)$roles); + }); + }else{ + $rolesData['error'] = $body->error; + } + + return $rolesData; + } + ); + } + /** * @param int $corporationId * @return RequestConfig diff --git a/app/Config/Ccp/Esi/Config.php b/app/Config/Ccp/Esi/Config.php index 6af1c30..711a190 100644 --- a/app/Config/Ccp/Esi/Config.php +++ b/app/Config/Ccp/Esi/Config.php @@ -53,6 +53,9 @@ class Config extends AbstractConfig { ], 'online' => [ 'GET' => '/v2/characters/{x}/online/' + ], + 'roles' => [ + 'GET' => '/v2/characters/{x}/roles/' ] ], 'dogma' => [ diff --git a/app/Mapper/Esi/Character/Roles.php b/app/Mapper/Esi/Character/Roles.php new file mode 100644 index 0000000..ae20d5f --- /dev/null +++ b/app/Mapper/Esi/Character/Roles.php @@ -0,0 +1,19 @@ + 'roles', + 'roles_at_base' => 'rolesAtBase', + 'roles_at_hq' => 'rolesAtHq', + 'roles_at_other' => 'rolesAtOther' + ]; +} \ No newline at end of file diff --git a/app/Mapper/Esi/Character/Ship.php b/app/Mapper/Esi/Character/Ship.php index bafd9f0..65efc36 100644 --- a/app/Mapper/Esi/Character/Ship.php +++ b/app/Mapper/Esi/Character/Ship.php @@ -16,10 +16,10 @@ class Ship extends AbstractIterator { * @var array */ protected static $map = [ - 'ship_type_id' => ['ship' => 'typeId'], + 'ship_type_id' => ['ship' => 'typeId'], - 'ship_item_id' => ['ship' => 'id'], + 'ship_item_id' => ['ship' => 'id'], - 'ship_name' => ['ship' => 'name'] + 'ship_name' => ['ship' => 'name'] ]; } \ No newline at end of file