1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace InShore\Bookwhen; |
6
|
|
|
|
7
|
|
|
use GuzzleHttp; |
8
|
|
|
use GuzzleHttp\Client as GuzzleClient; |
9
|
|
|
use GuzzleHttp\Psr7\Request; |
10
|
|
|
use InShore\Bookwhen\Exceptions\ConfigurationException; |
11
|
|
|
use InShore\Bookwhen\Exceptions\RestException; |
12
|
|
|
use InShore\Bookwhen\Exceptions\ValidationException; |
13
|
|
|
use InShore\Bookwhen\Interfaces\ClientInterface; |
14
|
|
|
use InShore\Bookwhen\Validator; |
15
|
|
|
use Monolog\Level; |
16
|
|
|
use Monolog\Logger; |
17
|
|
|
use Monolog\Handler\StreamHandler; |
18
|
|
|
use Psr\Http\Message\ResponseInterface; |
19
|
|
|
use InShore\Bookwhen\Resources\Attachments; |
20
|
|
|
use InShore\Bookwhen\Resources\ClassPasses; |
21
|
|
|
use InShore\Bookwhen\Resources\Events; |
22
|
|
|
use InShore\Bookwhen\Resources\Locations; |
23
|
|
|
use InShore\Bookwhen\Resources\Tickets; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Class Client |
27
|
|
|
* |
28
|
|
|
* The main class for API consumption |
29
|
|
|
* |
30
|
|
|
* @package inshore\bookwhen |
31
|
|
|
* @todo comments |
32
|
|
|
* @todo externalise config |
33
|
|
|
* @todo fix token |
34
|
|
|
*/ |
35
|
|
|
class Client implements ClientInterface |
36
|
|
|
{ |
37
|
|
|
/** |
38
|
|
|
* {@inheritDoc} |
39
|
|
|
* @see \InShore\Bookwhen\Interfaces\ClientInterface::__construct() |
40
|
|
|
* @todo sanity check the log level passed in an exception if wrong. |
41
|
|
|
* @todo handle guzzle error |
42
|
|
|
*/ |
43
|
20 |
|
public function __construct(private $transporter) |
44
|
|
|
{ |
45
|
20 |
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* |
49
|
|
|
*/ |
50
|
2 |
|
public function attachments(): Attachments |
51
|
|
|
{ |
52
|
2 |
|
return new Attachments($this->transporter); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
|
57
|
|
|
*/ |
58
|
2 |
|
public function classPasses(): ClassPasses |
59
|
|
|
{ |
60
|
2 |
|
return new ClassPasses($this->transporter); |
61
|
|
|
} |
62
|
|
|
/* |
63
|
|
|
* |
64
|
|
|
*/ |
65
|
3 |
|
public function events(): Events |
66
|
|
|
{ |
67
|
3 |
|
return new Events($this->transporter); |
68
|
|
|
} |
69
|
|
|
/** |
70
|
|
|
|
71
|
|
|
*/ |
72
|
2 |
|
public function locations(): Locations |
73
|
|
|
{ |
74
|
2 |
|
return new Locations($this->transporter); |
75
|
|
|
} |
76
|
|
|
/** |
77
|
|
|
|
78
|
|
|
*/ |
79
|
2 |
|
public function tickets(): Tickets |
80
|
|
|
{ |
81
|
2 |
|
return new Tickets($this->transporter); |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
// EOF! |
86
|
|
|
|