@param array|JsonSerializable|Subscription $data
@param string $subscriptionId

@throws UnprocessableEntityException The input data does not valid

@return Subscription
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');
    }
666284
public function upcomingInvoice($customerId, $subscriptionId = null, array $parameters = [])
    {
        $parameters = array_merge($parameters, [
            'customer'     => $customerId,
            'subscription' => $subscriptionId,
        ]);

        return $this->_get('invoices/upcoming', $parameters);
    }
183427
public static function connectSubscriptions($customerUUID, array $data = [], ClientInterface $client = null)
    {
        (new static([], $client))
            ->getClient()
            ->setResourcekey(static::class)
            ->send('/v1/customers/'.$customerUUID.'/connect_subscriptions', 'POST', $data);
        return true;
    }
486069
@Override
    public java.util.concurrent.Future<UnsubscribeResult> unsubscribeAsync(String subscriptionArn) {

        return unsubscribeAsync(new UnsubscribeRequest().withSubscriptionArn(subscriptionArn));
    }
278818
public function getSubscription($subscriptionId, array $parameters = [])
    {
        return $this->client->subscriptions->getFor($this, $subscriptionId, $parameters);
    }
956718
public function setSubscribed($id, $subscribed)
    {
        return $this->put($this->getPath().'/'.rawurlencode($id).'/subscribed', array('value' => $subscribed));
    }
444279
public function createFromData(array $data): AbstractEntity
    {
        /** @var AbstractEntity $result */
        $result = $this->factory->create();
        $result->mapFromArray($data);
        return $result;
    }
849394
public function reactivateSubscription($subscriptionId)
    {
        $requestData = new Reactivate\RequestData($subscriptionId);
        $request = new Reactivate\Request($requestData);

        return $this->sendRequest($request, Reactivate\ApiResponse::class);
    }
461161
public function handleData(array $data)
    {
        $subscriptionName = $data['subscription'];
        $subscriptions = array_get($this->subscriptions, $subscriptionName);

        if (is_null($subscriptions)) {
            return;
        }

        foreach ($subscriptions as $subscription) {
            try {
                $payload = array_get($data, 'payload');
                $query = array_get($subscription['payload'], 'query');
                $variables = array_get($subscription['payload'], 'variables');

                if (isset($this->filters[$subscription['name']])) {
                    if (!$this->filters[$subscription['name']]($payload, $variables, $this->context)) {
                        continue;
                    }
                }

                $result = $this->execute($query, $payload, $variables);

                $response = [
                    'type' => GQL_DATA,
                    'id' => $subscription['id'],
                    'payload' => $result
                ];

                $response = json_encode($response);

                if (false === $response) {
                    throw new UnexpectedValueException('Could not encode response');
                }

                /** @noinspection PhpUndefinedMethodInspection */
                $subscription['conn']->send($response);
            } catch (Exception $e) {
                $response = [
                    'type' => GQL_ERROR,
                    'id' => $subscription['id'],
                    'payload' => $e->getMessage()
                ];

                $response = json_encode($response);

                if (false === $response) {
                    throw new UnexpectedValueException('Could not encode response');
                }

                /** @noinspection PhpUndefinedMethodInspection */
                $subscription['conn']->send($response);
            } //end try
        } //end foreach
    }
1213337
public function cancelSubscriptionEstimate(string $subscriptionId, array $data, array $headers = [])
    {
        $url = $this->url('subscriptions/%s/cancel_subscription_estimate', $subscriptionId);

        return $this->post($url, $data, $headers);
    }
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);
    }
743197
public function sendData($data)
    {
        $response = $this->gocardless->subscriptions()->get($this->getSubscriptionId());

        return $this->response = new SubscriptionResponse($this, $response);
    }
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;
    }
330276
public function readSubscription($subscriptionId, $componentId)
    {
        $service = $this->getService();

        $response      = $service->request('subscriptions/' . (int)$subscriptionId . '/components/' . (int)$componentId, 'GET');
        $responseArray = $this->getResponseArray($response);

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

        return $this;
    }
987241
public function addEntitySubject($id, $type = null, $idKey = "id", $typeKey = "type")
    {
        if(!isset($this->_subscription->subject)){
            $this->_subscription->subject = (object) [
                "entities" => [],
                "condition" => (object)["attrs" => []]
            ];
        }

        $entity = (object) [];
        $entity->$idKey = $id;

        if (null != $type) {
            $entity->$typeKey = (string)$type;
        }

        $this->_subscription->subject->entities[] = $entity;
        return $this;
    }
944334
public SubscriptionEnvelope deleteSubscription(String subId) throws ApiException {
        ApiResponse<SubscriptionEnvelope> resp = deleteSubscriptionWithHttpInfo(subId);
        return resp.getData();
    }
1001357
public function create($data, $organizationId = null)
    {
        if (isset($organizationId)) {
            return $this->client()->put($data, 'organizations/{organizationId}', ['organizationId' => $organizationId]);
        }

        return $this->client()->post($data, 'organizations');
    }