File tree Expand file tree Collapse file tree 5 files changed +45
-2
lines changed Expand file tree Collapse file tree 5 files changed +45
-2
lines changed Original file line number Diff line number Diff line change 55 "type" : " library" ,
66 "require" : {
77 "php" : " ^7.4" ,
8- "laravel/support" : " ^7.0|^8.0"
8+ "guzzlehttp/guzzle" : " ^6.5" ,
9+ "illuminate/http" : " ^7.0|^8.0" ,
10+ "illuminate/support" : " ^7.0|^8.0"
911 },
1012 "require-dev" : {
1113 "orchestra/testbench" : " ^5.2" ,
Original file line number Diff line number Diff line change 11<?php
22
3- return [];
3+ return [
4+ 'endpoint ' => env ('SNAPSHOT_ENDPOINT ' ),
5+ 'api_token ' => env ('SNAPSHOT_API_TOKEN ' ),
6+ ];
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Soved \Laravel \Snapshot \Contracts ;
4+
5+ use GuzzleHttp \Psr7 \Stream ;
6+
7+ interface Snapshot
8+ {
9+ public function take (string $ url ): Stream ;
10+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Soved \Laravel \Snapshot ;
4+
5+ use GuzzleHttp \Psr7 \Stream ;
6+ use Illuminate \Support \Facades \Http ;
7+ use Soved \Laravel \Snapshot \Contracts \Snapshot as SnapshotContract ;
8+
9+ class Snapshot implements SnapshotContract
10+ {
11+ public function take (string $ url ): Stream
12+ {
13+ $ parameters = [
14+ 'url ' => $ url ,
15+ ];
16+
17+ $ response = Http::withToken (config ('snapshot.api_token ' ))
18+ ->post (config ('snapshot.endpoint ' ), $ parameters );
19+
20+ // Throw an exception if a client or server error occurred...
21+ $ response ->throw ();
22+
23+ return $ response ->getBody ();
24+ }
25+ }
Original file line number Diff line number Diff line change 55use Illuminate \Support \ServiceProvider ;
66use Laravel \Lumen \Application as LumenApplication ;
77use Illuminate \Foundation \Application as LaravelApplication ;
8+ use Soved \Laravel \Snapshot \Contracts \Snapshot as SnapshotContract ;
89
910class SnapshotServiceProvider extends ServiceProvider
1011{
@@ -26,6 +27,8 @@ public function register()
2627 {
2728 $ this ->configure ();
2829 $ this ->offerPublishing ();
30+
31+ $ this ->app ->singleton (SnapshotContract::class, Snapshot::class);
2932 }
3033
3134 /**
You can’t perform that action at this time.
0 commit comments