2016-09-06 15:26:39 +05:30
|
|
|
<?php
|
|
|
|
namespace common\components\SkinSystem;
|
|
|
|
|
|
|
|
use GuzzleHttp\Client as GuzzleClient;
|
|
|
|
use Yii;
|
|
|
|
|
|
|
|
class Api {
|
|
|
|
|
|
|
|
const BASE_DOMAIN = 'http://skinsystem.ely.by';
|
|
|
|
|
2016-12-23 04:20:34 +05:30
|
|
|
/**
|
|
|
|
* @param string $username
|
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function textures(string $username): array {
|
2016-09-06 15:26:39 +05:30
|
|
|
$response = $this->getClient()->get($this->getBuildUrl('/textures/' . $username));
|
|
|
|
|
2016-12-23 04:20:34 +05:30
|
|
|
return json_decode($response->getBody(), true);
|
2016-09-06 15:26:39 +05:30
|
|
|
}
|
|
|
|
|
2016-12-23 04:20:34 +05:30
|
|
|
protected function getBuildUrl(string $url): string {
|
2016-09-06 15:26:39 +05:30
|
|
|
return self::BASE_DOMAIN . $url;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return GuzzleClient
|
|
|
|
*/
|
2016-12-23 04:20:34 +05:30
|
|
|
protected function getClient(): GuzzleClient {
|
2016-09-06 15:26:39 +05:30
|
|
|
return Yii::$app->guzzle;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|