Check account balance and status

@return object   Semaphore response
426679
public function account($mustInit = true)
    {
        if ($mustInit) $this->_init();

        $params = array(
            'api' => $this->api_key,
        );

        $query = http_build_query($params);

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, Config::get('semaphore::url.sms.account') . '?' . $query);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($ch);
        curl_close($ch);

        return $response;
    }
761238
public static function getPaymentStatusList()
    {
        return [
            self::PAYMENT_STATUS_CANCELED_REVERSAL => 'A reversal has been cancelled. For example, you won a dispute with the customer, and the funds for the transaction that was reversed have been returned to you',
            self::PAYMENT_STATUS_COMPLETED => 'The payment has been completed, and the funds have been added successfully to your account balance',
            self::PAYMENT_STATUS_DENIED => 'You denied the payment. This happens only if the payment was previously pending because of possible reasons',
            self::PAYMENT_STATUS_FAILED => 'The payment has failed. This happens only if the payment was made from your customer’s bank account.',
            self::PAYMENT_STATUS_PENDING => 'The payment is pending. See pending_reason for more information.',
            self::PAYMENT_STATUS_REFUNDED => 'You refunded the payment.',
            self::PAYMENT_STATUS_REVERSED => 'A payment was reversed due to a chargeback or other type of reversal. The funds have been removed from your account balance and returned to the buyer. The reason for the reversal is specified in the ReasonCode element.',
            self::PAYMENT_STATUS_PROCESSED => 'A payment has been accepted.',
            self::PAYMENT_STATUS_VOIDED => 'This authorization has been voided.',
        ];
    }
1108280
public function getStatus() {
        if ($this->pid) {
            $waitPID = \pcntl_waitpid($this->pid, $status, WNOHANG);

            if ($waitPID == $this->pid) {
                return Thread::THREAD_EXITED;
            } else {
                return Thread::THREAD_RUNNING;
            }
        }
    }
565531
public function status(): ?int
    {
        if ($this->agent != null) {
            return $this->agent->isConnected() ? self::STATUS_CONNECTED : self::STATUS_DISCONNECTED;
        }

        return null;
    }
795673
public static function checkBalance(){
        //主帐号
        $accountSid = self::$yun['accountSid'];

        //主帐号Token
        $accountToken = self::$yun['accountToken'];

        //应用Id
        $appId = self::$yun['appid'];

        //请求地址，格式如下，不需要写https://
        $serverIP = self::$yun['serverIP'];

        //请求端口
        $serverPort = self::$yun['serverPort'];

        //REST版本号
        $softVersion = self::$yun['softVersion'];

        $rest = new CCPRest($serverIP,$serverPort,$softVersion);
        $rest->setAccount($accountSid,$accountToken);
        $rest->setAppId($appId);

        $result = $rest->queryAccountInfo();

        if($result == NULL ) {
            return 0;
        }
        if($result->statusCode!= 0) {
            //echo "error code :" . $result->statusCode . "<br>";
            //echo "error msg :" . $result->statusMsg . "<br>";
            return 'ERROR';
        }

        return intval($result->Account->balance);
    }
724105
private function monitorPending()
    {
        foreach ($this->inProcess as $index => $process) {

            /** @var Process $process */
            if ($process->isTerminated()) {

                if ($process->isSuccessful()) {

                    call_user_func($this->onSuccess, $process->getOutput(), $index);

                } else {

                    call_user_func($this->onError, $process->getErrorOutput(), $index);
                }

                unset($this->inProcess[$index]);

                $this->addPending();
            }
        }
    }
534418
protected function getStatus()
    {
        if ($this->detail instanceof \Throwable) {
            $this->status = $this->createStatusFromException();
        }

        return $this->status;
    }
631787
public function check()
    {
        $this->loadDatabase();

        $current = $this->getCurrentUptime();

        $this->persist($current);

        $rebooted =
            ($cs = $this->uptimeInSeconds($current)) <
            ($ss = $this->uptimeInSeconds($this->database));

        return $this->makeResult(
            ! $rebooted,
            $this->makeMessage($current, $this->database)
        );
    }
333158
public function nextPending()
    {
        if (!$this->hasPending()) {
            return null;
        }

        $current = $this->pending->current();
        $this->pending->next();

        return $current;
    }
209764
public function getBalance()
    {
        $resource = 'campaigns/' . $this->campaignId . '/balance.json';

        $response = $this->sendRequest('GET', $this->getServiceUrl($resource));

        $decodedResponseBody = $this->getDecodedBody($response->getBody());

        $getBalanceResponse = new Models\GetBalanceResponse($decodedResponseBody);
        return $getBalanceResponse->getBalance();
    }
468566
public function getAccounts()
    {
        $resource = 'accounts';

        $response = $this->sendGetRequest($resource);
        $accountsResponse = new Models\GetAccountsResponse($response);
        return $accountsResponse->getAccounts();
    }
142544
public function getBalance()
    {

        $result = $this->client->GetCreditBalance();

        // в спеке на запрос возвращается строка.
        // в саппорте говорят, что баланс в кредитах может быть дробным (о_О)
        // будем оперировать целым остатком.

        if (isset($result->GetCreditBalanceResult)) {
            return intval($result->GetCreditBalanceResult);
        }

        throw new TurboSmsException('Cannot get balance');
    }
1040086
public function getAccountInformation() {
    $url = $this->url . self::$API_ROUTES['ACCOUNT_INFO'];
    $url .= '?apiVersion=' . $this->apiVersion;

    $result = $this->doGet($url, array(), false);

    if ($result !== null && is_object($result)) {
      $accountInfo = AccountInformation::getFromJson($result);

      if ($accountInfo != null) {
        return $accountInfo;
      }
    }

    return null;
  }
858468
public function getAccount()
    {
        $response = $this->rest->get(
            static::ACCOUNT_PATH
        );

        $this->checkResponse($response);

        return new Account($response);
    }
920429
protected function currentStatus()
    {
        if (! $masters = app(MasterSupervisorRepository::class)->all()) {
            return 'inactive';
        }

        return collect($masters)->contains(function ($master) {
            return $master->status === 'paused';
        }) ? 'paused' : 'running';
    }
1283339
public function getBalance($user_id, $type = -1){
        $url = $this->authenticationService->getServerEndPoint() . Endpoints::VERSION . Endpoints::BASE_WALLET . Endpoints::WALLET_CREDITS_BALANCE;
        $url = sprintf($url, $user_id, $type);
        $result = $this->authenticationService->getTransport()->fetch($url);

        if($result["code"] == APIResponse::RESPONSE_SUCCESS){
            return $result['results'];
        }else{
            return 0;
        }
    }
71163
public function getTransactionStatus(): string
    {
        // If the user cancelled in the terminal window, then we need to detect that.
        if ($this->hasError()) {
            $error = $this->getError();
            if (
                !empty($error['operation']) && $error['operation'] === 'Terminal' &&
                !empty($error['responseCode']) && $error['responseCode'] === '17' &&
                !empty($error['responseSource']) && ($error['responseSource'] === 'Terminal' || $error['responseSource'] === '05') &&
                !empty($error['responseText']) && $error['responseText'] === 'Cancelled by customer.'
            ) {
                return QueryInterface::STATUS_CANCELLED;
            }

            return QueryInterface::STATUS_FAILED;
        }

        $summary = $this->getSummary();

        // If the cancelled flag is set, then it can no longer be considered to be authed, captured or credited.
        if ($summary['cancelled']) {
            return QueryInterface::STATUS_CANCELLED;
        }

        // If there's an amount present in the amountCredited field, it's because it's not a request for payment.
        if ($summary['amountCredited']) {
            return QueryInterface::STATUS_CREDITED;
        }

        // If it's not cancelled, not credited, but is authed and not captured, then it must just be authed.
        if ($summary['authorized'] && !$summary['amountCaptured']) {
            return QueryInterface::STATUS_AUTHORIZED;
        }

        // If it's not cancelled, not credited, not authed, and not captured, then it's either pending, (Netaxept's
        // 'registered' state) or rejected.
        if (!$summary['authorized'] && !$summary['amountCaptured']) {
            return QueryInterface::STATUS_PENDING;
        }

        // The only other option is that it's been captured.
        return QueryInterface::STATUS_CAPTURED;
    }