/// <summary>
        /// List all host custom channels in this AdSense account.
        /// Documentation https://developers.google.com/adsensehost/v4.1/reference/customchannels/list
        /// 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 Adsensehost service.</param>
        /// <param name="adClientId">Ad client for which to list custom channels.</param>
        /// <param name="optional">Optional paramaters.</param>
        /// <returns>CustomChannelsResponse</returns>
        public static CustomChannels List(AdsensehostService service, string adClientId, CustomchannelsListOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (adClientId == null)
                {
                    throw new ArgumentNullException(adClientId);
                }

                // Building the initial request.
                var request = service.Customchannels.List(adClientId);

                // Applying optional parameters to the request.
                request = (CustomchannelsResource.ListRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Customchannels.List failed.", ex);
            }
        }
        /// <summary>
        /// Get a specific custom channel from the host AdSense account.
        /// Documentation https://developers.google.com/adsensehost/v4.1/reference/customchannels/get
        /// 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 Adsensehost service.</param>
        /// <param name="adClientId">Ad client from which to get the custom channel.</param>
        /// <param name="customChannelId">Custom channel to get.</param>
        /// <returns>CustomChannelResponse</returns>
        public static CustomChannel Get(AdsensehostService service, string adClientId, string customChannelId)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (adClientId == null)
                {
                    throw new ArgumentNullException(adClientId);
                }
                if (customChannelId == null)
                {
                    throw new ArgumentNullException(customChannelId);
                }

                // Make the request.
                return(service.Customchannels.Get(adClientId, customChannelId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Customchannels.Get failed.", ex);
            }
        }
        /// <summary>
        /// Create an association session for initiating an association with an AdSense user.
        /// Documentation https://developers.google.com/adsensehost/v4.1/reference/associationsessions/start
        /// 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 Adsensehost service.</param>
        /// <param name="productCode">Products to associate with the user.</param>
        /// <param name="websiteUrl">The URL of the user's hosted website.</param>
        /// <param name="optional">Optional paramaters.</param>
        /// <returns>AssociationSessionResponse</returns>
        public static AssociationSession Start(AdsensehostService service, string productCode, string websiteUrl, AssociationsessionsStartOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (productCode == null)
                {
                    throw new ArgumentNullException(productCode);
                }
                if (websiteUrl == null)
                {
                    throw new ArgumentNullException(websiteUrl);
                }

                // Building the initial request.
                var request = service.Associationsessions.Start(productCode, websiteUrl);

                // Applying optional parameters to the request.
                request = (AssociationsessionsResource.StartRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Associationsessions.Start failed.", ex);
            }
        }
Пример #4
0
        /// <summary>
        /// Add a new URL channel to the host AdSense account.
        /// Documentation https://developers.google.com/adsensehost/v4.1/reference/urlchannels/insert
        /// 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 Adsensehost service.</param>
        /// <param name="adClientId">Ad client to which the new URL channel will be added.</param>
        /// <param name="body">A valid Adsensehost v4.1 body.</param>
        /// <returns>UrlChannelResponse</returns>
        public static UrlChannel Insert(AdsensehostService service, string adClientId, UrlChannel body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (adClientId == null)
                {
                    throw new ArgumentNullException(adClientId);
                }

                // Make the request.
                return(service.Urlchannels.Insert(body, adClientId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Urlchannels.Insert failed.", ex);
            }
        }
Пример #5
0
        /// <summary>
        /// Generate an AdSense report based on the report request sent in the query parameters. Returns the result as JSON; to retrieve output in CSV format specify "alt=csv" as a query parameter.
        /// Documentation https://developers.google.com/adsensehost/v4.1/reference/reports/generate
        /// 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 Adsensehost service.</param>
        /// <param name="startDate">Start of the date range to report on in "YYYY-MM-DD" format, inclusive.</param>
        /// <param name="endDate">End of the date range to report on in "YYYY-MM-DD" format, inclusive.</param>
        /// <param name="optional">Optional paramaters.</param>
        /// <returns>ReportResponse</returns>
        public static Report Generate(AdsensehostService service, string startDate, string endDate, ReportsGenerateOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (startDate == null)
                {
                    throw new ArgumentNullException(startDate);
                }
                if (endDate == null)
                {
                    throw new ArgumentNullException(endDate);
                }

                // Building the initial request.
                var request = service.Reports.Generate(startDate, endDate);

                // Applying optional parameters to the request.
                request = (ReportsResource.GenerateRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Reports.Generate failed.", ex);
            }
        }
        /// <summary>
        /// Verify an association session after the association callback returns from AdSense signup.
        /// Documentation https://developers.google.com/adsensehost/v4.1/reference/associationsessions/verify
        /// 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 Adsensehost service.</param>
        /// <param name="token">The token returned to the association callback URL.</param>
        /// <returns>AssociationSessionResponse</returns>
        public static AssociationSession Verify(AdsensehostService service, string token)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (token == null)
                {
                    throw new ArgumentNullException(token);
                }

                // Make the request.
                return(service.Associationsessions.Verify(token).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Associationsessions.Verify failed.", ex);
            }
        }
        /// <summary>
        /// Get information about one of the ad clients in the Host AdSense account.
        /// Documentation https://developers.google.com/adsensehost/v4.1/reference/adclients/get
        /// 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 Adsensehost service.</param>
        /// <param name="adClientId">Ad client to get.</param>
        /// <returns>AdClientResponse</returns>
        public static AdClient Get(AdsensehostService service, string adClientId)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (adClientId == null)
                {
                    throw new ArgumentNullException(adClientId);
                }

                // Make the request.
                return(service.Adclients.Get(adClientId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Adclients.Get failed.", ex);
            }
        }