Exemple #1
0
 public function get()
 {
     // TODO: create a full response object for this
     $response = $this->connection->get('/ping');
     if ($response && $response->getStatusCode() == 200) {
         return true;
     }
     return false;
 }
 public function getCategoryByName($name)
 {
     $response = $this->connection->get('/ProductCategories?categoryName=' . $name);
     // this campaigner endpoint puts successes in an extra, single element array on successes so we have to unwrap it by grabbing the 0th index
     // failures do not so we don't have to worry about that
     if (array_key_exists(0, $response->getBody())) {
         $body = $response->getBody()[0];
     } else {
         $body = $response->getBody();
     }
     return $this->getResponseFromBody($body);
 }
Exemple #3
0
 public function get()
 {
     $response = $this->connection->get('/Lists');
     $body = $response->getBody();
     $mailingLists = new MailingListCollection();
     foreach ($body['Lists'] as $list) {
         $mailingList = new \Vynyl\Campaigner\DTO\MailingList();
         $mailingList->setActiveMembers($list['ActiveMembers'])->setDescription($list['Description'])->setIsActive($list['IsActive'])->setListId($list['ListID'])->setName($list['Name']);
         $mailingLists->addMailingList($mailingList);
     }
     $mailingListResponse = new MailingListResponse();
     $mailingListResponse->setMailingLists($mailingLists);
     return $mailingListResponse;
 }
Exemple #4
0
 public function post(DatabaseColumn $databaseColumn)
 {
     $payload = $databaseColumn->toPost();
     $response = $this->connection->post('/Database', $payload);
     $body = $response->getBody();
     $databaseColumnResponse = null;
     if ($response->getStatusCode() != 201) {
         $databaseColumnResponse = (new ErrorResponse())->setErrorCode($body['ErrorCode'])->setMessage($body['Message'])->setIsError(true);
     } else {
         $databaseColumn = new DatabaseColumn();
         $databaseColumn->setColumnName($body['ColumnName'])->setColumnSize($body['ColumnSize'])->setColumnType($body['ColumnType'])->setIsCustom($body['IsCustom'])->setVariable($body['Variable']);
         $databaseColumnResponse = (new DatabaseColumnAddResponse())->setDatabaseColumn($databaseColumn);
     }
     return $databaseColumnResponse;
 }
Exemple #5
0
 public function addMultiple(OrdersCollection $ordersCollection)
 {
     $payload = $ordersCollection->toPost();
     $response = $this->connection->post('/Orders/Import', $payload);
     $body = $response->getBody();
     $ordersResponse = null;
     if (!empty($body['ErrorCode'])) {
         $ordersResponse = new ErrorResponse();
         $ordersResponse->setErrorCode($body['ErrorCode'])->setMessage($body['Message'])->setIsError(true);
     } else {
         $ordersResponse = new OrdersResponse();
         if (!empty($body['Failures'])) {
             foreach ($body['Failures'] as $failure) {
                 $orderError = new OrderError();
                 $orderError->setEmailAddress($failure['EmailAddress'])->setOrderNumber($failure['OrderNumber'])->setErrorCode($failure['ErrorCode'])->setMessage($failure['Message']);
                 $ordersResponse->addError($orderError);
             }
         }
         $ordersResponse->setOrdersSubmitted($body['OrdersSubmitted'])->setSuccesses($body['Successes']);
     }
     return $ordersResponse;
 }
Exemple #6
0
 public function addProductToCategories($productId, $categoryIds)
 {
     $payload = ['Categories' => $categoryIds];
     $response = $this->connection->post('/Products/' . $productId . '/AddToCategories', $payload);
     return $this->getProductResponseFromBody($response);
 }
Exemple #7
0
 public function post(Subscriber $subscriber)
 {
     $payload = $subscriber->toPost();
     return $this->connection->post('/Subscribers', $payload);
 }