Return events for the given subscription

@param int $subscriptionId

@return Event
@see Event::setPagination()
@see Event::setSinceId()
@see Event::setMaxId()
@see Event::setDirection()
541247
public function forSubscription($subscriptionId)
    {
        $service = $this->getService();

        // events for a subscription
        $response = $service->request('subscriptions/' . $subscriptionId . '/events', 'GET', NULL, $this->getParams());

        $responseArray = $this->getResponseArray($response);

        if (!$this->isError()) {
            $this->_data = $this->_normalizeResponseArray($responseArray);
        } else {
            $this->_data = array();
        }

        return $this;
    }
443021
public static function count_user_subscriptions($userid = 0) {
        global $DB, $USER;;
        if ($userid == 0) {
            $userid = $USER->id;
        }
        $sql = self::get_subscription_join_rule_sql(true);
        $sql .= "WHERE s.userid = :userid";

        return $DB->count_records_sql($sql, array('userid' => $userid));
    }
240353
public function getContentIdsByContentTypeId($contentTypeId)
    {
        try {
            return $this->innerGateway->getContentIdsByContentTypeId($contentTypeId);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
888465
public function listByCustomer($customerId)
    {
        $service = $this->getService();
        $response = $service->request('customers/' . (int)$customerId . '/subscriptions', 'GET');
        $responseArray = $this->getResponseArray($response);

        if (!$this->isError()) {
            $this->_data = $this->_normalizeResponseArray($responseArray);
        } else {
            $this->_data = array();
        }

        return $this;
    }
956718
public function setSubscribed($id, $subscribed)
    {
        return $this->put($this->getPath().'/'.rawurlencode($id).'/subscribed', array('value' => $subscribed));
    }
120076
public function getSubscription($subscriptionId)
    {
        /** @var SubscriptionFbApi $response */
        $response = $this->call(new Request('subscription.get', array('subscription_id' => $subscriptionId)), 'DVelopment\FastBill\Model\SubscriptionFbApi');
        $subscriptions = $response->getResponse()->getSubscriptions();

        return reset($subscriptions);
    }
864505
public function getClubAnnouncements($id)
    {
        try {
            return $this->service->getClubAnnouncements($id);
        } catch (ServiceException $e) {
            throw new ClientException('[SERVICE] ' . $e->getMessage());
        }
    }
468056
public function cancelSubscription($subscriptionId, \DateTime $cancellationDate = null, $cancellationNote = null)
    {
        $requestData = new Cancel\RequestData($subscriptionId);
        $requestData->setCancellationDate($cancellationDate);
        $requestData->setCancellationNote($cancellationNote);

        $request = new Cancel\Request($requestData);

        return $this->sendRequest($request, Cancel\ApiResponse::class);
    }
763052
public function create($data, $subscriptionId = null)
    {
        if (isset($subscriptionId)) {
            return $this->client()->put($data, 'subscriptions/{subscriptionId}', ['subscriptionId' => $subscriptionId]);
        }

        return $this->client()->post($data, 'subscriptions');
    }
1156758
protected function eventCollection(): EventCollection
    {
        if ($this->eventCollection === null) {
            $this->eventCollection = new EventCollection($this->id(), Type::create($this));
        }

        return $this->eventCollection;
    }
1107763
public function setQuantityAllocation($subscriptionId, $componentId)
    {
        $service       = $this->getService();
        $rawData       = $this->getRawData(array('component' => $this->_params));
        $response      = $service->request('subscriptions/' . (int)$subscriptionId . '/components/' . (int)$componentId, 'PUT', $rawData);
        $responseArray = $this->getResponseArray($response);

        if (!$this->isError()) {
            $this->_data = $responseArray['component'];
        } else {
            $this->_data = array();
        }

        return $this;
    }
881519
public function getBeforeDay($days = 7,$eventTypeId = null)
    {
        $this->getByDays($days);

        if(!is_null($eventTypeId))
            $this->eventQuery->where('point_event_type_id' ,$eventTypeId);

        return $this->doQuery();
    }
753193
public function all($orderId, $fulfillmentId)
    {
        $endpoint = '/admin/orders/'.$orderId.'/fulfillments/'.$fulfillmentId.'/events.json';
        $response = $this->request($endpoint, 'GET');
        return $this->createCollection(FulfillmentEvent::class, $response['fulfillment_events']);
    }
336054
public function getSubscriptionByCustomerExtUid($customerExtUid)
    {
        /** @var SubscriptionFbApi $response */
        $response = $this->call(new Request('subscription.get', array('customer_ext_uid' => $customerExtUid)), 'DVelopment\FastBill\Model\SubscriptionFbApi');
        $subscriptions = $response->getResponse()->getSubscriptions();

        return reset($subscriptions);
    }
367444
public function getSubscriptionInvoices(int $subscriptionId): array
    {
        $results = $this->_createInvoiceQuery()
            ->where(['subscriptionId' => $subscriptionId])
            ->orderBy(['dateCreated' => SORT_DESC])
            ->all();

        $invoices = [];

        foreach ($results as $result) {
            $result['invoiceData'] = Json::decodeIfJson($result['invoiceData']);
            $invoices[] = new Invoice($result);
        }

        return $invoices;
    }
733247
public function getSubscription()
    {
        if (null === $this->_subscription) {
            $this->_subscription = Subscription::find()->id($this->subscriptionId)->one();
        }

        return $this->_subscription;
    }
712888
public function subscriptions()
    {
        return $this->client->subscriptions->listFor($this, null, null, $this->getPresetOptions());
    }