adcenter_api 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. data/lib/adcenter_api.rb +10 -11
  2. data/lib/adcenter_api/api_config.rb +2 -4
  3. data/lib/adcenter_api/client_login_header_handler.rb +1 -2
  4. data/lib/adcenter_api/credential_handler.rb +4 -5
  5. data/lib/adcenter_api/errors.rb +5 -6
  6. data/lib/adcenter_api/report_utils.rb +1 -2
  7. data/lib/adcenter_api/v7/administration_service.rb +1 -2
  8. data/lib/adcenter_api/v7/campaign_management_service.rb +2 -2
  9. data/lib/adcenter_api/v7/customer_billing_service.rb +2 -2
  10. data/lib/adcenter_api/v7/customer_management_service.rb +2 -2
  11. data/lib/adcenter_api/v7/notification_service.rb +2 -2
  12. data/lib/adcenter_api/v7/reporting_service.rb +2 -2
  13. data/lib/adcenter_api/v8/ad_intelligence_service.rb +2 -2
  14. data/lib/adcenter_api/v8/administration_service.rb +2 -2
  15. data/lib/adcenter_api/v8/bulk_service.rb +2 -2
  16. data/lib/adcenter_api/v8/campaign_management_service.rb +2 -2
  17. data/lib/adcenter_api/v8/customer_billing_service.rb +2 -2
  18. data/lib/adcenter_api/v8/customer_management_service.rb +2 -2
  19. data/lib/adcenter_api/v8/notification_service.rb +2 -2
  20. data/lib/adcenter_api/v8/optimizer_service.rb +2 -2
  21. data/lib/adcenter_api/v8/reporting_service.rb +2 -2
  22. data/lib/adcenter_api/version.rb +1 -1
  23. data/lib/ads_common_for_adcenter.rb +15 -0
  24. data/lib/{ads_common/api_config_decorator.rb → ads_common_for_adcenter/api_config.rb} +2 -3
  25. data/lib/{ads_common/auth/client_login_handler_decorator.rb → ads_common_for_adcenter/auth/client_login_handler.rb} +13 -13
  26. data/lib/{ads_common/build/savon_registry_decorator.rb → ads_common_for_adcenter/build/savon_registry.rb} +1 -2
  27. data/lib/{ads_common/parameters_validator_decorator.rb → ads_common_for_adcenter/parameters_validator.rb} +1 -2
  28. data/lib/ads_common_for_adcenter/savon_headers_base_header_handler.rb +9 -0
  29. data/lib/{ads_common/savon_service_decorator.rb → ads_common_for_adcenter/savon_service.rb} +24 -7
  30. data/rakefile.rb +3 -4
  31. metadata +9 -8
  32. data/lib/ads_common/savon_headers_base_header_handler_decorator.rb +0 -23
@@ -1,19 +1,18 @@
1
1
  require 'savon'
2
2
  require 'httpi'
3
3
  require 'active_support/inflector'
4
- require 'ads_common/api'
5
- #require 'ads_common/savon_headers/oauth_header_handler'
6
4
 
5
+ require 'ads_common_for_adcenter'
6
+ require 'ads_common_for_adcenter/api_config'
7
+ require 'ads_common_for_adcenter/parameters_validator'
8
+ require 'ads_common_for_adcenter/auth/client_login_handler'
9
+ require 'ads_common_for_adcenter/savon_service'
10
+ require 'ads_common_for_adcenter/savon_headers_base_header_handler'
7
11
  require 'adcenter_api/api_config'
8
12
  require 'adcenter_api/client_login_header_handler'
9
13
  require 'adcenter_api/credential_handler'
10
14
  require 'adcenter_api/errors'
11
15
  require 'adcenter_api/report_utils'
12
- require 'ads_common/api_config_decorator'
13
- require 'ads_common/parameters_validator_decorator'
14
- require 'ads_common/auth/client_login_handler_decorator'
15
- require 'ads_common/savon_service_decorator'
16
- require 'ads_common/savon_headers_base_header_handler_decorator'
17
16
 
18
17
  module AdcenterApi
19
18
 
@@ -21,7 +20,7 @@ module AdcenterApi
21
20
  #
22
21
  # Holds all the services, as well as login credentials.
23
22
  #
24
- class Api < AdsCommon::Api
23
+ class Api < AdsCommonForAdcenter::Api
25
24
 
26
25
  # Constructor for API.
27
26
  def initialize(provided_config = nil)
@@ -37,7 +36,7 @@ module AdcenterApi
37
36
  # Retrieve correct soap_header_handler.
38
37
  #
39
38
  # Args:
40
- # - auth_handler: instance of an AdsCommon::Auth::BaseHandler subclass to
39
+ # - auth_handler: instance of an AdsCommonForAdcenter::Auth::BaseHandler subclass to
41
40
  # handle authentication
42
41
  # - version: intended API version
43
42
  # - header_ns: header namespace
@@ -50,7 +49,7 @@ module AdcenterApi
50
49
  auth_method = @config.read('authentication.method', :CLIENTLOGIN)
51
50
  handler_class = case auth_method
52
51
  when :CLIENTLOGIN then AdcenterApi::ClientLoginHeaderHandler
53
- when :OAUTH, :OAUTH2 then AdsCommon::SavonHeaders::OAuthHeaderHandler
52
+ when :OAUTH, :OAUTH2 then AdsCommonForAdcenter::SavonHeaders::OAuthHeaderHandler
54
53
  end
55
54
  return handler_class.new(@credential_handler, auth_handler, header_ns, default_ns, version)
56
55
  end
@@ -151,7 +150,7 @@ module AdcenterApi
151
150
  version = api_config.default_version if version.nil?
152
151
  # Check if version exists.
153
152
  if !api_config.versions.include?(version)
154
- raise AdsCommon::Errors::Error, "Unknown version '%s'" % version
153
+ raise AdsCommonForAdcenter::Errors::Error, "Unknown version '%s'" % version
155
154
  end
156
155
  return AdcenterApi::ReportUtils.new(self, version)
157
156
  end
@@ -1,8 +1,6 @@
1
1
  # encoding: utf-8
2
2
  # Helper methods for loading and managing the available services in the AdCenter API.
3
3
 
4
- require 'ads_common/api_config'
5
-
6
4
  require 'adcenter_api/version'
7
5
 
8
6
  module AdcenterApi
@@ -10,9 +8,9 @@ module AdcenterApi
10
8
  # Contains helper methods for loading and managing the available services.
11
9
  module ApiConfig
12
10
 
13
- # Inherit from AdsCommon::ApiConfig
11
+ # Inherit from AdsCommonForAdcenter::ApiConfig
14
12
  class << ApiConfig
15
- include AdsCommon::ApiConfig
13
+ include AdsCommonForAdcenter::ApiConfig
16
14
  end
17
15
 
18
16
  # Set defaults
@@ -1,8 +1,7 @@
1
1
  # Handles SOAP headers and namespaces definition for ClientLogin type header.
2
- require 'ads_common/savon_headers/base_header_handler'
3
2
 
4
3
  module AdcenterApi
5
- class ClientLoginHeaderHandler < AdsCommon::SavonHeaders::BaseHeaderHandler
4
+ class ClientLoginHeaderHandler < AdsCommonForAdcenter::SavonHeaders::BaseHeaderHandler
6
5
 
7
6
  private
8
7
 
@@ -1,8 +1,7 @@
1
- require 'ads_common/credential_handler'
2
1
  require 'adcenter_api/api_config'
3
2
 
4
3
  module AdcenterApi
5
- class CredentialHandler < AdsCommon::CredentialHandler
4
+ class CredentialHandler < AdsCommonForAdcenter::CredentialHandler
6
5
  # Whether we're making MCC-level requests.
7
6
  attr_accessor :use_mcc
8
7
  # Whether we're making validate-only requests.
@@ -51,7 +50,7 @@ module AdcenterApi
51
50
  # environment.
52
51
  #
53
52
  # Raises:
54
- # - AdsCommon::Error::EnvironmentMismatchError if sandbox credentials are
53
+ # - AdsCommonForAdcenter::Error::EnvironmentMismatchError if sandbox credentials are
55
54
  # being used for production or vice-versa.
56
55
  # - AdcenterApi::Errors:BadCredentialsError if supplied credentials are not
57
56
  # valid.
@@ -76,12 +75,12 @@ module AdcenterApi
76
75
  #case environment
77
76
  # when :PRODUCTION
78
77
  # if sandbox_token
79
- # raise AdsCommon::Errors::EnvironmentMismatchError,
78
+ # raise AdsCommonForAdcenter::Errors::EnvironmentMismatchError,
80
79
  # 'Attempting to connect to production with sandbox credentials.'
81
80
  # end
82
81
  # when :SANDBOX
83
82
  # if (!sandbox_token)
84
- # raise AdsCommon::Errors::EnvironmentMismatchError,
83
+ # raise AdsCommonForAdcenter::Errors::EnvironmentMismatchError,
85
84
  # 'Attempting to connect to the sandbox with malformatted ' +
86
85
  # 'credentials. Please check http://msdn.microsoft.com/en-US/library/aa983013 for details.'
87
86
  # end
@@ -1,13 +1,12 @@
1
1
  # Specific error handling for the Adcenter API.
2
2
 
3
- require 'ads_common/errors'
4
3
 
5
4
  module AdcenterApi
6
5
  module Errors
7
6
 
8
7
  # This class encapsulates base class for API exceptions. More specific
9
8
  # exceptions are generated based on Service WSDL.
10
- class ApiException < AdsCommon::Errors::ApiException
9
+ class ApiException < AdsCommonForAdcenter::Errors::ApiException
11
10
  attr_reader :array_fields
12
11
 
13
12
  def initialize(exception_fault)
@@ -38,15 +37,15 @@ module AdcenterApi
38
37
  end
39
38
 
40
39
  # Error for invalid credentials sush as malformed ID.
41
- class BadCredentialsError < AdsCommon::Errors::ApiException
40
+ class BadCredentialsError < AdsCommonForAdcenter::Errors::ApiException
42
41
  end
43
42
 
44
43
  # Error for malformed report definition.
45
- class InvalidReportDefinitionError < AdsCommon::Errors::ApiException
44
+ class InvalidReportDefinitionError < AdsCommonForAdcenter::Errors::ApiException
46
45
  end
47
46
 
48
47
  # Error for server-side report error.
49
- class ReportError < AdsCommon::Errors::ApiException
48
+ class ReportError < AdsCommonForAdcenter::Errors::ApiException
50
49
  attr_reader :http_code
51
50
 
52
51
  def initialize(http_code, message)
@@ -557,7 +556,7 @@ module AdcenterApi
557
556
  }
558
557
  CODES.each do |_, constant|
559
558
  unless const_defined?(constant)
560
- const_set(constant,Class.new(AdsCommon::Errors::ApiException))
559
+ const_set(constant,Class.new(AdsCommonForAdcenter::Errors::ApiException))
561
560
  end
562
561
  end
563
562
 
@@ -3,7 +3,6 @@
3
3
  require 'cgi'
4
4
  require 'gyoku'
5
5
 
6
- require 'ads_common/http'
7
6
  require 'adcenter_api/errors'
8
7
  require 'adcenter_api/report_header_handler'
9
8
 
@@ -83,7 +82,7 @@ module AdcenterApi
83
82
  @api.config.read('service.environment'), @version)
84
83
  headers = get_report_request_headers(url, cid)
85
84
  log_request(url, headers, definition_text)
86
- response = AdsCommon::Http.post_response(url, data, @api.config, headers)
85
+ response = AdsCommonForAdcenter::Http.post_response(url, data, @api.config, headers)
87
86
  check_for_errors(response)
88
87
  return response
89
88
  end
@@ -7,11 +7,10 @@
7
7
  #
8
8
  # Code generated by AdsCommon library 0.7.3 on 2012-07-04 16:49:14.
9
9
 
10
- require 'ads_common/savon_service'
11
10
  require 'adcenter_api/v7/administration_service_registry'
12
11
 
13
12
  module AdcenterApi; module V7; module AdministrationService
14
- class AdministrationService < AdsCommon::SavonService
13
+ class AdministrationService < AdsCommonForAdcenter::SavonService
15
14
  def initialize(config, endpoint)
16
15
  namespace = 'https://adcenter.microsoft.com/v7'
17
16
  super(config, endpoint, namespace, :v7)
@@ -7,11 +7,11 @@
7
7
  #
8
8
  # Code generated by AdsCommon library 0.7.3 on 2012-07-04 16:49:16.
9
9
 
10
- require 'ads_common/savon_service'
10
+ require 'ads_common_for_adcenter/savon_service'
11
11
  require 'adcenter_api/v7/campaign_management_service_registry'
12
12
 
13
13
  module AdcenterApi; module V7; module CampaignManagementService
14
- class CampaignManagementService < AdsCommon::SavonService
14
+ class CampaignManagementService < AdsCommonForAdcenter::SavonService
15
15
  def initialize(config, endpoint)
16
16
  namespace = 'https://adcenter.microsoft.com/v7'
17
17
  super(config, endpoint, namespace, :v7)
@@ -7,11 +7,11 @@
7
7
  #
8
8
  # Code generated by AdsCommon library 0.7.3 on 2012-07-04 16:49:46.
9
9
 
10
- require 'ads_common/savon_service'
10
+ require 'ads_common_for_adcenter/savon_service'
11
11
  require 'adcenter_api/v7/customer_billing_service_registry'
12
12
 
13
13
  module AdcenterApi; module V7; module CustomerBillingService
14
- class CustomerBillingService < AdsCommon::SavonService
14
+ class CustomerBillingService < AdsCommonForAdcenter::SavonService
15
15
  def initialize(config, endpoint)
16
16
  namespace = 'https://adcenter.microsoft.com/api/customerbilling'
17
17
  super(config, endpoint, namespace, :v7)
@@ -7,11 +7,11 @@
7
7
  #
8
8
  # Code generated by AdsCommon library 0.7.3 on 2012-07-04 16:49:48.
9
9
 
10
- require 'ads_common/savon_service'
10
+ require 'ads_common_for_adcenter/savon_service'
11
11
  require 'adcenter_api/v7/customer_management_service_registry'
12
12
 
13
13
  module AdcenterApi; module V7; module CustomerManagementService
14
- class CustomerManagementService < AdsCommon::SavonService
14
+ class CustomerManagementService < AdsCommonForAdcenter::SavonService
15
15
  def initialize(config, endpoint)
16
16
  namespace = 'https://adcenter.microsoft.com/api/customermanagement'
17
17
  super(config, endpoint, namespace, :v7)
@@ -7,11 +7,11 @@
7
7
  #
8
8
  # Code generated by AdsCommon library 0.7.3 on 2012-07-04 16:49:49.
9
9
 
10
- require 'ads_common/savon_service'
10
+ require 'ads_common_for_adcenter/savon_service'
11
11
  require 'adcenter_api/v7/notification_service_registry'
12
12
 
13
13
  module AdcenterApi; module V7; module NotificationService
14
- class NotificationService < AdsCommon::SavonService
14
+ class NotificationService < AdsCommonForAdcenter::SavonService
15
15
  def initialize(config, endpoint)
16
16
  namespace = 'https://adcenter.microsoft.com/api/notifications'
17
17
  super(config, endpoint, namespace, :v7)
@@ -7,11 +7,11 @@
7
7
  #
8
8
  # Code generated by AdsCommon library 0.7.3 on 2012-07-04 16:49:50.
9
9
 
10
- require 'ads_common/savon_service'
10
+ require 'ads_common_for_adcenter/savon_service'
11
11
  require 'adcenter_api/v7/reporting_service_registry'
12
12
 
13
13
  module AdcenterApi; module V7; module ReportingService
14
- class ReportingService < AdsCommon::SavonService
14
+ class ReportingService < AdsCommonForAdcenter::SavonService
15
15
  def initialize(config, endpoint)
16
16
  namespace = 'https://adcenter.microsoft.com/v7'
17
17
  super(config, endpoint, namespace, :v7)
@@ -7,11 +7,11 @@
7
7
  #
8
8
  # Code generated by AdsCommon library 0.7.3 on 2012-07-04 16:49:50.
9
9
 
10
- require 'ads_common/savon_service'
10
+ require 'ads_common_for_adcenter/savon_service'
11
11
  require 'adcenter_api/v8/ad_intelligence_service_registry'
12
12
 
13
13
  module AdcenterApi; module V8; module AdIntelligenceService
14
- class AdIntelligenceService < AdsCommon::SavonService
14
+ class AdIntelligenceService < AdsCommonForAdcenter::SavonService
15
15
  def initialize(config, endpoint)
16
16
  namespace = 'https://adcenter.microsoft.com/v8'
17
17
  super(config, endpoint, namespace, :v8)
@@ -7,11 +7,11 @@
7
7
  #
8
8
  # Code generated by AdsCommon library 0.7.3 on 2012-07-04 16:49:52.
9
9
 
10
- require 'ads_common/savon_service'
10
+ require 'ads_common_for_adcenter/savon_service'
11
11
  require 'adcenter_api/v8/administration_service_registry'
12
12
 
13
13
  module AdcenterApi; module V8; module AdministrationService
14
- class AdministrationService < AdsCommon::SavonService
14
+ class AdministrationService < AdsCommonForAdcenter::SavonService
15
15
  def initialize(config, endpoint)
16
16
  namespace = 'https://adcenter.microsoft.com/v8'
17
17
  super(config, endpoint, namespace, :v8)
@@ -7,11 +7,11 @@
7
7
  #
8
8
  # Code generated by AdsCommon library 0.7.3 on 2012-07-04 16:49:53.
9
9
 
10
- require 'ads_common/savon_service'
10
+ require 'ads_common_for_adcenter/savon_service'
11
11
  require 'adcenter_api/v8/bulk_service_registry'
12
12
 
13
13
  module AdcenterApi; module V8; module BulkService
14
- class BulkService < AdsCommon::SavonService
14
+ class BulkService < AdsCommonForAdcenter::SavonService
15
15
  def initialize(config, endpoint)
16
16
  namespace = 'https://adcenter.microsoft.com/v8'
17
17
  super(config, endpoint, namespace, :v8)
@@ -7,11 +7,11 @@
7
7
  #
8
8
  # Code generated by AdsCommon library 0.7.3 on 2012-07-04 16:49:55.
9
9
 
10
- require 'ads_common/savon_service'
10
+ require 'ads_common_for_adcenter/savon_service'
11
11
  require 'adcenter_api/v8/campaign_management_service_registry'
12
12
 
13
13
  module AdcenterApi; module V8; module CampaignManagementService
14
- class CampaignManagementService < AdsCommon::SavonService
14
+ class CampaignManagementService < AdsCommonForAdcenter::SavonService
15
15
  def initialize(config, endpoint)
16
16
  namespace = 'https://adcenter.microsoft.com/v8'
17
17
  super(config, endpoint, namespace, :v8)
@@ -7,11 +7,11 @@
7
7
  #
8
8
  # Code generated by AdsCommon library 0.7.3 on 2012-07-04 16:50:24.
9
9
 
10
- require 'ads_common/savon_service'
10
+ require 'ads_common_for_adcenter/savon_service'
11
11
  require 'adcenter_api/v8/customer_billing_service_registry'
12
12
 
13
13
  module AdcenterApi; module V8; module CustomerBillingService
14
- class CustomerBillingService < AdsCommon::SavonService
14
+ class CustomerBillingService < AdsCommonForAdcenter::SavonService
15
15
  def initialize(config, endpoint)
16
16
  namespace = 'https://adcenter.microsoft.com/api/customerbilling'
17
17
  super(config, endpoint, namespace, :v8)
@@ -7,11 +7,11 @@
7
7
  #
8
8
  # Code generated by AdsCommon library 0.7.3 on 2012-07-04 16:50:25.
9
9
 
10
- require 'ads_common/savon_service'
10
+ require 'ads_common_for_adcenter/savon_service'
11
11
  require 'adcenter_api/v8/customer_management_service_registry'
12
12
 
13
13
  module AdcenterApi; module V8; module CustomerManagementService
14
- class CustomerManagementService < AdsCommon::SavonService
14
+ class CustomerManagementService < AdsCommonForAdcenter::SavonService
15
15
  def initialize(config, endpoint)
16
16
  namespace = 'https://adcenter.microsoft.com/api/customermanagement'
17
17
  super(config, endpoint, namespace, :v8)
@@ -7,11 +7,11 @@
7
7
  #
8
8
  # Code generated by AdsCommon library 0.7.3 on 2012-07-04 16:50:29.
9
9
 
10
- require 'ads_common/savon_service'
10
+ require 'ads_common_for_adcenter/savon_service'
11
11
  require 'adcenter_api/v8/notification_service_registry'
12
12
 
13
13
  module AdcenterApi; module V8; module NotificationService
14
- class NotificationService < AdsCommon::SavonService
14
+ class NotificationService < AdsCommonForAdcenter::SavonService
15
15
  def initialize(config, endpoint)
16
16
  namespace = 'https://adcenter.microsoft.com/api/notifications'
17
17
  super(config, endpoint, namespace, :v8)
@@ -7,11 +7,11 @@
7
7
  #
8
8
  # Code generated by AdsCommon library 0.7.3 on 2012-07-04 16:50:31.
9
9
 
10
- require 'ads_common/savon_service'
10
+ require 'ads_common_for_adcenter/savon_service'
11
11
  require 'adcenter_api/v8/optimizer_service_registry'
12
12
 
13
13
  module AdcenterApi; module V8; module OptimizerService
14
- class OptimizerService < AdsCommon::SavonService
14
+ class OptimizerService < AdsCommonForAdcenter::SavonService
15
15
  def initialize(config, endpoint)
16
16
  namespace = 'https://adcenter.microsoft.com/v8'
17
17
  super(config, endpoint, namespace, :v8)
@@ -7,11 +7,11 @@
7
7
  #
8
8
  # Code generated by AdsCommon library 0.7.3 on 2012-07-04 16:50:32.
9
9
 
10
- require 'ads_common/savon_service'
10
+ require 'ads_common_for_adcenter/savon_service'
11
11
  require 'adcenter_api/v8/reporting_service_registry'
12
12
 
13
13
  module AdcenterApi; module V8; module ReportingService
14
- class ReportingService < AdsCommon::SavonService
14
+ class ReportingService < AdsCommonForAdcenter::SavonService
15
15
  def initialize(config, endpoint)
16
16
  namespace = 'https://adcenter.microsoft.com/v8'
17
17
  super(config, endpoint, namespace, :v8)
@@ -1,5 +1,5 @@
1
1
  module AdcenterApi
2
2
  module ApiConfig
3
- CLIENT_LIB_VERSION = "0.0.3"
3
+ CLIENT_LIB_VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -0,0 +1,15 @@
1
+ require 'ads_common/api'
2
+ require 'ads_common/api_config'
3
+ require 'ads_common/savon_headers/base_header_handler'
4
+ require 'ads_common/credential_handler'
5
+ require 'ads_common/errors'
6
+ require 'ads_common/http'
7
+ require 'ads_common/savon_service'
8
+ require 'ads_common/build/savon_generator'
9
+ require 'ads_common/build/savon_registry'
10
+ require 'ads_common/parameters_validator'
11
+
12
+ ####### AdsCommon Overriden for Adcenter #########
13
+ module AdsCommonForAdcenter
14
+ include AdsCommon
15
+ end
@@ -1,7 +1,6 @@
1
1
  ####### Overriden for Adcenter #########
2
-
3
- AdsCommon::ApiConfig.module_eval do
4
-
2
+ module AdsCommonForAdcenter::ApiConfig
3
+ include AdsCommon::ApiConfig
5
4
  # Get the endpoint for a service on a given environment and API version.
6
5
  #
7
6
  # Args:
@@ -1,11 +1,11 @@
1
1
  ####### Overriden for Adcenter #########
2
2
 
3
- AdsCommon::Auth::ClientLoginHandler.class_eval do
3
+ class AdsCommonForAdcenter::Auth::ClientLoginHandler
4
4
 
5
- ACCOUNT_TYPE = 'GOOGLE'
6
- AUTH_PATH = '/accounts/ClientLogin'
7
- AUTH_PREFIX = 'GoogleLogin auth='
8
- CAPTCHA_PATH = '/accounts/'
5
+ #ACCOUNT_TYPE = 'GOOGLE'
6
+ #AUTH_PATH = '/accounts/ClientLogin'
7
+ #AUTH_PREFIX = 'GoogleLogin auth='
8
+ #CAPTCHA_PATH = '/accounts/'
9
9
 
10
10
  # Initializes the ClientLoginHandler with all the necessary details.
11
11
  def initialize(config, auth_server, service_name)
@@ -47,20 +47,20 @@ AdsCommon::Auth::ClientLoginHandler.class_eval do
47
47
  # accessed
48
48
  #
49
49
  # Raises:
50
- # - AdsCommon::Errors::AuthError if validation fails
50
+ # - AdsCommonForAdcenter::Errors::AuthError if validation fails
51
51
  #
52
52
  def validate_credentials(credentials)
53
53
  if credentials.nil?
54
- raise AdsCommon::Errors::AuthError, 'No credentials supplied.'
54
+ raise AdsCommonForAdcenter::Errors::AuthError, 'No credentials supplied.'
55
55
  end
56
56
 
57
57
  if credentials[:auth_token].nil?
58
58
  if credentials[:user_name].nil?
59
- raise AdsCommon::Errors::AuthError,
59
+ raise AdsCommonForAdcenter::Errors::AuthError,
60
60
  'UserName address not included in credentials.'
61
61
  end
62
62
  if credentials[:password].nil?
63
- raise AdsCommon::Errors::AuthError,
63
+ raise AdsCommonForAdcenter::Errors::AuthError,
64
64
  'Password not included in credentials.'
65
65
  end
66
66
  else
@@ -82,7 +82,7 @@ AdsCommon::Auth::ClientLoginHandler.class_eval do
82
82
  # - The auth token for the account
83
83
  #
84
84
  # Raises:
85
- # - AdsCommon::Errors::AuthError if authentication fails
85
+ # - AdsCommonForAdcenter::Errors::AuthError if authentication fails
86
86
  #
87
87
  def create_token(credentials)
88
88
  token = credentials.include?(:auth_token) ?
@@ -119,7 +119,7 @@ AdsCommon::Auth::ClientLoginHandler.class_eval do
119
119
  data = get_login_data(credentials)
120
120
  headers = {'Content-Type' => 'application/x-www-form-urlencoded'}
121
121
 
122
- response = AdsCommon::Http.post_response(url, data, @config, headers)
122
+ response = AdsCommonForAdcenter::Http.post_response(url, data, @config, headers)
123
123
  results = parse_token_text(response.body)
124
124
 
125
125
  if response.code == 200 and results.include?('Auth')
@@ -134,7 +134,7 @@ AdsCommon::Auth::ClientLoginHandler.class_eval do
134
134
  # Handling for known errors.
135
135
  if 'CaptchaRequired'.eql?(results['Error'])
136
136
  captcha_url = @server + CAPTCHA_PATH + results['CaptchaUrl']
137
- raise AdsCommon::Errors::CaptchaRequiredError.new(results['Error'],
137
+ raise AdsCommonForAdcenter::Errors::CaptchaRequiredError.new(results['Error'],
138
138
  results['CaptchaToken'], captcha_url, results['Url'])
139
139
  end
140
140
  # For other errors throwing a generic error.
@@ -145,7 +145,7 @@ AdsCommon::Auth::ClientLoginHandler.class_eval do
145
145
  if results.include?('Info')
146
146
  error_message += " Info: %s." % results['Info']
147
147
  end
148
- raise AdsCommon::Errors::AuthError.new(error_message, error_str,
148
+ raise AdsCommonForAdcenter::Errors::AuthError.new(error_message, error_str,
149
149
  results['Info'])
150
150
  end
151
151
 
@@ -1,6 +1,5 @@
1
- require 'ads_common/build/savon_registry'
2
1
 
3
- AdsCommon::Build::SavonRegistry.class_eval do
2
+ class AdsCommonForAdcenter::Build::SavonRegistry
4
3
 
5
4
  # Extracts input parameters of given method as an array.
6
5
  def extract_input_parameters(op_node, doc)
@@ -1,6 +1,5 @@
1
- require 'ads_common/parameters_validator'
2
1
 
3
- AdsCommon::ParametersValidator.class_eval do
2
+ class AdsCommonForAdcenter::ParametersValidator < AdsCommon::ParametersValidator
4
3
 
5
4
  # Validates input parameters to:
6
5
  # - add parameter names;
@@ -0,0 +1,9 @@
1
+
2
+ class AdsCommonForAdcenter::SavonHeaders::BaseHeaderHandler
3
+
4
+ # Generates SOAP headers with the default request header element.
5
+ def generate_headers(request, soap)
6
+ soap.header.merge!(generate_request_header())
7
+ end
8
+
9
+ end
@@ -1,10 +1,27 @@
1
1
  ####### Overriden for Adcenter #########
2
- require 'ads_common/savon_service'
3
2
 
4
- AdsCommon::SavonService.class_eval do
3
+ class AdsCommonForAdcenter::SavonService < AdsCommon::SavonService
5
4
 
6
5
  private
7
6
 
7
+ # [CHANGES:
8
+ # => ParametersValidator to AdsCommonForAdcenter::ParametersValidator
9
+ # => ResultsExtractor to AdsCommon::ResultsExtractor]
10
+ # Executes SOAP action specified as a string with given arguments.
11
+ def execute_action(action_name, args, &block)
12
+ registry = get_service_registry()
13
+ validator = AdsCommonForAdcenter::ParametersValidator.new(registry)
14
+ args = validator.validate_args(action_name, args)
15
+ response = execute_soap_request(
16
+ action_name.to_sym, args, validator.extra_namespaces)
17
+ log_headers(response.http.headers)
18
+ handle_errors(response)
19
+ extractor = AdsCommon::ResultsExtractor.new(registry)
20
+ result = extractor.extract_result(response, action_name, &block)
21
+ run_user_block(extractor, response, result, &block) if block_given?
22
+ return result
23
+ end
24
+
8
25
  # Adds namespace to the given string.
9
26
  #
10
27
  # Args:
@@ -13,13 +30,13 @@ AdsCommon::SavonService.class_eval do
13
30
  # Returns:
14
31
  # - String with a namespace
15
32
  #
16
- def prepend_namespace(str, namespace = AdsCommon::SavonHeaders::BaseHeaderHandler::DEFAULT_NAMESPACE)
33
+ def prepend_namespace(str, namespace = AdsCommonForAdcenter::SavonHeaders::BaseHeaderHandler::DEFAULT_NAMESPACE)
17
34
  return "%s:%s" % [namespace, str]
18
35
  end
19
36
 
20
37
  # Executes the SOAP request with original SOAP name.
21
38
  def execute_soap_request(action, args, extra_namespaces)
22
- ns = AdsCommon::SavonHeaders::BaseHeaderHandler::DEFAULT_NAMESPACE
39
+ ns = AdsCommonForAdcenter::SavonHeaders::BaseHeaderHandler::DEFAULT_NAMESPACE
23
40
  original_input_name = get_service_registry.get_method_signature(action)[:input][:name].to_s.camelize
24
41
  original_action_name = get_service_registry.get_method_signature(action)[:original_name].to_s.camelize
25
42
  original_action_name = action if original_action_name.nil?
@@ -59,7 +76,7 @@ AdsCommon::SavonService.class_eval do
59
76
  wsdl.endpoint = endpoint
60
77
  wsdl.namespace = namespace
61
78
  wsdl.element_form_default = :qualified
62
- AdsCommon::Http.configure_httpi(@config, httpi)
79
+ AdsCommonForAdcenter::Http.configure_httpi(@config, httpi)
63
80
  end
64
81
  client.config.raise_errors = false
65
82
  client.config.logger.subject = get_logger()
@@ -107,14 +124,14 @@ AdsCommon::SavonService.class_eval do
107
124
  return exception_class.new("#{operation_error[:message]} (#{operation_error[:details]})")
108
125
  elsif fault[:faultstring]
109
126
  fault_message = fault[:faultstring]
110
- return AdsCommon::Errors::ApiException.new(
127
+ return AdsCommonForAdcenter::Errors::ApiException.new(
111
128
  "Unknown exception with error: %s" % fault_message)
112
129
  else
113
130
  raise ArgumentError.new(fault.to_s)
114
131
  end
115
132
  rescue Exception => e
116
133
  operation_error ||= response[:fault][:detail][:api_fault][:operation_errors][:operation_error] rescue {}
117
- return AdsCommon::Errors::ApiException.new(
134
+ return AdsCommonForAdcenter::Errors::ApiException.new(
118
135
  "Failed to resolve exception (%s), details: %s, SOAP fault: %s" %
119
136
  [e.message, "#{operation_error[:message]} (#{operation_error[:details]})", response.soap_fault])
120
137
  end
@@ -31,10 +31,9 @@ lib = File.expand_path('../lib/', __FILE__)
31
31
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
32
32
 
33
33
  # GENERATE API SERVICES
34
- require 'ads_common/build/savon_generator'
35
34
  require 'adcenter_api/api_config'
36
- require 'ads_common/api_config_decorator'
37
- require 'ads_common/build/savon_registry_decorator'
35
+ require 'ads_common_for_adcenter/api_config'
36
+ require 'ads_common_for_adcenter/build/savon_registry'
38
37
  desc 'Generate the Adcenter API stubs.'
39
38
 
40
39
  task :generate do
@@ -47,7 +46,7 @@ task :generate do
47
46
  wsdls = AdcenterApi::ApiConfig.get_wsdls(version)
48
47
  wsdls.each do |service_name, wsdl_url|
49
48
  logger.info('Processing %s at [%s]...' % [service_name, wsdl_url])
50
- generator = AdsCommon::Build::SavonGenerator.new(wsdl_url, code_path, api_config.api_name, version, service_name)
49
+ generator = AdsCommonForAdcenter::Build::SavonGenerator.new(wsdl_url, code_path, api_config.api_name, version, service_name)
51
50
  generator.process_wsdl()
52
51
  end
53
52
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adcenter_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-22 00:00:00.000000000 Z
12
+ date: 2012-08-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -120,12 +120,13 @@ files:
120
120
  - lib/adcenter_api/v8/reporting_service_registry.rb
121
121
  - lib/adcenter_api/version.rb
122
122
  - lib/adcenter_api.rb
123
- - lib/ads_common/api_config_decorator.rb
124
- - lib/ads_common/auth/client_login_handler_decorator.rb
125
- - lib/ads_common/build/savon_registry_decorator.rb
126
- - lib/ads_common/parameters_validator_decorator.rb
127
- - lib/ads_common/savon_headers_base_header_handler_decorator.rb
128
- - lib/ads_common/savon_service_decorator.rb
123
+ - lib/ads_common_for_adcenter/api_config.rb
124
+ - lib/ads_common_for_adcenter/auth/client_login_handler.rb
125
+ - lib/ads_common_for_adcenter/build/savon_registry.rb
126
+ - lib/ads_common_for_adcenter/parameters_validator.rb
127
+ - lib/ads_common_for_adcenter/savon_headers_base_header_handler.rb
128
+ - lib/ads_common_for_adcenter/savon_service.rb
129
+ - lib/ads_common_for_adcenter.rb
129
130
  - rakefile.rb
130
131
  - README.md
131
132
  homepage: https://github.com/weboglobin/adcenter_api
@@ -1,23 +0,0 @@
1
- ####### Overriden for Adcenter #########
2
- require 'ads_common/savon_headers/base_header_handler'
3
-
4
- AdsCommon::SavonHeaders::BaseHeaderHandler.class_eval do
5
-
6
- # Generates SOAP headers with the default request header element.
7
- def generate_headers(request, soap)
8
- soap.header.merge!(generate_request_header())
9
- end
10
- # Generates SOAP default request header with all requested headers.
11
- #def generate_request_header()
12
- # credentials = @credential_handler.credentials
13
- # extra_headers = credentials[:extra_headers]
14
- # puts "extra_headers=#{extra_headers}"
15
- # return extra_headers.inject({}) do |result, (header, value)|
16
- # puts "header=#{header}"
17
- # puts "value=#{value}"
18
- # result[prepend_namespace(header)] = value
19
- # result
20
- # end
21
- #end
22
-
23
- end