Synchronize promotions through the API.

@param mixed $types
The type of promotion to synchronize.
510274
public function syncPromotions($types = ['category', 'cart']) {
    $types = is_array($types) ? $types : [$types];
    $ids = [];
    $fetched_promotions = [];

    foreach ($types as $type) {
      $promotions = $this->apiWrapper->getPromotions($type);

      foreach ($promotions as $key => $promotion) {
        // Add type to $promotion array, to be saved later.
        $promotion['promotion_type'] = $type;
        $fetched_promotions[] = $promotion;
        $ids[] = $promotion['rule_id'];
      }
    }

    if (!empty($fetched_promotions)) {
      $this->processPromotions($fetched_promotions);
    }

    // Delete promotions, which are not part of API response.
    if (!empty($ids)) {
      $this->deletePromotions($types, $ids);
    }
  }
1292549
public function setType( $type )
	{
		if ( $type == $this->getType() ) { return; }

		$this->_checkType( $type );

		$this->_values['type'] = (string) $type;
		$this->setModified();
	}
830855
static function notify( $message, $type )
    {
        $nots = State::get( 'notifications' );
        array_push( $nots, array( 'message' => $message, 'type' => $type ) );
        State::set( 'notifications', $nots );
    }
503895
public function block($messages, $type = 'error')
    {
        $output = [];
        if (!is_array($messages)) {
            $messages = (array) $messages;
        }
        foreach ($messages as $message) {
            $output[] = trim($message);
        }
        $formatter = new FormatterHelper();
        $this->line($formatter->formatBlock($output, $type, true));
    }
1210336
protected function setRequestType(string $type):void
    {
        if ($type !== Protocol::REQUEST_TYPE_NOTIFY && $type !== Protocol::REQUEST_TYPE_FORWARD && $type !== protocol::REQUEST_TYPE_REGISTER) {
            throw new \TypeError("Unsupported request type: $type!");
        }

        $this->requestType = $type;
        $this->setHeader(Protocol::VERSION." ".$type);

    }
279192
public function onCreate($type = null)
    {
        $this->onList();
        Breadcrumbs::register('notification-create', function($breadcrumbs) {
            $breadcrumbs->parent('notifications');
            $breadcrumbs->push(trans('antares/notifications::messages.notification_templates_create'));
        });
        view()->share('breadcrumbs', Breadcrumbs::render('notification-create'));
    }
881169
public function useCache($type = self::CACHE_APC) {
    if ($type === self::CACHE_APC) {
      $this->setCache(new \Doctrine\Common\Cache\ApcCache);
    } else {
      $this->setCache(new \Doctrine\Common\Cache\ArrayCache);
    }
  }
1252272
public function add($type, $message, $title = null)
    {
        $notifications = $this->getNotifications();

        $notifications[] = [
            'type'    => $type,
            'message' => $message,
            'title'   => $title
        ];

        $this->session->flash(self::SESSION_KEY, $notifications);
    }
1082326
public function addCallback( $type, $callback ) {
		if ( !isset( $this->callbacks[$type] ) ) {
			$this->callbacks[$type] = [];
		}
		$this->callbacks[$type][] = $callback;
	}
705554
public function setType($type)
    {
        if (!in_array($type,[$this::WORK, $this::HOME, $this::MOBILE, $this::FAX]))
        {
            throw new InvalidArgumentException("Type is not a valid type. You must use one of the constants in the PhoneNumber class as the type.");
        }
        $this->type = $type;
    }
104006
public function hasAnyDynamicType($types)
    {
        if (\is_string($types)) {
            return isset($this->dynamicTypes[$types]);
        } else {
            foreach ($types as $type) {
                if (isset($this->dynamicTypes[$type])) {
                    return true;
                }
            }
        }

        return false;
    }
454965
public function add($type)
    {
        $this->value[] = $type;
        $this->value = array_unique($this->value);
    }
78908
public function setType($type)
    {
        if ($type instanceof PagSeguroPaymentMethodType) {
            $this->type = $type;
        } else {
            $this->type = new PagSeguroPaymentMethodType($type);
        }
    }
199877
public function my_dispatchEvent($type, $data)
    {
        foreach ($this->client as $client) {
            $client->dispatchEvent($type, $data);
        }
    }
205999
public function notify($type = 'default')
    {
        if (isset($this->observers[$type])) {
            foreach ($this->observers[$type] as $obs) {
                $obs->update($this);
            }
        }
        return $this;
    }
1186228
public function enqueueMessage($msg, $type = 'message')
	{
		if ($this->messageStatus) {
			$event = new Event('onApplicationEnqueueMessage');
			$event->addArgument('message', $msg);
			$event->addArgument('type', $type);
			Factory::getDispatcher()->triggerEvent($event);
		}
	}
565178
public function setDynamicTypes($types)
    {
        if ($types) {
            unset($this->dynamicTypes['unknown']);

            if (\is_string($types)) {
                if (!isset($this->dynamicTypes[$types])) {
                    $this->dynamicTypes[$types] = true;
                }
            } else {
                foreach ($types as $type => $one) {
                    if (!isset($this->dynamicTypes[$one])) {
                        $this->dynamicTypes[$one] = true;
                    }
                }
            }
        }
    }