gnib-ads-api 0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +121 -0
  4. data/Rakefile +38 -0
  5. data/lib/gnib-ads-api.rb +44 -0
  6. data/lib/gnib-ads-api.yml +355 -0
  7. data/lib/gnib-ads-api/api_exception.rb +42 -0
  8. data/lib/gnib-ads-api/client_proxy.rb +147 -0
  9. data/lib/gnib-ads-api/config.rb +75 -0
  10. data/lib/gnib-ads-api/constants.rb +150 -0
  11. data/lib/gnib-ads-api/data/accounts_info.rb +72 -0
  12. data/lib/gnib-ads-api/data/ad.rb +119 -0
  13. data/lib/gnib-ads-api/data/ad_group.rb +121 -0
  14. data/lib/gnib-ads-api/data/campaign.rb +40 -0
  15. data/lib/gnib-ads-api/data/report_request.rb +78 -0
  16. data/lib/gnib-ads-api/data/report_request_status.rb +48 -0
  17. data/lib/gnib-ads-api/data/reporting/account_performance_report_request.rb +176 -0
  18. data/lib/gnib-ads-api/data/reporting/campaign_performance_report_request.rb +186 -0
  19. data/lib/gnib-ads-api/data/reporting/helpers/column_helper.rb +65 -0
  20. data/lib/gnib-ads-api/data/reporting/helpers/filter_helper.rb +124 -0
  21. data/lib/gnib-ads-api/data/reporting/helpers/scope_helper.rb +51 -0
  22. data/lib/gnib-ads-api/data/reporting/helpers/time_helper.rb +69 -0
  23. data/lib/gnib-ads-api/data/reporting/performance_report_request.rb +78 -0
  24. data/lib/gnib-ads-api/data_object.rb +35 -0
  25. data/lib/gnib-ads-api/fault/ad_api_error.rb +15 -0
  26. data/lib/gnib-ads-api/fault/ad_api_fault_detail.rb +67 -0
  27. data/lib/gnib-ads-api/fault/api_fault_detail.rb +97 -0
  28. data/lib/gnib-ads-api/fault/application_fault.rb +18 -0
  29. data/lib/gnib-ads-api/fault/batch_error.rb +47 -0
  30. data/lib/gnib-ads-api/fault/operation_error.rb +22 -0
  31. data/lib/gnib-ads-api/fault/partial_errors.rb +75 -0
  32. data/lib/gnib-ads-api/service.rb +176 -0
  33. data/lib/gnib-ads-api/service/campaign_management.rb +483 -0
  34. data/lib/gnib-ads-api/service/customer_management.rb +83 -0
  35. data/lib/gnib-ads-api/service/reporting.rb +101 -0
  36. data/lib/gnib-ads-api/soap_hasheable.rb +160 -0
  37. data/lib/gnib-ads-api/version.rb +6 -0
  38. data/lib/locales/es.yml +174 -0
  39. data/lib/tasks/gnib-ads-api_tasks.rake +4 -0
  40. data/test/campaign_management_test.rb +463 -0
  41. data/test/customer_management_test.rb +44 -0
  42. data/test/data_object_test.rb +46 -0
  43. data/test/dummy/README.rdoc +261 -0
  44. data/test/dummy/Rakefile +7 -0
  45. data/test/dummy/app/assets/javascripts/application.js +15 -0
  46. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  47. data/test/dummy/app/controllers/application_controller.rb +3 -0
  48. data/test/dummy/app/helpers/application_helper.rb +2 -0
  49. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  50. data/test/dummy/config.ru +4 -0
  51. data/test/dummy/config/application.rb +56 -0
  52. data/test/dummy/config/boot.rb +10 -0
  53. data/test/dummy/config/database.yml +25 -0
  54. data/test/dummy/config/environment.rb +5 -0
  55. data/test/dummy/config/environments/development.rb +37 -0
  56. data/test/dummy/config/environments/production.rb +67 -0
  57. data/test/dummy/config/environments/test.rb +37 -0
  58. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  59. data/test/dummy/config/initializers/inflections.rb +15 -0
  60. data/test/dummy/config/initializers/mime_types.rb +5 -0
  61. data/test/dummy/config/initializers/secret_token.rb +7 -0
  62. data/test/dummy/config/initializers/session_store.rb +8 -0
  63. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  64. data/test/dummy/config/locales/en.yml +5 -0
  65. data/test/dummy/config/routes.rb +58 -0
  66. data/test/dummy/public/404.html +26 -0
  67. data/test/dummy/public/422.html +26 -0
  68. data/test/dummy/public/500.html +25 -0
  69. data/test/dummy/public/favicon.ico +0 -0
  70. data/test/dummy/script/rails +6 -0
  71. data/test/gnib-ads-api_test.rb +172 -0
  72. data/test/report_request_test.rb +312 -0
  73. data/test/reporting_test.rb +145 -0
  74. data/test/test_helper.rb +11 -0
  75. metadata +193 -0
@@ -0,0 +1,119 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ module GnibAdsApi
4
+
5
+ ##
6
+ # Public : Defines the base object of an ad.
7
+ # Do not instantiate this object. Instead you can instantiate the
8
+ # GnibAdsApi::TextAd, GnibAdsApi::MobileAd, or GnibAdsApi::ProductAd
9
+ # object that derives from this object.
10
+ #
11
+ # Reference: http://msdn.microsoft.com/en-US/library/bing-ads-campaign-management-ad.aspx
12
+ #
13
+ # Author:: jlopezn@neonline.cl
14
+ #
15
+ class Ad < GnibAdsApi::DataObject
16
+ include GnibAdsApi::AdEditorialStatus
17
+ include GnibAdsApi::AdStatus
18
+ include GnibAdsApi::AdType
19
+
20
+
21
+ attr_accessor :id,
22
+
23
+ :device_preference,
24
+ :editorial_status,
25
+
26
+ :status,
27
+ :type
28
+
29
+ end
30
+
31
+ ##
32
+ # Public : Defines a text ad.
33
+ #
34
+ # Reference: http://msdn.microsoft.com/en-US/library/bing-ads-campaign-management-textad.aspx
35
+ #
36
+ # Author:: jlopezn@neonline.cl
37
+ #
38
+ class TextAd < GnibAdsApi::Ad
39
+
40
+ attr_accessor :destination_url,
41
+ :display_url,
42
+ :text,
43
+ :title
44
+
45
+ # Public : Specification of DataObject#to_hash method that ads the type attribute based on this specific class
46
+ #
47
+ # Author:: jlopezn@neonline.cl
48
+ #
49
+ # keys - specifies the keys case
50
+ #
51
+ # Returns:: Hash
52
+ def to_hash(keys = :underscore)
53
+ hash = super(keys)
54
+ hash[get_attribute_key("type", keys)] = "Text"
55
+ return hash
56
+ end
57
+ end
58
+
59
+
60
+ ##
61
+ # Public : Defines a mobile ad. A mobile ad is displayed to a user
62
+ # when the ad is viewed on a low-fi mobile device.
63
+ #
64
+ # Reference: http://msdn.microsoft.com/en-US/library/bing-ads-campaign-management-mobilead.aspx
65
+ #
66
+ # Author:: jlopezn@neonline.cl
67
+ #
68
+ class MobileAd < GnibAdsApi::Ad
69
+
70
+ attr_accessor :business_name,
71
+ :destination_url,
72
+ :display_url,
73
+ :phone_number,
74
+ :text,
75
+ :title
76
+
77
+ # Public : Specification of DataObject#to_hash method that ads the type attribute based on this specific class
78
+ #
79
+ # Author:: jlopezn@neonline.cl
80
+ #
81
+ # keys - specifies the keys case
82
+ #
83
+ # Returns:: Hash
84
+ def to_hash(keys = :underscore)
85
+ hash = super(keys)
86
+ hash[get_attribute_key("type", keys)] = "Mobile"
87
+ return hash
88
+ end
89
+
90
+ end
91
+
92
+
93
+ ##
94
+ # Public : Defines a product ad.
95
+ #
96
+ # Reference: http://msdn.microsoft.com/en-US/library/bing-ads-productad-campaign-management.aspx
97
+ #
98
+ # Author:: jlopezn@neonline.cl
99
+ #
100
+ class ProductAd < GnibAdsApi::Ad
101
+
102
+ attr_accessor :promotional_text
103
+
104
+ # Public : Specification of DataObject#to_hash method that ads the type attribute based on this specific class
105
+ #
106
+ # Author:: jlopezn@neonline.cl
107
+ #
108
+ # keys - specifies the keys case
109
+ #
110
+ # Returns:: Hash
111
+ def to_hash(keys = :underscore)
112
+ hash = super(keys)
113
+ hash[get_attribute_key("type", keys)] = "Product"
114
+ return hash
115
+ end
116
+
117
+ end
118
+
119
+ end
@@ -0,0 +1,121 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ module GnibAdsApi
4
+
5
+ # Public : Defines an ad group.
6
+ #
7
+ # Author:: jlopezn@neonline.cl
8
+ #
9
+ # Examples
10
+ # ad_group = GnibAdsApi::AdGroup.new(
11
+ # :ad_distribution => GnibAdsApi::AdGroup::SEARCH,
12
+ # :language => GnibAdsApi::AdGroup::SPANISH,
13
+ # :name => "Ad Group name",
14
+ # :pricing_model => GnibAdsApi::AdGroup::CPC,
15
+ # :bidding_model => GnibAdsApi::AdGroup::KEYWORD)
16
+ # # => <GnibAdsApi::AdGroup>
17
+ class AdGroup < GnibAdsApi::DataObject
18
+ include GnibAdsApi::AdDistribution
19
+ include GnibAdsApi::AdRotationType
20
+ include GnibAdsApi::PricingModel
21
+ include GnibAdsApi::BiddingModel
22
+ include GnibAdsApi::AdLanguage
23
+ include GnibAdsApi::AdGroupStatus
24
+
25
+
26
+ attr_accessor :id,
27
+ :ad_distribution,
28
+ :ad_rotation,
29
+
30
+ :broad_match_bid,
31
+ :content_match_bid,
32
+ :exact_match_bid,
33
+ :phrase_match_bid,
34
+
35
+ :bidding_model,
36
+ :pricing_model,
37
+
38
+ :language,
39
+ :name,
40
+ :status,
41
+
42
+ :start_date,
43
+ :end_date
44
+
45
+
46
+
47
+ # Public : Constructor in a ActiveRecord style, with a hash of attributes as input
48
+ #
49
+ # Author:: jlopezn@neonline.cl
50
+ #
51
+ # attributes - Hash with the objects attributes
52
+ def initialize(attributes={})
53
+ super(attributes)
54
+ set_custom_attributes(attributes)
55
+ end
56
+
57
+
58
+ # Public : Returns this object as a hash to SOAP requests
59
+ # This methods is a specialization for the +DataObject#to_hash+ method
60
+ # that ads specific hash keys for the AdGroup object
61
+ #
62
+ # Author:: jlopezn@neonline.cl
63
+ #
64
+ # keys - specifies the keys case: CamelCase or underscore_case
65
+ #
66
+ # Returns:: Hash
67
+ def to_hash(keys = :underscore)
68
+ hash = super(keys)
69
+
70
+ amount_key = get_attribute_key("amount", keys)
71
+ if self.content_match_bid
72
+ #hash.delete(:content_match_bid)
73
+ hash[get_attribute_key("content_match_bid", keys)] = {amount_key => self.content_match_bid}
74
+ end
75
+
76
+ if self.exact_match_bid
77
+ hash[get_attribute_key("exact_match_bid", keys)] = {amount_key => self.exact_match_bid}
78
+ end
79
+
80
+ if self.phrase_match_bid
81
+ hash[get_attribute_key("phrase_match_bid", keys)] = {amount_key => self.phrase_match_bid}
82
+ end
83
+
84
+ if self.broad_match_bid
85
+ hash[get_attribute_key("broad_match_bid", keys)] = {amount_key => self.broad_match_bid}
86
+ end
87
+
88
+ if self.start_date
89
+ hash[get_attribute_key("start_date", keys)] = date_to_hash(self.start_date, keys)
90
+ end
91
+
92
+ if self.end_date
93
+ hash[get_attribute_key("end_date", keys)] = date_to_hash(self.end_date, keys)
94
+ end
95
+
96
+ return hash
97
+ end
98
+
99
+
100
+ private
101
+ def set_custom_attributes(attributes)
102
+ self.content_match_bid = attributes[:content_match_bid][:amount] if attributes.key?(:content_match_bid)
103
+ self.exact_match_bid = attributes[:exact_match_bid][:amount] if attributes.key?(:exact_match_bid)
104
+ self.phrase_match_bid = attributes[:phrase_match_bid][:amount] if attributes.key?(:phrase_match_bid)
105
+ self.broad_match_bid = attributes[:broad_match_bid][:amount] if attributes.key?(:broad_match_bid)
106
+
107
+ if attributes.key?(:start_date) && !attributes[:start_date].nil?
108
+ self.start_date = DateTime.strptime(
109
+ "#{attributes[:start_date][:year]}-#{attributes[:start_date][:month]}-#{attributes[:start_date][:day]}",
110
+ "%Y-%m-%d")
111
+ end
112
+
113
+ if attributes.key?(:end_date) && !attributes[:end_date].nil?
114
+ self.end_date = DateTime.strptime(
115
+ "#{attributes[:end_date][:year]}-#{attributes[:end_date][:month]}-#{attributes[:end_date][:day]}",
116
+ "%Y-%m-%d")
117
+ end
118
+
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,40 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ module GnibAdsApi
4
+
5
+ # Public : Define a campaign
6
+ #
7
+ # Author:: jlopezn@neonline.cl
8
+ #
9
+ # Examples
10
+ # campaign = GnibAdsApi::Campaign.new(
11
+ # :budget_type => GnibAdsApi::Campaign::DAILY_BUDGET_STANDARD,
12
+ # :conversion_tracking_enabled => "false",
13
+ # :daily_budget => 2000,
14
+ # :daylight_saving => "false",
15
+ # :description => name + " first description",
16
+ # :monthly_budget => 5400,
17
+ # :name => name + " first name",
18
+ # :status => GnibAdsApi::Campaign::PAUSED,
19
+ # :time_zone => GnibAdsApi::Campaign::SANTIAGO)
20
+ # # => <GnibAdsApi::Campaign>
21
+ class Campaign < GnibAdsApi::DataObject
22
+ include GnibAdsApi::TimeZone
23
+ include GnibAdsApi::BudgetLimitType
24
+ include GnibAdsApi::CampaignStatus
25
+ include GnibAdsApi::PricingModel
26
+
27
+
28
+ attr_accessor :id,
29
+ :budget_type,
30
+ :conversion_tracking_enabled,
31
+ :daily_budget,
32
+ :daylight_saving,
33
+ :description,
34
+ :monthly_budget,
35
+ :name,
36
+ :status,
37
+ :time_zone
38
+
39
+ end
40
+ end
@@ -0,0 +1,78 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ module GnibAdsApi
4
+
5
+ ##
6
+ # Public : Defines the base object for all report requests.
7
+ # Do not instantiate this object. Instead, you may instantiate one
8
+ # of the following report request objects which derives from this object to request a report.
9
+ #
10
+ # Reference: http://msdn.microsoft.com/en-us/library/bing-ads-reporting-bing-ads-reportrequest.aspx
11
+ #
12
+ # Author:: jlopezn@neonline.cl
13
+ class ReportRequest < GnibAdsApi::DataObject
14
+
15
+ # Valid Formats for reports
16
+ FORMATS = GnibAdsApi::Config.instance.
17
+ reporting_constants['format']
18
+
19
+ # Valid languages for reports
20
+ LANGUAGES = GnibAdsApi::Config.instance.
21
+ reporting_constants['language']
22
+
23
+ # Valid report request status for reports
24
+ REQUEST_STATUS = GnibAdsApi::Config.instance.
25
+ reporting_constants['request_status_type']
26
+
27
+ attr_accessor :format, :language, :report_name, :return_only_complete_data
28
+
29
+ # Public : Constructor. Adds validations to format and language attributes
30
+ #
31
+ # Author:: jlopezn@neonline.cl
32
+ #
33
+ # === Parameters
34
+ # attributes - Hash with Report request parameters
35
+ def initialize(attributes={})
36
+ raise Exception.new("Invalid format '#{attributes[:format]}'") if !valid_format(attributes[:format])
37
+ raise Exception.new("Invalid language '#{attributes[:language]}'") if !valid_language(attributes[:language])
38
+ super(attributes)
39
+ self.return_only_complete_data = attributes[:return_only_complete_data] || false
40
+ end
41
+
42
+
43
+ # Public:: Returns this object as a Hash for SOAP Requests
44
+ #
45
+ # Author:: jlopezn@neonline.cl
46
+ #
47
+ # === Parameters
48
+ # * +keys_case+ - specifies the case for the hash keys
49
+ # ==== keys_case
50
+ # * :camelcase - CamelCase
51
+ # * :underscore - underscore_case
52
+ #
53
+ # === Examples
54
+ # report_request.to_hash(:camelcase)
55
+ # # => {"Format"=>"Xml", "Language"=>"English", "ReportName"=>"My Report", "ReturnOnlyCompleteData"=>true}
56
+ #
57
+ # Returns:: Hash
58
+ def to_hash(keys_case = :underscore)
59
+ hash = super(keys_case)
60
+ hash[get_attribute_key('format', keys_case)] = FORMATS[self.format.to_s]
61
+ hash[get_attribute_key('language', keys_case)] = LANGUAGES[self.language.to_s]
62
+ return hash
63
+ end
64
+
65
+ private
66
+
67
+ def valid_format(format)
68
+ return FORMATS.key?(format.to_s)
69
+ end
70
+
71
+
72
+ def valid_language(language)
73
+ return LANGUAGES.key?(language.to_s)
74
+ end
75
+
76
+ end
77
+
78
+ end
@@ -0,0 +1,48 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ module GnibAdsApi
4
+
5
+ ##
6
+ # Public : Defines the status of a report request.
7
+ #
8
+ # Reference: http://msdn.microsoft.com/en-US/library/bing-ads-reporting-bing-ads-reportrequeststatus.aspx
9
+ #
10
+ # Author:: jlopezn@neonline.cl
11
+ class ReportRequestStatus < GnibAdsApi::DataObject
12
+
13
+ # Valid report request status for reports
14
+ REQUEST_STATUS = GnibAdsApi::Config.instance.
15
+ reporting_constants['request_status_type']
16
+
17
+ attr_accessor :report_download_url, :status
18
+
19
+ # Public:: Returns true if the status is success
20
+ #
21
+ # Author:: jlopezn@neonline.cl
22
+ #
23
+ # Returns:: boolean
24
+ def success?
25
+ return status == REQUEST_STATUS['success']
26
+ end
27
+
28
+ # Public:: Returns true if the status is pending
29
+ #
30
+ # Author:: jlopezn@neonline.cl
31
+ #
32
+ # Returns:: boolean
33
+ def pending?
34
+ return status == REQUEST_STATUS['pending']
35
+ end
36
+
37
+ # Public:: Returns true if the status is error
38
+ #
39
+ # Author:: jlopezn@neonline.cl
40
+ #
41
+ # Returns:: boolean
42
+ def error?
43
+ return status == REQUEST_STATUS['error']
44
+ end
45
+
46
+ end
47
+
48
+ end
@@ -0,0 +1,176 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ module GnibAdsApi
4
+
5
+ ##
6
+ # Public : Defines the base object for all report requests.
7
+ # Do not instantiate this object. Instead, you may instantiate one
8
+ # of the following report request objects which derives from this object to request a report.
9
+ #
10
+ # Reference: http://msdn.microsoft.com/en-us/library/bing-ads-reporting-bing-ads-reportrequest.aspx
11
+ #
12
+ # Author:: jlopezn@neonline.cl
13
+ #
14
+ # === Usage
15
+ #
16
+ # request = GnibAdsApi::AccountPerformanceReportRequest.new(
17
+ # :format => :xml,
18
+ # :language => :english,
19
+ # :report_name => "Me report",
20
+ # :aggregation => :hourly,
21
+ # :columns => [:account_name, :account_number, :time_period],
22
+ # # The filter is specified as a hash
23
+ # :filter => {
24
+ # :ad_distribution => :search,
25
+ # :device_os => :android,
26
+ # :device_type => :tablet,
27
+ # :status => :submited },
28
+ # :scope => {
29
+ # :account_ids => [123456, 234567],
30
+ # :campaigns => [<GnibAdsApi::CampaignReportScope>] },
31
+ # # predefined date
32
+ # :time => :this_week)
33
+ #
34
+ # request2 = GnibAdsApi::AccountPerformanceReportRequest.new(
35
+ # :format => :csv,
36
+ # :language => :french,
37
+ # :report_name => "Me report",
38
+ # :aggregation => :daily,
39
+ # :columns => [:account_name, :account_number, :time_period],
40
+ # # no filter is specified
41
+ # :scope => {
42
+ # :account_ids => [123456, 234567],
43
+ # :campaigns => [<GnibAdsApi::CampaignReportScope>] },
44
+ # # Custom date range
45
+ # :time => {
46
+ # :custom_date_range_start => {:day => 1, :month => 12, :year => 2013},
47
+ # :custom_date_range_end => {:day => 12, :month => 12, :year => 2013} }
48
+ # )
49
+ class AccountPerformanceReportRequest < GnibAdsApi::PerformanceReportRequest
50
+
51
+ # Valid Columns for this report request
52
+ COLUMNS = GnibAdsApi::Config.instance.
53
+ reporting_constants['account_performance_report']['columns']
54
+
55
+ # Valid Filters for this report request
56
+ FILTERS = GnibAdsApi::Config.instance.
57
+ reporting_constants['account_performance_report']['filter']
58
+
59
+
60
+ # Public : Constructor. Adds a validations for the columns, filter
61
+ # and scope attributes
62
+ #
63
+ # Author:: jlopezn@neonline.cl
64
+ #
65
+ # === Parameters
66
+ # attributes - Hash with the report request attributes
67
+ #
68
+ # === Example
69
+ #
70
+ # request = GnibAdsApi::AccountPerformanceReportRequest.new(
71
+ # :format => :xml,
72
+ # :language => :english,
73
+ # :report_name => "Me report",
74
+ # :aggregation => :hourly,
75
+ # :columns => [:account_name, :account_number, :time_period],
76
+ # # The filter is specified as a hash
77
+ # :filter => {
78
+ # :ad_distribution => :search,
79
+ # :device_os => :android,
80
+ # :device_type => :tablet,
81
+ # :status => :submited },
82
+ # :scope => {
83
+ # :account_ids => [123456, 234567],
84
+ # :campaigns => [<GnibAdsApi::CampaignReportScope>] },
85
+ # # predefined date
86
+ # :time => :this_week)
87
+ #
88
+ # request2 = GnibAdsApi::AccountPerformanceReportRequest.new(
89
+ # :format => :csv,
90
+ # :language => :french,
91
+ # :report_name => "Me report",
92
+ # :aggregation => :daily,
93
+ # :columns => [:account_name, :account_number, :time_period],
94
+ # # no filter is specified
95
+ # :scope => {
96
+ # :account_ids => [123456, 234567],
97
+ # :campaigns => [<GnibAdsApi::CampaignReportScope>] },
98
+ # # Custom date range
99
+ # :time => {
100
+ # :custom_date_range_start => {:day => 1, :month => 12, :year => 2013},
101
+ # :custom_date_range_end => {:day => 12, :month => 12, :year => 2013} }
102
+ # )
103
+ def initialize(attributes={})
104
+ raise "Invalid columns" if !valid_columns(COLUMNS, attributes[:columns])
105
+ raise "Invalid filters" if !valid_filter(FILTERS, attributes[:filter])
106
+ raise "Invalid scope" if !valid_scope(attributes[:scope])
107
+ super(attributes)
108
+ end
109
+
110
+ # Public:: Returns the object as a Hash valid for SOAP requests
111
+ #
112
+ # Author:: jlopezn@neonline.cl
113
+ #
114
+ # === Parameters
115
+ # * +keys_case+ - case for the hashes keys: underscore or camelcase
116
+ #
117
+ # Returns:: Hash
118
+ def to_hash(keys = :underscore)
119
+ hash = super(keys)
120
+ hash[get_attribute_key('columns', keys)] =
121
+ columns_to_hash(COLUMNS, columns, keys)
122
+ hash[get_attribute_key('filter', keys)] =
123
+ filter_to_hash(FILTERS, keys)
124
+ hash[get_attribute_key('scope', keys)] = scope_to_hash(keys)
125
+ hash["@xsi:type"] = type_attribute_for_soap
126
+ return hash
127
+ end
128
+
129
+ private
130
+
131
+
132
+
133
+ # Internal:: Validates the scope attribute given in the constructor
134
+ #
135
+ # Author:: jlopezn@neonline.cl
136
+ #
137
+ # === Parameters
138
+ # * +scope+ - value for the 'scope' key in the has initializer
139
+ #
140
+ # Returns:: true if the scope specification is valid. Raises Exception otherwise
141
+ #
142
+ # Raises:: Exception if the scope is not valid
143
+ def valid_scope(scope)
144
+ raise Exception.new("Invalid scope: no account_ids key") if !scope.key?(:account_ids)
145
+ return true
146
+ end
147
+
148
+
149
+ # Internal:: Returns the scope attribute as a hash for the SOAP request
150
+ #
151
+ # Author:: jlopezn@neonline.cl
152
+ #
153
+ # === Parameters
154
+ # * +keys_case+ - case for the hash: underscore or camelcase
155
+ #
156
+ # Returns:: Hash
157
+ def scope_to_hash(keys_case=:underscore)
158
+ return { get_attribute_key('account_ids', keys_case) =>
159
+ {"ins0:long" => object_to_hash(scope[:account_ids], keys_case)} }
160
+ end
161
+
162
+
163
+ # Internal:: Returns a string with type attribute for the ReportRequest SOAP tag
164
+ #
165
+ # Author:: jlopezn@neonline.cl
166
+ #
167
+ # Returns:: "v9:AccountPerformanceReportRequest"
168
+ def type_attribute_for_soap
169
+ return GnibAdsApi::ClientProxy::NAMESPACE.to_s + ":" +
170
+ GnibAdsApi::Config.instance.
171
+ reporting_constants['account_performance_report']['type']
172
+ end
173
+
174
+ end
175
+
176
+ end