1 | <?php |
||
19 | class Client |
||
20 | { |
||
21 | const ENV_DEV = 'dev'; |
||
22 | const ENV_PRODUCTION = 'production'; |
||
23 | |||
24 | /** |
||
25 | * This URL is used for testing purposes |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $testServerUrl = 'http://sstest.consignor.com/ship/ShipmentServerModule.dll'; |
||
30 | |||
31 | /** |
||
32 | * This URL is used for production requests |
||
33 | * |
||
34 | * @var string |
||
35 | */ |
||
36 | protected $productionServerUrl = 'https://www.shipmentserver.com/ship/ShipmentServerModule.dll'; |
||
37 | |||
38 | /** |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $actor; |
||
42 | |||
43 | /** |
||
44 | * @var string |
||
45 | */ |
||
46 | protected $key; |
||
47 | |||
48 | /** |
||
49 | * Should be either 'dev' or 'production' |
||
50 | * |
||
51 | * @var string |
||
52 | */ |
||
53 | protected $environment; |
||
54 | |||
55 | /** |
||
56 | * @var HttpClient |
||
57 | */ |
||
58 | protected $httpClient; |
||
59 | |||
60 | /** |
||
61 | * @var RequestFactory |
||
62 | */ |
||
63 | protected $requestFactory; |
||
64 | |||
65 | /** |
||
66 | * This is the last request |
||
67 | * |
||
68 | * @var PsrRequestInterface|null |
||
69 | */ |
||
70 | protected $request; |
||
71 | |||
72 | /** |
||
73 | * This is the last response |
||
74 | * |
||
75 | * @var ResponseInterface|null |
||
76 | */ |
||
77 | protected $response; |
||
78 | |||
79 | 1 | public function __construct(string $actor, string $key, array $plugins = [], HttpClient $httpClient = null, RequestFactory $requestFactory = null, string $environment = 'production') |
|
95 | |||
96 | /** |
||
97 | * @param RequestInterface $request |
||
98 | * @return array |
||
99 | * @throws InvalidJsonException |
||
100 | */ |
||
101 | 1 | public function doRequest(RequestInterface $request) : array |
|
125 | |||
126 | /** |
||
127 | * @return string |
||
128 | */ |
||
129 | public function getActor(): string |
||
133 | |||
134 | /** |
||
135 | * @return null|PsrRequestInterface |
||
136 | */ |
||
137 | public function getRequest(): ?PsrRequestInterface |
||
141 | |||
142 | /** |
||
143 | * @return null|ResponseInterface |
||
144 | */ |
||
145 | public function getResponse(): ?ResponseInterface |
||
149 | } |
||
150 |