Closed enekochan closed 10 months ago
I think this could be more or less the content of the recipe.
manifest.json
:
{
"copy-from-recipe": {
"config/": "%CONFIG_DIR%/"
},
"env": {
"TWITCH_ID": "",
"TWITCH_SECRET": "",
"TWITCH_REDIRECT_URI": "",
"TWITCH_WEBHOOK_SECRET": ""
}
}
config/packages/simplystream_twitch_api.yaml
:
simplystream_twitch_api:
twitch_id: '%env(TWITCH_ID)%'
twitch_secret: '%env(TWITCH_SECRET)%'
redirect_uri: '%env(TWITCH_REDIRECT_URI)%'
webhook:
secret: '%env(TWITCH_WEBHOOK_SECRET)%'
Hey @enekochan, thanks for the advice, I'll look into it :) I've honestly never actually contributed to the official recipe repo.
And thanks for the contribution btw! If you want to use the most recent updates, I've mostly worked on the feature/implement-symfony-http-client
branch but it's hell of a quality right now ...
Recipe has been merged to symfony/recipes-contrib
I'm looking a little bit into feature/implement-symfony-http-client
and looks good to me :) I think only the Music and Tag services need to be removed in api.xml
. Then updateSimplyStream\TwitchApiBundle\Helix\Api\TwitchApi
service definition to remove those and the GuestStar service. Do you want a pull request?
Should be already in now, sorry if you already put some time into it :( But sure, any contribution is welcome!
To minimize potential conflicts, I'm currently working on changing the way requests and responses work (or at least prototyping it). I think that the TwitchResponse in some ways is not that useful.
For example when Twitch only returns a 204 (no content) statuscode, you receive nothing as a user of this package. Also in case of errors, you only get a generic exception with errors from the API. I'm thinking about adding the statuscode and an optional error attribute to the response.
Also the request body might be changed into objects to prevent faulty data. You'll then have something like this:
public function createCustomRewards(
string $broadcasterId,
CustomReward $body,
AccessTokenInterface $accessToken
): TwitchResponseInterface {
return $this->sendRequest(
path: self::BASE_PATH . '/custom_rewards',
query: [
'broadcaster_id' => $broadcasterId,
],
type: CustomReward::class . '[]',
body: $body,
accessToken: $accessToken,
);
}
// ...
$channelPointsApi->createCustomRewards('1234', new CustomReward('some reward', 10, ...everythingElse), $accessToken);
This will allow me to execute assertions on the CustomReward DTO and also gives the bundle user the assurance, that their data is most likely valid. But I'm still prototyping, if I like the way it works
When installing with composer require it always gives an error because the configuration has not yet been done for the bundle.
This could be avoided now using Flex recipes. It's just a matter of adding the creation of the appropriate config file with env variables in the symfony/recipes-contrib repo. This is an example that could be helpfull to use as base:
https://github.com/symfony/recipes-contrib/tree/main/velhron/dadata-bundle/1.0