예제 #1
0
        /// <summary>
        /// TODO: type endpoint description here
        /// </summary>
        /// <param name="days">Required parameter: Example: </param>
        /// <return>Returns the ServerResponse response from the API call</return>
        public async Task <ServerResponse> StringEnumArrayAsync(List <Days> days)
        {
            //validating required parameters
            if (null == days)
            {
                throw new ArgumentNullException("days", "The parameter \"days\" is a required parameter and cannot be null.");
            }

            //the base uri for api requestss
            string _baseUri = Configuration.BaseUri;

            //prepare query string for API call
            StringBuilder _queryBuilder = new StringBuilder(_baseUri);

            _queryBuilder.Append("/query/stringenumarray");

            //process optional query parameters
            APIHelper.AppendUrlWithQueryParameters(_queryBuilder, new Dictionary <string, object>()
            {
                { "days", DaysHelper.ToValue(days) }
            });


            //validate and preprocess url
            string _queryUrl = APIHelper.CleanUrl(_queryBuilder);

            //append request with appropriate headers and parameters
            var _headers = new Dictionary <string, string>()
            {
                { "user-agent", "Stamplay SDK" },
                { "accept", "application/json" }
            };

            //prepare the API call request to fetch the response
            HttpRequest _request = ClientInstance.Get(_queryUrl, _headers);

            //invoke request and get response
            HttpStringResponse _response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(_request);

            HttpContext _context = new HttpContext(_request, _response);

            //return null on 404
            if (_response.StatusCode == 404)
            {
                return(null);
            }

            //handle errors defined at the API level
            base.ValidateResponse(_response, _context);

            try
            {
                return(APIHelper.JsonDeserialize <ServerResponse>(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
예제 #2
0
 private void SetStateMonths(WeeksDayMask wd)
 {
     for (int i = 0; i < _daysList.Count; i++)
     {
         checkedListBoxControl1.SetItemChecked(i, DaysHelper.CheckDay(wd, _daysList[i].DayMask));
         //checkedListBoxControl1.Items[i].CheckState = DaysHelper.CheckDay(wd, _daysList[i].DayMask) ? CheckState.Checked : CheckState.Unchecked;
     }
 }
        /// <summary>
        /// TODO: type endpoint description here
        /// </summary>
        /// <return>Returns the Days? response from the API call</return>
        public async Task <Days?> GetStringEnumAsync()
        {
            //the base uri for api requestss
            string _baseUri = Configuration.BaseUri;

            //prepare query string for API call
            StringBuilder _queryBuilder = new StringBuilder(_baseUri);

            _queryBuilder.Append("/response/enum");

            //process optional query parameters
            APIHelper.AppendUrlWithQueryParameters(_queryBuilder, new Dictionary <string, object>()
            {
                { "type", "string" }
            });


            //validate and preprocess url
            string _queryUrl = APIHelper.CleanUrl(_queryBuilder);

            //append request with appropriate headers and parameters
            var _headers = new Dictionary <string, string>()
            {
                { "user-agent", "Stamplay SDK" }
            };

            //prepare the API call request to fetch the response
            HttpRequest _request = ClientInstance.Get(_queryUrl, _headers);

            //invoke request and get response
            HttpStringResponse _response = (HttpStringResponse)await ClientInstance.ExecuteAsStringAsync(_request);

            HttpContext _context = new HttpContext(_request, _response);

            //return null on 404
            if (_response.StatusCode == 404)
            {
                return(null);
            }

            //handle errors defined at the API level
            base.ValidateResponse(_response, _context);

            try
            {
                return(DaysHelper.ParseString(_response.Body));
            }
            catch (Exception _ex)
            {
                throw new APIException("Failed to parse the response: " + _ex.Message, _context);
            }
        }
예제 #4
0
        private WeeksDayMask GetStateMonths()
        {
            WeeksDayMask wd = WeeksDayMask.Empty;

            for (int i = 0; i < _daysList.Count; i++)
            {
                if (checkedListBoxControl1.GetItemChecked(i))
                {
                    DaysHelper.AddDay(ref wd, _daysList[i].DayMask);
                }
            }
            return(wd);
        }
        public async Task TestGetStringEnum()
        {
            // Perform API call
            Days?result = null;

            try
            {
                result = await controller.GetStringEnumAsync();
            }
            catch (APIException) {};

            // Test response code
            Assert.AreEqual(200, httpCallBackHandler.Response.StatusCode,
                            "Status should be 200");

            // Test whether the captured response is as we expected
            Assert.IsNotNull(result, "Result should exist");


            Assert.AreEqual(
                DaysHelper.ParseString("Monday"), result,
                "Response should match expected value");
        }