Проверка доступности квоты по UID-у типа отчета.

@param string $auth_token      Токен безопасности
@param string $report_type_uid UID типа отчета
@param bool   $detailed

@throws B2BApiException

@return B2BResponse
349499
public function balance($auth_token, $report_type_uid, $detailed = false)
    {
        return new B2BResponse($this->client->apiRequest(
            'get',
            sprintf('user/balance/%s', urlencode($report_type_uid)),
            [
                '_detailed' => (bool) $detailed ? 'true' : 'false',
            ],
            [
                'Authorization' => (string) $auth_token,
            ],
            $this->client->isTest() ? new Response(
                200,
                $this->getTestingResponseHeaders(),
                str_replace(
                    [
                        '%domain%',
                        '%default_report_type_uid%',
                    ],
                    [
                        AuthToken::extractDomainFromToken($auth_token),
                        $report_type_uid,
                    ],
                    file_get_contents(__DIR__ . '/balance.json')
                )
            ) : null
        ));
    }
516110
public function createMicroPay($auth_code, $out_trade_no, $total_fee, $body, $goods_tag = null)
    {
        $data = array(
            "appid"            => $this->appid,
            "mch_id"           => $this->mch_id,
            "body"             => $body,
            "out_trade_no"     => $out_trade_no,
            "total_fee"        => $total_fee,
            "auth_code"        => $auth_code,
            "spbill_create_ip" => Tools::getAddress(),
        );
        empty($goods_tag) || $data['goods_tag'] = $goods_tag;
        $json = Tools::xml2arr($this->postXml($data, self::MCH_BASE_URL . '/pay/micropay'));
        if (!empty($json) && false === $this->_parseResult($json)) {
            return false;
        }
        return $json;
    }
219866
public function tokenCreate(
        $type = Teamspeak::TOKEN_SERVERGROUP,
        $id1,
        $id2 = 0,
        $description = null,
        $customset = null
    ) {
        return $this->privilegeKeyCreate($type, $id1, $id2, $description, $customset);
    }
704554
public JwtToken build(JwtAuth userDetails) {
        Date expireTime = generateExpirationDate();
        Map<String, Object> claims = new HashMap<>(16);
        claims.put(CLAIM_KEY_LOGIN_NAME, userDetails.getLoginName());
        claims.put(CLAIM_KEY_ID, userDetails.getId());
        claims.put(CLAIM_KEY_MICK_NAME, userDetails.getNickName());
        claims.put(CLAIM_KEY_CREATED, expireTime.getTime());
        claims.put(CLAIM_KEY_ROLE, userDetails.getRoles());
        claims.put(CLAIM_KEY_AVATAR,userDetails.getAvatar());
        return new JwtToken(build(claims, expireTime), expireTime.getTime());
    }
1080134
public function getTransactionDetailsForUser($user_id, $count = 10, $paginated_url = null, $page = 1){
        if($paginated_url) {
            $url = $paginated_url;
        }else {
            $url = $this->authenticationService->getServerEndPoint() . Endpoints::VERSION . Endpoints::BASE_WALLET
                . Endpoints::WALLET_TRANSACTIONS_USER . ($paginated_url ? '' : '?page=' . (int) $page);
            $url = sprintf($url, $user_id, $count);
        }

        $result = $this->authenticationService->getTransport()->fetch($url);

        if($result["code"] == APIResponse::RESPONSE_SUCCESS){
            $this->maskData($result['results']['data']);
            $paginatedResult = new PaginatedResults($result['results'],array($this,'getTransactionDetailsForUser'),array($user_id,$count));
            return $paginatedResult;
        }else{
            return new PaginatedResults(array(),null,null);
        }

    }
893214
public function detailFunctionaryAction(string $aID, string $fID)
    {
        $this->checkStaticTemplateIsIncluded();
        $this->checkSettings();

        $this->slotExtendedAssignMultiple([
            self::VIEW_VARIABLE_ASSOCIATION_ID => $aID,
            self::VIEW_VARIABLE_FUNCTIONARY_ID => $fID
        ], __CLASS__, __FUNCTION__);

        return $this->view->render();
    }
11876
function newService()
    {
        ### Attain Login Continue If Has
        /** @var iHttpRequest $request */
        $request  = \IOC::GetIoC()->get('/HttpRequest');
        $tokenAuthIdentifier = new IdentifierHttpToken;
        $tokenAuthIdentifier
            ->setRequest($request)
            ->setTokenAssertion( \Module\OAuth2Client\Actions::AssertToken()->assertion() )
        ;

        // In Cases That we request and token has no owner_identifier
        // client_credentials token in example
        //
        /*
        $authenticator = new Authenticator(
            $tokenAuthIdentifier
        );
        */


        // So I Disable This Here; this cause problem
        $authenticator = new Authenticator(
            new IdentifierWrapIdentityMap(
                $tokenAuthIdentifier
                , new IdentityFulfillmentLazy( $this->getIdentityProvider() , 'owner_identifier' )
            )
        );

        return $authenticator;
    }
697629
private function makeChargeCalls($chargeType, $setParameters, $confirmParameters, $authorizeParameters)
    {
        switch ($chargeType) {
            
            case 'OrderReference':
        
                // Get the Order Reference details and feed the response object to the ResponseParser
                $responseObj = $this->getOrderReferenceDetails($setParameters);
        
               // Call the function getOrderReferenceDetailsStatus in ResponseParser.php providing it the XML response
               // $oroStatus is an array containing the State of the Order Reference ID
               $oroStatus = $responseObj->getOrderReferenceDetailsStatus($responseObj->toXml());
        
                if ($oroStatus['State'] === 'Draft') {
                    $response = $this->setOrderReferenceDetails($setParameters);
                    if ($this->success) {
                        $this->confirmOrderReference($confirmParameters);
                    }
                }
        
                $responseObj = $this->getOrderReferenceDetails($setParameters);
        
                // Check the Order Reference Status again before making the Authorization.
                $oroStatus = $responseObj->getOrderReferenceDetailsStatus($responseObj->toXml());
        
                if ($oroStatus['State'] === 'Open') {
                    if ($this->success) {
                        $response = $this->authorize($authorizeParameters);
                    }
                }

                if ($oroStatus['State'] != 'Open' && $oroStatus['State'] != 'Draft') {
                    throw new \Exception('The Order Reference is in the ' . $oroStatus['State'] . " State. It should be in the Draft or Open State");
                }
                
                return $response;
            
            case 'BillingAgreement':
                
                // Get the Billing Agreement details and feed the response object to the ResponseParser
                
                $responseObj = $this->getBillingAgreementDetails($setParameters);
                
                // Call the function getBillingAgreementDetailsStatus in ResponseParser.php providing it the XML response
                // $baStatus is an array containing the State of the Billing Agreement
                $baStatus = $responseObj->getBillingAgreementDetailsStatus($responseObj->toXml());
                
                if ($baStatus['State'] === 'Draft') {
                    $response = $this->setBillingAgreementDetails($setParameters);
                    if ($this->success) {
                        $response = $this->confirmBillingAgreement($confirmParameters);
                    }
                }
                
                // Check the Billing Agreement status again before making the Authorization.
                $responseObj = $this->getBillingAgreementDetails($setParameters);
                $baStatus = $responseObj->getBillingAgreementDetailsStatus($responseObj->toXml());
        
                if ($this->success && $baStatus['State'] === 'Open') {
                    $response = $this->authorizeOnBillingAgreement($authorizeParameters);
                }
        
                if ($baStatus['State'] != 'Open' && $baStatus['State'] != 'Draft') {
                    throw new \Exception('The Billing Agreement is in the ' . $baStatus['State'] . " State. It should be in the Draft or Open State");
                }
        
                return $response;

            default:
                throw new \Exception('Invalid Charge Type');
        }
    }
435635
protected function addressbookQueryReport($report)
    {
        $depth = $this->server->getHTTPDepth(0);

        if (0 == $depth) {
            $candidateNodes = [
                $this->server->tree->getNodeForPath($this->server->getRequestUri()),
            ];
            if (!$candidateNodes[0] instanceof ICard) {
                throw new ReportNotSupported('The addressbook-query report is not supported on this url with Depth: 0');
            }
        } else {
            $candidateNodes = $this->server->tree->getChildren($this->server->getRequestUri());
        }

        $contentType = $report->contentType;
        if ($report->version) {
            $contentType .= '; version='.$report->version;
        }

        $vcardType = $this->negotiateVCard(
            $contentType
        );

        $validNodes = [];
        foreach ($candidateNodes as $node) {
            if (!$node instanceof ICard) {
                continue;
            }

            $blob = $node->get();
            if (is_resource($blob)) {
                $blob = stream_get_contents($blob);
            }

            if (!$this->validateFilters($blob, $report->filters, $report->test)) {
                continue;
            }

            $validNodes[] = $node;

            if ($report->limit && $report->limit <= count($validNodes)) {
                // We hit the maximum number of items, we can stop now.
                break;
            }
        }

        $result = [];
        foreach ($validNodes as $validNode) {
            if (0 == $depth) {
                $href = $this->server->getRequestUri();
            } else {
                $href = $this->server->getRequestUri().'/'.$validNode->getName();
            }

            list($props) = $this->server->getPropertiesForPath($href, $report->properties, 0);

            if (isset($props[200]['{'.self::NS_CARDDAV.'}address-data'])) {
                $props[200]['{'.self::NS_CARDDAV.'}address-data'] = $this->convertVCard(
                    $props[200]['{'.self::NS_CARDDAV.'}address-data'],
                    $vcardType,
                    $report->addressDataProperties
                );
            }
            $result[] = $props;
        }

        $prefer = $this->server->getHTTPPrefer();

        $this->server->httpResponse->setStatus(207);
        $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8');
        $this->server->httpResponse->setHeader('Vary', 'Brief,Prefer');
        $this->server->httpResponse->setBody($this->server->generateMultiStatus($result, 'minimal' === $prefer['return']));
    }
723861
@View(name = "by_uid_otp", map = "function(doc) { if(doc.token && doc.userId) { emit([doc.userId, doc.token], doc) } }")
    public CouchDbGoogleAuthenticatorToken findOneByUidForOtp(final String uid, final Integer otp) {
        val view = createQuery("by_uid_otp").key(ComplexKey.of(uid, otp)).limit(1);
        return db.queryView(view, CouchDbGoogleAuthenticatorToken.class).stream().findFirst().orElse(null);
    }
995691
@Override
    protected void loadReport(ReportsConfig result, File report, String reportId) throws IOException {
        // Need to refresh? -- CahcedReport should be made abstract and the type should define which class to use
        // and what refresh checking method is used.
        if (!cache.containsKey(reportId) || cache.get(reportId).getLastModified() != report.lastModified())
        {
            super.loadReport(result, report, reportId);
            cache.put(reportId,new CachedReport(result.getReports().get(reportId),report.lastModified()));
        }
        result.getReports().put(reportId, cache.get(reportId).getReportConfig());
    }
1347785
public function actionReport($cid = null, $fid = null, $tid = null, $pid = null)
    {
        $post = Post::verify($cid, $fid, $tid, $pid);
        if (empty($post)) {
            $this->error(Yii::t('podium/flash', 'Sorry! We can not find the post you are looking for.'));
            return $this->redirect(['forum/index']);
        }

        if (User::can(Rbac::PERM_UPDATE_POST, ['item' => $post])) {
            $this->info(Yii::t('podium/flash', "You don't have to report this post since you are allowed to modify it."));
            return $this->redirect([
                'forum/edit',
                'cid' => $post->forum->category->id,
                'fid' => $post->forum->id,
                'tid' => $post->thread->id,
                'pid' => $post->id
            ]);
        }

        if ($post->author_id == User::loggedId()) {
            $this->info(Yii::t('podium/flash', 'You can not report your own post. Please contact the administrator or moderators if you have got any concerns regarding your post.'));
            return $this->redirect([
                'forum/thread',
                'cid' => $post->forum->category->id,
                'fid' => $post->forum->id,
                'id' => $post->thread->id,
                'slug' => $post->thread->slug
            ]);
        }

        $model = new Message();
        $model->scenario = 'report';
        if ($model->load(Yii::$app->request->post()) && $model->validate()) {
            if ($model->podiumReport($post)) {
                $this->success(Yii::t('podium/flash', 'Thank you for your report. The moderation team will take a look at this post.'));
                return $this->redirect([
                    'forum/thread',
                    'cid' => $post->forum->category->id,
                    'fid' => $post->forum->id,
                    'id' => $post->thread->id,
                    'slug' => $post->thread->slug
                ]);
            }
            $this->error(Yii::t('podium/flash', 'Sorry! There was an error while notifying the moderation team. Contact administrator about this problem.'));
        }
        return $this->render('report', ['model' => $model, 'post' => $post]);
    }
533483
public function refreshToken($refresh_token, array $client = [], $grant_type = 'refresh_token', $username = '', $scopes = [])
	{
		$request_data = [
			'client_id'     => $client['client_id'],
			'client_secret' => $client['client_secret'],
			'grant_type'    => $grant_type,
			'refresh_token' => $refresh_token,
		];

		if (! empty($scopes)) {
			$request_data['scope'] = implode(',', $scopes);
		}

		$response = $this->post($this->oauthUrl(), $request_data)->getJson();

		// If this was a successful auth, set the access token
		if (isset($response->access_token)) {
			$this->access_tokens[$username] = $response->access_token;
		}

		return $response;
	}
541606
public function print_badge_tabs($badgeid, $context, $current = 'overview') {
        global $DB;

        $badge = new badge($badgeid);
        $row = array();

        $row[] = new tabobject('overview',
                    new moodle_url('/badges/overview.php', array('id' => $badgeid)),
                    get_string('boverview', 'badges')
                );

        if (has_capability('moodle/badges:configuredetails', $context)) {
            $row[] = new tabobject('details',
                        new moodle_url('/badges/edit.php', array('id' => $badgeid, 'action' => 'details')),
                        get_string('bdetails', 'badges')
                    );
        }

        if (has_capability('moodle/badges:configurecriteria', $context)) {
            $row[] = new tabobject('criteria',
                        new moodle_url('/badges/criteria.php', array('id' => $badgeid)),
                        get_string('bcriteria', 'badges')
                    );
        }

        if (has_capability('moodle/badges:configuremessages', $context)) {
            $row[] = new tabobject('message',
                        new moodle_url('/badges/edit.php', array('id' => $badgeid, 'action' => 'message')),
                        get_string('bmessage', 'badges')
                    );
        }

        if (has_capability('moodle/badges:viewawarded', $context)) {
            $awarded = $DB->count_records_sql('SELECT COUNT(b.userid)
                                               FROM {badge_issued} b INNER JOIN {user} u ON b.userid = u.id
                                               WHERE b.badgeid = :badgeid AND u.deleted = 0', array('badgeid' => $badgeid));
            $row[] = new tabobject('awards',
                        new moodle_url('/badges/recipients.php', array('id' => $badgeid)),
                        get_string('bawards', 'badges', $awarded)
                    );
        }

        if (has_capability('moodle/badges:configuredetails', $context)) {
            $row[] = new tabobject('bendorsement',
                new moodle_url('/badges/endorsement.php', array('id' => $badgeid)),
                get_string('bendorsement', 'badges')
            );
        }

        if (has_capability('moodle/badges:configuredetails', $context)) {
            $sql = "SELECT COUNT(br.badgeid)
                      FROM {badge_related} br
                     WHERE (br.badgeid = :badgeid OR br.relatedbadgeid = :badgeid2)";
            $related = $DB->count_records_sql($sql, ['badgeid' => $badgeid, 'badgeid2' => $badgeid]);
            $row[] = new tabobject('brelated',
                new moodle_url('/badges/related.php', array('id' => $badgeid)),
                get_string('brelated', 'badges', $related)
            );
        }

        if (has_capability('moodle/badges:configuredetails', $context)) {
            $alignments = $DB->count_records_sql("SELECT COUNT(bc.id)
                      FROM {badge_alignment} bc WHERE bc.badgeid = :badgeid", array('badgeid' => $badgeid));
            $row[] = new tabobject('balignment',
                new moodle_url('/badges/alignment.php', array('id' => $badgeid)),
                get_string('balignment', 'badges', $alignments)
            );
        }

        echo $this->tabtree($row, $current);
    }
145446
def view_fullreport(token, dstore):
    
    # avoid circular imports
    from openquake.calculators.reportwriter import ReportWriter
    return ReportWriter(dstore).make_report()
926507
private String createReportContent(String suiteName, List<TestResult> results, ReportTemplates templates) throws IOException {
        final StringBuilder reportDetails = new StringBuilder();

        for (TestResult result: results) {
            Properties detailProps = new Properties();
            detailProps.put("test.class", result.getClassName());
            detailProps.put("test.name", StringEscapeUtils.escapeXml(result.getTestName()));
            detailProps.put("test.duration", "0.0");

            if (result.isFailed()) {
                detailProps.put("test.error.cause", Optional.ofNullable(result.getCause()).map(Object::getClass).map(Class::getName).orElse(result.getFailureType()));
                detailProps.put("test.error.msg", StringEscapeUtils.escapeXml(result.getErrorMessage()));
                detailProps.put("test.error.stackTrace", Optional.ofNullable(result.getCause()).map(cause -> {
                    StringWriter writer = new StringWriter();
                    cause.printStackTrace(new PrintWriter(writer));
                    return writer.toString();
                }).orElse(result.getFailureStack()));
                reportDetails.append(PropertyUtils.replacePropertiesInString(templates.getFailedTemplate(), detailProps));
            } else {
                reportDetails.append(PropertyUtils.replacePropertiesInString(templates.getSuccessTemplate(), detailProps));
            }
        }

        Properties reportProps = new Properties();
        reportProps.put("test.suite", suiteName);
        reportProps.put("test.cnt", Integer.toString(results.size()));
        reportProps.put("test.skipped.cnt", Long.toString(results.stream().filter(TestResult::isSkipped).count()));
        reportProps.put("test.failed.cnt", Long.toString(results.stream().filter(TestResult::isFailed).count()));
        reportProps.put("test.success.cnt", Long.toString(results.stream().filter(TestResult::isSuccess).count()));
        reportProps.put("test.error.cnt", "0");
        reportProps.put("test.duration", "0.0");
        reportProps.put("tests", reportDetails.toString());
        return PropertyUtils.replacePropertiesInString(templates.getReportTemplate(), reportProps);
    }
791160
public function info($auth_token)
    {
        return new B2BResponse($this->client->apiRequest(
            'get',
            'user',
            null,
            [
                'Authorization' => (string) $auth_token,
            ],
            $this->client->isTest() ? new Response(
                200,
                $this->getTestingResponseHeaders(),
                str_replace(
                    [
                        '%domain%',
                        '%username%',
                    ],
                    [
                        AuthToken::extractDomainFromToken($auth_token),
                        AuthToken::extractUsernameFromToken($auth_token),
                    ],
                    file_get_contents(__DIR__ . '/user.json')
                )
            ) : null
        ));
    }