当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript querystring.stringify函数代码示例

本文整理汇总了TypeScript中querystring.stringify函数的典型用法代码示例。如果您正苦于以下问题:TypeScript stringify函数的具体用法?TypeScript stringify怎么用?TypeScript stringify使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了stringify函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: step1

    private static async step1(session: builder.Session, args?: any | builder.IDialogResult<any>, next?: (args?: builder.IDialogResult<any>) => void): Promise<void> {
        let buttons = new Array<builder.CardAction>();

        if (isMessageFromChannel(session.message)) {
            // create button to deep link to the configurable channel tab - configurable channel tab must have been added for this to work
            // pattern for configurable channel tab deep link:
            // https://teams.microsoft.com/l/entity/APP_ID/ENTITY_ID?webUrl=ENTITY_WEB_URL&label=<entityLabel>&context=CONTEXT
            // APP_ID is the appId assigned in the manifest
            // ENTITY_ID is the entityId that is set for that channel tab when your config page creates it
            // ENTITY_WEB_URL is a url that is opened in a browswer on a mobile device if this url is opened on a mobile device
            // CONTEXT is a url encoded json object with a channelId parameter inside of it
            let appId = config.get("app.appId");
            let configTabEntityId = "test123";
            let queryParams = querystring.stringify({ context: "{\"channelId\":\"" + session.message.sourceEvent.channel.id + "\"}" });
            let configTabHardCodedUrl = "https://teams.microsoft.com/l/entity/" + appId + "/" + configTabEntityId + "?" + queryParams;
            buttons.push(builder.CardAction.openUrl(session, configTabHardCodedUrl, Strings.open_configurable_tab));
        }

        // create a button to deep link to the static tab located in the 1:1 chat with the bot
        // pattern for static tab deep link:
        // (at a minimum to get to the static tab)
        // https://teams.microsoft.com/l/entity/28:BOT_ID/ENTITY_ID?conversationType=chat

        // (for sending data to that tab) - look at the HelpDialog for an example
        // https://teams.microsoft.com/l/entity/28:BOT_ID/ENTITY_ID?conversationType=chat&context=CONTEXT

        // BOT_ID is the bot id that comes from your bot registration with 28: added to the front
        // ENTITY_ID is the entityId that is set for that static tab in the manifest
        // CONTEXT is a url encoded json object with a subEntityId parameter inside of it – this is how you can pass data to your static tab
        // e.g. %7B%22subEntityId%22%3A%22SUB_ENTITY_ID_DATA%22%7D
        let botId = "28:" + config.get("bot.botId");
        let staticTabEntityId = "1on1test123"; // this comes from the manifest file
        let queryParams = querystring.stringify(
            {
                conversationType: "chat",
                context: JSON.stringify({ subEntityId: "stuff" }),
            },
        );
        let staticTabHardCodedUrl = "https://teams.microsoft.com/l/entity/" + botId + "/" + staticTabEntityId + "?" + queryParams;
        buttons.push(builder.CardAction.openUrl(session, staticTabHardCodedUrl, Strings.open_static_tab));

        let newCard = new builder.HeroCard(session)
            .text(Strings.deeplink_card_text, staticTabHardCodedUrl)
            .buttons(buttons);

        session.send(new builder.Message(session)
            .addAttachment(newCard));

        session.endDialog();
    }
开发者ID:gvprime,项目名称:microsoft-teams-sample-complete-node,代码行数:50,代码来源:DeeplinkDialog.ts

示例2: reject

                    return new Promise<string>((resolve, reject) => {
                        const q = qs.stringify({
                            limit: 3
                        });

                        msg.http(FoDApiHelper.getApiUri(`/api/v3/applications/${appId}/scans?${q}`))
                            .headers({
                                'authorization': `Bearer ${token}`,
                                'content-type': 'application/octet-stream'
                            })
                            .get()((err: any, res: any, body: any) => {
                                if (err)
                                    return reject(err);

                                switch (res.statusCode) {
                                    case 200:

                                        const parsedBody = JSON.parse(body);

                                        if (parsedBody && parsedBody.totalCount) {
                                            const items = parsedBody.items.map((item: any) => {
                                                return `${item.scanType} Scan  --  Completed On: ${item.completedDateTime} -- ${item.totalIssues} Issues \
                                                        \n${FoDApiHelper.getSiteUri()}/redirect/releases/${item.releaseId}`;
                                            });

                                            return resolve(`Three most recent scans for App Id ${appId}: \n${items.join('\n')}`);
                                        }

                                        return resolve(`Sorry, I couldn't find anything.`);

                                    case 404:
                                        return resolve(`Sorry, I couldn't find anything.`);
                                }
                            });
                    });
开发者ID:mtgibbs,项目名称:hubot-fod,代码行数:35,代码来源:hubot-fod.ts

示例3: step1

    private static async step1(session: builder.Session, args?: any | builder.IDialogResult<any>, next?: (args?: builder.IDialogResult<any>) => void): Promise<void> {
        let buttons = new Array<builder.CardAction>();
        let botId = "28:" + config.get("bot.botId");
        let staticTabEntityId = "1on1test123"; // this comes from the manifest file
        let queryParams = querystring.stringify(
            {
                conversationType: "chat",
                // context: "{\"subEntityId\":\"allCommands\"}",
                context: JSON.stringify({ subEntityId: "allCommands" }),
            },
        );

        // hardCodedUrl has url encoded {"subEntityId":"allCommands"} set as the context
        let staticTabHardCodedUrl = "https://teams.microsoft.com/l/entity/" + botId + "/" + staticTabEntityId + "?" + queryParams;
        buttons.push(builder.CardAction.openUrl(session, staticTabHardCodedUrl, Strings.all_commands_button));

        let newCard = new builder.HeroCard(session)
            .text(Strings.help_msg)
            .buttons(buttons);

        session.send(new builder.Message(session)
            .addAttachment(newCard));

        session.endDialog();
    }
开发者ID:gvprime,项目名称:microsoft-teams-sample-complete-node,代码行数:25,代码来源:HelpDialog.ts

示例4: serve

    serve(log).then((url) => {
      console.log(url);

      // Open the program in the browser.
      let query = querystring.stringify({ code });
      open_url(url + '/#' + query);
    });
开发者ID:kleopatra999,项目名称:staticstaging,代码行数:7,代码来源:harness.ts

示例5: encodeURIComponent

    return new Promise<void>((resolve, reject) => {
      const query = {clientVersion: this.clientVersion};
      const options = {
        uri:
          API +
          '/debuggees/' +
          encodeURIComponent(debuggeeId) +
          '/breakpoints/' +
          encodeURIComponent(breakpointId) +
          '?' +
          qs.stringify(query),
        method: 'DELETE',
        json: true,
      };

      this.request(options, (err, body, response) => {
        if (err) {
          reject(err);
        } else if (!response) {
          reject(new Error('unknown error - request response missing'));
        } else if (response.statusCode !== 200) {
          reject(
            new Error(
              'unable to delete breakpoint, status code ' + response.statusCode
            )
          );
        } else if (Object.keys(body).length > 0) {
          reject(new Error('response body is non-empty'));
        } else {
          resolve();
        }
      });
    });
开发者ID:GoogleCloudPlatform,项目名称:cloud-debug-nodejs,代码行数:33,代码来源:debugger.ts

示例6: sign

    sign(url: string, options: Types.SignMethodOptions = {}): string {
        const data : {
            e?: number,
            a?: string,
            r: string,
            m?: string
        } = {
            r: Math.floor(Math.random()*10000000000).toString()
        };

        const exp = (options.ttl ? Math.ceil(+new Date()/1000)+options.ttl : null) ||
            options.exp ||
            (this.ttl ? Math.ceil(+new Date()/1000)+this.ttl : null);
        if(exp) {
            data.e = exp;
        }

        if(options.addr) {
            data.a = options.addr;
        }

        if(options.method) {
            data.m = (Array.isArray(options.method) ? options.method.join(',') : options.method).toUpperCase();
        }

        url += (url.indexOf('?') == -1 ? '?' : '&') + 'signed='+querystring.stringify(data, ';', ':') + ';';

        const hash = createHash('md5');
        hash.update(url, 'utf8');
        hash.update(this.secret[0]);

        url += hash.digest('hex');

        return url;
    }
开发者ID:smbwain,项目名称:signed,代码行数:35,代码来源:index.ts

示例7: queryTradeInfo

 /**
  * 提供會員系統查詢 O'Pay 訂單資訊,可透過此 API 來過濾是否為有效訂單,更多應用請參考 [FAQ](https://forum.allpay.com.tw/forum.php?mod=viewthread&tid=95&extra=page%3D1)
  */
 public async queryTradeInfo(info: ITradeInfo) {
   let body = extend<ITradeInfo>(
     {
       TimeStamp: Math.floor(Date.now() / 1000),
       MerchantID: this.config.MerchantID,
       PlatformID: ""
     },
     info
   );
   let check = new V();
   check.verify(body, {
     TimeStamp: [V.isNumber],
     MerchantID: [V.isString, V.limitLength(1, 10)],
     MerchantTradeNo: [
       V.isString,
       V.limitLength(1, 20),
       V.isNumberOrEnglishLetter
     ]
   });
   if (check.invalid) throw check.errorMessage;
   body.CheckMacValue = getMacValue(body, this.config);
   let data = qs.stringify(body);
   return request
     .post(this.config.QueryTradeInfoUrl, {
       form: body,
       headers: {
         "Content-Type": "application/x-www-form-urlencoded",
         "Content-Length": Buffer.byteLength(data)
       },
       json: false
     })
     .then(qs.parse);
 }
开发者ID:EJayCheng,项目名称:oPay-ts,代码行数:36,代码来源:oPay.ts

示例8: getRealm

	return getRealm(url).then(authParams => {
		var tokenUrl = `https://accounts.accesscontrol.windows.net/${authParams.realm}/tokens/OAuth/2`;
		var client_id = `${clientId}@${authParams.realm}`;
		var resource = `${authParams.client_id}/${urlParts.host}@${authParams.realm}`;

		var postBody = {
			grant_type: "client_credentials",
			client_id,
			client_secret: clientSecret,
			resource: resource,
			scope: resource
		};
		var bodyStr = querystring.stringify(postBody);

		var opts: any = {
			method: "POST",
			body: bodyStr,
			headers: {
				"Content-Type": "application/x-www-form-urlencoded",
				"Content-Length": bodyStr.length
			}
		};
		return request(tokenUrl, opts).then(data => {
			return data.access_token;
		});
	});
开发者ID:DroopyTersen,项目名称:spscript,代码行数:26,代码来源:tokenHelper.ts

示例9: function

	var authenticate = function() {
		var emitter = new events.EventEmitter

		var auth_prefixes = {
			v1: '/oauth',
			preview1: '/oauthpreview',
			openpreview1: '/oauthopenpreview',
		}

		// Set up the request
		var verb = 'POST'
		var path = path_join(auth_prefixes[_version], '/token')
		var params = querystring.stringify({grant_type: 'client_credentials'})
		var headers = {
			'authorization': 'Basic ' + new Buffer(_key + ':' + _secret).toString('base64'),
			'content-type': 'application/x-www-form-urlencoded',
			'content-length': params.length,
		}

		// Make the request and propagate the events, storing the token for later
		call(verb, path, params, headers, false)
			.on('done', function(response) {
				_token = response.access_token
				emitter.emit('ready')
			}).on('error', function(error) {
				emitter.emit('error', error)
			})

		return emitter
	}
开发者ID:RemediIO,项目名称:NurseBot,代码行数:30,代码来源:athenahealthapi.ts


注:本文中的querystring.stringify函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。