Add credits to a customer.

@param integer $customerId The customer ID.
@param float $amount The amount of credit to add.
@return AddCredits\ApiResponse
166182
public function addCredits($customerId, $amount)
    {
        $requestData = new AddCredits\RequestData($customerId, $amount);
        $request = new AddCredits\Request($requestData);

        return $this->sendRequest($request, AddCredits\ApiResponse::class);
    }
455531
public function getCustomer($customerId)
    {
        $requestData = new Get\RequestData();
        $requestData->setCustomerId($customerId);

        $customers = $this->getCustomers($requestData)->getResponse()->getCustomers();

        return isset($customers[0]) ? $customers[0] : null;
    }
56385
public function getSubscriptionByCustomerId($customerId)
    {
        /** @var SubscriptionFbApi $response */
        $response = $this->call(new Request('subscription.get', array('customer_id' => $customerId)), 'DVelopment\FastBill\Model\SubscriptionFbApi');
        $subscriptions = $response->getResponse()->getSubscriptions();

        return reset($subscriptions);
    }
493010
public function createCustomer($type, $customerId ,$payment = [], $additional = [])
    {
        $request = new CreateCustomer($this->config->getMerchantId());

        $request->setPType($type);
        $request->setPaymentData($payment);
        $request->setCustomerId($customerId);
        $request->setAdditional($additional);

        $this->request = $request->getXml();

        $this->send();

        $result = new CreateCustomerResponse($this->response);

        return $result;
    }
594137
public function registerCard(string $customerId, string $urlReturn = null)
    {
        $this->flow->getLogger()->debug("Registering Card for $customerId, returns to $urlReturn");

        return BasicResponse::make(
            $this->flow->send('post',
                $this->endpoint . '/register',
                [
                    'customerId' => $customerId,
                    'url_return' => $urlReturn ?? $this->flow->getReturnUrls('card.url_return'),
                ]
            )
        );
    }
746008
public function buildCustomerCollection($customerIds)
    {
        $customerLog = $this->getTable('customer_log');
        $customerCollection = $this->customerCollection->create()
            ->addAttributeToSelect('*')
            ->addNameToSelect();
        $customerCollection = $this->addBillingJoinAttributesToCustomerCollection($customerCollection);
        $customerCollection = $this->addShippingJoinAttributesToCustomerCollection($customerCollection);
        $customerCollection = $customerCollection->addAttributeToFilter('entity_id', ['in' => $customerIds]);

        // get the last login date from the log_customer table
        $customerCollection->getSelect()->columns([
            'last_logged_date' => $this->expressionFactory->create(
                ["expression" => "(
                    SELECT last_login_at 
                    FROM  $customerLog 
                    WHERE customer_id =e.entity_id ORDER BY log_id DESC LIMIT 1
                )"]
            ),
        ]);

        return $customerCollection;
    }
1356412
public function cpcEdit($transactionId, $cpcData)
    {
        $xml = new DOMDocument();
        $hpsTransaction = $xml->createElement('hps:Transaction');
        $hpsPosCreditCPCEdit = $xml->createElement('hps:CreditCPCEdit');
        $hpsPosCreditCPCEdit->appendChild($xml->createElement('hps:GatewayTxnId', $transactionId));
        $hpsPosCreditCPCEdit->appendChild($this->_hydrateCPCData($cpcData, $xml));
        $hpsTransaction->appendChild($hpsPosCreditCPCEdit);

        return $this->_submitTransaction($hpsTransaction, 'CreditCPCEdit');
    }
282407
public function credit($points, UserContext $context)
    {
        // credit points
        $this->userTable->creditPoints($context->getUserId(), $points);

        // dispatch credited event
        $this->eventDispatcher->dispatch(PlanEvents::CREDIT, new CreditedEvent($points, $context));
    }
360809
public function create($chargeId, $amount = null, array $parameters = [])
    {
        $parameters = array_merge($parameters, array_filter(compact('amount')));

        return $this->_post("charges/{$chargeId}/refunds", $parameters);
    }
98584
public function send(OrderInterface $order, $customerId = null)
    {
        $request = new ApiRequest();
        if (!empty($customerId)) {
            $request->setPath(ApiRequest::PATH_ORDER_TAGGING);
            $replaceParams = array('{m}' => $this->account->getName(), '{cid}' => $customerId);
        } else {
            $request->setPath(ApiRequest::PATH_UNMATCHED_ORDER_TAGGING);
            $replaceParams = array('{m}' => $this->account->getName());
        }
        if (is_string($this->activeDomain)) {
            $request->setActiveDomainHeader($this->activeDomain);
        }
        if (is_string($this->account->getName())) {
            $request->setNostoAccountHeader($this->account->getName());
        }
        $request->setReplaceParams($replaceParams);
        $response = $request->post($order);
        return self::checkResponse($request, $response);
    }
344851
public function updateCustomerDiscount(int $customerId, $customerDiscount) : array
    {
        Assert::that($customerId)->greaterThan(0, 'The $customerId has to be positive');

        return (array)$this->master->doRequest(
            'POST',
            sprintf('/admin/WEBAPI/Endpoints/v1_0/CustomerService/{KEY}/UpdateCustomerDiscount/%d', $customerId),
            $customerDiscount
        );
    }
1315248
public function setCreditCardHash($hash, Customers $holder)
    {
        $this->data->fundingInstrument->method = self::METHOD_CREDIT_CARD;
        $this->data->fundingInstrument->creditCard = new stdClass();
        $this->data->fundingInstrument->creditCard->hash = $hash;
        $this->setCreditCardHolder($holder);

        return $this;
    }
308581
public function updateCustomerData($customerId, $updateData)
    {
        return $this->getCustomerModel()->getCustomer($customerId)
            ->setUpdateData($updateData)
            ->save();
    }
284998
public function getWishlistsForCustomer($customerId)
    {
        if ($customerId) {
            $collection = $this->wishlist->create()
                ->getCollection()
                ->addFieldToFilter('customer_id', $customerId)
                ->setOrder('updated_at', 'DESC')
                ->setPageSize(1);

            if ($collection->getSize()) {
                return $collection->getFirstItem();
            }
        }

        return false;
    }
363220
public function getCustomerDiscount(int $customerId) : array
    {
        Assert::that($customerId)->greaterThan(0, 'The $customerId has to be positive');

        return (array)$this->master->doRequest(
            'GET',
            sprintf(
                '/admin/WEBAPI/Endpoints/v1_0/CustomerService/{KEY}/GetCustomerDiscount/%d',
                $customerId
            )
        );
    }
1105016
public function deleteCustomer(int $customerId) : bool
    {
        Assert::that($customerId)->greaterThan(0, 'The $customerId has to be positive');

        return (bool)$this->master->doRequest(
            'DELETE',
            sprintf(
                '/admin/WEBAPI/Endpoints/v1_0/CustomerService/{KEY}/%d',
                $customerId
            )
        );
    }
134578
public function getPayment($userId, $monetaryAccountId, $id)
    {
        $paymentResponse = $this->client->get($this->getResourceEndpoint($userId, $monetaryAccountId) . '/' . (int)$id);

        $payment = $paymentResponse['Response'][0]['Payment'];

        $payment['amount']['value'] = $this->floatToCents($payment['amount']['value']);

        return $payment;
    }