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


TypeScript Client.get方法代码示例

本文整理汇总了TypeScript中node-rest-client.Client.get方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Client.get方法的具体用法?TypeScript Client.get怎么用?TypeScript Client.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在node-rest-client.Client的用法示例。


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

示例1: function

    function (session, results) {
        session.userData.countryCode = results.response;
        var stateInfo = "";
        var Client = require('node-rest-client').Client;
        var client = new Client();
        // set content-type header and data as json in args parameter 
        var args = {
            data: { test: "hello" },
            headers: { "Content-Type": "application/json" }
        };
        client.get("http://services.groupkt.com/state/get/" + session.userData.countryCode + "/all", args, function (data, response) {
            // parsed response body as js object 
            var result = data["RestResponse"]["result"];
            for (var idx = 0; idx < result.length; idx++) {
                var info = result[idx];
                stateInfo = stateInfo + info["country"] + "-" + info["name"] + ",";
                console.log(info["country"] + "-" + info["name"]);	
                //console.log(stateInfo);
            }
            session.send("Hello " + session.userData.name + "! I am going to check the " + session.userData.product +
                " availability for the address:" + session.userData.address + ", ZipCode:" + session.userData.zipCode +
                "\nList of States for your country code:" + session.userData.countryCode + "\n" + stateInfo);

        });
    }
开发者ID:giriganapathy,项目名称:CheckServiceAvailabilityApp,代码行数:25,代码来源:server.ts

示例2: getSomethig

 getSomethig() : Q.Promise<string> {
   let deferred = Q.defer<string>();
   let client = new Client();
   client.on('error', function (err) {
     log.error(err);
     deferred.reject(err);
   });
   client.get(config.env.rest.url + '/something', function (data, response) {
     log.debug({data:data});
     deferred.resolve(data);
   }).on('error', function (err) {
     log.error(err);
     deferred.reject(err);
   });
   return deferred.promise;
 }
开发者ID:FranzZemen,项目名称:nodets-scaffolding,代码行数:16,代码来源:someThing.service.ts

示例3: function

    function (session, args, next) {
        var entity = builder.EntityRecognizer.findEntity(args.entities, 'pnr-number');
        if (null != entity) {
            var pnrNumber = entity.entity;
            if (null != pnrNumber) {
                session.userData.pnrNumber = pnrNumber;
                var Client = require('node-rest-client').Client;
                var client = new Client();
                // set content-type header and data as json in args parameter 
                var options = {
                    headers: { "Content-Type": "application/json" }
                };

                client.get("http://api.railwayapi.com/pnr_status/pnr/" + session.userData.pnrNumber + "/apikey/" + key, options, function (data, response) {
                    // parsed response body as js object 
                    if (data) {
                        var resultInfo = "\nTrain Name: " + data["train_name"] +
                            "\nFrom Station: " + data["from_station"]["name"] +
                            "\To Station: " + data["to_station"]["name"] +
                            "\Date Of Journey: " + data["doj"];

                        session.send(resultInfo);
                        //var msg = "Wow.. That’s a FiOS available location...\n\nLet me ask you few usage questions to help you select suitable Fios package.\n\n" +
                        //    "How many devices does your family connect to the Internet such as: cell phone, tablet, laptop, Smart TV, etc.? Also, do you do any gaming or stream any videos?"

                        //builder.Prompts.text(session, msg);
                    }
                    else {                    
                        session.send("Sorry! Information not available...");
                        delete session.userData.pnrNumber
                    }
                });
            }
            else {
                session.send("Please provide your PNR Number...");
            }
        }
        else {
            session.send("Please provide your PNR Number...");
        }
    }
开发者ID:giriganapathy,项目名称:TrainStatusApp,代码行数:41,代码来源:server.ts

示例4: function

    function (session, results, next) {
        if (results.response && !session.userData.zipCode) {
            var zipAndState = "";
            var zipCode = "";

            var userResponse = results.response;

            var zipAndStatePattern = "\\w{2}\\s\\d{5}";
            var regExpZipAndStatePattern = new RegExp(zipAndStatePattern);
            if (regExpZipAndStatePattern.test(userResponse)) {
                var zipAndStateArr = regExpZipAndStatePattern.exec(userResponse);
                if (null != zipAndStateArr) {
                    zipAndState = zipAndStateArr[0];

                    var zipCodePattern = new RegExp("\\d{5}");
                    var zipCodeArr = zipCodePattern.exec(zipAndState);
                    if (null != zipCodeArr) {
                        zipCode = zipCodeArr[0];
                    }
                }
                if (null != zipCode && zipCode.trim().length > 0) {
                    session.userData.zipCode = zipCode;
                    builder.DialogAction.send("Please wait while checking the service availability...");
                    var Client = require('node-rest-client').Client;
                    var client = new Client();
                    // set content-type header and data as json in args parameter 
                    var args = {
                        headers: { "Content-Type": "application/json" }
                    };
                    client.get("http://fiosserviceavailabilityapp.azurewebsites.net/zipcode/" + zipCode, args, function (data, response) {
                        // parsed response body as js object 
                        var result = data["status"];
                        if (result) {
                            session.userData.serviceAvailable = true;
                            var msg = "Great! " + session.userData.selectedOffer + " is available in your address with the zip code:" + zipCode + "\n\n" +
                                "To recommend best plan, can u tell me your usage..like do u use internet more or tv...etc.";
                            builder.Prompts.text(session, msg);
                        }
                        else {
                            session.userData.serviceAvailable = false;
                            session.send("Sorry! " + session.userData.selectedOffer + " is unavailable in your address with the zip code:" + zipCode);
                        }
                    });
                }
            }
            else {
                //Pl. provide the valid zip code.
                //session.userData.zipCode = null;
                session.send("Sorry! " + "I dont see the zip code in the address you provided...\nPlease provide me the address with zip code.");
                //session.replaceDialog("/showOffer");
            }
        }
        else {
            if (!session.userData.serviceAvailable) {
                session.send("Sorry! " + session.userData.selectedOffer + " is unavailable in your address with the zip code:" + session.userData.zipCode);
            }
            else {
                next({ response: session.message.text });
            }            
        }
    },
开发者ID:giriganapathy,项目名称:VZChatBotApp,代码行数:61,代码来源:server.ts


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