mirror of
https://github.com/jikan-me/jikan-rest.git
synced 2025-02-20 11:23:35 +08:00
v2: add Character endpoints
This commit is contained in:
parent
6f02553adc
commit
cfae2906a9
@ -7,15 +7,46 @@ use Jikan\Request\Character\CharacterPicturesRequest;
|
||||
|
||||
class CharacterController extends Controller
|
||||
{
|
||||
public function _main($id) {
|
||||
$character = $this->jikan->getCharacter(new CharacterRequest($id));
|
||||
|
||||
// backwards compatibility
|
||||
$character = json_decode(
|
||||
$this->serializer->serialize($character, 'json'),
|
||||
true
|
||||
);
|
||||
|
||||
$character['nicknames'] = empty($character['nicknames']) ? null : implode(",", $character['nicknames']);;
|
||||
|
||||
return $character;
|
||||
}
|
||||
|
||||
public function main(int $id)
|
||||
{
|
||||
$character = $this->jikan->getCharacter(new CharacterRequest($id));
|
||||
return response($this->serializer->serialize($character, 'json'));
|
||||
$character = $this->_main($id);
|
||||
|
||||
return response($character);
|
||||
}
|
||||
|
||||
public function pictures(int $id)
|
||||
{
|
||||
$character = $this->jikan->getCharacterPictures(new CharacterPicturesRequest($id));
|
||||
return response($this->serializer->serialize($character, 'json'));
|
||||
$character = $this->_main($id);
|
||||
$pictures = ['image' =>$this->jikan->getCharacterPictures(new CharacterPicturesRequest($id))];
|
||||
$pictures = json_decode(
|
||||
$this->serializer->serialize($pictures, 'json'),
|
||||
true
|
||||
);
|
||||
|
||||
foreach($pictures['image'] as $key => $value) {
|
||||
$pictures['image'][$key] = $value['small'];
|
||||
}
|
||||
|
||||
|
||||
return response(
|
||||
array_merge(
|
||||
$character,
|
||||
$pictures
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
Jikan\Model\Character\Character:
|
||||
exclusion_policy: NONE
|
||||
properties:
|
||||
url:
|
||||
serialized_name: link_canonical
|
||||
voiceActors:
|
||||
serialized_name: voice_actor
|
Loading…
x
Reference in New Issue
Block a user