1 | <?php |
||
13 | class Client |
||
14 | { |
||
15 | |||
16 | /** |
||
17 | * @var string |
||
18 | */ |
||
19 | const CONTROLPAY_HOST_DEFAULT = ""; |
||
20 | |||
21 | /** |
||
22 | * Timeout padrão |
||
23 | * |
||
24 | * @var integer |
||
25 | */ |
||
26 | const CONTROLPAY_TIMEOUT_DEFAULT = 25; |
||
27 | |||
28 | /** |
||
29 | * Timeout padrão |
||
30 | * |
||
31 | * @var IAuthentication |
||
32 | */ |
||
33 | const CONTROLPAY_OAUTH_TYPE_DEFAULT = KeyQueryStringAuthentication::class; |
||
34 | |||
35 | /** |
||
36 | * Parâmetros, pré inicializado com valores padrão |
||
37 | * |
||
38 | * @var array |
||
39 | */ |
||
40 | private $_params = [ |
||
41 | ControlPayParameterConst::CONTROLPAY_HOST => self::CONTROLPAY_HOST_DEFAULT, |
||
42 | ControlPayParameterConst::CONTROLPAY_TIMEOUT => self::CONTROLPAY_TIMEOUT_DEFAULT, |
||
43 | ControlPayParameterConst::CONTROLPAY_OAUTH_TYPE => self::CONTROLPAY_OAUTH_TYPE_DEFAULT |
||
44 | ]; |
||
45 | |||
46 | /** |
||
47 | * @var IAuthentication |
||
48 | */ |
||
49 | private $authentication; |
||
50 | |||
51 | /** |
||
52 | * Client constructor |
||
53 | * |
||
54 | * $params Configurações opcionais, caso não seja passado os parâmetros será |
||
55 | * acatado as presentes na raiz "/controlpay-sdk/config.ini" |
||
56 | * |
||
57 | * @param array[ControlPayParameterConst::{PARAM} => '', ...] $params |
||
58 | * @throws \Exception |
||
59 | */ |
||
60 | public function __construct(array $params = null, IAuthentication $authentication = null) |
||
64 | |||
65 | /** |
||
66 | * Obter parâmetro |
||
67 | * |
||
68 | * @param $key |
||
69 | * @return mixed |
||
70 | */ |
||
71 | public function getParameter($key) |
||
75 | |||
76 | /** |
||
77 | * Adicionar Parâmetro |
||
78 | * |
||
79 | * @param $key |
||
80 | * @param $value |
||
81 | * @return $this |
||
82 | */ |
||
83 | public function setParameter($key, $value) |
||
89 | |||
90 | /** |
||
91 | * Carrega parâmetros |
||
92 | * |
||
93 | * @param $params |
||
94 | * @param IAuthentication $authentication |
||
95 | * @throws \Exception |
||
96 | */ |
||
97 | private function loadParameters($params, IAuthentication $authentication = null) |
||
147 | |||
148 | /** |
||
149 | * @return IAuthentication |
||
150 | */ |
||
151 | public function getAuthentication() |
||
155 | |||
156 | |||
157 | } |
||
158 | |||
165 |