public void TestCreateServiceClientLoginDeprecated()
 {
     ConfigureForClientLogin();
       serviceSignature = new AdWordsServiceSignature(DEPRECATED_CLIENT_LOGIN_VERSION,
       TEST_SERVICE, TEST_GROUP_NAME);
       serviceFactory.CreateService(serviceSignature, new AdWordsUser(), testUri);
 }
 /// <summary>
 /// Gets the signature.
 /// </summary>
 /// <param name="user">The user for which service should be mocked.</param>
 /// <param name="signature">The service signature to be mocked.</param>
 /// <param name="mockType">Type of the mock service.</param>
 /// <returns>The mock service signature.</returns>
 public static ServiceSignature RegisterMockService(AdsUser user, ServiceSignature signature,
     Type mockType) {
   MockAdWordsServiceSignature mockSignature = MockAdWordsServiceSignature.FromSignature(
       signature, mockType);
   user.RegisterService(signature.Id, user.GetServiceFactory(mockSignature.Id));
   return mockSignature;
 }
        /// <summary>
        /// Create a service object.
        /// </summary>
        /// <param name="signature">Signature of the service being created.</param>
        /// <param name="user">The user for which the service is being created.
        /// <param name="serverUrl">The server to which the API calls should be
        /// made.</param>
        /// </param>
        /// <returns>An object of the desired service type.</returns>
        public override AdsClient CreateService(ServiceSignature signature, AdsUser user,
            Uri serverUrl)
        {
            AdWordsAppConfig awConfig = (AdWordsAppConfig) Config;
              if (serverUrl == null) {
            serverUrl = new Uri(awConfig.AdWordsApiServer);
              }

              if (user == null) {
            throw new ArgumentNullException("user");
              }

              if (signature == null) {
            throw new ArgumentNullException("signature");
              }

              if (!(signature is AdWordsServiceSignature)) {
            throw new InvalidCastException(string.Format(CultureInfo.InvariantCulture,
            AdWordsErrorMessages.SignatureIsOfWrongType, typeof(AdWordsServiceSignature)));
              }

              AdWordsServiceSignature awapiSignature = signature as AdWordsServiceSignature;

              AdsClient service = (AdsClient) Activator.CreateInstance(awapiSignature.ServiceType);
              PropertyInfo propInfo = awapiSignature.ServiceType.GetProperty("RequestHeader");
              if (propInfo != null) {
            RequestHeader clonedHeader = (RequestHeader) requestHeader.Clone();
            clonedHeader.Version = awapiSignature.Version;
            clonedHeader.GroupName = awapiSignature.GroupName;
            propInfo.SetValue(service, clonedHeader, null);
              }

              if (awConfig.Proxy != null) {
            service.Proxy = awConfig.Proxy;
              }
              service.Timeout = awConfig.Timeout;
              service.Url = string.Format("{0}api/adwords/{1}/{2}/{3}",
              serverUrl.AbsoluteUri, awapiSignature.GroupName, awapiSignature.Version,
              awapiSignature.ServiceName);
              service.EnableDecompression = awConfig.EnableGzipCompression;
              service.User = user;
              service.Signature = awapiSignature;
              return service;
        }
    /// <summary>
    /// Create a service of desired type.
    /// </summary>
    /// <param name="signature">Signature of the service being created.</param>
    /// <param name="user">The user for which this service is being created.
    /// </param>
    /// <param name="serverUrl">The server to which the API calls should be
    /// made.</param>
    /// <returns>The service object.</returns>
    public override AdsClient CreateService(ServiceSignature signature, AdsUser user,
        Uri serverUrl) {
      AdWordsAppConfig awConfig = (AdWordsAppConfig) AppConfig;
      if (serverUrl == null) {
        serverUrl = new Uri(awConfig.LegacyAdWordsApiServer);
      }

      if (user == null) {
        throw new ArgumentNullException("user");
      }

      if (signature == null) {
        throw new ArgumentNullException("signature");
      }

      if (!(signature is LegacyAdwordsServiceSignature)) {
        throw new ArgumentException("Expecting a LegacyAdwordsApiServiceSignature object.");
      }
      LegacyAdwordsServiceSignature awapiSignature = (LegacyAdwordsServiceSignature) signature;

      AdsClient service = (AdsClient) Activator.CreateInstance(awapiSignature.ServiceType);

      Type type = service.GetType();
      PropertyInfo propInfo = null;

      if (this.headers != null) {
        foreach (string key in headers.Keys) {
          propInfo = type.GetProperty(key);
          if (propInfo != null) {
            propInfo.SetValue(service, headers[key], null);
          }
        }
      }

      if (awConfig.Proxy != null) {
        service.Proxy = awConfig.Proxy;
      }
      service.Timeout = awConfig.Timeout;
      service.Url = String.Join("", new string[] {serverUrl.AbsoluteUri, "api/adwords/",
          awapiSignature.Version, "/", awapiSignature.ServiceName});

      service.User = user;
      return service;
    }
        /// <summary>
        /// Create a service object.
        /// </summary>
        /// <param name="signature">Signature of the service being created.</param>
        /// <param name="user">The user for which the service is being created.
        /// <param name="serverUrl">The server to which the API calls should be
        /// made.</param>
        /// </param>
        /// <returns>An object of the desired service type.</returns>
        public override AdsClient CreateService(ServiceSignature signature, AdsUser user,
        Uri serverUrl)
        {
            DfaAppConfig config = (DfaAppConfig) base.Config;

              if (serverUrl == null) {
            serverUrl = new Uri(config.DfaApiServer);
              }

              if (user == null) {
            throw new ArgumentNullException("user");
              }

              CheckServicePreconditions(signature);

              DfaServiceSignature dfaapiSignature = signature as DfaServiceSignature;

              AdsClient service = (AdsClient) Activator.CreateInstance(dfaapiSignature.ServiceType);

              if (config.Proxy != null) {
            service.Proxy = config.Proxy;
              }

              service.Timeout = config.Timeout;
              service.Url = string.Format("{0}{1}/api/dfa-api/{2}",
              serverUrl, dfaapiSignature.Version, dfaapiSignature.ServiceEndpoint);
              service.UserAgent = config.GetUserAgent();

              service.User = user;
              service.Signature = signature;

              service.GetType().GetProperty("RequestHeader").SetValue(service,
              GetRequestHeader(), null);
              SetRequestHeaderNameSpace(signature as DfaServiceSignature, service);

              return service;
        }
Example #6
0
 /// <summary>
 /// Registers a family of services against this user.
 /// </summary>
 /// <param name="servicesFamilies">The family of services that should be
 /// registered against this user.</param>
 /// <remarks>
 /// Every family of services that should be registered with an AdsUser
 /// should be like follows:
 ///
 /// <code>
 ///   public class vX {
 ///     /// Type of the factory that can create services of SomeService.vX
 ///     public Type factoryType = typeof(SomeServiceVxFactory);
 ///
 ///     /// Various services under vX.
 ///
 ///     public readonly ServiceSignature Service1;
 ///     public readonly ServiceSignature Service2;
 ///   }
 /// </code>
 ///
 /// The method uses reflection to
 /// - Find all the fields of type ServiceSignature.
 /// - Extract the factory type from factoryType field.
 /// - Register each found service type with the user.
 ///
 /// </remarks>
 protected void RegisterServices(Type[] servicesFamilies)
 {
     if (servicesFamilies == null)
     {
         return;
     }
     foreach (Type serviceFamily in servicesFamilies)
     {
         FieldInfo fieldInfo = serviceFamily.GetField("factoryType", BindingFlags.Public
                                                      | BindingFlags.Static);
         Type serviceFactoryType = null;
         if (fieldInfo != null)
         {
             serviceFactoryType = (Type)fieldInfo.GetValue(null);
         }
         else
         {
             throw new ArgumentException(string.Format(CommonErrorMessages.MissingFactoryType,
                                                       serviceFactoryType.AssemblyQualifiedName));
         }
         if (serviceFactoryType != null)
         {
             ServiceFactory serviceFactory =
                 (ServiceFactory)Activator.CreateInstance(serviceFactoryType);
             FieldInfo[] fields = serviceFamily.GetFields();
             foreach (FieldInfo field in fields)
             {
                 ServiceSignature signature = field.GetValue(null) as ServiceSignature;
                 if (signature != null)
                 {
                     RegisterService(signature.Id, serviceFactory);
                 }
             }
         }
     }
 }
    /// <summary>
    /// Create a service object.
    /// </summary>
    /// <param name="signature">Signature of the service being created.</param>
    /// <param name="user">The user for which the service is being created.
    /// <param name="serverUrl">The server to which the API calls should be
    /// made.</param>
    /// </param>
    /// <returns>An object of the desired service type.</returns>
    public override AdsClient CreateService(ServiceSignature signature, AdsUser user,
        Uri serverUrl) {
      DfpAppConfig dfpConfig = (DfpAppConfig) Config;
      if (serverUrl == null) {
        serverUrl = new Uri(dfpConfig.DfpApiServer);
      }

      if (user == null) {
        throw new ArgumentNullException("user");
      }

      CheckServicePreconditions(signature);

      DfpServiceSignature dfpapiSignature = signature as DfpServiceSignature;

      AdsClient service = (AdsClient) Activator.CreateInstance(dfpapiSignature.ServiceType);
      PropertyInfo propInfo = dfpapiSignature.ServiceType.GetProperty("RequestHeader");

      if (propInfo != null) {
        RequestHeader clonedHeader = (RequestHeader) requestHeader.Clone();
        clonedHeader.Version = dfpapiSignature.Version;
        propInfo.SetValue(service, clonedHeader, null);
      }

      if (dfpConfig.Proxy != null) {
        service.Proxy = dfpConfig.Proxy;
      }
      service.Timeout = dfpConfig.Timeout;
      service.Url = string.Format("{0}apis/ads/publisher/{1}/{2}",
          serverUrl, dfpapiSignature.Version, dfpapiSignature.ServiceName);
      service.UserAgent = dfpConfig.GetUserAgent();

      service.Signature = signature;
      service.User = user;
      return service;
    }
 /// <summary>
 /// Creates an object of the requested type of service.
 /// </summary>
 /// <param name="serviceSignature">Signature of the service being requested.
 /// </param>
 /// <returns>An object of the requested type of service. The
 /// caller should cast this object to the desired type.</returns>
 public AdsClient GetService(ServiceSignature serviceSignature) {
   return GetService(serviceSignature, String.Empty);
 }
 /// <summary>
 /// Static constructor to initialize the service constants.
 /// </summary>
 static v1_19() {
   AdRemoteService = DfaService.MakeServiceSignature("v1.19", "AdRemoteService");
   AdvertiserRemoteService = DfaService.MakeServiceSignature("v1.19",
       "AdvertiserRemoteService");
   AdvertiserGroupRemoteService = DfaService.MakeServiceSignature("v1.19",
       "AdvertiserGroupRemoteService");
   CampaignRemoteService = DfaService.MakeServiceSignature("v1.19", "CampaignRemoteService");
   ChangeLogRemoteService = DfaService.MakeServiceSignature("v1.19", "ChangeLogRemoteService");
   ContentCategoryRemoteService = DfaService.MakeServiceSignature("v1.19",
       "ContentCategoryRemoteService");
   CreativeRemoteService = DfaService.MakeServiceSignature("v1.19", "CreativeRemoteService");
   CreativeFieldRemoteService = DfaService.MakeServiceSignature("v1.19",
       "CreativeFieldRemoteService");
   CreativeGroupRemoteService = DfaService.MakeServiceSignature("v1.19",
       "CreativeGroupRemoteService");
   LoginRemoteService = DfaService.MakeServiceSignature("v1.19", "LoginRemoteService");
   NetworkRemoteService = DfaService.MakeServiceSignature("v1.19", "NetworkRemoteService");
   PlacementRemoteService = DfaService.MakeServiceSignature("v1.19", "PlacementRemoteService");
   SiteRemoteService = DfaService.MakeServiceSignature("v1.19", "SiteRemoteService");
   SizeRemoteService = DfaService.MakeServiceSignature("v1.19", "SizeRemoteService");
   SpotlightRemoteService = DfaService.MakeServiceSignature("v1.19", "SpotlightRemoteService");
   PlacementStrategyRemoteService = DfaService.MakeServiceSignature("v1.19",
       "PlacementStrategyRemoteService");
   SubnetworkRemoteService = DfaService.MakeServiceSignature("v1.19",
       "SubnetworkRemoteService");
   UserRemoteService = DfaService.MakeServiceSignature("v1.19", "UserRemoteService");
   UserRoleRemoteService = DfaService.MakeServiceSignature("v1.19", "UserRoleRemoteService");
 }
 /// <summary>
 /// Static constructor to initialize the service constants.
 /// </summary>
 static v13() {
   AccountService = AdWordsService.MakeLegacyServiceSignature("v13", "AccountService");
 }
            /// <summary>
            /// Static constructor to initialize the service constants.
            /// </summary>
            static v201601()
            {
                #region Campaign Management.

                AdGroupAdService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "AdGroupAdService");
                AdGroupBidModifierService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "AdGroupBidModifierService");
                AdGroupCriterionService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "AdGroupCriterionService");
                AdGroupFeedService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "AdGroupFeedService");
                AdGroupService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "AdGroupService");
                AdParamService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "AdParamService");
                BatchJobService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "BatchJobService");
                BiddingStrategyService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "BiddingStrategyService");
                BudgetService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "BudgetService");
                CampaignAdExtensionService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "CampaignAdExtensionService");
                CampaignCriterionService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "CampaignCriterionService");
                CampaignFeedService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "CampaignFeedService");
                CampaignService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "CampaignService");
                CampaignSharedSetService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "CampaignSharedSetService");
                ConstantDataService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "ConstantDataService");
                ConversionTrackerService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "ConversionTrackerService");

                CustomerFeedService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "CustomerFeedService");
                DataService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "DataService");
                ExperimentService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "ExperimentService");
                FeedItemService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "FeedItemService");
                FeedMappingService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "FeedMappingService");
                FeedService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "FeedService");
                LabelService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "LabelService");
                LocationCriterionService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "LocationCriterionService");
                MediaService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "MediaService");
                MutateJobService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "MutateJobService");
                OfflineConversionFeedService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "OfflineConversionFeedService");
                ReportDefinitionService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "ReportDefinitionService");
                SharedCriterionService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "SharedCriterionService");
                SharedSetService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "SharedSetService");

                #endregion

                #region Blling.

                BudgetOrderService =
                AdWordsService.MakeServiceSignature("v201601", "billing", "BudgetOrderService");

                #endregion

                #region Remarketing.

                AdwordsUserListService =
                AdWordsService.MakeServiceSignature("v201601", "rm", "AdwordsUserListService");

                #endregion

                #region Optimization.

                TargetingIdeaService =
                AdWordsService.MakeServiceSignature("v201601", "o", "TargetingIdeaService");
                TrafficEstimatorService =
                AdWordsService.MakeServiceSignature("v201601", "o", "TrafficEstimatorService");

                #endregion

                #region AdWords Express.

                BudgetSuggestionService =
                  AdWordsService.MakeServiceSignature("v201601", "express", "BudgetSuggestionService");
                ExpressBusinessService =
                AdWordsService.MakeServiceSignature("v201601", "express",
                "ExpressBusinessService");
                ProductServiceService =
                AdWordsService.MakeServiceSignature("v201601", "express", "ProductServiceService");
                PromotionService =
                AdWordsService.MakeServiceSignature("v201601", "express", "PromotionService");

                #endregion

                #region Change History.

                CustomerSyncService =
                AdWordsService.MakeServiceSignature("v201601", "ch", "CustomerSyncService");

                #endregion

                #region Account Management.

                AccountLabelService =
                AdWordsService.MakeServiceSignature("v201601", "mcm", "AccountLabelService");

                CustomerService =
                AdWordsService.MakeServiceSignature("v201601", "mcm", "CustomerService");
                ManagedCustomerService =
                AdWordsService.MakeServiceSignature("v201601", "mcm", "ManagedCustomerService");

                #endregion

                #region Extension setting

                AdCustomizerFeedService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "AdCustomizerFeedService");
                AdGroupExtensionSettingService =
                AdWordsService.MakeServiceSignature("v201601", "cm", "AdGroupExtensionSettingService");

                CampaignExtensionSettingService =
                AdWordsService.MakeServiceSignature("v201601", "cm",
                "CampaignExtensionSettingService");
                CustomerExtensionSettingService =
                AdWordsService.MakeServiceSignature("v201601", "cm",
                "CustomerExtensionSettingService");

                #endregion
            }
      /// <summary>
      /// Static constructor to initialize the service constants.
      /// </summary>
      static v201406() {
        OfflineConversionFeedService =
            AdWordsService.MakeServiceSignature("v201406", "cm", "OfflineConversionFeedService");
        AdGroupAdService =
            AdWordsService.MakeServiceSignature("v201406", "cm", "AdGroupAdService");
        AdGroupCriterionService =
            AdWordsService.MakeServiceSignature("v201406", "cm", "AdGroupCriterionService");
        AdGroupService =
            AdWordsService.MakeServiceSignature("v201406", "cm", "AdGroupService");
        AdGroupBidModifierService =
            AdWordsService.MakeServiceSignature("v201406", "cm", "AdGroupBidModifierService");
        AdGroupFeedService =
            AdWordsService.MakeServiceSignature("v201406", "cm", "AdGroupFeedService");
        AdParamService =
            AdWordsService.MakeServiceSignature("v201406", "cm", "AdParamService");
        AdwordsUserListService =
            AdWordsService.MakeServiceSignature("v201406", "rm", "AdwordsUserListService");
        AlertService =
            AdWordsService.MakeServiceSignature("v201406", "mcm", "AlertService");
        BiddingStrategyService =
            AdWordsService.MakeServiceSignature("v201406", "cm", "BiddingStrategyService");
        BudgetService =
            AdWordsService.MakeServiceSignature("v201406", "cm", "BudgetService");
        BudgetOrderService =
            AdWordsService.MakeServiceSignature("v201406", "billing", "BudgetOrderService");
        CampaignAdExtensionService =
            AdWordsService.MakeServiceSignature("v201406", "cm", "CampaignAdExtensionService");
        CampaignCriterionService =
            AdWordsService.MakeServiceSignature("v201406", "cm", "CampaignCriterionService");
        CampaignService =
            AdWordsService.MakeServiceSignature("v201406", "cm", "CampaignService");
        CampaignFeedService =
            AdWordsService.MakeServiceSignature("v201406", "cm", "CampaignFeedService");
        ConstantDataService =
            AdWordsService.MakeServiceSignature("v201406", "cm", "ConstantDataService");
        ConversionTrackerService =
            AdWordsService.MakeServiceSignature("v201406", "cm", "ConversionTrackerService");
        CustomerService =
            AdWordsService.MakeServiceSignature("v201406", "mcm", "CustomerService");
        CustomerSyncService =
            AdWordsService.MakeServiceSignature("v201406", "ch", "CustomerSyncService");
        CustomerFeedService =
            AdWordsService.MakeServiceSignature("v201406", "cm", "CustomerFeedService");
        DataService =
            AdWordsService.MakeServiceSignature("v201406", "cm", "DataService");
        ExperimentService =
            AdWordsService.MakeServiceSignature("v201406", "cm", "ExperimentService");
        FeedService =
            AdWordsService.MakeServiceSignature("v201406", "cm", "FeedService");
        FeedItemService =
            AdWordsService.MakeServiceSignature("v201406", "cm", "FeedItemService");
        FeedMappingService =
            AdWordsService.MakeServiceSignature("v201406", "cm", "FeedMappingService");
        GeoLocationService =
            AdWordsService.MakeServiceSignature("v201406", "cm", "GeoLocationService");
        LocationCriterionService =
            AdWordsService.MakeServiceSignature("v201406", "cm", "LocationCriterionService");
        ManagedCustomerService =
            AdWordsService.MakeServiceSignature("v201406", "mcm", "ManagedCustomerService");
        MediaService =
            AdWordsService.MakeServiceSignature("v201406", "cm", "MediaService");
        MutateJobService =
            AdWordsService.MakeServiceSignature("v201406", "cm", "MutateJobService");
        ReportDefinitionService =
            AdWordsService.MakeServiceSignature("v201406", "cm", "ReportDefinitionService");
        TargetingIdeaService =
            AdWordsService.MakeServiceSignature("v201406", "o", "TargetingIdeaService");
        TrafficEstimatorService =
            AdWordsService.MakeServiceSignature("v201406", "o", "TrafficEstimatorService");

        ExpressBusinessService =
            AdWordsService.MakeServiceSignature("v201406", "express",
                "ExpressBusinessService");
        BudgetSuggestionService =
              AdWordsService.MakeServiceSignature("v201406", "express", "BudgetSuggestionService");
        PromotionService =
            AdWordsService.MakeServiceSignature("v201406", "express", "PromotionService");
        ProductServiceService =
            AdWordsService.MakeServiceSignature("v201406", "express", "ProductServiceService");

        SharedCriterionService =
            AdWordsService.MakeServiceSignature("v201406", "cm", "SharedCriterionService");
        CampaignSharedSetService =
            AdWordsService.MakeServiceSignature("v201406", "cm", "CampaignSharedSetService");
        SharedSetService =
            AdWordsService.MakeServiceSignature("v201406", "cm", "SharedSetService");
        LabelService =
            AdWordsService.MakeServiceSignature("v201406", "cm", "LabelService");
      }
 /// <summary>
 /// Checks preconditions of the service signature and throws and exception if the service
 /// cannot be generated.
 /// </summary>
 /// <param name="signature">the service signature for generating the service</param>
 protected abstract void CheckServicePreconditions(ServiceSignature signature);
 /// <summary>
 /// Checks preconditions of the service signature and throws and exception if the service
 /// cannot be generated.
 /// </summary>
 /// <param name="signature">the service signature for generating the service</param>
 protected abstract void CheckServicePreconditions(ServiceSignature signature);
 public void TestCreateServiceOAuth2ClientLoginDeprecated() {
   ConfigureForOAuth2();
   serviceSignature = new DfpServiceSignature(DEPRECATED_CLIENT_LOGIN_VERSION, TEST_SERVICE);
   serviceFactory.CreateService(serviceSignature, new DfpUser(), null);
 }
 /// <summary>
 /// Static constructor to initialize the service constants.
 /// </summary>
 static v201306() {
   ActivityGroupService = DfpService.MakeServiceSignature("v201306", "ActivityGroupService");
   ActivityService = DfpService.MakeServiceSignature("v201306", "ActivityService");
   AdRuleService = DfpService.MakeServiceSignature("v201306", "AdRuleService");
   BaseRateService = DfpService.MakeServiceSignature("v201306", "BaseRateService");
   ContactService = DfpService.MakeServiceSignature("v201306", "ContactService");
   AudienceSegmentService = DfpService.MakeServiceSignature("v201306",
       "AudienceSegmentService");
   CompanyService = DfpService.MakeServiceSignature("v201306", "CompanyService");
   ContentService = DfpService.MakeServiceSignature("v201306", "ContentService");
   CreativeService = DfpService.MakeServiceSignature("v201306", "CreativeService");
   CreativeSetService = DfpService.MakeServiceSignature("v201306", "CreativeSetService");
   CreativeTemplateService = DfpService.MakeServiceSignature("v201306",
       "CreativeTemplateService");
   CreativeWrapperService = DfpService.MakeServiceSignature("v201306",
       "CreativeWrapperService");
   CustomTargetingService = DfpService.MakeServiceSignature("v201306",
       "CustomTargetingService");
   CustomFieldService = DfpService.MakeServiceSignature("v201306",
       "CustomFieldService");
   ForecastService = DfpService.MakeServiceSignature("v201306", "ForecastService");
   InventoryService = DfpService.MakeServiceSignature("v201306", "InventoryService");
   LabelService = DfpService.MakeServiceSignature("v201306", "LabelService");
   LineItemTemplateService = DfpService.MakeServiceSignature("v201306",
       "LineItemTemplateService");
   LineItemService = DfpService.MakeServiceSignature("v201306", "LineItemService");
   LineItemCreativeAssociationService =
       DfpService.MakeServiceSignature("v201306", "LineItemCreativeAssociationService");
   NetworkService = DfpService.MakeServiceSignature("v201306", "NetworkService");
   OrderService = DfpService.MakeServiceSignature("v201306", "OrderService");
   PlacementService = DfpService.MakeServiceSignature("v201306", "PlacementService");
   ProductService = DfpService.MakeServiceSignature("v201306", "ProductService");
   ProductTemplateService = DfpService.MakeServiceSignature("v201306",
       "ProductTemplateService");
   ProposalService = DfpService.MakeServiceSignature("v201306", "ProposalService");
   ProposalLineItemService = DfpService.MakeServiceSignature("v201306",
       "ProposalLineItemService");
   PublisherQueryLanguageService = DfpService.MakeServiceSignature("v201306",
       "PublisherQueryLanguageService");
   RateCardService = DfpService.MakeServiceSignature("v201306", "RateCardService");
   RateCardCustomizationService = DfpService.MakeServiceSignature("v201306",
       "RateCardCustomizationService");
   ReconciliationOrderReportService = DfpService.MakeServiceSignature("v201306",
       "ReconciliationOrderReportService");
   ReconciliationReportService = DfpService.MakeServiceSignature("v201306",
       "ReconciliationReportService");
   ReconciliationReportRowService = DfpService.MakeServiceSignature("v201306",
       "ReconciliationReportRowService");
   ReportService = DfpService.MakeServiceSignature("v201306", "ReportService");
   SuggestedAdUnitService = DfpService.MakeServiceSignature("v201306",
       "SuggestedAdUnitService");
   TeamService = DfpService.MakeServiceSignature("v201306", "TeamService");
   UserService = DfpService.MakeServiceSignature("v201306", "UserService");
   UserTeamAssociationService = DfpService.MakeServiceSignature("v201306",
       "UserTeamAssociationService");
   WorkflowActionService = DfpService.MakeServiceSignature("v201306",
       "WorkflowActionService");
 }
 /// <summary>
 /// Create a service object.
 /// </summary>
 /// <param name="signature">Signature of the service being created.</param>
 /// <param name="user">The user for which the service is being created.</param>
 /// <param name="serverUrl">The server to which the API calls should be
 /// made.</param>
 /// <returns>An object of the desired service type.</returns>
 public abstract AdsClient CreateService(ServiceSignature signature, AdsUser user,
                                         Uri serverUrl);
 /// <summary>
 /// Create a mock service signature from an existing service signature.
 /// </summary>
 /// <param name="signature">The service signature.</param>
 /// <param name="serviceType">Type of the mock service.</param>
 /// <returns></returns>
 public static MockAdWordsServiceSignature FromSignature(ServiceSignature signature,
     Type serviceType) {
   AdWordsServiceSignature awSignature = (AdWordsServiceSignature) signature;
   MockAdWordsServiceSignature retval = new MockAdWordsServiceSignature(
       awSignature.Version, awSignature.ServiceName, awSignature.GroupName);
   retval.serviceType = serviceType;
   return retval;
 }
 /// <summary>
 /// Static constructor to initialize the service constants.
 /// </summary>
 static v201109() {
   AdExtensionOverrideService =
       AdWordsService.MakeServiceSignature("v201109", "cm", "AdExtensionOverrideService");
   AdGroupAdService =
       AdWordsService.MakeServiceSignature("v201109", "cm", "AdGroupAdService");
   AdGroupCriterionService =
       AdWordsService.MakeServiceSignature("v201109", "cm", "AdGroupCriterionService");
   AdGroupService =
       AdWordsService.MakeServiceSignature("v201109", "cm", "AdGroupService");
   AdParamService =
       AdWordsService.MakeServiceSignature("v201109", "cm", "AdParamService");
   AlertService =
       AdWordsService.MakeServiceSignature("v201109", "mcm", "AlertService");
   BulkMutateJobService =
       AdWordsService.MakeServiceSignature("v201109", "job", "BulkMutateJobService");
   BulkOpportunityService =
       AdWordsService.MakeServiceSignature("v201109", "o", "BulkOpportunityService");
   CampaignAdExtensionService =
       AdWordsService.MakeServiceSignature("v201109", "cm", "CampaignAdExtensionService");
   CampaignCriterionService =
       AdWordsService.MakeServiceSignature("v201109", "cm", "CampaignCriterionService");
   CampaignService =
       AdWordsService.MakeServiceSignature("v201109", "cm", "CampaignService");
   CampaignTargetService =
       AdWordsService.MakeServiceSignature("v201109", "cm", "CampaignTargetService");
   ConstantDataService =
       AdWordsService.MakeServiceSignature("v201109", "cm", "ConstantDataService");
   ConversionTrackerService =
       AdWordsService.MakeServiceSignature("v201109", "cm", "ConversionTrackerService");
   CreateAccountService =
       AdWordsService.MakeServiceSignature("v201109", "mcm", "CreateAccountService");
   CustomerSyncService =
       AdWordsService.MakeServiceSignature("v201109", "ch", "CustomerSyncService");
   DataService =
       AdWordsService.MakeServiceSignature( "v201109", "cm", "DataService");
   ExperimentService =
       AdWordsService.MakeServiceSignature("v201109", "cm", "ExperimentService");
   GeoLocationService =
       AdWordsService.MakeServiceSignature("v201109", "cm", "GeoLocationService");
   InfoService =
       AdWordsService.MakeServiceSignature("v201109", "info", "InfoService");
   LocationCriterionService =
       AdWordsService.MakeServiceSignature("v201109", "cm", "LocationCriterionService");
   MediaService =
       AdWordsService.MakeServiceSignature("v201109", "cm", "MediaService");
   MutateJobService =
       AdWordsService.MakeServiceSignature("v201109", "cm", "MutateJobService");
   ReportDefinitionService =
       AdWordsService.MakeServiceSignature("v201109", "cm", "ReportDefinitionService");
   ServicedAccountService =
       AdWordsService.MakeServiceSignature("v201109", "mcm", "ServicedAccountService");
   TargetingIdeaService =
       AdWordsService.MakeServiceSignature("v201109", "o", "TargetingIdeaService");
   TrafficEstimatorService =
       AdWordsService.MakeServiceSignature("v201109", "o", "TrafficEstimatorService");
   UserListService =
       AdWordsService.MakeServiceSignature("v201109", "cm", "UserListService");
 }
 public void TestCreateServiceOAuth2ClientLoginSupported()
 {
     ConfigureForOAuth2();
       serviceSignature = new AdWordsServiceSignature(SUPPORTED_CLIENT_LOGIN_VERSION,
       TEST_SERVICE, TEST_GROUP_NAME);
       serviceFactory.CreateService(serviceSignature, new AdWordsUser(), testUri);
 }
 /// <summary>
 /// Creates an object of the requested type of service.
 /// </summary>
 /// <param name="serviceSignature">Signature of the service being requested.
 /// </param>
 /// <param name="serverUrl">The server url for Ads service.</param>
 /// <returns>An object of the requested type of service. The
 /// caller should cast this object to the desired type.</returns>
 public AdsClient GetService(ServiceSignature serviceSignature, string serverUrl) {
   Uri uri = null;
   if (!string.IsNullOrEmpty(serverUrl)) {
     uri = new Uri(serverUrl);
   }
   return GetService(serviceSignature, uri);
 }
 public void TestCreateService() {
   serviceSignature = new AdWordsServiceSignature(TEST_API_VERSION,
       TEST_SERVICE, TEST_GROUP_NAME);
   serviceFactory.CreateService(serviceSignature, new AdWordsUser(), testUri);
 }
 public AdsClient GetService(ServiceSignature serviceSignature, Uri serverUrl) {
   if (serviceSignature == null) {
     throw new ArgumentNullException("serviceSignature");
   } else {
     ServiceFactory factory = GetServiceFactory(serviceSignature.Id);
     if (factory == null) {
       throw new ArgumentException(string.Format(
           CommonErrorMessages.UnregisteredServiceTypeRequested, serviceSignature.ServiceName));
     } else {
       return factory.CreateService(serviceSignature, this, serverUrl);
     }
   }
 }
 public void TestCreateServiceClientLoginSupported() {
   ConfigureForClientLogin();
   serviceSignature = new DfpServiceSignature(SUPPORTED_CLIENT_LOGIN_VERSION, TEST_SERVICE);
   serviceFactory.CreateService(serviceSignature, new DfpUser(), null);
 }
 /// <summary>
 /// Create a service object.
 /// </summary>
 /// <param name="signature">Signature of the service being created.</param>
 /// <param name="user">The user for which the service is being created.
 /// <param name="serverUrl">The server to which the API calls should be
 /// made.</param>
 /// </param>
 /// <returns>An object of the desired service type.</returns>
 public abstract AdsClient CreateService(ServiceSignature signature, AdsUser user,
     Uri serverUrl);
 /// <summary>
 /// Create a service object.
 /// </summary>
 /// <param name="signature">Signature of the service being created.</param>
 /// <param name="user">The user for which the service is being created.
 /// <param name="serverUrl">The server to which the API calls should be
 /// made.</param></param>
 /// <param name="serverUrl"></param>
 /// <returns>
 /// An object of the desired service type.
 /// </returns>
 public override AdsClient CreateService(ServiceSignature signature, AdsUser user,
     Uri serverUrl) {
   return null;
 }
 /// <summary>
 /// Checks preconditions of the service signature and throws and exception if the service
 /// cannot be generated.
 /// </summary>
 /// <param name="signature">the service signature for generating the service</param>
 protected override void CheckServicePreconditions(ServiceSignature signature) {
   if (signature == null) {
     throw new ArgumentNullException("signature");
   }
   if (!(signature is DfpServiceSignature)) {
     throw new InvalidCastException(string.Format(CultureInfo.InvariantCulture,
         DfpErrorMessages.SignatureIsOfWrongType, typeof(DfpServiceSignature)));
   }
   DfpAppConfig dfpConfig = (DfpAppConfig) Config;
   DfpServiceSignature dfpSignature = signature as DfpServiceSignature;
   String version = dfpSignature.Version;
   if (dfpConfig.AuthorizationMethod == DfpAuthorizationMethod.ClientLogin
       && version.CompareTo(FINAL_CLIENT_LOGIN_VERSION) > 0) {
     throw new DfpException(string.Format(DfpErrorMessages.ClientLoginNotSupported, version));
   }
 }
 /// <summary>
 /// Checks preconditions of the service signature and throws and exception if the service
 /// cannot be generated.
 /// </summary>
 /// <param name="signature">the service signature for generating the service</param>
 protected override void CheckServicePreconditions(ServiceSignature signature) {
   return;
 }
Example #29
0
 /// <summary>
 /// Creates an object of the requested type of service.
 /// </summary>
 /// <param name="serviceSignature">Signature of the service being requested.
 /// </param>
 /// <returns>An object of the requested type of service. The
 /// caller should cast this object to the desired type.</returns>
 public AdsClient GetService(ServiceSignature serviceSignature)
 {
     return(GetService(serviceSignature, String.Empty));
 }
 /// <summary>
 /// Checks preconditions of the service signature and throws and exception if the service
 /// cannot be generated.
 /// </summary>
 /// <param name="signature">the service signature for generating the service</param>
 protected override void CheckServicePreconditions(ServiceSignature signature) {
   if (signature == null) {
     throw new ArgumentNullException("signature");
   }
   if (!(signature is DfpServiceSignature)) {
     throw new InvalidCastException(string.Format(CultureInfo.InvariantCulture,
         DfpErrorMessages.SignatureIsOfWrongType, typeof(DfpServiceSignature)));
   }
 }
 /// <summary>
 /// Static constructor to initialize the service constants.
 /// </summary>
 static v201508() {
   ActivityGroupService = DfpService.MakeServiceSignature("v201508", "ActivityGroupService");
   ActivityService = DfpService.MakeServiceSignature("v201508", "ActivityService");
   AdExclusionRuleService = DfpService.MakeServiceSignature("v201508", "AdExclusionRuleService");
   AdRuleService = DfpService.MakeServiceSignature("v201508", "AdRuleService");
   BaseRateService = DfpService.MakeServiceSignature("v201508", "BaseRateService");
   ContactService = DfpService.MakeServiceSignature("v201508", "ContactService");
   AudienceSegmentService = DfpService.MakeServiceSignature("v201508",
       "AudienceSegmentService");
   CompanyService = DfpService.MakeServiceSignature("v201508", "CompanyService");
   ContentService = DfpService.MakeServiceSignature("v201508", "ContentService");
   ContentMetadataKeyHierarchyService = DfpService.MakeServiceSignature("v201508",
       "ContentMetadataKeyHierarchyService");
   CreativeService = DfpService.MakeServiceSignature("v201508", "CreativeService");
   CreativeSetService = DfpService.MakeServiceSignature("v201508", "CreativeSetService");
   CreativeTemplateService = DfpService.MakeServiceSignature("v201508",
       "CreativeTemplateService");
   CreativeWrapperService = DfpService.MakeServiceSignature("v201508",
       "CreativeWrapperService");
   CustomTargetingService = DfpService.MakeServiceSignature("v201508",
       "CustomTargetingService");
   CustomFieldService = DfpService.MakeServiceSignature("v201508",
       "CustomFieldService");
   ExchangeRateService = DfpService.MakeServiceSignature("v201508", "ExchangeRateService");
   ForecastService = DfpService.MakeServiceSignature("v201508", "ForecastService");
   InventoryService = DfpService.MakeServiceSignature("v201508", "InventoryService");
   LabelService = DfpService.MakeServiceSignature("v201508", "LabelService");
   LineItemTemplateService = DfpService.MakeServiceSignature("v201508",
       "LineItemTemplateService");
   LineItemService = DfpService.MakeServiceSignature("v201508", "LineItemService");
   LineItemCreativeAssociationService =
       DfpService.MakeServiceSignature("v201508", "LineItemCreativeAssociationService");
   LiveStreamEventService = DfpService.MakeServiceSignature("v201508",
       "LiveStreamEventService");
   NetworkService = DfpService.MakeServiceSignature("v201508", "NetworkService");
   OrderService = DfpService.MakeServiceSignature("v201508", "OrderService");
   PackageService = DfpService.MakeServiceSignature("v201508", "PackageService");
   ProductPackageService = DfpService.MakeServiceSignature("v201508", "ProductPackageService");
   ProductPackageItemService = DfpService.MakeServiceSignature("v201508", "ProductPackageItemService");
   PlacementService = DfpService.MakeServiceSignature("v201508", "PlacementService");
   PremiumRateService = DfpService.MakeServiceSignature("v201508", "PremiumRateService");
   ProductService = DfpService.MakeServiceSignature("v201508", "ProductService");
   ProductTemplateService = DfpService.MakeServiceSignature("v201508",
       "ProductTemplateService");
   ProposalService = DfpService.MakeServiceSignature("v201508", "ProposalService");
   ProposalLineItemService = DfpService.MakeServiceSignature("v201508",
       "ProposalLineItemService");
   PublisherQueryLanguageService = DfpService.MakeServiceSignature("v201508",
       "PublisherQueryLanguageService");
   RateCardService = DfpService.MakeServiceSignature("v201508", "RateCardService");
   ReconciliationLineItemReportService = DfpService.MakeServiceSignature("v201508",
       "ReconciliationLineItemReportService");
   ReconciliationOrderReportService = DfpService.MakeServiceSignature("v201508",
       "ReconciliationOrderReportService");
   ReconciliationReportService = DfpService.MakeServiceSignature("v201508",
       "ReconciliationReportService");
   ReconciliationReportRowService = DfpService.MakeServiceSignature("v201508",
       "ReconciliationReportRowService");
   ReportService = DfpService.MakeServiceSignature("v201508", "ReportService");
   SharedAdUnitService = DfpService.MakeServiceSignature("v201508",
       "SharedAdUnitService");
   SuggestedAdUnitService = DfpService.MakeServiceSignature("v201508",
       "SuggestedAdUnitService");
   TeamService = DfpService.MakeServiceSignature("v201508", "TeamService");
   UserService = DfpService.MakeServiceSignature("v201508", "UserService");
   UserTeamAssociationService = DfpService.MakeServiceSignature("v201508",
       "UserTeamAssociationService");
   WorkflowRequestService = DfpService.MakeServiceSignature("v201508",
       "WorkflowRequestService");
 }
 /// <summary>
 /// Static constructor to initialize the service constants.
 /// </summary>
 static v201211()
 {
     AudienceSegmentService = DfpService.MakeServiceSignature("v201211",
     "AudienceSegmentService");
     CompanyService = DfpService.MakeServiceSignature("v201211", "CompanyService");
     ContentService = DfpService.MakeServiceSignature("v201211", "ContentService");
     CreativeService = DfpService.MakeServiceSignature("v201211", "CreativeService");
     CreativeSetService = DfpService.MakeServiceSignature("v201211", "CreativeSetService");
     CreativeTemplateService = DfpService.MakeServiceSignature("v201211",
     "CreativeTemplateService");
     CreativeWrapperService = DfpService.MakeServiceSignature("v201211",
     "CreativeWrapperService");
     CustomTargetingService = DfpService.MakeServiceSignature("v201211",
     "CustomTargetingService");
     CustomFieldService = DfpService.MakeServiceSignature("v201211",
     "CustomFieldService");
     ForecastService = DfpService.MakeServiceSignature("v201211", "ForecastService");
     InventoryService = DfpService.MakeServiceSignature("v201211", "InventoryService");
     LabelService = DfpService.MakeServiceSignature("v201211", "LabelService");
     LineItemService = DfpService.MakeServiceSignature("v201211", "LineItemService");
     LineItemCreativeAssociationService =
     DfpService.MakeServiceSignature("v201211", "LineItemCreativeAssociationService");
     NetworkService = DfpService.MakeServiceSignature("v201211", "NetworkService");
     OrderService = DfpService.MakeServiceSignature("v201211", "OrderService");
     PlacementService = DfpService.MakeServiceSignature("v201211", "PlacementService");
     PublisherQueryLanguageService = DfpService.MakeServiceSignature("v201211",
     "PublisherQueryLanguageService");
     ReportService = DfpService.MakeServiceSignature("v201211", "ReportService");
     SuggestedAdUnitService = DfpService.MakeServiceSignature("v201211",
     "SuggestedAdUnitService");
     TeamService = DfpService.MakeServiceSignature("v201211", "TeamService");
     ThirdPartySlotService = DfpService.MakeServiceSignature("v201211",
     "ThirdPartySlotService");
     UserService = DfpService.MakeServiceSignature("v201211", "UserService");
     UserTeamAssociationService = DfpService.MakeServiceSignature("v201211",
     "UserTeamAssociationService");
 }