renttek / bitbucket-webhook-types
Library to convert bitbucket webhook payloads to typed objects
0.0.1
2023-06-01 18:33 UTC
Requires
- php: 8.2.*
- cuyz/valinor: ^1.4
- doctrine/collections: ^2.1
- symfony/uid: ^6.3
Requires (Dev)
- captainhook/captainhook: ^5.16
- captainhook/plugin-composer: ^5.3
- ergebnis/composer-normalize: ^2.31
- php-parallel-lint/php-console-highlighter: ^1.0
- php-parallel-lint/php-parallel-lint: ^1.3
- phpstan/extension-installer: ^1.3
- phpstan/phpstan: ^1.10
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-strict-rules: ^1.5
- roave/security-advisories: dev-latest
- symfony/var-dumper: 5.* || 6.*
- symplify/easy-coding-standard: ^11.3
- vimeo/psalm: ^5.12
README
This library provides a converter as well as value objects for the bitbucket webhook payloads.
Installation
The module can be asily installed using composer:
composer require renttek/bitbucket-webhook-types
Usage
$pullRequestCreatedPayload = '<webhook json here>'; $converter = new \Renttek\BitbucketWebhookTypes\Converter(); $pullRequestCreated = $converter->fromJson( \Renttek\BitbucketWebhookTypes\EventPayload\PullrequestCreated::class, $pullRequestCreatedPayload )
Using a custom mapper/configuration
The converter is built using cuyz/valinor
and if you want to use a custom mapper, instead of the default one, you can
pass a mapper to the constructor of \Renttek\BitbucketWebhookTypes\Converter
:
$pullRequestCreatedPayload = '<webhook json here>'; $myAwesomeMapper = (new MapperBuilder()) ->supportDateFormats('Y-m-d\TH:i:s.uP') ->infer( ... ) ->registerConstructor( ... ) ->allowSuperfluousKeys() ->mapper(); $converter = new \Renttek\BitbucketWebhookTypes\Converter($myAwesomeMapper); $pullRequestCreated = $converter->fromJson( \Renttek\BitbucketWebhookTypes\EventPayload\PullrequestCreated::class, $pullRequestCreatedPayload )
Credits & thank you
I'd like to thank Team CuyZ and all the contributors for valinor!