Skip to content

Commit

Permalink
Merge pull request #17 from exodus4d/develop
Browse files Browse the repository at this point in the history
v2.0.1
  • Loading branch information
exodus4d authored Mar 22, 2020
2 parents 1fead0d + a35a7b4 commit 3fbd58e
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 3 deletions.
25 changes: 25 additions & 0 deletions app/Client/Ccp/Esi/Esi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions app/Config/Ccp/Esi/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class Config extends AbstractConfig {
],
'online' => [
'GET' => '/v2/characters/{x}/online/'
],
'roles' => [
'GET' => '/v2/characters/{x}/roles/'
]
],
'dogma' => [
Expand Down
19 changes: 19 additions & 0 deletions app/Mapper/Esi/Character/Roles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php


namespace Exodus4D\ESI\Mapper\Esi\Character;

use Exodus4D\Pathfinder\Data\Mapper\AbstractIterator;

class Roles extends AbstractIterator {

/**
* @var array
*/
protected static $map = [
'roles' => 'roles',
'roles_at_base' => 'rolesAtBase',
'roles_at_hq' => 'rolesAtHq',
'roles_at_other' => 'rolesAtOther'
];
}
6 changes: 3 additions & 3 deletions app/Mapper/Esi/Character/Ship.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']
];
}

0 comments on commit 3fbd58e

Please sign in to comment.