public void Test_2_Parameters_Return_Valid_Query_String() { QueryStringBuilder qsb = new QueryStringBuilder(); qsb.AddParameter("q", "environment"); qsb.AddParameter("filter", "uk"); Assert.AreEqual("?q=environment&filter=uk", qsb.GetQueryString()); }
public void Test_With_Date_Parameter() { QueryStringBuilder qsb = new QueryStringBuilder(); qsb.AddParameter("q", "environment"); qsb.AddParameter("filter", "uk"); qsb.AddParameter("After", new DateTime(1971, 2, 20)); Assert.AreEqual("?q=environment&filter=uk&after=1971-02-20", qsb.GetQueryString()); }
public virtual void AddParamenter_WhenNoParametersWereAdded_QueryStringFirstCharacterIsquestionMark() { const string parameterName = "testParameter"; const string parameterValue = "testParameterValue"; //act _builder.AddParameter(parameterName, parameterValue); //assert Assert.AreEqual(_builder.QueryString[0], '?'); }
/// <summary> /// <para>Get a report.</para> /// <para>It mirrors To the following Smartsheet REST API method: GET GET /report/{reportId}</para> /// </summary> /// <param name="id"> the Id of the report </param> /// <param name="includes"> used To specify the optional objects To include. </param> /// <param name="pageSize"> /// This operation will return a minimum of 1 row, and a maximum of 500. If not specified, the /// default value is 100. /// </param> /// <returns> /// the report resource (note that if there is no such resource, this method will throw /// ResourceNotFoundException rather than returning null). /// </returns> /// <exception cref="System.InvalidOperationException"> if any argument is null or empty string </exception> /// <exception cref="InvalidRequestException"> if there is any problem with the REST API request </exception> /// <exception cref="AuthorizationException"> if there is any problem with the REST API authorization (access token) </exception> /// <exception cref="ResourceNotFoundException"> if the resource cannot be found </exception> /// <exception cref="ServiceUnavailableException"> if the REST API service is not available (possibly due To rate limiting) </exception> /// <exception cref="SmartsheetException"> if there is any other error during the operation </exception> public virtual Report GetReport(long id, IEnumerable <ObjectInclusion> includes, int pageSize) { if (pageSize <= 0 && pageSize > 500) { throw new SmartsheetException(new ArgumentOutOfRangeException("pageSize", "Must be between 1 and 500")); } StringBuilder path = GetReportUri(id); var queryStringBuilder = new QueryStringBuilder(); if (includes != null) { queryStringBuilder.AddParameter(IncludeParameterName, FormatIncludeValue(includes)); } queryStringBuilder.AddParameter(PageSizeParameterName, pageSize); path.Append(queryStringBuilder.QueryString); return(GetResource <Report>(path.ToString(), typeof(Report))); }
/// <summary> /// Get a sheet. /// It mirrors To the following Smartsheet REST API method: GET /report/{reportId} /// Exceptions: /// - InvalidRequestException : if there is any problem with the REST API request /// - AuthorizationException : if there is any problem with the REST API authorization(access token) /// - ResourceNotFoundException : if the resource can not be found /// - ServiceUnavailableException : if the REST API service is not available (possibly due To rate limiting) /// - SmartsheetRestException : if there is any other REST API related error occurred during the operation /// - SmartsheetException : if there is any other error occurred during the operation /// </summary> /// <param name="id"> the Id of the report </param> /// <param name="includes"> /// used To specify the optional objects To include, currently DISCUSSIONS and /// ATTACHMENTS are supported. /// </param> /// <returns> /// the resource (note that if there is no such resource, this method will throw ResourceNotFoundException /// rather than returning null). /// </returns> /// <exception cref="SmartsheetException"> the Smartsheet exception </exception> public virtual Report GetReport(long id, IEnumerable <ObjectInclusion> includes) { StringBuilder path = GetReportUri(id); if (includes != null) { var queryStringBuilder = new QueryStringBuilder(); queryStringBuilder.AddParameter(IncludeParameterName, FormatIncludeValue(includes)); path.Append(queryStringBuilder.QueryString); } return(GetResource <Report>(path.ToString(), typeof(Report))); }
public void Test_Parameter_With_No_Value_Does_Not_Appear_In_Query_String() { QueryStringBuilder qsb = new QueryStringBuilder(); qsb.AddParameter("q", "environment"); qsb.AddParameter("filter", "uk"); qsb.AddParameter("", "blank"); qsb.AddParameter(null, "blank"); qsb.AddParameter("blank", ""); qsb.AddParameter("", ""); Assert.AreEqual("?q=environment&filter=uk", qsb.GetQueryString()); }