/// <summary> /// List all URL channels in the specified ad client for this AdSense account. /// Documentation https://developers.google.com/adsense/v1.3/reference/urlchannels/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 AdSense service.</param> /// <param name="adClientId">Ad client for which to list URL channels.</param> /// <param name="optional">Optional paramaters.</param> /// <returns>UrlChannelsResponse</returns> public static UrlChannels List(AdSenseService service, string adClientId, UrlchannelsListOptionalParms 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.Urlchannels.List(adClientId); // Applying optional parameters to the request. request = (UrlchannelsResource.ListRequest)SampleHelpers.ApplyOptionalParms(request, optional); // Requesting data. return(request.Execute()); } catch (Exception ex) { throw new Exception("Request Urlchannels.List failed.", ex); } }
internal static void Main(string[] args) { Console.WriteLine("AdSense Management API Command Line Sample"); Console.WriteLine("=========================================="); GoogleWebAuthorizationBroker.Folder = "AdSense.Sample"; var credential = GoogleWebAuthorizationBroker.AuthorizeAsync( new ClientSecrets { ClientId = "INSERT_CLIENT_ID_HERE", ClientSecret = "INSERT_CLIENT_SECRET_HERE" }, new string[] { AdSenseService.Scope.Adsense }, "user", CancellationToken.None).Result; // Create the service. var service = new AdSenseService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = "AdSense Sample" }); // Execute Publisher calls ManagementApiConsumer managementApiConsumer = new ManagementApiConsumer(service, MaxListPageSize); managementApiConsumer.RunCalls(); Console.WriteLine("Press any key to continue..."); Console.ReadKey(); }
/// <summary> /// Generate an AdSense report based on the saved report ID sent in the query parameters. /// Documentation https://developers.google.com/adsense/v1.4/reference/saved/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 AdSense service.</param> /// <param name="savedReportId">The saved report to retrieve.</param> /// <param name="optional">Optional paramaters.</param> /// <returns>AdsenseReportsGenerateResponseResponse</returns> public static AdsenseReportsGenerateResponse Generate(AdSenseService service, string savedReportId, SavedGenerateOptionalParms optional = null) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } if (savedReportId == null) { throw new ArgumentNullException(savedReportId); } // Building the initial request. var request = service.Saved.Generate(savedReportId); // Applying optional parameters to the request. request = (SavedResource.GenerateRequest)SampleHelpers.ApplyOptionalParms(request, optional); // Requesting data. return(request.Execute()); } catch (Exception ex) { throw new Exception("Request Saved.Generate failed.", ex); } }
/// <summary> /// List the payments for this AdSense account. /// Documentation https://developers.google.com/adsense/v1.4/reference/payments/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 AdSense service.</param> /// <returns>PaymentsResponse</returns> public static Payments List(AdSenseService service) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } // Make the request. return(service.Payments.List().Execute()); } catch (Exception ex) { throw new Exception("Request Payments.List failed.", ex); } }
/// <summary> /// Get a specific saved ad style from the user's account. /// Documentation https://developers.google.com/adsense/v1.3/reference/savedadstyles/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 AdSense service.</param> /// <param name="savedAdStyleId">Saved ad style to retrieve.</param> /// <returns>SavedAdStyleResponse</returns> public static SavedAdStyle Get(AdSenseService service, string savedAdStyleId) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } if (savedAdStyleId == null) { throw new ArgumentNullException(savedAdStyleId); } // Make the request. return(service.Savedadstyles.Get(savedAdStyleId).Execute()); } catch (Exception ex) { throw new Exception("Request Savedadstyles.Get failed.", ex); } }
/// <summary> /// Dismiss (delete) the specified alert from the publisher's AdSense account. /// Documentation https://developers.google.com/adsense/v1.4/reference/alerts/delete /// 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 AdSense service.</param> /// <param name="alertId">Alert to delete.</param> public static void Delete(AdSenseService service, string alertId) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } if (alertId == null) { throw new ArgumentNullException(alertId); } // Make the request. return(service.Alerts.Delete(alertId).Execute()); } catch (Exception ex) { throw new Exception("Request Alerts.Delete failed.", ex); } }
/// <summary> /// List all saved ad styles in the user's account. /// Documentation https://developers.google.com/adsense/v1.3/reference/savedadstyles/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 AdSense service.</param> /// <param name="optional">Optional paramaters.</param> /// <returns>SavedAdStylesResponse</returns> public static SavedAdStyles List(AdSenseService service, SavedadstylesListOptionalParms optional = null) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } // Building the initial request. var request = service.Savedadstyles.List(); // Applying optional parameters to the request. request = (SavedadstylesResource.ListRequest)SampleHelpers.ApplyOptionalParms(request, optional); // Requesting data. return(request.Execute()); } catch (Exception ex) { throw new Exception("Request Savedadstyles.List failed.", ex); } }
/// <summary>Initializes a new instance of the <see cref="ManagementApiConsumer"/> class.</summary> /// <param name="service">AdSense service object on which to run the requests.</param> /// <param name="maxListPageSize">The maximum page size to retrieve.</param> public ManagementApiConsumer(AdSenseService service, int maxListPageSize) { this.service = service; this.maxListPageSize = maxListPageSize; }