示例#1
0
        /// <summary>
        /// Obtains a ClientLogin token for use with various Ads APIs.
        /// </summary>
        /// <returns>The token string.</returns>
        /// <exception cref="AuthTokenException">If the token cannot be obtained,
        /// then an AuthTokenException is thrown with appropriate error code.
        /// </exception>
        public string GetToken()
        {
            DeprecationUtilities.ShowDeprecationMessage(this.GetType());

            if (string.IsNullOrEmpty(Email))
            {
                throw new ArgumentNullException(CommonErrorMessages.EmailCannotBeNull);
            }

            if (string.IsNullOrEmpty(Password))
            {
                throw new ArgumentNullException(CommonErrorMessages.PasswordCannotBeNull);
            }

            string cachedToken = cache.GetToken(this.service, Email);

            if (cachedToken == null)
            {
                lock (this.GetType()) {
                    cachedToken = cache.GetToken(this.service, Email);
                    return((cachedToken != null) ? cachedToken : cache.AddToken(this.service, Email,
                                                                                GenerateToken()));
                }
            }
            return(cachedToken);
        }
示例#2
0
        public void TestDoesNotShowDeprecationForNonDeprecatedField()
        {
            DeprecationUtilities.ShowDeprecationMessage(nonDeprecatedMemberInfo);
            String traceContents = Encoding.UTF8.GetString(memStream.ToArray());

            if (traceContents.Contains(DEPRECATION_MESSAGE))
            {
                Assert.Fail("Deprecation message is present in trace logs.");
            }
        }
        /// <summary>
        /// Downloads a report to disk.
        /// </summary>
        /// <param name="query">The AWQL query for report definition.</param>
        /// <param name="format">The report format.</param>
        /// <param name="path">The path to which report should be downloaded.
        /// </param>
        /// <returns>The client report.</returns>
        public ClientReport DownloadClientReport(string query, string format, string path)
        {
            DeprecationUtilities.ShowDeprecationMessage(this.GetType());

            AdWordsAppConfig config      = (AdWordsAppConfig)User.Config;
            string           downloadUrl = string.Format(QUERY_REPORT_URL_FORMAT, config.AdWordsApiServer,
                                                         reportVersion, format);
            string postData = string.Format("__rdquery={0}", HttpUtility.UrlEncode(query));

            return(DownloadClientReportInternal(downloadUrl, postData, path));
        }
        /// <summary>
        /// Downloads a report to disk.
        /// </summary>
        /// <param name="reportDefinition">The report definition.</param>
        /// <param name="path">The path to which report should be downloaded.
        /// </param>
        /// <returns>The client report.</returns>
        public ClientReport DownloadClientReport <T>(T reportDefinition, string path)
        {
            DeprecationUtilities.ShowDeprecationMessage(this.GetType());
            AdWordsAppConfig config = (AdWordsAppConfig)User.Config;

            string postBody = "__rdxml=" + HttpUtility.UrlEncode(ConvertDefinitionToXml(
                                                                     reportDefinition));
            string downloadUrl = string.Format(ADHOC_REPORT_URL_FORMAT, config.AdWordsApiServer,
                                               reportVersion);

            return(DownloadClientReportInternal(downloadUrl, postBody, path));
        }
示例#5
0
 /// <summary>
 /// Downloads a report to disk.
 /// </summary>
 /// <param name="reportDefinition">The report definition.</param>
 /// <param name="path">The path to which report should be downloaded.
 /// </param>
 /// <returns>The client report.</returns>
 public ClientReport DownloadClientReport <T>(T reportDefinition, string path)
 {
     DeprecationUtilities.ShowDeprecationMessage(this.GetType());
     return(DownloadClientReport(reportDefinition, path));
 }
示例#6
0
 /// <summary>
 /// Downloads a report to disk.
 /// </summary>
 /// <param name="query">The AWQL query for report definition.</param>
 /// <param name="format">The report format.</param>
 /// <param name="path">The path to which report should be downloaded.
 /// </param>
 /// <returns>The client report.</returns>
 public ClientReport DownloadClientReport(string query, string format, string path)
 {
     DeprecationUtilities.ShowDeprecationMessage(this.GetType());
     return(DownloadClientReport(query, format, path));
 }
示例#7
0
 /// <summary>
 ///  Downloads a report into memory.
 /// </summary>
 /// <param name="reportDefinition">The report definition.</param>
 /// <returns>The client report.</returns>
 public ClientReport GetClientReport <T>(T reportDefinition)
 {
     DeprecationUtilities.ShowDeprecationMessage(this.GetType());
     return(GetClientReport(reportDefinition));
 }
示例#8
0
 /// <summary>
 /// Downloads a report into memory.
 /// </summary>
 /// <param name="query">The AWQL query for report definition. See
 /// https://developers.google.com/adwords/api/docs/guides/awql for AWQL
 /// documentation.</param>
 /// <param name="format">The report format.</param>
 /// <returns>The client report.</returns>
 public ClientReport GetClientReport(string query, string format)
 {
     DeprecationUtilities.ShowDeprecationMessage(this.GetType());
     return(GetClientReport(query, format));
 }