/// <summary>
        /// <para>Get a sheet.</para>
        ///
        /// <para>It mirrors To the following Smartsheet REST API method: GET /sheets/{sheetId}</para>
        /// </summary>
        /// <param name="sheetId"> the Id of the sheet </param>
        /// <param name="includes"> used To specify the optional objects To include. </param>
        /// <param name="excludes"> used To specify the optional objects To include. </param>
        /// <param name="rowIds"> used To specify the optional objects To include. </param>
        /// <param name="rowNumbers"> used To specify the optional objects To include. </param>
        /// <param name="columnIds"> used To specify the optional objects To include. </param>
        /// <param name="pageSize"> used To specify the optional objects To include. </param>
        /// <param name="page"> used To specify the optional objects To include. </param>
        /// <returns> the sheet 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 Sheet GetSheet(long sheetId, IEnumerable <SheetLevelInclusion> includes, IEnumerable <SheetLevelExclusion> excludes, IEnumerable <long> rowIds, IEnumerable <int> rowNumbers, IEnumerable <long> columnIds, long?pageSize, long?page)
        {
            IDictionary <string, string> parameters = new Dictionary <string, string>();

            if (includes != null)
            {
                parameters.Add("include", QueryUtil.GenerateCommaSeparatedList(includes));
            }
            if (excludes != null)
            {
                parameters.Add("exclude", QueryUtil.GenerateCommaSeparatedList(excludes));
            }
            if (rowIds != null)
            {
                parameters.Add("rowIds", QueryUtil.GenerateCommaSeparatedList(rowIds));
            }
            if (rowNumbers != null)
            {
                parameters.Add("rowNumbers", QueryUtil.GenerateCommaSeparatedList(rowNumbers));
            }
            if (columnIds != null)
            {
                parameters.Add("columnIds", QueryUtil.GenerateCommaSeparatedList(columnIds));
            }
            if (pageSize != null)
            {
                parameters.Add("pageSize", pageSize.ToString());
            }
            if (page != null)
            {
                parameters.Add("page", page.ToString());
            }

            return(this.GetResource <Sheet>("sheets/" + sheetId + QueryUtil.GenerateUrl(null, parameters), typeof(Sheet)));
        }
        /// <summary>
        /// <para>Creates a copy of the specified Sheet.</para>
        /// <para>It mirrors To the following Smartsheet REST API method:<br />
        /// POST /sheets/{sheetId}/copy</para>
        /// </summary>
        /// <param name="sheetId"> the sheet Id </param>
        /// <param name="destination"> the destination to copy to </param>
        /// <param name="include"> the elements to copy. Note: Cell history will not be copied, regardless of which include parameter values are specified.</param>
        /// <returns> the created folder </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 Sheet CopySheet(long sheetId, ContainerDestination destination, IEnumerable <SheetCopyInclusion> include)
        {
            IDictionary <string, string> parameters = new Dictionary <string, string>();

            if (include != null)
            {
                parameters.Add("include", QueryUtil.GenerateCommaSeparatedList(include));
            }
            return(this.CreateResource <RequestResult <Sheet>, ContainerDestination>(QueryUtil.GenerateUrl("sheets/" + sheetId + "/copy", parameters), destination).Result);
        }
        /// <summary>
        /// <para>Creates a sheet at the top-level of the specified workspace, from the specified template. </para>
        /// <para>Mirrors to the following Smartsheet REST API method: POST /workspaces/{workspaceId}/Sheets</para>
        /// </summary>
        /// <param name="workspaceId"> the workspace Id </param>
        /// <param name="sheet"> the sheet to create </param>
        /// <param name="includes"> used to specify the optional objects to include </param>
        /// <returns> the created sheet </returns>
        /// <exception cref="System.InvalidOperationException"> if any argument is null or an 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 Sheet CreateSheetFromTemplate(long workspaceId, Sheet sheet, IEnumerable <TemplateInclusion> includes)
        {
            StringBuilder path = new StringBuilder("workspaces/" + workspaceId + "/sheets");

            if (includes != null)
            {
                path.Append("?include=" + QueryUtil.GenerateCommaSeparatedList(includes));
            }
            return(this.CreateResource(path.ToString(), typeof(Sheet), sheet));
        }
        /// <summary>
        /// <para>Removes one or multiple objects from the user’s list of Favorite items.</para>
        /// <para>objectIds must not be null or empty.</para>
        /// <para>It mirrors To the following Smartsheet REST API methods:
        /// <list type="bullet">
        /// <item><description>DELETE /favorites/folder</description></item>
        /// <item><description>DELETE /favorites/report</description></item>
        /// <item><description>DELETE /favorites/sheet</description></item>
        /// <item><description>DELETE /favorites/template</description></item>
        /// <item><description>DELETE /favorites/workspace</description></item>
        /// </list>
        /// </para>
        /// </summary>
        /// <param name="objectIds">(required): a comma-separated list of object IDs representing the items to remove from Favorites</param>
        /// <param name="type">the object type to remove </param>
        /// <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 void RemoveFavorites(ObjectType type, IList <long> objectIds)
        {
            StringBuilder path = new StringBuilder("favorites/" + Enum.GetName(typeof(ObjectType), type).ToLower());

            if (objectIds != null)
            {
                path.Append("?objectIds=" + QueryUtil.GenerateCommaSeparatedList(objectIds));
            }
            this.DeleteResource <Favorite>(path.ToString(), typeof(Favorite));
        }
        /// <summary>
        /// <para>Gets the specified Folder (and lists its contents).</para>
        /// <para>It mirrors To the following Smartsheet REST API method: GET /folders/{folderId}</para>
        /// </summary>
        /// <param name="folderId"> the folder Id </param>
        /// <param name="include"> (optional) – comma-separated list of elements to include in the respons</param>
        /// <returns> the folder (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 Folder GetFolder(long folderId, IEnumerable <FolderInclusion> include)
        {
            StringBuilder path = new StringBuilder("folders/" + folderId);

            if (include != null)
            {
                path.Append("?include=" + QueryUtil.GenerateCommaSeparatedList(include));
            }
            return(this.GetResource <Folder>(path.ToString(), typeof(Folder)));
        }
예제 #6
0
        /// <summary>
        /// <para>Gets the Column specified in the URL.</para>
        ///
        /// <para>It mirrors to the following Smartsheet REST API method: GET /sheets/{sheetId}/columns/{columnId}</para>
        /// </summary>
        /// <param name="sheetId"> the sheet Id </param>
        /// <param name="columnId"> the columnId </param>
        /// <param name="include"> elements to include in response </param>
        /// <returns> the created column </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 Column GetColumn(long sheetId, long columnId, IEnumerable <ColumnInclusion> include)
        {
            StringBuilder path = new StringBuilder("sheets/" + sheetId + "/columns/" + columnId);

            if (include != null)
            {
                path.Append("?include=" + QueryUtil.GenerateCommaSeparatedList(include));
            }
            return(this.GetResource <Column>(path.ToString(), typeof(Column)));
        }
        /// <summary>
        /// <para>
        /// Get a nested list of all Home objects, including Sheets, Workspaces and Folders, and optionally reports and/or
        /// Templates, as shown on the Home tab..
        /// </para>
        /// <para>
        /// It mirrors To the following Smartsheet REST API method: GET /home
        /// </para>
        /// </summary>
        /// <param name="includes"> used To specify the optional objects To include, currently TEMPLATES is supported. </param>
        /// <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="InvalidRequestException">if the resource can not be found</exception>
        /// <exception cref="ResourceNotFoundException">if the REST API service is not available (possibly due To rate limiting)</exception>
        /// <exception cref="ServiceUnavailableException">if there is any other REST API related error occurred during the operation</exception>
        /// <exception cref="SmartsheetException">if there is any other error occurred during the operation</exception>
        /// <returns> the resource (note that if there is no such resource, this method will throw ResourceNotFoundException
        /// rather than returning null). </returns>
        public virtual Home GetHome(IEnumerable <HomeInclusion> includes)
        {
            StringBuilder path = new StringBuilder("home");

            if (includes != null)
            {
                path.Append("?include=" + QueryUtil.GenerateCommaSeparatedList(includes));
            }
            return(this.GetResource <Home>(path.ToString(), typeof(Home)));
        }
        /// <summary>
        /// <para>Get the current user.</para>
        /// <para>It mirrors to the following Smartsheet REST API method: GET /users/me</para>
        /// </summary>
        /// <param name="includes">used to specify the optional objects to include.</param>
        /// <returns> the current user </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 UserProfile GetCurrentUser(IEnumerable <UserInclusion> includes)
        {
            IDictionary <string, string> parameters = new Dictionary <string, string>();

            if (includes != null)
            {
                parameters.Add("include", QueryUtil.GenerateCommaSeparatedList(includes));
            }

            return(this.GetResource <UserProfile>("users/me" + QueryUtil.GenerateUrl(null, parameters), typeof(UserProfile)));
        }
        /// <summary>
        /// <para>Deletes one or more row(s) from the Sheet</para>
        /// <para>It mirrors to the following Smartsheet REST API method: DELETE /sheets/{sheetId}/rows?ids={rowId1},{rowId2},{rowId3}...</para>
        /// <remarks>This operation will delete ALL child Rows of the specified Row(s).</remarks>
        /// </summary>
        /// <param name="sheetId"> The sheet ID </param>
        /// <param name="ids"> The list of row IDs </param>
        /// <param name="ignoreRowsNotFound"> If set to false and any of the specified Row IDs are not found, no rows will be deleted, and the “not found” error will be returned.</param>
        /// <returns>Row IDs corresponding to all rows that were successfully deleted (including any child rows of rows specified in the URL).</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 IList <long> DeleteRows(long sheetId, IEnumerable <long> ids, bool?ignoreRowsNotFound)
        {
            Utility.Utility.ThrowIfNull(ids);
            IDictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("ids", QueryUtil.GenerateCommaSeparatedList(ids));
            if (ignoreRowsNotFound.HasValue)
            {
                parameters.Add("ignoreRowsNotFound", ignoreRowsNotFound.Value.ToString());
            }
            return(this.DeleteResource <IList <long> >(QueryUtil.GenerateUrl("sheets/" + sheetId + "/rows", parameters)));
        }
 /// <summary>
 /// <para>Gets the specified Workspace (and lists its contents).</para>
 /// <para>It mirrors to the following Smartsheet REST API method: GET /workspaces/{workspaceid}</para>
 /// <remarks><para>By default, this operation only returns the top-level items in the Workspace. To load all of the contents, 
 /// including nested Folders, include the loadAll query string parameter with a value of true.</para>
 /// <para>If no Folders, Sheets, Reports, or Templates are present in the Workspace, the corresponding attribute 
 /// (e.g., "folders", "sheets") will not be present in the response object.</para></remarks>
 /// </summary>
 /// <param name="workspaceId">the workspace id</param>
 /// <param name="loadAll"> Defaults to false. If true, loads all of the contents, including nested Folders. </param>
 /// <param name="include"> When specified with a value of "source", response will include the source for any sheet that was created from another sheet or template</param>
 /// <returns> the workspace (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 Workspace GetWorkspace(long workspaceId, bool? loadAll, IEnumerable<WorkspaceInclusion> include)
 {
     IDictionary<string, string> parameters = new Dictionary<string, string>();
     if (loadAll.HasValue)
     {
         parameters.Add("loadAll", loadAll.ToString());
     }
     if (include != null)
     {
         parameters.Add("include", QueryUtil.GenerateCommaSeparatedList(include));
     }
     return this.GetResource<Workspace>(QueryUtil.GenerateUrl("workspaces/" + workspaceId, parameters), typeof(Workspace));
 }
 /// <summary>
 /// <para>Creates a copy of the specified Workspace.</para>
 /// <para>It mirrors to the following Smartsheet REST API method:<br />
 /// POST /workspaces/{workspaceId}/copy</para>
 /// </summary>
 /// <param name="workspaceId"> the workspace Id </param>
 /// <param name="destination"> the destination to copy to </param>
 /// <param name="include"> the elements to copy. Note: Cell history will not be copied, regardless of which include parameter values are specified.</param>
 /// <param name="skipRemap"> the references to NOT re-map for the newly created folder
 /// <para>
 /// If "cellLinks" is specified in the skipRemap parameter value, the cell links within the newly created folder will continue to point to the original source sheets.
 /// If "reports" is specified in the skipRemap parameter value, the reports within the newly created folder will continue to point to the original source sheets.
 /// </para>
 /// </param>
 /// <returns> the created workspace </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 Workspace CopyWorkspace(long workspaceId, ContainerDestination destination, IEnumerable<WorkspaceCopyInclusion> include, IEnumerable<WorkspaceRemapExclusion> skipRemap)
 {
     IDictionary<string, string> parameters = new Dictionary<string, string>();
     if (include != null)
     {
         parameters.Add("include", QueryUtil.GenerateCommaSeparatedList(include));
     }
     if (skipRemap != null)
     {
         parameters.Add("skipRemap", QueryUtil.GenerateCommaSeparatedList(skipRemap));
     }
     return this.CreateResource<RequestResult<Workspace>, ContainerDestination>(QueryUtil.GenerateUrl("workspaces/" + workspaceId + "/copy", parameters), destination).Result;
 }
        /// <summary>
        /// <para>Get a specified Sight.</para>
        ///
        /// <para>It mirrors to the following Smartsheet REST API method: GET /sights/{sightId}</para>
        /// </summary>
        /// <param name="sightId"> the Id of the sight </param>
        /// <param name="includes">used to specify the optional objects to include.</param>
        /// <param name="level"> compatibility level </param>
        /// <returns> the sight 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 Sight GetSight(long sightId, IEnumerable <SightInclusion> includes, int?level)
        {
            IDictionary <string, string> parameters = new Dictionary <string, string>();

            if (includes != null)
            {
                parameters.Add("include", QueryUtil.GenerateCommaSeparatedList(includes));
            }
            if (level != null)
            {
                parameters.Add("level", level.ToString());
            }
            return(this.GetResource <Sight>("sights/" + sightId + QueryUtil.GenerateUrl(null, parameters), typeof(Sight)));
        }
        /// <summary>
        /// <para>Creates a copy of the specified Folder.</para>
        /// <para>It mirrors To the following Smartsheet REST API method:<br />
        /// POST /folders/{folderId}/copy</para>
        /// </summary>
        /// <param name="folderId"> the folder Id </param>
        /// <param name="destination"> the destination to copy to </param>
        /// <param name="include"> the elements to copy. Note: Cell history will not be copied, regardless of which include parameter values are specified.</param>
        /// <param name="skipRemap"> the references to NOT re-map for the newly created folder
        /// <para>
        /// If “cellLinks” is specified in the skipRemap parameter value, the cell links within the newly created folder will continue to point to the original source sheets.
        /// If “reports” is specified in the skipRemap parameter value, the reports within the newly created folder will continue to point to the original source sheets.
        /// </para>
        /// </param>
        /// <returns> the created folder </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 Folder CopyFolder(long folderId, ContainerDestination destination, IEnumerable <FolderCopyInclusion> include, IEnumerable <FolderRemapExclusion> skipRemap)
        {
            IDictionary <string, string> parameters = new Dictionary <string, string>();

            if (include != null)
            {
                parameters.Add("include", QueryUtil.GenerateCommaSeparatedList(include));
            }
            if (skipRemap != null)
            {
                parameters.Add("skipRemap", QueryUtil.GenerateCommaSeparatedList(skipRemap));
            }
            return(this.CreateResource <RequestResult <Folder>, ContainerDestination>(QueryUtil.GenerateUrl("folders/" + folderId + "/copy", parameters), destination).Result);
        }
        /// <summary>
        /// <para>Gets the Row specified in the URL.</para>
        /// <para>It mirrors to the following Smartsheet REST API method: GET /sheets/{sheetId}/rows/{rowId}</para>
        /// </summary>
        /// <param name="include"> comma-separated list of elements to include in the response. </param>
        /// <param name="exclude"> a comma-separated list of optional objects to exclude in the response. </param>
        /// <param name="sheetId"> the sheetId </param>
        /// <param name="rowId"> the rowId </param>
        /// <returns> the row object </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 Row GetRow(long sheetId, long rowId, IEnumerable <RowInclusion> include, IEnumerable <RowExclusion> exclude)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            if (include != null)
            {
                parameters.Add("include", QueryUtil.GenerateCommaSeparatedList(include));
            }
            if (exclude != null)
            {
                parameters.Add("exclude", QueryUtil.GenerateCommaSeparatedList(exclude));
            }
            return(this.GetResource <Row>("sheets/" + sheetId + "/rows/" + rowId + QueryUtil.GenerateUrl(null, parameters), typeof(Row)));
        }
예제 #15
0
        /// <summary>
        /// <para>Gets the list of all Sheets that the User has access to, in alphabetical order, by name.</para>
        ///
        /// <para>It mirrors To the following Smartsheet REST API method: GET /Sheets</para>
        /// </summary>
        /// <returns> A list of all Sheets (note that an empty list will be returned if there are none). </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 PaginatedResult <Sheet> ListSheets(IEnumerable <SheetInclusion> includes, PaginationParameters paging)
        {
            IDictionary <string, string> parameters = new Dictionary <string, string>();

            if (paging != null)
            {
                parameters = paging.toDictionary();
            }
            if (includes != null)
            {
                parameters.Add("include", QueryUtil.GenerateCommaSeparatedList(includes));
            }
            return(this.ListResourcesWithWrapper <Sheet>("sheets" + QueryUtil.GenerateUrl(null, parameters)));
        }
        /// <summary>
        /// <para>
        /// Gets a nested list of all Home objects, including folders, reports, sheets, templates, and workspaces as shown on the Home tab.
        /// </para>
        /// <para>
        /// Mirrors to the following Smartsheet REST API method: GET /home
        /// </para>
        /// </summary>
        /// <param name="includes"> used to specify the optional objects to include, currently TEMPLATES is supported. </param>
        /// <param name="excludes"> used to specify the optional object to exclude </param>
        /// <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="InvalidRequestException">if the resource cannot be found</exception>
        /// <exception cref="ResourceNotFoundException">if the REST API service is not available (possibly due to rate limiting)</exception>
        /// <exception cref="ServiceUnavailableException">if any other REST API related error occurred during the operation</exception>
        /// <exception cref="SmartsheetException">if any other error occurred during the operation</exception>
        /// <returns> the resource (note that if there is no such resource, this method will throw ResourceNotFoundException
        /// rather than returning null). </returns>
        public virtual Home GetHome(IEnumerable <HomeInclusion> includes, IEnumerable <HomeExclusion> excludes)
        {
            IDictionary <string, string> parameters = new Dictionary <string, string>();

            if (includes != null)
            {
                parameters.Add("include", QueryUtil.GenerateCommaSeparatedList(includes));
            }
            if (excludes != null)
            {
                parameters.Add("exclude", QueryUtil.GenerateCommaSeparatedList(excludes));
            }
            return(this.GetResource <Home>("home" + QueryUtil.GenerateUrl(null, parameters), typeof(Home)));
        }
        /// <summary>
        /// <para>Gets the sheet summary</para>
        /// <para>It mirrors to the following Smartsheet REST API method: GET /sheets/{sheetId}/summary</para>
        /// </summary>
        /// <param name="sheetId"> the sheet Id </param>
        /// <param name="include"> optional objects to include </param>
        /// <param name="exclude"> optional object to exclude </param>
        /// <returns> the sheet summary </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 SheetSummary GetSheetSummary(long sheetId, IEnumerable <SummaryFieldInclusion> include, IEnumerable <SummaryFieldExclusion> exclude)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            if (include != null)
            {
                parameters.Add("include", QueryUtil.GenerateCommaSeparatedList(include));
            }
            if (exclude != null)
            {
                parameters.Add("exclude", QueryUtil.GenerateCommaSeparatedList(exclude));
            }
            return(this.GetResource <SheetSummary>("sheets/" + sheetId + "/summary" + QueryUtil.GenerateUrl(null, parameters), typeof(SheetSummary)));
        }
예제 #18
0
        /// <summary>
        /// <para>Gets a list of all Columns belonging to the Sheet specified in the URL.</para>
        /// <para>It mirrors to the following Smartsheet REST API method: GET /sheets/{sheetId}/columns</para>
        /// <remarks>This operation supports pagination of results. For more information, see Paging.</remarks>
        /// </summary>
        /// <param name="sheetId"> the sheet Id </param>
        /// <param name="include">elements to include in response</param>
        /// <param name="paging">the paging</param>
        /// <returns> the list of Columns (note that an empty list will be returned if there is none) </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 PaginatedResult <Column> ListColumns(long sheetId, IEnumerable <ColumnInclusion> include, PaginationParameters paging)
        {
            StringBuilder path = new StringBuilder("sheets/" + sheetId + "/columns");
            IDictionary <string, string> parameters = new Dictionary <string, string>();

            if (paging != null)
            {
                parameters = paging.toDictionary();
            }
            if (include != null)
            {
                parameters.Add("include", QueryUtil.GenerateCommaSeparatedList(include));
            }
            return(this.ListResourcesWithWrapper <Column>(QueryUtil.GenerateUrl("sheets/" + sheetId + "/columns", parameters)));
        }
        /// <summary>
        /// <para>Moves Row(s) from the Sheet specified in the URL to (the bottom of) another sheet.</para>
        /// <para>It mirrors to the following Smartsheet REST API method: POST /sheets/{sheetId}/rows/copy</para>
        /// <remarks><para>Up to 5,000 row IDs can be specified in the request,
        /// but if the total number of rows in the destination sheet after the copy exceeds the Smartsheet row limit,
        /// an error response will be returned.</para>
        /// <para>Any child rows of the rows specified in the request will also be moved.
        /// Parent-child relationships amongst rows will be preserved within the destination sheet.</para></remarks>
        /// </summary>
        /// <param name="sheetId"> the sheet Id </param>
        /// <param name="ignoreRowsNotFound"> ignoreRowsNotFound </param>
        /// <param name="directive"> directive </param>
        /// <param name="include">the elements to include.</param>
        /// <returns> CopyOrMoveRowResult object </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 CopyOrMoveRowResult MoveRowsToAnotherSheet(long sheetId, CopyOrMoveRowDirective directive, IEnumerable <MoveRowInclusion> include, bool?ignoreRowsNotFound)
        {
            Utility.Utility.ThrowIfNull(directive);
            IDictionary <string, string> parameters = new Dictionary <string, string>();

            if (include != null)
            {
                parameters.Add("include", QueryUtil.GenerateCommaSeparatedList(include));
            }
            if (ignoreRowsNotFound.HasValue)
            {
                parameters.Add("ignoreRowsNotFound", ignoreRowsNotFound.ToString().ToLower());
            }
            return(this.CreateResource <CopyOrMoveRowResult, CopyOrMoveRowDirective>(QueryUtil.GenerateUrl("sheets/" + sheetId + "/rows/move", parameters), directive));
        }
        /// <summary>
        /// <para>Gets the list of all Sheets that the User has access to, in alphabetical order, by name.</para>
        ///
        /// <para>It mirrors To the following Smartsheet REST API method: GET /Sheets</para>
        /// </summary>
        /// <returns> A list of all Sheets (note that an empty list will be returned if there are none). </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 PaginatedResult <Sheet> ListSheets(IEnumerable <SheetInclusion> includes, PaginationParameters paging, DateTime?modifiedSince)
        {
            IDictionary <string, string> parameters = new Dictionary <string, string>();

            if (paging != null)
            {
                parameters = paging.toDictionary();
            }
            if (includes != null)
            {
                parameters.Add("include", QueryUtil.GenerateCommaSeparatedList(includes));
            }
            if (modifiedSince != null)
            {
                parameters.Add("modifiedSince", ((DateTime)modifiedSince).ToUniversalTime().ToString("o"));
            }

            return(this.ListResourcesWithWrapper <Sheet>("sheets" + QueryUtil.GenerateUrl(null, parameters)));
        }
        /// <summary>
        /// <para>Gets the sheet summary fields</para>
        /// <para>It mirrors to the following Smartsheet REST API method: GET /sheets/{sheetId}/summary/fields</para>
        /// </summary>
        /// <param name="sheetId"> the sheet Id </param>
        /// <param name="include"> optional objects to include </param>
        /// <param name="exclude"> optional object to exclude </param>
        /// <returns> the paged list of sheet summary fields </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 PaginatedResult <SummaryField> GetSheetSummaryFields(long sheetId, IEnumerable <SummaryFieldInclusion> include, IEnumerable <SummaryFieldExclusion> exclude, PaginationParameters paging)
        {
            IDictionary <string, string> parameters = new Dictionary <string, string>();

            if (paging != null)
            {
                parameters = paging.toDictionary();
            }
            if (include != null)
            {
                parameters.Add("include", QueryUtil.GenerateCommaSeparatedList(include));
            }
            if (exclude != null)
            {
                parameters.Add("exclude", QueryUtil.GenerateCommaSeparatedList(exclude));
            }

            return(this.ListResourcesWithWrapper <SummaryField>("sheets/" + sheetId + "/summary/fields" + QueryUtil.GenerateUrl(null, parameters)));
        }
        /// <summary>
        /// <para>Gets the Report, including one page of Rows, and optionally populated with Discussions, Attachments, and source Sheets.</para>
        /// <para>It mirrors to the following Smartsheet REST API method: GET /reports/{reportId}</para>
        /// </summary>
        /// <remarks>This method returns the top 100 rows. To get more or less rows please use the other overloaded versions of this method</remarks>
        /// <param name="reportId"> the Id of the report </param>
        /// <param name="includes"> used to specify the optional objects to include. </param>
        /// <param name="pageSize">(optional): Number of rows per page. If not specified, the default value is 100.
        /// This operation can return a maximum of 500 rows per page.</param>
        /// <param name="page">(optional): Which page number (1-based) to return.
        /// If not specified, the default value is 1. If a page number is specified that is greater than the number of total pages, the last page will be returned.</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 reportId, IEnumerable <ReportInclusion> includes, int?pageSize, int?page)
        {
            IDictionary <string, string> parameters = new Dictionary <string, string>();

            if (includes != null)
            {
                parameters.Add("include", QueryUtil.GenerateCommaSeparatedList(includes));
            }
            if (pageSize != null)
            {
                parameters.Add("pageSize", pageSize.ToString());
            }
            if (page != null)
            {
                parameters.Add("page", page.ToString());
            }

            return(this.GetResource <Report>(QueryUtil.GenerateUrl("reports/" + reportId, parameters), typeof(Report)));
        }
        /// <summary>
        /// <para>Searches all sheets that the user can access for the specified text.</para>
        /// <para>Mirrors to the following Smartsheet REST API method: GET /search</para>
        /// </summary>
        /// <param name="query"> (required): Text with which to perform the search. </param>
        /// <param name="includes">includes enum set of inclusions</param>
        /// <param name="location">location when specified with a value of "personalWorkspace limits response to only those
        /// items in the user's workspace</param>
        /// <param name="modifiedSince">only return items modified since this date</param>
        /// <param name="scopes">scopes enum set of search filters</param>
        /// <returns> SearchResult object that contains a maximum of 100 SearchResultems </returns>
        /// <exception cref="System.InvalidOperationException"> if any argument is null or an 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 SearchResult Search(string query, IEnumerable <SearchInclusion> includes, SearchLocation?location,
                                           DateTime?modifiedSince, IEnumerable <SearchScope> scopes)
        {
            IDictionary <string, string> parameters = new Dictionary <string, string>();

            if (includes != null)
            {
                parameters.Add("include", QueryUtil.GenerateCommaSeparatedList(includes));
            }
            if (location != null)
            {
                Regex regex = new Regex(@"[^_]+");
                // Converts the enum members to camel case to be passed in the url as a parameter.
                // For example, 'COLUMN_TYPE' becomes 'columnType' and is appended to the path.
                // Different from JsonEnymTypeConverter because this does not involve serialization/deserialization.
                MatchCollection matches = regex.Matches(location.ToString());
                List <string>   values  = new List <string>();
                foreach (Match match in matches)
                {
                    if (values.Count == 0)
                    {
                        values.Add(match.Value.ToLower());
                    }
                    else
                    {
                        values.Add(match.Value.Substring(0, 1).ToUpper() + match.Value.Substring(1).ToLower());
                    }
                }
                parameters.Add("location", string.Join(string.Empty, values));
            }
            if (modifiedSince != null)
            {
                parameters.Add("modifiedSince", ((DateTime)modifiedSince).ToUniversalTime().ToString("o"));
            }
            if (scopes != null)
            {
                parameters.Add("scopes", QueryUtil.GenerateCommaSeparatedList(scopes));
            }
            parameters.Add("query", query);
            return(this.GetResource <SearchResult>("search" + QueryUtil.GenerateUrl(null, parameters), typeof(SearchResult)));
        }
        public virtual void TestGenerateCommaSeparatedList()
        {
            HashSet <long> list = new HashSet <long>();

            list.Add(123456789L);
            list.Add(987654321L);

            // List
            string commaSeparatedStringList = QueryUtil.GenerateCommaSeparatedList(list);

            Assert.AreEqual("123456789,987654321", commaSeparatedStringList);

            // EnumSet
            string commaSeparatedStringEnumSet = QueryUtil.GenerateCommaSeparatedList(new List <RowInclusion> {
                RowInclusion.DISCUSSIONS, RowInclusion.ATTACHMENTS
            });

            Assert.AreEqual("discussions,attachments", commaSeparatedStringEnumSet);

            Assert.AreEqual("", QueryUtil.GenerateCommaSeparatedList <object>(null));
        }
        /// <summary>
        /// <para>Lists all users.</para>
        /// <para>Mirrors to the following Smartsheet REST API method: GET /Users</para>
        /// </summary>
        /// <param name="emails">list of emails</param>
        /// <param name="includes">elements to include in response</param>
        /// <param name="paging"> the pagination</param>
        /// <returns> the list of all users </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 PaginatedResult <User> ListUsers(IEnumerable <string> emails, IEnumerable <ListUserInclusion> includes, PaginationParameters paging)
        {
            StringBuilder path = new StringBuilder("users");

            IDictionary <string, string> parameters = new Dictionary <string, string>();

            if (paging != null)
            {
                parameters = paging.toDictionary();
            }
            if (emails != null)
            {
                parameters.Add("email", string.Join(",", emails));
            }
            if (includes != null)
            {
                parameters.Add("include", QueryUtil.GenerateCommaSeparatedList(includes));
            }

            path.Append(QueryUtil.GenerateUrl(null, parameters));

            return(this.ListResourcesWithWrapper <User>(path.ToString()));
        }