Closed WildEgo closed 4 years ago
Hello! Thank you for your interest in the library πΈ To answer your questions:
Does this package have any way for me to use a proxy?
It does now. π All you have to do is to use LeagueAPI::SET_GUZZLE_REQ_CFG
to set configuration during library initialization or by using $api->setSetting(LeagueAPI::SET_GUZZLE_REQ_CFG, [...])
anytime during the lifetime of the library.
How Guzzle works with proxies is documented here.
Is there a way to access the Region constants thru a variable?
What exactly do you mean by this? Region constants are defined here as well as Region::$list
- which contains list of all regions. It doesn't really matter whether the library receives the string value via constant or variable - all of these are exactly the same:
$api->setRegion(Region::EUROPE_EAST);
$api->setRegion(Region::$list[Region::EUROPE_EAST]);
$api->setRegion("eune");
$region = "eune"
$api->setRegion($region);
Thanks a lot, I had to add it (proxying) myself on a deprecated package and it was very unfun due to how new to this I am, for the regions I was thinking around the logic of something like:
$region = 'EUROPE_WEST';
$api->setRegion(Region::$region);
But to be honestly I don't mind just saving the correct slug in the database (I just like the way EUROPE_WEST looks like compared to euw).
Other thing I noticed, I didn't scheme too much but I made myself an helper so I can chain various methods and I really don't know if I'm being redundant due to the way ur snippet looks, is that possible without permanently passing the same "summoner id".
Also congrats on the package I think it's by far the longest maintained one which is pretty cool
Thank you, I'm happy that people are actually using it and creating amazing projects!
Currently, there is no built-in way to automatically fill in the summoner I'd, sorry.
Learn not to prefer looks of variable contents, it will ease your programming life, trust me! π
I'm just migrating libraries so I'm trying to keep stuff as like before as I can so I'll just keep using my helper, thanks a lot!
If there's nothing else, you can close the issue yourself βΊοΈ
Sorry for reopening the issue, are you sure this is how it should work?
$this->api->setSettings(
LeagueAPI::SET_GUZZLE_REQ_CFG,
$config
);
I'm receiving a
Argument 1 passed to RiotAPI\LeagueAPI\LeagueAPI::setSettings() must be of the type array, string given
It's setSetting
not setSettings
. π
Hi there, @WildEgo! As it turns out I've lied to you a bit because I've completely forgotten about a feature I've implemented long time ago just for the cases where someone would like to use their own Region and Platform constants π .
You create your own class implementing IRegion
interface. The library uses IRegion::getRegionName
method to convert your constants to actual API endpoint regions. I think it is necessary to implement custom platform provider too, but that is basically the same thing just with IPlatform
interface.
class CustomRegion implements IRegion
{
public static $list = array(
"CustomNAID" => self::NORTH_AMERICA,
"CustomEUNEID" => self::EUROPE_EAST,
// ...
);
public function getList(): array
{
return $this::$list;
}
public function getRegionName( string $region ): string
{
$region = strtolower($region);
if (!isset($this::$list[$region]))
throw new GeneralException('Invalid region provided. Can not find requested region.');
return $this::$list[$region];
}
}
// ...
$api = new LeagueAPI([...], new CustomRegion(), new CustomPlatform());
But please keep in mind that this probably hasn't been tested very much, it may or may not work properly π .
Hey guys I didn't see an issue type that fitted the topic I'm here for so I'd like to ask
That's basically it sorry if it's not the correct place I'm pretty new to this.
Kind Regards, Luis Bizarro.