Set a Repository Subscription

@link https://developer.github.com/v3/activity/watching/#set-a-repository-subscription

@param bool $subscribed
@param bool $ignored

@return array
425590
public function setRepositorySubscription(bool $subscribed = false, bool $ignored = false): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/subscription?:args',
            $this->getActivity()->getOwner(), $this->getActivity()->getRepo(), http_build_query([
                'subscribed' => $subscribed,
                'ignored'    => $ignored
            ])), Request::METHOD_PUT);
    }
648128
public function bind(Subscriber $subscriber, $eventIdentifier) {
    if ($eventIdentifier instanceof Event) {
      $eventIdentifier = $eventIdentifier->getIdentifier();
    }
    
    if (!isset($this->subscribers[$eventIdentifier]))
      $this->subscribers[$eventIdentifier] = array();
      
    $this->subscribers[$eventIdentifier][] = $subscriber;
    
    return $this;
  }
934106
public function storeSubscriber(Subscriber $subscriber, string $topic): void
    {
        $topicKey = self::TOPIC_KEY.".{$topic}";
        $subscriberKey = self::SUBSCRIBER_KEY.".{$subscriber->channel}";

        $topic = $this->cache->has($topicKey)
            ? json_decode($this->cache->get($topicKey), true)
            : [];

        $topic[] = $subscriber->channel;

        $this->cache->forever($topicKey, json_encode($topic));
        $this->cache->forever($subscriberKey, $subscriber);
    }
1021821
protected function endSubscription($subscriptionId = null)
    {
        if (!$subscriptionId) {
            $subscriptionId = $this->subscriptions->getLast()->getSubscriptionId();
        }
        if (!isset($this->subscriptions[$subscriptionId])) {
            throw new InvalidArgumentException(sprintf('%s is no active subscription!', $subscriptionId));
        }
        $subscription = $this->subscriptions[$subscriptionId];
        $this->getClient()->sendFrame(
            $this->getProtocol()->getUnsubscribeFrame(
                $subscription->getDestination(),
                $subscription->getSubscriptionId()
            )
        );
        IdGenerator::releaseId($subscription->getSubscriptionId());

        unset($this->subscriptions[$subscription->getSubscriptionId()]);

        if ($this->subscriptions->count() == 0) {
            return true;
        }
        return false;
    }
1263937
private function getDataFromSubscription(Subscriber $subscriber)
    {
        $data = [
            'subscriber' => $subscriber->getData(),
        ];

        if ($subscriber->getConfirmationLink()) {
            $data['subscriber'] = $subscriber->getData();
        }
        if ($subscriber->getCustomerId()) {
            $customer = $this->customerFactory->create()->load($subscriber->getCustomerId());
            $data['customer'] = $customer->getData();
        }
        return $data;
    }
388959
public function subscribe(ChannelInterface $channel, SubscriberInterface $subscriber)
    {
        $this->subscribers[$channel->getIdentifier()][$subscriber->getIdentifier()] = $subscriber;

        return $this;
    }
55742
public void setSubscribe(boolean subscribe) {
        addField(ConfigureNodeFields.subscribe, FormField.Type.bool);
        setAnswer(ConfigureNodeFields.subscribe.getFieldName(), subscribe);
    }
61753
public function setIgnores(array $ignores = []): self
    {
        foreach ($ignores as $ignore) {
            $this->addIgnore($ignore);
        }

        return $this;
    }
901191
public function saveSubscriber(SubscriberInterface $subscriber)
    {
        $token = $this->getToken();

        $groups = $subscriber->getGroups()->getValues();

        $data = [
            'postdata' => [
                [
                    'email' => $subscriber->getEmail()
                ]
            ]
        ];

        $event = new CleverReachEvent($subscriber, $data);
        $this->eventDispatcher->dispatch(NewsletterEvents::EVENT_CLEVERREACH_PRE_SEND, $event);
        if($event->getDataArray()){
            $data = $event->getDataArray();
        }

        /** @var Group $group */
        foreach ($groups as $group) {
            if ($this->exists($subscriber->getEmail(), $group)) {
                continue;
            }

            $groupId = $this->mapGroup($group);

            $res = $this->guzzleClient->request('POST', 'groups.json/' . $groupId . '/receivers/insert' . '?token=' . $token, [
                'json' => $data
            ]);

            $response = $res->getBody()->getContents();

            if (json_decode($response)[0]->status !== 'insert success') {
                throw new InsertException(
                    sprintf('Insertion in group "%s" with id "%s" failed.', $group->getName(), $groupId)
                );
            }
        }
    }
278818
public function getSubscription($subscriptionId, array $parameters = [])
    {
        return $this->client->subscriptions->getFor($this, $subscriptionId, $parameters);
    }
385958
public function getListSubscriber($list, $subscriber)
	{
		$result = $this->client->get("lists/{$list}/subscribers/{$subscriber}");
		return $result ? new Resources\Subscriber($this, $result) : null;
	}
751310
public function unserialize($subscription): self
    {
        $data = json_decode($subscription, true);

        $this->operationName = $data['operation_name'];
        $this->channel = $data['channel'];
        $this->args = $data['args'];
        $this->context = $this->contextSerializer()->unserialize(
            $data['context']
        );
        $this->query = AST::fromArray(
            unserialize($data['query'])
        );

        return $this;
    }
1310302
public function subscribe($subject, \Closure $callback)
    {
        $sid = $this->randomGenerator->generateString(16);
        $msg = 'SUB '.$subject.' '.$sid;
        $this->send($msg);
        $this->subscriptions[$sid] = $callback;
        return $sid;
    }
371760
public function setFilterable(array $filterable): Repository
	{
		if ($filterable === self::ALLOW_ALL) {
			$this->filterable = self::ALLOW_ALL;

			return $this;
		}

		// Reset filterable
		$this->filterable = [];

		foreach ($filterable as $allowed_field) {
			$this->filterable[$allowed_field] = true;
		}

		return $this;
	}
548126
public function subscribe($subscriber)
    {
        if (is_object($subscriber)) {
            $subscriber->subscribe($this);
            return;
        }
        $this->subscribe(new $subscriber);
    }
744462
public function unsubscribe( ?IObserver $observer = null ) : IObservable
   {

      for ( $i = 0, $c = \count( $this->_observers ); $i < $c; $i++)
      {
         if ( $observer === $this->_observers[ $i ] )
         {
            unset( $this->_observers[ $i ] );
         }
      }

      $this->_observers = array_values( $this->_observers );

      return $this;

   }
1120942
public function setSubscriber($email, $is_confirmed = true, $fields = [])
	{
		$subscriber = [
			'emailaddress' => $email,
			'fields' => $fields,
		];

		if (!$is_confirmed) {
			$subscriber = array_merge($subscriber, [
				'confirmed' => false,
				'confirmdate' => null,
				'confirmip' => null,
			]);
		}

		$result = $this->iconneqt->putListSubscriber($this->id, $subscriber);

		return $this->iconneqt->getListSubscriber($this->id, $result->subscriberid);
	}