jmoati / ring
0.0.4
2020-09-27 19:26 UTC
Requires
- php: >=7.4
- symfony/http-client-contracts: ^2.2
- symfony/http-foundation: ^5.1
- symfony/property-access: ^5.1
- symfony/serializer: ^5.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.14
- phpstan/phpstan: ^0.12
- symfony/http-client: ^5.1
- symfony/var-dumper: ^5.0
This package is auto-updated.
Last update: 2024-11-28 04:40:53 UTC
README
<?php use Jmoati\Ring\Model\Doorbot; use Jmoati\Ring\Ring; use Jmoati\Ring\Serializer\DoorbotNormalizer; use Symfony\Component\HttpClient\HttpClient; use Symfony\Component\Serializer\Encoder\JsonEncoder; use Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter; use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; use Symfony\Component\Serializer\Serializer; require __DIR__ . '/vendor/autoload.php'; $httpClient = HttpClient::create(); $serializer = new Serializer([ new DoorbotNormalizer(), new ObjectNormalizer(null, new CamelCaseToSnakeCaseNameConverter()), ], [ new JsonEncoder(), ]); $ring = new Ring( $httpClient, $refreshToken, $serializer ); if ($ring->updateSnapshots()) { $doorbots = $ring->getDoorbots(); array_walk( $doorbots, fn(Doorbot $device) => file_put_contents('/tmp/'.$device->id.'.jpeg', $ring->getSnapshot($device->id)) ); }