Code Duplication    Length = 139-139 lines in 2 locations

src/Networks/Brandreward.php 1 location

@@ 18-156 (lines=139) @@
15
 * Class Brandreward
16
 * @package Padosoft\AffiliateNetwork\Networks
17
 */
18
class Brandreward extends AbstractNetwork implements NetworkInterface
19
{
20
    /**
21
     * @var object
22
     */
23
    private $_network = null;
24
    private $_username = '';
25
    private $_password = '';
26
    private $_idSite = '';
27
28
    /**
29
     * @method __construct
30
     */
31
    public function __construct(string $username, string $password, string $idSite='')
32
    {
33
        $this->_network = new \Oara\Network\Publisher\Brandreward;
34
        $this->_username = $username;
35
        $this->_password = $password;
36
        $this->_idSite = $idSite;
37
38
        $this->login( $this->_username, $this->_password, $idSite );
39
    }
40
41
    public function login(string $username, string $password,string $idSite=''): bool{
42
        $this->_logged = false;
43
        if (isNullOrEmpty( $username ) || isNullOrEmpty( $password )) {
44
45
            return false;
46
        }
47
        $this->_username = $username;
48
        $this->_password = $password;
49
        $this->_idSite = $idSite;
50
        $credentials = array();
51
        $credentials["user"] = $this->_username;
52
        $credentials["password"] = $this->_password;
53
        $credentials["idSite"] = $this->_idSite;
54
        $this->_network->login($credentials);
55
        if ($this->_network->checkConnection()) {
56
            $this->_logged = true;
57
        }
58
59
        return $this->_logged;
60
    }
61
62
    /**
63
     * @return bool
64
     */
65
    public function checkLogin() : bool
66
    {
67
        return $this->_logged;
68
    }
69
70
    /**
71
	 * @return array of Merchants
72
	 * @throws \Exception
73
	 */
74
    public function getMerchants() : array
75
    {
76
        throw new \Exception("Not implemented yet");
77
    }
78
79
    /**
80
	 * @param null $merchantID
81
	 * @param int $page
82
	 * @param int $items_per_page
83
	 * @return DealsResultset  array of Deal
84
	 * @throws \Exception
85
	 */
86
    public function getDeals($merchantID=NULL,int $page=0,int $items_per_page=100 ): DealsResultset
87
    {
88
        throw new \Exception("Not implemented yet");
89
90
    }
91
92
   	/**
93
	 * @param \DateTime $dateFrom
94
	 * @param \DateTime $dateTo
95
	 * @param array $arrMerchantID
96
	 * @return array of Transaction
97
	 * @throws \Exception
98
	 */
99
    public function getSales(\DateTime $dateFrom, \DateTime $dateTo, array $arrMerchantID = array()) : array
100
    {
101
102
        $arrResult = array();
103
        $transactionList = $this->_network->getTransactionList($arrMerchantID, $dateFrom, $dateTo);
104
        foreach($transactionList as $transaction) {
105
            $Transaction = Transaction::createInstance();
106
            if (isset($transaction['currency']) && !empty($transaction['currency'])) {
107
                $Transaction->currency = $transaction['currency'];
108
            } else {
109
                $Transaction->currency = "USD";
110
            }
111
            $Transaction->status = $transaction['status'];
112
            $Transaction->amount = 0; //value set default to 0, attribute does not exist in the API
113
            array_key_exists_safe( $transaction,'custom_id' ) ? $Transaction->custom_ID = $transaction['custom_id'] : $Transaction->custom_ID = '';
114
            $Transaction->title = '';
115
            $Transaction->unique_ID = $transaction['unique_id'];
116
            $Transaction->commission = $transaction['commission'];
117
            $Transaction->date = $transaction['date'];
118
            $Transaction->click_date = $transaction['click_date'];
119
            $Transaction->update_date = $transaction['update_date'];
120
            $Transaction->program_name =  $transaction['merchantName'];
121
            $Transaction->approved = false;
122
            if ($Transaction->status == \Oara\Utilities::STATUS_CONFIRMED){
123
                $Transaction->approved = true;
124
            }
125
            $arrResult[] = $Transaction;
126
        }
127
128
        return $arrResult;
129
    }
130
131
    /**
132
     * @param \DateTime $dateFrom
133
     * @param \DateTime $dateTo
134
     * @param int $merchantID
135
     * @return array of Stat
136
     */
137
    public function getStats(\DateTime $dateFrom, \DateTime $dateTo, int $merchantID = 0) : array
138
    {
139
        return array();
140
    }
141
142
143
    /**
144
	 * @param array $params
145
	 * @return ProductsResultset
146
	 * @throws \Exception
147
	 */
148
    public function getProducts(array $params = []): ProductsResultset
149
    {
150
        throw new \Exception("Not implemented yet");
151
    }
152
153
154
155
156
}
157

src/Networks/MyLead.php 1 location

@@ 18-156 (lines=139) @@
15
 * Class MyLead
16
 * @package Padosoft\AffiliateNetwork\Networks
17
 */
18
class MyLead extends AbstractNetwork implements NetworkInterface
19
{
20
    /**
21
     * @var object
22
     */
23
    private $_network = null;
24
    private $_username = '';
25
    private $_password = '';
26
    private $_idSite = '';
27
28
    /**
29
     * @method __construct
30
     */
31
    public function __construct(string $username, string $password, string $idSite='')
32
    {
33
        $this->_network = new \Oara\Network\Publisher\MyLead;
34
        $this->_username = $username;
35
        $this->_password = $password;
36
        $this->_idSite = $idSite;
37
38
        $this->login( $this->_username, $this->_password, $idSite );
39
    }
40
41
    public function login(string $username, string $password,string $idSite=''): bool{
42
        $this->_logged = false;
43
        if (isNullOrEmpty( $username ) || isNullOrEmpty( $password )) {
44
45
            return false;
46
        }
47
        $this->_username = $username;
48
        $this->_password = $password;
49
        $this->_idSite = $idSite;
50
        $credentials = array();
51
        $credentials["user"] = $this->_username;
52
        $credentials["password"] = $this->_password;
53
        $credentials["idSite"] = $this->_idSite;
54
        $this->_network->login($credentials);
55
        if ($this->_network->checkConnection()) {
56
            $this->_logged = true;
57
        }
58
59
        return $this->_logged;
60
    }
61
62
    /**
63
     * @return bool
64
     */
65
    public function checkLogin() : bool
66
    {
67
        return $this->_logged;
68
    }
69
70
    /**
71
	 * @return array of Merchants
72
	 * @throws \Exception
73
	 */
74
    public function getMerchants() : array
75
    {
76
        throw new \Exception("Not implemented yet");
77
    }
78
79
    /**
80
	 * @param null $merchantID
81
	 * @param int $page
82
	 * @param int $items_per_page
83
	 * @return DealsResultset  array of Deal
84
	 * @throws \Exception
85
	 */
86
    public function getDeals($merchantID=NULL,int $page=0,int $items_per_page=100 ): DealsResultset
87
    {
88
        throw new \Exception("Not implemented yet");
89
90
    }
91
92
   	/**
93
	 * @param \DateTime $dateFrom
94
	 * @param \DateTime $dateTo
95
	 * @param array $arrMerchantID
96
	 * @return array of Transaction
97
	 * @throws \Exception
98
	 */
99
    public function getSales(\DateTime $dateFrom, \DateTime $dateTo, array $arrMerchantID = array()) : array
100
    {
101
102
        $arrResult = array();
103
        $transactionList = $this->_network->getTransactionList($arrMerchantID, $dateFrom, $dateTo);
104
        foreach($transactionList as $transaction) {
105
            $Transaction = Transaction::createInstance();
106
            if (isset($transaction['currency']) && !empty($transaction['currency'])) {
107
                $Transaction->currency = $transaction['currency'];
108
            } else {
109
                $Transaction->currency = "EUR";
110
            }
111
            $Transaction->status = $transaction['status'];
112
            $Transaction->amount = 0; //value set default to 0, attribute does not exist in the API
113
            array_key_exists_safe( $transaction,'custom_id' ) ? $Transaction->custom_ID = $transaction['custom_id'] : $Transaction->custom_ID = '';
114
            $Transaction->title = '';
115
            $Transaction->unique_ID = $transaction['unique_id'];
116
            $Transaction->commission = $transaction['commission'];
117
            $Transaction->date = $transaction['date'];
118
            $Transaction->merchant_ID = $transaction['merchantId'];
119
            $Transaction->program_name =  $transaction['merchantName'];
120
            $Transaction->IP =  $transaction['IP'];
121
            $Transaction->approved = false;
122
            if ($Transaction->status == \Oara\Utilities::STATUS_CONFIRMED){
123
                $Transaction->approved = true;
124
            }
125
            $arrResult[] = $Transaction;
126
        }
127
128
        return $arrResult;
129
    }
130
131
    /**
132
     * @param \DateTime $dateFrom
133
     * @param \DateTime $dateTo
134
     * @param int $merchantID
135
     * @return array of Stat
136
     */
137
    public function getStats(\DateTime $dateFrom, \DateTime $dateTo, int $merchantID = 0) : array
138
    {
139
        return array();
140
    }
141
142
143
    /**
144
	 * @param array $params
145
	 * @return ProductsResultset
146
	 * @throws \Exception
147
	 */
148
    public function getProducts(array $params = []): ProductsResultset
149
    {
150
        throw new \Exception("Not implemented yet");
151
    }
152
153
154
155
156
}
157