コード例 #1
0
ファイル: Widget.php プロジェクト: ufik/php-sdk
 public function __construct($config = null)
 {
     $this->context = new Context();
     if ($config) {
         if (is_object($config) && get_class($config) == 'stdClass') {
             $config = get_object_vars($config);
         }
         $this->config = new ArrayConfig();
         if (isset($config['accountId'])) {
             $this->config->setAccountId($config['accountId']);
             unset($config['accountId']);
         }
         $this->initPropertiesFromArray($config);
     }
 }
コード例 #2
0
ファイル: Client.php プロジェクト: ufik/php-sdk
 /**
  * Sends request to recommendation server and returns recommendations on success or null on error
  * @return Response|null
  */
 public function execute()
 {
     $httpClient = $this->getHttpClient();
     $httpRequest = $httpClient->post('/eps/crosssell/recommendations/' . $this->config->getAccountId() . '.do');
     $headers = $httpRequest->getHeaders();
     $httpRequest->addHeader('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8');
     $httpRequest->addHeader('User-Agent', 'Econda PHP SDK');
     $httpRequest->addPostFields($this->getHttpPostFields());
     $httpResponse = $httpRequest->send();
     if ($httpResponse->isSuccessful()) {
         $responseData = $httpResponse->json();
         $this->response = $this->getResponseFromHttpResponse($responseData);
     }
     $this->lastHttpRequest = $httpRequest;
     return $this->response;
 }