bing-ads-api 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +92 -0
- data/Rakefile +38 -0
- data/lib/bing-ads-api.rb +38 -0
- data/lib/bing-ads-api.yml +345 -0
- data/lib/bing-ads-api/api_exception.rb +42 -0
- data/lib/bing-ads-api/client_proxy.rb +131 -0
- data/lib/bing-ads-api/config.rb +75 -0
- data/lib/bing-ads-api/constants.rb +133 -0
- data/lib/bing-ads-api/data/ad.rb +119 -0
- data/lib/bing-ads-api/data/ad_group.rb +121 -0
- data/lib/bing-ads-api/data/campaign.rb +40 -0
- data/lib/bing-ads-api/data/report_request.rb +78 -0
- data/lib/bing-ads-api/data/report_request_status.rb +48 -0
- data/lib/bing-ads-api/data/reporting/account_performance_report_request.rb +176 -0
- data/lib/bing-ads-api/data/reporting/campaign_performance_report_request.rb +186 -0
- data/lib/bing-ads-api/data/reporting/helpers/column_helper.rb +65 -0
- data/lib/bing-ads-api/data/reporting/helpers/filter_helper.rb +124 -0
- data/lib/bing-ads-api/data/reporting/helpers/scope_helper.rb +51 -0
- data/lib/bing-ads-api/data/reporting/helpers/time_helper.rb +69 -0
- data/lib/bing-ads-api/data/reporting/performance_report_request.rb +78 -0
- data/lib/bing-ads-api/data_object.rb +35 -0
- data/lib/bing-ads-api/fault/ad_api_error.rb +15 -0
- data/lib/bing-ads-api/fault/ad_api_fault_detail.rb +67 -0
- data/lib/bing-ads-api/fault/api_fault_detail.rb +97 -0
- data/lib/bing-ads-api/fault/application_fault.rb +18 -0
- data/lib/bing-ads-api/fault/batch_error.rb +47 -0
- data/lib/bing-ads-api/fault/operation_error.rb +22 -0
- data/lib/bing-ads-api/fault/partial_errors.rb +75 -0
- data/lib/bing-ads-api/service.rb +174 -0
- data/lib/bing-ads-api/service/campaign_management.rb +483 -0
- data/lib/bing-ads-api/service/reporting.rb +101 -0
- data/lib/bing-ads-api/soap_hasheable.rb +143 -0
- data/lib/bing-ads-api/version.rb +6 -0
- data/lib/locales/es.yml +174 -0
- data/lib/tasks/bing-ads-api_tasks.rake +4 -0
- data/test/bing-ads-api_test.rb +134 -0
- data/test/campaign_management_test.rb +463 -0
- data/test/data_object_test.rb +46 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +56 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +58 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +29 -0
- data/test/dummy/log/test.log +3264 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/report_request_test.rb +312 -0
- data/test/reporting_test.rb +145 -0
- data/test/test_helper.rb +11 -0
- metadata +205 -0
@@ -0,0 +1,78 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
module BingAdsApi
|
4
|
+
|
5
|
+
##
|
6
|
+
# Public : Defines the base class for 'performance report requests'.
|
7
|
+
# Do not instantiate this object. Instead, use BingAdsApi::AccountPerformanceReportRequest,
|
8
|
+
# BingAdsApi::CampaignPerformanceReportRequest, BingAdsApi::AdGroupPerformanceReportRequest or
|
9
|
+
# BingAdsApi::AdPerformanceReportRequest
|
10
|
+
#
|
11
|
+
# Reference: http://msdn.microsoft.com/en-us/library/bing-ads-reporting-bing-ads-reportrequest.aspx
|
12
|
+
#
|
13
|
+
# Author:: jlopezn@neonline.cl
|
14
|
+
class PerformanceReportRequest < BingAdsApi::ReportRequest
|
15
|
+
|
16
|
+
# Adds helper methods to time attribute
|
17
|
+
include BingAdsApi::Helpers::TimeHelper
|
18
|
+
|
19
|
+
# Adds helper methods to column attribute
|
20
|
+
include BingAdsApi::Helpers::ColumnHelper
|
21
|
+
|
22
|
+
# Adds helper methods to filter attribute
|
23
|
+
include BingAdsApi::Helpers::FilterHelper
|
24
|
+
|
25
|
+
|
26
|
+
# Valid aggregations for reports
|
27
|
+
AGGREGATIONS = BingAdsApi::Config.instance.
|
28
|
+
reporting_constants['aggregation']
|
29
|
+
|
30
|
+
|
31
|
+
attr_accessor :aggregation, :columns, :filter, :scope, :time
|
32
|
+
|
33
|
+
|
34
|
+
# Public : Constructor. Adds validations to aggregations and time
|
35
|
+
#
|
36
|
+
# Author:: jlopezn@neonline.cl
|
37
|
+
#
|
38
|
+
# === Parameters
|
39
|
+
# attributes - Hash with Performance report request
|
40
|
+
#
|
41
|
+
def initialize(attributes={})
|
42
|
+
raise Exception.new("Invalid aggregation '#{attributes[:aggregation]}'") if !valid_aggregation(attributes[:aggregation])
|
43
|
+
raise Exception.new("Invalid time") if !valid_time(attributes[:time])
|
44
|
+
super(attributes)
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
# Public:: Returns this object as a Hash for SOAP Requests
|
49
|
+
#
|
50
|
+
# Author:: jlopezn@neonline.cl
|
51
|
+
#
|
52
|
+
# === Parameters
|
53
|
+
# * +keys_case+ - specifies the case for the hash keys
|
54
|
+
# ==== keys_case
|
55
|
+
# * :camelcase - CamelCase
|
56
|
+
# * :underscore - underscore_case
|
57
|
+
#
|
58
|
+
# === Examples
|
59
|
+
# performance_report_request.to_hash(:camelcase)
|
60
|
+
# # => {"Format"=>"Xml", "Language"=>"English", "ReportName"=>"My Report", "Aggregation"=>"Hourly", "Time"=>"Today", "ReturnOnlyCompleteData"=>false}
|
61
|
+
#
|
62
|
+
# Returns:: Hash
|
63
|
+
def to_hash(keys_case = :underscore)
|
64
|
+
hash = super(keys_case)
|
65
|
+
hash[get_attribute_key('aggregation', keys_case)] = AGGREGATIONS[self.aggregation.to_s]
|
66
|
+
hash[get_attribute_key('time', keys_case)] = time_to_hash(keys_case)
|
67
|
+
return hash
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def valid_aggregation(aggregation)
|
73
|
+
return AGGREGATIONS.key?(aggregation.to_s)
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
module BingAdsApi
|
4
|
+
|
5
|
+
##
|
6
|
+
# Public : Base Class to define Bing API data objects
|
7
|
+
# Do not use this class directly, use any of the derived classes
|
8
|
+
#
|
9
|
+
# Author:: jlopezn@neonline.cl
|
10
|
+
#
|
11
|
+
class DataObject
|
12
|
+
|
13
|
+
|
14
|
+
include BingAdsApi::SOAPHasheable
|
15
|
+
|
16
|
+
# Public : Constructor in a ActiveRecord style, with a hash of attributes as input
|
17
|
+
#
|
18
|
+
# Author:: jlopezn@neonline.cl
|
19
|
+
#
|
20
|
+
# attributes - Hash with the objects attributes
|
21
|
+
def initialize(attributes={})
|
22
|
+
attributes.each { |key, val| send("#{key}=", val) if respond_to?("#{key}=") }
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
# Public : Specified to string method
|
27
|
+
#
|
28
|
+
# Author:: jlopezn@neonline.cl
|
29
|
+
def to_s
|
30
|
+
to_hash.to_s
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
module BingAdsApi
|
4
|
+
|
5
|
+
# Public : Defines an error object that contains the details that explain why the service operation failed.
|
6
|
+
#
|
7
|
+
# Reference : http://msdn.microsoft.com/en-US/library/bing-ads-overview-adapierror.aspx
|
8
|
+
#
|
9
|
+
# Author:: jlopezn@neonline.cl
|
10
|
+
class AdApiError < BingAdsApi::DataObject
|
11
|
+
|
12
|
+
attr_accessor :code, :detail, :error_code, :message
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
module BingAdsApi
|
4
|
+
|
5
|
+
# Public : Defines a fault object that operations return when generic errors occur,
|
6
|
+
# such as an authentication error.
|
7
|
+
#
|
8
|
+
# Author:: jlopezn@neonline.cl
|
9
|
+
class AdApiFaultDetail < BingAdsApi::ApplicationFault
|
10
|
+
|
11
|
+
attr_accessor :errors
|
12
|
+
|
13
|
+
|
14
|
+
# Public : Constructor
|
15
|
+
#
|
16
|
+
# Author:: jlopezn@neonline.cl
|
17
|
+
#
|
18
|
+
# attributes - Hash with the initial attributes
|
19
|
+
# === Attributes
|
20
|
+
# * tracking_id : the operation tracking id value
|
21
|
+
# * errors : array of hashes with the Ad api errors
|
22
|
+
def initialize(attributes={})
|
23
|
+
super(attributes)
|
24
|
+
if attributes
|
25
|
+
initialize_errors(attributes[:errors])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Public : Specified to string method
|
30
|
+
#
|
31
|
+
# Author:: jlopezn@neonline.cl
|
32
|
+
def to_s
|
33
|
+
str = super.to_s + ":\n"
|
34
|
+
if batch_errors
|
35
|
+
str += "\tErrors:\n" + errors.map{ |e| "\t" + e.to_s }.join("\n")
|
36
|
+
end
|
37
|
+
|
38
|
+
return str
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
# Public : Helper method for the AdApiFaultDetail constructor
|
45
|
+
# to initialize the errors array
|
46
|
+
#
|
47
|
+
# Author:: jlopezn@neonline.cl
|
48
|
+
#
|
49
|
+
# errors_hash - Hash with the :errors key received from the SOAP request
|
50
|
+
#
|
51
|
+
# Returns:: none
|
52
|
+
def initialize_errors(errors_hash)
|
53
|
+
return if errors_hash.nil?
|
54
|
+
|
55
|
+
if errors_hash[:ad_api_error].is_a?(Array)
|
56
|
+
self.errors = []
|
57
|
+
errors_hash[:ad_api_error].each do |aae|
|
58
|
+
self.errors << BingAdsApi::AdApiError.new(aae)
|
59
|
+
end
|
60
|
+
elsif errors_hash[:ad_api_error].is_a?(Hash)
|
61
|
+
self.errors = [BingAdsApi::AdApiError.new(errors_hash[:ad_api_error])]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
module BingAdsApi
|
4
|
+
|
5
|
+
# Public : Defines a fault object that operations return when web service-specific errors occur,
|
6
|
+
# such as when the request message contains incomplete or invalid data.
|
7
|
+
#
|
8
|
+
# Author:: jlopezn@neonline.cl
|
9
|
+
class ApiFaultDetail < BingAdsApi::ApplicationFault
|
10
|
+
|
11
|
+
attr_accessor :batch_errors, :operation_errors
|
12
|
+
|
13
|
+
|
14
|
+
# Public : Constructor
|
15
|
+
#
|
16
|
+
# Author:: jlopezn@neonline.cl
|
17
|
+
#
|
18
|
+
# attributes - Hash with the initial attributes
|
19
|
+
# === Attributes
|
20
|
+
# * tracking_id : the operation tracking id value
|
21
|
+
# * batch_errors : array of hashes with the batch errors
|
22
|
+
# * operation_errors : array of hashes with the operation errors
|
23
|
+
def initialize(attributes={})
|
24
|
+
super(attributes)
|
25
|
+
if attributes
|
26
|
+
initialize_batch_errors(attributes[:batch_errors])
|
27
|
+
initialize_operations_errors(attributes[:operation_errors])
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
# Public : Specific to string
|
33
|
+
#
|
34
|
+
# Author:: jlopezn@neonline.cl
|
35
|
+
#
|
36
|
+
# Returns:: the object 'stringified'
|
37
|
+
def to_s
|
38
|
+
str = super.to_s + ":\n"
|
39
|
+
if batch_errors
|
40
|
+
str += "\tBatch Errors:\n" + batch_errors.map{ |be| "\t" + be.to_s }.join("\n")
|
41
|
+
end
|
42
|
+
|
43
|
+
if operation_errors
|
44
|
+
str += "\tOperation Errors:\n" + operation_errors.map{ |oe| "\t" + oe.to_s }.join("\n")
|
45
|
+
end
|
46
|
+
return str
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
# Public : Helper method for the ApiFaultDetail constructor
|
53
|
+
# to initialize the batch errors array
|
54
|
+
#
|
55
|
+
# Author:: jlopezn@neonline.cl
|
56
|
+
#
|
57
|
+
# batch_errors_hash - Hash with the :batch_errors key received from the SOAP request
|
58
|
+
#
|
59
|
+
# Returns:: none
|
60
|
+
def initialize_batch_errors(batch_errors_hash)
|
61
|
+
return if batch_errors_hash.nil?
|
62
|
+
|
63
|
+
if batch_errors_hash[:batch_error].is_a?(Array)
|
64
|
+
self.batch_errors = []
|
65
|
+
batch_errors_hash[:batch_error].each do |be|
|
66
|
+
self.batch_errors << BingAdsApi::BatchError.new(be)
|
67
|
+
end
|
68
|
+
elsif batch_errors_hash[:batch_error].is_a?(Hash)
|
69
|
+
self.batch_errors = [BingAdsApi::BatchError.new(batch_errors_hash[:batch_error])]
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
# Public : Helper method for the ApiFaultDetail constructor
|
75
|
+
# to initialize the operation errors array
|
76
|
+
#
|
77
|
+
# Author:: jlopezn@neonline.cl
|
78
|
+
#
|
79
|
+
# operation_errors_hash - Hash with the :operation_errors key received from the SOAP request
|
80
|
+
#
|
81
|
+
# Returns:: none
|
82
|
+
def initialize_operations_errors(operation_errors_hash)
|
83
|
+
return if operation_errors_hash.nil?
|
84
|
+
|
85
|
+
if operation_errors_hash[:operations_error].is_a?(Array)
|
86
|
+
self.operation_errors = []
|
87
|
+
operation_errors_hash[:operation_error].each do |oe|
|
88
|
+
self.operation_errors << BingAdsApi::OperationError.new(oe)
|
89
|
+
end
|
90
|
+
elsif operation_errors_hash[:operation_error].is_a?(Hash)
|
91
|
+
self.operation_errors = [BingAdsApi::OperationError.new(operation_errors_hash[:operation_error])]
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
module BingAdsApi
|
4
|
+
|
5
|
+
# Public : Defines the base object from which all fault detail objects derive.
|
6
|
+
#
|
7
|
+
# Reference: http://msdn.microsoft.com/en-US/library/bing-ads-overview-applicationfault.aspx
|
8
|
+
#
|
9
|
+
# Author:: jlopezn@neonline.cl
|
10
|
+
class ApplicationFault < BingAdsApi::DataObject
|
11
|
+
|
12
|
+
attr_accessor :tracking_id
|
13
|
+
|
14
|
+
def to_s
|
15
|
+
return tracking_id.to_s
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
module BingAdsApi
|
4
|
+
|
5
|
+
# Public : Defines an error object that identifies the item within the batch of items
|
6
|
+
# in the request message that caused the operation to fail, and describes the reason for the failure.
|
7
|
+
#
|
8
|
+
# Author:: jlopezn@neonline.cl
|
9
|
+
#
|
10
|
+
# Reference : http://msdn.microsoft.com/en-US/library/bing-ads-overview-batcherror.aspx
|
11
|
+
class BatchError < BingAdsApi::DataObject
|
12
|
+
|
13
|
+
attr_accessor :code, :details, :error_code, :index, :message, :type
|
14
|
+
|
15
|
+
# Public : Specified to string method
|
16
|
+
#
|
17
|
+
# Author:: jlopezn@neonline.cl
|
18
|
+
def to_s
|
19
|
+
"#{index}:#{code}:#{error_code} - #{message} (#{type})"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Public : Subclass of BatchError present in AdAdds operations
|
24
|
+
# Defines an error object that identifies the entity with the
|
25
|
+
# batch of entities that failed editorial review.
|
26
|
+
#
|
27
|
+
# Reference : http://msdn.microsoft.com/en-US/library/bing-ads-overview-editorialerror.aspx
|
28
|
+
#
|
29
|
+
# Author:: jlopezn@neonline.cl
|
30
|
+
class EditorialError < BingAdsApi::BatchError
|
31
|
+
|
32
|
+
attr_accessor :appaleable, :disapproved_text, :location, :publisher_country, :reason_code
|
33
|
+
|
34
|
+
# Public : Specified to string method
|
35
|
+
#
|
36
|
+
# Author:: jlopezn@neonline.cl
|
37
|
+
def to_s
|
38
|
+
str = super() + "\n"
|
39
|
+
str += "\tAppaleable? #{appaleable}\n" if appaleable
|
40
|
+
str += "\tDisapproved text: #{disapproved_text}\n" if disapproved_text
|
41
|
+
str += "\tLocation: #{location}\n" if location
|
42
|
+
str += "\tDisapproved text: #{disapproved_text}\n" if disapproved_text
|
43
|
+
str += "\tReason code: #{reason_code} (see: http://msdn.microsoft.com/en-US/library/bing-ads-editorialfailurereasoncodes.aspx)\n" if reason_code
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
module BingAdsApi
|
4
|
+
|
5
|
+
# Public : Defines an error object that contains the details that explain why the service operation failed.
|
6
|
+
#
|
7
|
+
# Author:: jlopezn@neonline.cl
|
8
|
+
#
|
9
|
+
# Reference : http://msdn.microsoft.com/en-US/library/bing-ads-overview-operationerror.aspx
|
10
|
+
class OperationError < BingAdsApi::DataObject
|
11
|
+
|
12
|
+
attr_accessor :code, :details, :error_code, :message
|
13
|
+
|
14
|
+
|
15
|
+
# Public : Specified to string method
|
16
|
+
#
|
17
|
+
# Author:: jlopezn@neonline.cl
|
18
|
+
def to_s
|
19
|
+
"#{code}:#{error_code} - #{message}. #{details}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
module BingAdsApi
|
4
|
+
|
5
|
+
# Public : Defines an array of error that occur when adding ads
|
6
|
+
#
|
7
|
+
# Author:: jlopezn@neonline.cl
|
8
|
+
class PartialErrors < BingAdsApi::DataObject
|
9
|
+
|
10
|
+
attr_accessor :batch_errors
|
11
|
+
|
12
|
+
|
13
|
+
# Public : Constructor
|
14
|
+
#
|
15
|
+
# Author:: jlopezn@neonline.cl
|
16
|
+
#
|
17
|
+
# attributes - Hash with the initial attributes
|
18
|
+
# === Attributes
|
19
|
+
# * tracking_id : the operation tracking id value
|
20
|
+
# * batch_error : array of hashes with the batch errors
|
21
|
+
def initialize(attributes={})
|
22
|
+
super(attributes)
|
23
|
+
if attributes
|
24
|
+
initialize_batch_errors(attributes)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
# Public : Specified to string method
|
30
|
+
#
|
31
|
+
# Author:: jlopezn@neonline.cl
|
32
|
+
def to_s
|
33
|
+
str = " Batch Errors:\n"
|
34
|
+
if batch_errors
|
35
|
+
str += batch_errors.map{ |be| "\t" + be.to_s }.join("\n")
|
36
|
+
end
|
37
|
+
|
38
|
+
return str
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
# Public : Helper method for the ApiFaultDetail constructor
|
45
|
+
# to initialize the batch errors array
|
46
|
+
#
|
47
|
+
# Author:: jlopezn@neonline.cl
|
48
|
+
#
|
49
|
+
# batch_errors_hash - Hash with the :batch_errors key received from the SOAP request
|
50
|
+
#
|
51
|
+
# Returns:: none
|
52
|
+
def initialize_batch_errors(batch_errors_hash)
|
53
|
+
return if batch_errors_hash.nil?
|
54
|
+
|
55
|
+
if batch_errors_hash[:batch_error].is_a?(Array)
|
56
|
+
self.batch_errors = []
|
57
|
+
batch_errors_hash[:batch_error].each do |be|
|
58
|
+
self.batch_errors << init_batch_error(be)
|
59
|
+
end
|
60
|
+
elsif batch_errors_hash[:batch_error].is_a?(Hash)
|
61
|
+
self.batch_errors = [ init_batch_error(batch_errors_hash[:batch_error]) ]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
def init_batch_error(batch_error_hash)
|
67
|
+
if batch_error_hash.key?("@i:type".to_sym) && batch_error_hash["@i:type".to_sym] == "EditorialError"
|
68
|
+
return BingAdsApi::EditorialError.new(batch_error_hash)
|
69
|
+
else
|
70
|
+
return BingAdsApi::BatchError.new(batch_error_hash)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|