vvvinceocam / svix-php
Unofficial PHP SDK for Svix
dev-master
2024-02-12 09:58 UTC
Requires
- php: >=8.2
- jane-php/open-api-runtime: ^v7.5.4
- php-http/client-common: ^2.7
- php-http/discovery: ^1.17
- psr/http-client-implementation: *
- psr/http-factory-implementation: *
- symfony/http-client: ^6.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.36
- jane-php/open-api-3: v7.5.4
- nyholm/psr7: ^1.8
- pestphp/pest: ^2.24
- psy/psysh: ^0.11.22
This package is not auto-updated.
Last update: 2024-04-23 00:44:36 UTC
README
Unofficial PHP SDK for Svix.
Basic usage
<?php use Svix\Svix; use Svix\Internal\Model\ApplicationIn; use Svix\Internal\Model\EndpointIn; use Svix\Internal\Model\MessageIn; $client = new Svix('auth token'); // Create an application for a customer $app = new ApplicationIn(); $app->setName('Super Customer'); $app->setUid('id-from-our-application'); $app = $client->applications->create($app); // Bind an endpoint $endpoint = new EndpointIn(); $endpoint->setUrl('https://example.com/customer/endpoint'); $endpoint = $client->endpoints->create($app->getId(), $endpoint); // Get the secret that customer must use to validate webhook calls $secret = $client->endpoints->getSecret($app->getId(), $endpoint->getId()); // Send a message to our freshly enrolled customer $message = new MessageIn(); $message->setEventType('billing.started'); $message->setPayload([ 'some' => 'data', 'with' => [ 'arbitrary' => 'depth', ], ]); $client->messages->create($app->getId(), $message);