1 | <?php |
||
18 | class EasyMarketing extends AbstractNetwork implements NetworkInterface |
||
19 | { |
||
20 | /** |
||
21 | * @var object |
||
22 | */ |
||
23 | private $_network = null; |
||
24 | private $_username = ''; |
||
25 | private $_password = ''; |
||
26 | protected $_tracking_parameter = 'subid'; |
||
27 | private $_idSite = ''; |
||
28 | |||
29 | /** |
||
30 | * @method __construct |
||
31 | */ |
||
32 | public function __construct(string $username, string $password, string $idSite = '') |
||
41 | |||
42 | public function login(string $username, string $password, string $idSite = ''): bool |
||
43 | { |
||
44 | $this->_logged = false; |
||
|
|||
45 | if (isNullOrEmpty($username) || isNullOrEmpty($password)) { |
||
46 | |||
47 | return false; |
||
48 | } |
||
49 | $this->_username = $username; |
||
50 | $this->_password = $password; |
||
51 | $this->_idSite = $idSite; |
||
52 | $credentials = array(); |
||
53 | $credentials["user"] = $this->_username; |
||
54 | $credentials["password"] = $this->_password; |
||
55 | $credentials["idSite"] = $this->_idSite; |
||
56 | $this->_network->login($credentials); |
||
57 | if ($this->_network->checkConnection()) { |
||
58 | $this->_logged = true; |
||
59 | } |
||
60 | |||
61 | return $this->_logged; |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * @return bool |
||
66 | */ |
||
67 | public function checkLogin(): bool |
||
71 | |||
72 | /** |
||
73 | * @return array of Merchants |
||
74 | * @throws \Exception |
||
75 | */ |
||
76 | public function getMerchants(): array |
||
80 | |||
81 | /** |
||
82 | * @param null $merchantID |
||
83 | * @param int $page |
||
84 | * @param int $items_per_page |
||
85 | * @return DealsResultset array of Deal |
||
86 | * @throws \Exception |
||
87 | */ |
||
88 | public function getDeals($merchantID = NULL, int $page = 0, int $items_per_page = 100): DealsResultset |
||
93 | |||
94 | /** |
||
95 | * @param \DateTime $dateFrom |
||
96 | * @param \DateTime $dateTo |
||
97 | * @param array $arrMerchantID |
||
98 | * @return array of Transaction |
||
99 | * @throws \Exception |
||
100 | */ |
||
101 | public function getSales(\DateTime $dateFrom, \DateTime $dateTo, array $arrMerchantID = array()): array |
||
152 | |||
153 | /** |
||
154 | * @param \DateTime $dateFrom |
||
155 | * @param \DateTime $dateTo |
||
156 | * @param int $merchantID |
||
157 | * @return array of Stat |
||
158 | */ |
||
159 | public function getStats(\DateTime $dateFrom, \DateTime $dateTo, int $merchantID = 0): array |
||
164 | |||
165 | |||
166 | /** |
||
167 | * @param array $params |
||
168 | * @return ProductsResultset |
||
169 | * @throws \Exception |
||
170 | */ |
||
171 | public function getProducts(array $params = []): ProductsResultset |
||
176 | |||
177 | public function getTrackingParameter() |
||
181 | |||
182 | |||
183 | } |
||
184 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: