/// <summary>
        /// Subscribes to changes to a file
        /// Documentation https://developers.google.com/drive/v3/reference/files/watch
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated Drive service.</param>
        /// <param name="fileId">The ID of the file.</param>
        /// <param name="body">A valid Drive v3 body.</param>
        /// <param name="optional">Optional paramaters.</param>
        /// <returns>ChannelResponse</returns>
        public async Task <Channel> Watch(string fileId, Channel body, FilesWatchOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (_service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (fileId == null)
                {
                    throw new ArgumentNullException(fileId);
                }

                // Building the initial request.
                var request = _service.Files.Watch(body, fileId);

                // Applying optional parameters to the request.
                request = (FilesResource.WatchRequest)GoogleDriveFunctionsHelper.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(await request.ExecuteAsync());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Files.Watch failed.", ex);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Subscribe to changes on a file
        /// Documentation https://developers.google.com/drive/v2/reference/files/watch
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated Drive service.</param>
        /// <param name="fileId">The ID for the file in question.</param>
        /// <param name="body">A valid Drive v2 body.</param>
        /// <param name="optional">Optional paramaters.</param>
        /// <returns>ChannelResponse</returns>
        public static Channel Watch(DriveService service, string fileId, Channel body, FilesWatchOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (fileId == null)
                {
                    throw new ArgumentNullException(fileId);
                }

                // Building the initial request.
                var request = service.Files.Watch(body, fileId);

                // Applying optional parameters to the request.
                request = (FilesResource.WatchRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Files.Watch failed.", ex);
            }
        }