1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace TonicForHealth\PagerDutyClient\Client; |
4
|
|
|
|
5
|
|
|
use Http\Client\Common\HttpMethodsClient; |
6
|
|
|
use TonicForHealth\PagerDutyClient\RepresentProcessor\RepresentProcessorInterface; |
7
|
|
|
use TonicForHealth\PagerDutyClient\Validation\ValidationResponseInterface; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class AbstractClient. |
11
|
|
|
*/ |
12
|
|
|
abstract class AbstractClient |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @var array |
16
|
|
|
*/ |
17
|
|
|
protected $headers = ['Content-type' => 'application/json']; |
18
|
|
|
/** |
19
|
|
|
* @var HttpMethodsClient |
20
|
|
|
*/ |
21
|
|
|
protected $httpClient; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var string |
25
|
|
|
*/ |
26
|
|
|
protected $apiRootUrl; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var RepresentProcessorInterface |
30
|
|
|
*/ |
31
|
|
|
protected $representProcessor; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var ValidationResponseInterface |
35
|
|
|
*/ |
36
|
|
|
protected $validationResponse; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* RequestNotificationType constructor. |
40
|
|
|
* |
41
|
|
|
* @param string $apiRootUrl |
42
|
|
|
* @param HttpMethodsClient $httpClient |
43
|
|
|
* @param RepresentProcessorInterface $representProcessor |
44
|
|
|
* @param ValidationResponseInterface $validationResponse |
45
|
|
|
*/ |
46
|
4 |
|
public function __construct( |
47
|
|
|
$apiRootUrl, |
48
|
|
|
HttpMethodsClient $httpClient, |
49
|
|
|
RepresentProcessorInterface $representProcessor, |
50
|
|
|
ValidationResponseInterface $validationResponse |
51
|
|
|
) { |
52
|
4 |
|
$this->setApiRootUrl($apiRootUrl); |
53
|
|
|
|
54
|
4 |
|
$this->setHttpClient($httpClient); |
55
|
|
|
|
56
|
4 |
|
$this->setRepresentProcessor($representProcessor); |
57
|
|
|
|
58
|
4 |
|
$this->setValidationResponse($validationResponse); |
59
|
4 |
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @return HttpMethodsClient |
63
|
|
|
*/ |
64
|
4 |
|
public function getHttpClient() |
65
|
|
|
{ |
66
|
4 |
|
return $this->httpClient; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @return string |
71
|
|
|
*/ |
72
|
4 |
|
public function getApiRootUrl() |
73
|
|
|
{ |
74
|
4 |
|
return $this->apiRootUrl; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return RepresentProcessorInterface |
79
|
|
|
*/ |
80
|
4 |
|
public function getRepresentProcessor() |
81
|
|
|
{ |
82
|
4 |
|
return $this->representProcessor; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @return ValidationResponseInterface |
87
|
|
|
*/ |
88
|
3 |
|
public function getValidationResponse() |
89
|
|
|
{ |
90
|
3 |
|
return $this->validationResponse; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @param HttpMethodsClient $httpClient |
95
|
|
|
*/ |
96
|
4 |
|
protected function setHttpClient($httpClient) |
97
|
|
|
{ |
98
|
4 |
|
$this->httpClient = $httpClient; |
99
|
4 |
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @param string $apiRootUrl |
103
|
|
|
*/ |
104
|
4 |
|
protected function setApiRootUrl($apiRootUrl) |
105
|
|
|
{ |
106
|
4 |
|
$this->apiRootUrl = $apiRootUrl; |
107
|
4 |
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @param RepresentProcessorInterface $representProcessor |
111
|
|
|
*/ |
112
|
4 |
|
protected function setRepresentProcessor($representProcessor) |
113
|
|
|
{ |
114
|
4 |
|
$this->representProcessor = $representProcessor; |
115
|
4 |
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @param ValidationResponseInterface $validationResponse |
119
|
|
|
*/ |
120
|
4 |
|
protected function setValidationResponse($validationResponse) |
121
|
|
|
{ |
122
|
4 |
|
$this->validationResponse = $validationResponse; |
123
|
4 |
|
} |
124
|
|
|
} |
125
|
|
|
|