/**
  * Register all services with the continer.
  */
 protected function registerServices(Container $container)
 {
     $container['api'] = function ($c) {
         return KlaviyoApi::create($c['api_key']);
     };
     $container['campaign'] = function ($c) {
         return CampaignService::create($c['api']);
     };
     $container['lists'] = function ($c) {
         return ListService::create($c['api']);
     };
     $container['person'] = function ($c) {
         return PersonService::create($c['api']);
     };
     $container['template'] = function ($c) {
         return TemplateService::create($c['api']);
     };
     $container['track'] = function ($c) {
         return TrackService::create($c['api']);
     };
     return $container;
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function jsonSerialize()
 {
     return ['object' => KlaviyoApi::getModelType($this->objectType, TRUE), 'start' => $this->start, 'end' => $this->end, 'page_size' => $this->pageSize, 'total' => $this->total, 'page' => $this->page, 'data' => $this->data];
 }
 public function testDefaultOptions()
 {
     $api = KlaviyoApi::create('thisisakey');
     $this->assertSame(50, $api->getOption('records_per_page'));
 }
 /**
  * Get the model type.
  *
  * @param array $configuration
  *   The key, value pair array to use for populating the data model.
  * @param string $type
  *   If set then we will check out data map and retrieve the model type.
  *
  * @return string
  *   The model data type.
  */
 public static function getModelType($configuration = [], $type = '')
 {
     if (empty($type) && !empty($configuration['object'])) {
         $type = $configuration['object'];
     }
     if (empty($type) && !empty($configuration)) {
         throw new MissingModelTypeException('Unable to determine the model type.');
     }
     return KlaviyoApi::getModelType($type);
 }