Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration error on composer require #9

Closed
enekochan opened this issue Oct 26, 2023 · 5 comments
Closed

Configuration error on composer require #9

enekochan opened this issue Oct 26, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@enekochan
Copy link
Contributor

enekochan commented Oct 26, 2023

When installing with composer require it always gives an error because the configuration has not yet been done for the bundle.

Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 1
!!  
!!  In ArrayNode.php line 233:
!!                                                                                 
!!    The child config "twitch_id" under "simplystream_twitch_api" must be config  
!!    ured.                                                                        
!!                                                                                 
!!  
!!  
Script @auto-scripts was called via post-update-cmd

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

@enekochan
Copy link
Contributor Author

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)%'

@aaricdev
Copy link
Member

aaricdev commented Oct 26, 2023

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 ...

symfony/recipes-contrib#1557
👍

@aaricdev aaricdev added the enhancement New feature or request label Oct 26, 2023
@aaricdev
Copy link
Member

aaricdev commented Oct 28, 2023

Recipe has been merged to symfony/recipes-contrib

@enekochan
Copy link
Contributor Author

enekochan commented Oct 31, 2023

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?

@aaricdev
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants