Oara\Network\Publisher\AffiliNet::affilinetCall PHP Method

affilinetCall() private method

Call to the API controlling the exception and Login
private affilinetCall ( $call, $ws, $params, $try, $currentPage )
    private function affilinetCall($call, $ws, $params, $try = 0, $currentPage = 0)
    {
        $result = null;
        try {
            switch ($call) {
                case 'merchant':
                    $result = $ws->GetMyPrograms(array('CredentialToken' => $this->_token, 'GetProgramsRequestMessage' => $params));
                    break;
                case 'transaction':
                    $pageSettings = array("CurrentPage" => $currentPage, "PageSize" => 100);
                    $result = $ws->GetTransactions(array('CredentialToken' => $this->_token, 'TransactionQuery' => $params, 'PageSettings' => $pageSettings));
                    break;
                case 'overview':
                    $result = $ws->GetDailyStatistics(array('CredentialToken' => $this->_token, 'GetDailyStatisticsRequestMessage' => $params));
                    break;
                case 'payment':
                    $result = $ws->GetPayments($params);
                    break;
                default:
                    throw new \Exception('No Affilinet Call available');
                    break;
            }
        } catch (\Exception $e) {
            //checking if the token is valid
            if (\preg_match("/Login failed/", $e->getMessage()) && $try < 5) {
                self::login();
                $try++;
                $result = self::affilinetCall($call, $ws, $params, $try, $currentPage);
            } else {
                throw new \Exception("problem with Affilinet API, no login fault");
            }
        }
        return $result;
    }