示例#1
0
 /**
  * Convenience method for adding different contents
  *
  * @see parent
  */
 protected function _defaultMethod($prefix, $camelized, $arguments)
 {
     switch ($prefix) {
         case 'add':
         case 'content':
             if (!in_array($camelized, self::$_supportedTypes)) {
                 throw new InvalidArgumentException("Message object only supports " . implode(', ', self::$_supportedTypes) . " but provided {$camelized}.");
             }
             $object = $arguments[0];
             if ($object instanceof Bronto_Object) {
                 $object = $object->toArray();
             }
             if (is_array($object)) {
                 extract($object);
             }
             $object = array('type' => $camelized, 'subject' => empty($subject) ? $arguments[0] : $subject, 'content' => empty($content) ? $arguments[1] : $content);
             if (!array_key_exists('content', $this->_data)) {
                 $this->_data['content'] = array();
             }
             if (!array_key_exists($camelized, $this->_contentTypesToIndex)) {
                 $this->_contentTypesToIndex[$camelized] = array_push($this->_data['content'], $object) - 1;
             } else {
                 $this->_data['content'][$this->_contentTypesToIndex[$camelized]] = $object;
             }
             return $this;
         default:
             return parent::_defaultMethod($prefix, $camelized, $arguments);
     }
 }
 /**
  * @param array $filter
  * @param int $pageNumber
  * @return Bronto_Api_Rowset
  */
 public function readAll(array $filter = array(), $pageNumber = 1)
 {
     $params = array();
     $params['filter'] = $filter;
     $params['pageNumber'] = (int) $pageNumber;
     return parent::read($params);
 }
 /**
  * @param Bronto_Api_Object $object
  * @param int $attempts
  * @return string
  */
 public function store(Bronto_Api_Object $object, $attempts = 0)
 {
     if (!@is_dir($this->_path) && !@mkdir($this->_path, 0777, true)) {
         throw new Bronto_Util_RetryerException(sprintf('The Retryer path is not a directory: %s', $this->_path));
     } else {
         if (!@is_writable($this->_path)) {
             throw new Bronto_Util_RetryerException(sprintf('The Retryer path is not a writable: %s', $this->_path));
         }
     }
     $filename = sprintf('%s_%s_%s_%d.php', strtolower($object->getName()), str_replace('.', '', microtime()), str_pad(rand(0, 1000), 4, ' ', STR_PAD_LEFT), (int) $attempts);
     $filename = str_replace(' ', '', $filename);
     $fh = @fopen($this->_path . DIRECTORY_SEPARATOR . $filename, 'w');
     $serialized = serialize($object);
     $result = @fwrite($fh, sprintf("<?php return unserialize('%s'); ?>", $serialized));
     @fclose($fh);
     return $result ? $filename : false;
 }
 /**
  * @param array $filter
  * @param int $pageNumber
  * @return Bronto_Api_Rowset
  */
 public function readAll(array $filter = array(), $pageNumber = 1)
 {
     $params = array('filter' => array(), 'pageNumber' => (int) $pageNumber);
     if (!empty($filter)) {
         if (is_array($filter)) {
             $params['filter'] = $filter;
         } else {
             $params['filter'] = array($filter);
         }
     } else {
         $params['filter'] = array('contactId' => array());
     }
     return parent::read($params);
 }
示例#5
0
 /**
  * Allows an addtional prefix 'as' to set the type of field, ie: asText()
  * Also visibility, ie: asPublic(), asPrivate()
  *
  * @see parent
  */
 protected function _defaultMethod($prefix, $camelized, $arguments)
 {
     switch ($prefix) {
         case 'as':
             if (array_key_exists($camelized, self::$_mappedWords)) {
                 return $this->_set('visibility', self::$_mappedWords[$camelized]);
             } else {
                 return $this->_set('type', $camelized);
             }
         case 'is':
             if (array_key_exists($camelized, self::$_mappedWords)) {
                 return $this->_data['visibility'] == $camelized;
             }
             return $this->_data['type'] == $camelized;
         default:
             return parent::_defaultMethod($prefix, $camelized, $arguments);
     }
 }
示例#6
0
 /**
  * @param array $filter
  * @param array $fields
  * @param bool $includeLists
  * @param int $pageNumber
  * @return Bronto_Api_Rowset
  */
 public function readAll($filter = array(), $fields = array(), $includeLists = true, $pageNumber = 1)
 {
     $params = array('filter' => array(), 'fields' => array(), 'includeLists' => (bool) $includeLists, 'pageNumber' => (int) $pageNumber);
     if (!empty($filter)) {
         if (is_array($filter)) {
             $params['filter'] = $filter;
         } else {
             $params['filter'] = array($filter);
         }
     }
     if (!empty($fields)) {
         if (is_array($fields)) {
             $params['fields'] = $fields;
         } else {
             $params['fields'] = array($fields);
         }
     }
     return parent::read($params);
 }
 /**
  * @return Bronto_Api
  */
 public function getApi()
 {
     return $this->_apiObject->getApi();
 }
示例#8
0
 /**
  * @return string
  */
 public function getLastResponse()
 {
     return $this->_apiObject->getApi()->getLastResponse();
 }
示例#9
0
 /**
  * @param string $startDate
  * @param int $size
  * @param string|array $types
  * @param string $direction
  * @param string|array $contactIds
  * @return Bronto_Api_Rowset
  */
 public function readAll($startDate = '2002-01-01T00:00:00+00:00', $size = 1000, $types = array(), $direction = self::DIRECTION_FIRST, $contactIds = array())
 {
     $filter = array('start' => '2002-01-01T00:00:00+00:00', 'size' => 1000, 'types' => $this->getOptionValues('trackingType'), 'readDirection' => self::DIRECTION_FIRST, 'contactIds' => array());
     if (!empty($startDate)) {
         $filter['start'] = $startDate;
     }
     if (!empty($size)) {
         $filter['size'] = $size < 1000 ? 1000 : (int) $size;
     }
     if (!empty($types)) {
         if (is_array($types)) {
             $filter['types'] = $types;
         } else {
             $filter['types'] = array($types);
         }
     }
     $direction = strtoupper($direction);
     if (in_array($direction, $this->_options['readDirection'])) {
         $filter['readDirection'] = $direction;
     }
     if (!empty($contactIds)) {
         if (is_array($contactIds)) {
             $filter['contactIds'] = $contactIds;
         } else {
             $filter['contactIds'] = array($contactIds);
         }
     }
     // @todo Remove if the contactIds filter is enabled again
     unset($filter['contactIds']);
     return parent::read(array('filter' => $filter));
 }
示例#10
0
 /**
  * @see parent
  */
 public function __construct(array $data = array())
 {
     parent::__construct('Contact', $data);
 }
示例#11
0
 /**
  * Allows chaining recipients together through function calls, ie:
  * $delivery->addContact($contactId)->ineligibleList($listId);
  *
  * @see parent
  */
 protected function _defaultMethod($prefix, $camelized, $arguments)
 {
     switch ($prefix) {
         case 'add':
         case self::DELIVERY_SELECTED:
         case self::DELIVERY_ELIGIBLE:
         case self::DELIVERY_INELIGIBLE:
             $objectId = $arguments[0];
             if ($objectId instanceof Bronto_Object) {
                 $objectId = $objectId->getId();
             }
             if (!array_key_exists('recipients', $this->_data)) {
                 $this->_data['recipients'] = array();
             }
             // TODO: we'll probably want to very here before sending
             // if the types set are valid or not
             $this->_data['recipients'][] = array('type' => $camelized, 'id' => $objectId, 'deliveryType' => $prefix == 'add' ? self::DELIVERY_SELECTED : $prefix);
             return $this;
         default:
             return parent::_defaultMethod($prefix, $camelized, $arguments);
     }
 }
示例#12
0
 /**
  * @see parent
  */
 public function __construct(array $data = array())
 {
     parent::__construct('Order', $data);
 }