public void SaveTrcker(string tracker)
        {
            String cdate = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ssZ");

            Console.WriteLine("Current Date  " + cdate);
            String parameter = "[{\"DataSource\":0,\"DataTime\":\"" + cdate + "\",\"Measurement\":{\"Description\":\"Stress\",\"DisplayOrder\":1,\"Id\":25,\"IsRequired\":true,\"MaxRangeValue\":0,\"MeasurementType\":{\"Id\":3,\"Name\":\"Likert scale\"},\"MinRangeValue\":0,\"Name\":\"Stress\",\"ToolTip\":\"\",\"Unit\":{\"Abbreviation\":\"\",\"Description\":\"\",\"DisplayName\":\"\",\"Id\":11,\"Name\":\"best(1) to worst(5) scale\"},\"allowDecimal\":false},\"UserId\":\"" + GlobalVariables.userid + "\",\"Value\":5,\"isValueModified\":true,\"isValueValid\":true}]";
            String url;

            url = baseurl + "/mobileapi/api/trackers/userId/" + GlobalVariables.userid;
            ApiKeywords.InitializeRequest(url);
            ApiKeywords.SetMethod("GET");
            ApiKeywords.SetParameter("servicecycleid", GlobalVariables.servicecycleid);
            cma.SetMobileCommonHeader(token);
            string responsce = ApiKeywords.SendRequest();
            JToken to        = JToken.Parse(responsce);
            string exp       = "$.[?(@.Name=='" + tracker + "')].Guid";

            Guid = (String)to.SelectToken(exp, true);
            url  = baseurl + "/mobileapi/api/trackers/userId/" + GlobalVariables.userid + "/trackerGuid/" + Guid;
            //Console.WriteLine("URL:  "+url);
            ApiKeywords.InitializeRequest(url);
            //Console.WriteLine("Parameter   : " + parameter);
            ApiKeywords.SetParameter("application / json", parameter, "body");
            ApiKeywords.SetMethod("POST");
            cma.SetMobileCommonHeader(token);
            string  responsce1 = ApiKeywords.SendRequest();
            JObject ob         = JObject.Parse(responsce1);
            String  exp1       = "$.allow_user_feedback";
            String  result     = (String)ob.SelectToken(exp1);

            //System.Console.WriteLine("Response of API  " +result);
            softAssertions.Add("Stress Tracker save ", "false", result, "equals", "false");
        }
Ejemplo n.º 2
0
        public string GetToken()
        {
            Common cmn    = new Common();
            string env    = cmn.GetEnvFromUrl();
            string apiurl = "https://" + env + "services.onlifehealth.com/login/auth/token";

            Console.WriteLine("ApiUrl : " + apiurl);
            ApiKeywords.InitializeRequest(apiurl);
            ApiKeywords.SetMethod("post");
            ApiKeywords.SetParameter("platform_Id", "android");
            ApiKeywords.SetParameter("client_secret", "YcOTVgx11etcu0KFpPTWdumUTkvs7A3wxjqSqSjPRZw");
            ApiKeywords.SetParameter("scope", "manage");
            ApiKeywords.SetParameter("password", "Password1");
            ApiKeywords.SetParameter("device_token", "f3SBXqMIq40:APA91bFRoVTbQB0fJk5Cr2fPfQF1b3e_8Tn_rmPMjaLryCrCwAuMCEqzsBAIug-E6OQ7Qe2zaF5UBjtGUh7-P30IslZL6_WV_Yd4nf9hhBVCOkO7-9WnhNqv2JPgid5TJEXkAWZOwLa9");
            ApiKeywords.SetParameter("client_id", "277a638465ca44ab917fe4f45f2154a3");
            ApiKeywords.SetParameter("username", GlobalVariables.username);
            ApiKeywords.SetParameter("grant_type", "password");
            string response = ApiKeywords.SendRequest();

            Console.WriteLine("\nResponse : " + response);

            dynamic stuff = Newtonsoft.Json.JsonConvert.DeserializeObject(response);
            string  token = stuff.Access_Token;

            token = "Bearer " + token;
            Console.WriteLine("\n\nAccess_Token : " + token);

            return(token);
        }
Ejemplo n.º 3
0
        public void getUserLoginDetails(string username)
        {
            String url;
            string path;

            url = GetServicesUrl() + "/mobileapi/api/logindetails";
            ApiKeywords.InitializeRequest(url);
            ApiKeywords.SetMethod("GET");
            ApiKeywords.SetParameter("username", username);
            string responsce = ApiKeywords.SendRequest();

            path = "actor_Id";
            string actorid = ApiKeywords.GetValueFromJSONObject(responsce, path);

            System.Console.WriteLine("Response of API  " + responsce);
            //System.Console.WriteLine("Response of API  " + actorid);
            GlobalVariables.actorid = actorid;
            path = "user_Id";
            string user_Id = ApiKeywords.GetValueFromJSONObject(responsce, path);

            GlobalVariables.userid = user_Id;
            path = "serviceCycle_Id";
            string serviceCycle_Id = ApiKeywords.GetValueFromJSONObject(responsce, path);

            GlobalVariables.servicecycleid = serviceCycle_Id;
            path = "group_Id";
            string group_Id = ApiKeywords.GetValueFromJSONObject(responsce, path);

            GlobalVariables.groupid = group_Id;
        }
        public void VerifyTakerAPIs(String tracker, String title)
        {
            String url;

            url = baseurl + "/mobileapi/api/goals/tracker";
            ApiKeywords.InitializeRequest(url);
            ApiKeywords.SetMethod("GET");
            ApiKeywords.SetParameter("trackerType", tracker);
            cma.SetMobileCommonHeader(token);
            string responsce = ApiKeywords.SendRequest();

            System.Console.WriteLine("Response of API  " + responsce);
            string[]        parentpath = { "inactive_goals" };
            string[]        childpath  = { "title" };
            List <string[]> value      = ApiKeywords.GetResponse(responsce, parentpath, childpath);

            //for (int i = 0; i < value.Count(); i++)
            //{
            //    System.Console.WriteLine("Response of API  " + value[i]);
            //    softAssertions.Add("Trckers avilable", value.ElementAt(i)[0], tracker, "equals", "false");
            //}
            //softAssertions.Add("Configuration ha_percentage", "0", value, "equals", "false");
            for (int i = 0; i < value.Count; i++)
            {
                for (int j = 0; j < value.ElementAt(0).Count(); j++)
                {
                    Console.WriteLine("Title" + value.ElementAt(i)[j]);
                    softAssertions.Add("Trckers avilable", value.ElementAt(i)[j], title, "equals", "false");
                }
            }
        }
Ejemplo n.º 5
0
        // call in config test
        public void VerifyNotificationCountAPI()
        {
            String url;

            url = baseurl + "/mobileapi/api/member/" + GlobalVariables.actorid + "/notificationscount";
            ApiKeywords.InitializeRequest(url);
            ApiKeywords.SetMethod("GET");
            cma.SetMobileCommonHeader(token);
            string responsce = ApiKeywords.SendRequest();

            System.Console.WriteLine("Response of API  " + responsce);
            //GlobalVariables.actorid = actorid;
        }
Ejemplo n.º 6
0
        //Call by New member Journey Test case
        public void VerifyNewMemberJourney()
        {
            String url;

            url = baseurl + "/mobileapi/v1.0/member/" + GlobalVariables.actorid + "/journey";
            ApiKeywords.InitializeRequest(url);
            ApiKeywords.SetMethod("GET");
            cma.SetMobileCommonHeader(token);
            string responsce = ApiKeywords.SendRequest();

            System.Console.WriteLine("Response of API  " + responsce);
            VerifyJourneyTiles("MobileJourneyAPIContent", responsce);
        }
        public void FetchAnnouncements(List <string[]> announcementData)
        {
            int       length;
            CommonApi cmna        = new CommonApi();
            string    userid      = cmna.GetUserID();
            Common    cmn         = new Common();
            string    env         = cmn.GetEnvFromUrl();
            string    baseurl     = cmna.GetServices2Url();
            string    apiendpoint = baseurl + "/internalapi/v1.0/member/" + userid + "/allnotifications";

            Console.WriteLine(apiendpoint);
            ApiKeywords.InitializeRequest(apiendpoint);
            ApiKeywords.SetMethod("GET");
            string jsonresponse = ApiKeywords.SendRequest();

            string[]        parentObjPath = { "Notification" };
            string[]        subObjPath    = { "Description" };
            List <string[]> description   = ApiKeywords.GetResponse(jsonresponse, parentObjPath, subObjPath);

            Console.WriteLine("Announcements Result: " + description.Count);
            if (description.Count() != 0 && announcementData.Count() != 0)
            {
                if (announcementData.Count() < description.Count())
                {
                    length = announcementData.Count();
                }
                else
                {
                    length = description.Count();
                }
                Console.WriteLine("Length: " + length);
                for (int i = 0; i < length; i++)
                {
                    for (int j = 0; j < description.ElementAt(0).Count(); j++)
                    {
                        Console.WriteLine("Description: " + description.ElementAt(i)[j]);
                        string elementname  = "Announcement " + (i + 1);
                        string expectedtext = announcementData.ElementAt(i)[3];
                        string actualtext   = description.ElementAt(i)[j];
                        Console.WriteLine(elementname + "\tExpectedText : " + expectedtext + "\tActualText : " + actualtext);
                        softAssertions.Add(elementname, expectedtext, actualtext, "contains");
                    }
                }
            }
            else
            {
                softAssertions.Add("Total tiles Doesn't match", announcementData.Count(), description.Count(), "equals");
            }
        }
        public void CallAnnouncement()
        {
            ApiKeywords.InitializeRequest(url);
            ApiKeywords.SetMethod("get");
            string response = ApiKeywords.SendRequest();

            int responsecode = ApiKeywords.GetStatusCode();

            Console.WriteLine("Response : " + responsecode);
            dynamic stuff = Newtonsoft.Json.JsonConvert.DeserializeObject(response);
            string  s     = stuff[1].AnnouncementText[0].Value;

            Console.WriteLine("Response : " + response);
            Console.WriteLine("announcement=" + s);
        }
        public void VerifySavedTrcker()
        {
            String url = baseurl + "/mobileapi/api/trackers/userId/" + GlobalVariables.userid + "/trackerGuid/" + Guid;

            ApiKeywords.InitializeRequest(url);
            ApiKeywords.SetMethod("GET");
            cma.SetMobileCommonHeader(token);
            string responsce1 = ApiKeywords.SendRequest();

            Console.WriteLine("Response of APIs" + responsce1);
            JObject ob = JObject.Parse(responsce1);

            String result = (String)ob["UserId"];

            softAssertions.Add("Stress Tracker save ", result, GlobalVariables.userid, "equals", "false");
        }
Ejemplo n.º 10
0
        public void VerifyLoginDetailsAPI(string username)
        {
            String url;

            url = baseurl + "/mobileapi/api/logindetails";
            ApiKeywords.InitializeRequest(url);
            ApiKeywords.SetMethod("GET");
            ApiKeywords.SetParameter("username", username);
            string responsce = ApiKeywords.SendRequest();
            string path      = "actor_Id";
            string actorid   = ApiKeywords.GetValueFromJSONObject(responsce, path);

            //System.Console.WriteLine("Response of API  " + responsce);
            //System.Console.WriteLine("Response of API  " + actorid);
            GlobalVariables.actorid = actorid;
        }
Ejemplo n.º 11
0
        // Call by Dashboard tile
        public void VerifyDashboardTile()
        {
            String url;

            url = baseurl + "/mobileapi/api/dashboardtiles";
            ApiKeywords.InitializeRequest(url);
            ApiKeywords.SetMethod("POST");
            ApiKeywords.SetParameter("application / json", "{\"date\":\"09\\/19\\/2018\",\"tiles\":[\"points\",\"unread_messages_count\"]}", "body");
            cma.SetMobileCommonHeader(token);
            string responsce = ApiKeywords.SendRequest();

            System.Console.WriteLine("Response of API  " + responsce);
            string path  = "ha_percentage";
            string value = ApiKeywords.GetValueFromJSONObject(responsce, path);

            softAssertions.Add("Configuration ha_percentage", "0", value, "equals", "false");
        }
Ejemplo n.º 12
0
        public void VerifyMobileTosAPI()
        {
            String url;

            url = baseurl + "/mobileapi/api/tos?tosType=mobile";
            ApiKeywords.InitializeRequest(url);
            ApiKeywords.SetMethod("GET");
            cma.SetMobileCommonHeader(token);
            // ApiKeywords.SetParameter("tosType","mobile");
            string responsce = ApiKeywords.SendRequest();
            string path      = "content";
            string content   = ApiKeywords.GetValueFromJSONObject(responsce, path);

            softAssertions.Add("TOS content", "Terms of Service", content, "Contains");
            System.Console.WriteLine("Response of API  " + responsce);
            // System.Console.WriteLine("Response of API  " + content);
        }
Ejemplo n.º 13
0
        // call in config test
        public void VerifyMobileConfigurationAPI(string username)
        {
            String url;

            url = baseurl + "/mobileapi/api/configuration";
            ApiKeywords.InitializeRequest(url);
            ApiKeywords.SetMethod("GET");
            cma.SetMobileCommonHeader(token);
            string responsce = ApiKeywords.SendRequest();
            string path      = "is_fitness_enabled";
            string value     = ApiKeywords.GetValueFromJSONObject(responsce, path);

            softAssertions.Add("Configuration is_fitness_enabled", "true", value, "equals");
            System.Console.WriteLine("Response of API  " + responsce);
            //System.Console.WriteLine("Response of API  " + actorid);
            //GlobalVariables.actorid = actorid;
        }
Ejemplo n.º 14
0
        /// <summary>
        ///  Return the User Id
        /// </summary>

        public string GetUserID()
        {
            string path;
            Common cmn    = new Common();
            string env    = cmn.GetEnvFromUrl();
            string apiurl = "https://" + env + "services.onlifehealth.com/mobileapi/api/logindetails?username="******"GET");
            string jsonresponse = ApiKeywords.SendRequest();

            path = "user_Id";
            string userid = ApiKeywords.GetValueFromJSONObject(jsonresponse, path);

            return(userid);
        }
        public void VerifyAllmemberTrakerListAPI(string[] tracker)
        {
            String url;

            url = baseurl + "/mobileapi/api/trackers/userId/" + GlobalVariables.userid;
            ApiKeywords.InitializeRequest(url);
            ApiKeywords.SetMethod("GET");
            ApiKeywords.SetParameter("servicecycleid", GlobalVariables.servicecycleid);
            cma.SetMobileCommonHeader(token);
            string responsce = ApiKeywords.SendRequest();
            JToken to        = JToken.Parse(responsce);

            for (int i = 0; i < tracker.Length; i++)
            {
                string exp = "$.[?(@.Name=='" + tracker[i] + "')].Name";


                //String Guid = (String)to.SelectToken(exp,true);
                String name = (String)to.SelectToken(exp, true);
                // System.Console.WriteLine("exp of API  " + exp);
                System.Console.WriteLine("Name of API  " + name);
                softAssertions.Add("Trckers avilable", tracker[i], name, "equals", "false");
            }

            //JToken to = JToken.Parse(responsce);

            //String Guid = (String)to.SelectToken("$.[?(@.Name=='Stress')].Guid");
            //System.Console.WriteLine("Guid of API  " + Guid);

            //string[] path = { "Name" };
            //List<string[]> value = ApiKeywords.GetResponse(responsce, path);
            //for (int i = 0; i < value.Count(); i++)
            //{
            //    System.Console.WriteLine("Response of API  " + tracker[i]);
            //    softAssertions.Add("Trckers avilable", value.ElementAt(i)[0], tracker[i], "equals", "false");
            //}
        }
Ejemplo n.º 16
0
 public void SendRequest()
 {
     jsonresponse = ApiKeywords.SendRequest();
     //Console.WriteLine("JsonResponse : "+jsonresponse);
 }
Ejemplo n.º 17
0
 public void SendRequest()
 {
     jsonresponse = ApiKeywords.SendRequest();
 }