bing-ads-api 0.1.0
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.
- 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,101 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module BingAdsApi
|
3
|
+
|
4
|
+
# Public : This class represents the Reporting Services
|
5
|
+
# defined in the Bing Ads API, to request and download reports
|
6
|
+
#
|
7
|
+
# Author:: jlopezn@neonline.cl
|
8
|
+
#
|
9
|
+
# Examples
|
10
|
+
# options = {
|
11
|
+
# :environment => :sandbox,
|
12
|
+
# :username => "username",
|
13
|
+
# :password => "pass",
|
14
|
+
# :developer_token => "SOME_TOKEN",
|
15
|
+
# :customer_id => "1234567",
|
16
|
+
# :account_id => "9876543" }
|
17
|
+
# service = BingAdsApi::Reporting.new(options)
|
18
|
+
class Reporting < BingAdsApi::Service
|
19
|
+
|
20
|
+
|
21
|
+
# Public : Get the status of a report request
|
22
|
+
#
|
23
|
+
# Author:: jlopezn@neonline.cl
|
24
|
+
#
|
25
|
+
# === Parameters
|
26
|
+
# +report_request_id+ - Identifier of the report request
|
27
|
+
#
|
28
|
+
# === Examples
|
29
|
+
# service.poll_generate_report("12345")
|
30
|
+
# # => Hash
|
31
|
+
#
|
32
|
+
# Returns:: Hash with the PollGenerateReportResponse structure
|
33
|
+
#
|
34
|
+
# Raises:: exception
|
35
|
+
def poll_generate_report(report_request_id)
|
36
|
+
response = call(:poll_generate_report,
|
37
|
+
{report_request_id: report_request_id} )
|
38
|
+
response_hash = get_response_hash(response, __method__)
|
39
|
+
report_request_status = BingAdsApi::ReportRequestStatus.new(
|
40
|
+
response_hash[:report_request_status])
|
41
|
+
return report_request_status
|
42
|
+
end
|
43
|
+
|
44
|
+
# Public : Submits a report request
|
45
|
+
#
|
46
|
+
# Author:: jlopezn@neonline.cl
|
47
|
+
#
|
48
|
+
# === Parameters
|
49
|
+
# +report_request+ - a BingAdsApi::ReportRequest subclass instance
|
50
|
+
#
|
51
|
+
# === Examples
|
52
|
+
# ==== CampaignPerformanceReportRequest
|
53
|
+
# report_request = BingAdsApi::CampaignPerformanceReportRequest.new(:format => :xml,
|
54
|
+
# :language => :english,
|
55
|
+
# :report_name => "My Report",
|
56
|
+
# :aggregation => :hourly,
|
57
|
+
# :columns => [:account_name, :account_number, :time_period,
|
58
|
+
# :campaign_name, :campaign_id, :status, :currency_code,
|
59
|
+
# :impressions, :clicks, :ctr, :average_cpc, :spend,
|
60
|
+
# :conversions, :conversion_rate, :cost_per_conversion, :average_cpm ],
|
61
|
+
# :filter => {
|
62
|
+
# # String as bing expected
|
63
|
+
# :ad_distribution => "Search",
|
64
|
+
# :device_os => "Windows",
|
65
|
+
# # snake case symbol
|
66
|
+
# :device_type => :computer,
|
67
|
+
# # nil criteria
|
68
|
+
# :status => nil
|
69
|
+
# },
|
70
|
+
# :scope => {:account_ids => 5978083,
|
71
|
+
# :campaigns => [
|
72
|
+
# {:account_id => 5978083, :campaign_id => 1951230156},
|
73
|
+
# {:account_id => 5978083, :campaign_id => 1951245412},
|
74
|
+
# {:account_id => 5978083, :campaign_id => 1951245474}]
|
75
|
+
# },
|
76
|
+
# :time => {
|
77
|
+
# :custom_date_range_end => {:day => 31, :month => 12, :year => 2013},
|
78
|
+
# :custom_date_range_start => {:day => 1, :month => 12, :year => 2013},
|
79
|
+
# })
|
80
|
+
# report_request_id = reporting_service.submit_generate_report(report_request)
|
81
|
+
# # => "1234567890"
|
82
|
+
#
|
83
|
+
# Returns:: String with the requested report id
|
84
|
+
#
|
85
|
+
# Raises:: Exception if report_request is invalid or SOAP request failed
|
86
|
+
def submit_generate_report(report_request)
|
87
|
+
response = call(:submit_generate_report,
|
88
|
+
{report_request: report_request.to_hash(:camelcase)})
|
89
|
+
response_hash = get_response_hash(response, __method__)
|
90
|
+
report_request_id = response_hash[:report_request_id]
|
91
|
+
return report_request_id
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
private
|
96
|
+
def get_service_name
|
97
|
+
"reporting"
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
module BingAdsApi
|
4
|
+
|
5
|
+
##
|
6
|
+
# Public:: Module to define an object as Hasheable for the SOAP requests
|
7
|
+
#
|
8
|
+
# Author:: jlopezn@neonline.cl
|
9
|
+
module SOAPHasheable
|
10
|
+
|
11
|
+
|
12
|
+
# Internal: Metodo custom para transformar a hash un objeto.
|
13
|
+
# Se puede indicar si se desean las keys en formato CamelCase o underscore_case
|
14
|
+
#
|
15
|
+
# Author:: asaavedrab@neonline.cl
|
16
|
+
#
|
17
|
+
# === Parameters
|
18
|
+
# * keys_case - indica si las keys del hash deben estar en formato
|
19
|
+
# ** :camelcase - CamelCase
|
20
|
+
# ** :underscore - underscore_case
|
21
|
+
#
|
22
|
+
# === Example
|
23
|
+
# a=BusinessPartner.new
|
24
|
+
# a.to_hash
|
25
|
+
# # => {id => 1, name => "emol"}
|
26
|
+
#
|
27
|
+
# Returns:: Hash
|
28
|
+
def to_hash(keys_case=:underscore)
|
29
|
+
object_to_hash(self, keys_case)
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
# Internal: Internal method to return an object as a SOAP Request alike hash
|
34
|
+
# If the object is an array, this methods executes object_to_hash for each item.
|
35
|
+
# If the object is a Hash, this methods normalize the keys according to +keys_case+ and executes object_to_hash for each value
|
36
|
+
# If the object is a String or Numeric, returns the object
|
37
|
+
#
|
38
|
+
# Author:: asaavedrab@neonline.cl, jlopezn@neonline.cl
|
39
|
+
#
|
40
|
+
# === Parameters
|
41
|
+
# * +object+ - object instance to be hashed
|
42
|
+
# * +keys_case+ - specifies the hash keys case, default 'underscore'
|
43
|
+
# ==== keys_case
|
44
|
+
# * :camelcase - CamelCase
|
45
|
+
# * :underscore - underscore_case
|
46
|
+
#
|
47
|
+
# === Example:
|
48
|
+
# a=Person.new
|
49
|
+
# a.to_hash(:underscore)
|
50
|
+
# # => {'id' => 1, 'full_name' => "John Doe"}
|
51
|
+
#
|
52
|
+
# a=Person.new
|
53
|
+
# a.to_hash(:camelcase)
|
54
|
+
# # => {'Id' => 1, 'FullName' => "John Doe"}
|
55
|
+
#
|
56
|
+
# a=[<Person>, <Person>, <Cat>]
|
57
|
+
# a.to_hash(:underscore)
|
58
|
+
# # => [{'id' => 1, 'full_name' => "John Doe"}, {'id' => 2, 'full_name' => "Ms Mary"}, {'id' => 3, 'name' => "Mr Whiskers", 'color' => "Gray"}]
|
59
|
+
#
|
60
|
+
# Returns:: Hash
|
61
|
+
def object_to_hash(object, keys_case=:underscore)
|
62
|
+
|
63
|
+
# Nil safe
|
64
|
+
return nil if object.nil?
|
65
|
+
|
66
|
+
# In case of hash, we only normalize the keys values
|
67
|
+
return normalize_hash_keys(object, keys_case) if object.is_a?(Hash)
|
68
|
+
# In case of array, we make hasheable each element
|
69
|
+
return object.collect{ |item| object_to_hash(item, keys_case) } if object.is_a?(Array)
|
70
|
+
# In case of number or string, this methods return the object
|
71
|
+
return object if object.is_a?(String) || object.is_a?(Numeric)
|
72
|
+
|
73
|
+
hash={}
|
74
|
+
object.instance_variables.each do |var|
|
75
|
+
if !object.instance_variable_get(var).nil?
|
76
|
+
value = object.instance_variable_get(var)
|
77
|
+
hashed_value = case value.class.to_s
|
78
|
+
when "Hash" then normalize_hash_keys(value, keys_case)
|
79
|
+
when "Array" then value.collect{ |item| object_to_hash(item, keys_case) }
|
80
|
+
else value
|
81
|
+
end
|
82
|
+
hash[get_attribute_key(var, keys_case)] = hashed_value
|
83
|
+
end
|
84
|
+
end
|
85
|
+
return hash
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
def normalize_hash_keys(hash, keys_case)
|
90
|
+
return hash.inject({}) { |h, (k, v)| h[get_attribute_key(k, keys_case)] = object_to_hash(v, keys_case); h }
|
91
|
+
end
|
92
|
+
|
93
|
+
# Internal : Helper method to determinate the key name in the hash for the SOAP request
|
94
|
+
#
|
95
|
+
# Author:: jlopezn@neonline.cl
|
96
|
+
#
|
97
|
+
# === Parameters
|
98
|
+
# * attribute - the attribute name
|
99
|
+
# * keys_case - defines the case for the attribute name.
|
100
|
+
# ==== keys_case
|
101
|
+
# * :camelcase - CamelCase
|
102
|
+
# * :underscore - underscore_case
|
103
|
+
#
|
104
|
+
# === Examples
|
105
|
+
# get_attribute_key("attribute_name", :underscore)
|
106
|
+
# # => "attribute_name"
|
107
|
+
#
|
108
|
+
# get_attribute_key("name", :camelcase)
|
109
|
+
# # => "AttributeName"
|
110
|
+
#
|
111
|
+
# Returns:: String with the attribute name for the key in the hash
|
112
|
+
def get_attribute_key(attribute, keys_case = :underscore)
|
113
|
+
if keys_case == :underscore
|
114
|
+
return attribute.to_s.delete("@").underscore
|
115
|
+
elsif keys_case == :camelcase
|
116
|
+
return attribute.to_s.delete("@").camelcase
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
|
121
|
+
# Internal : Returns a DateTime as a hash for SOAP requests
|
122
|
+
#
|
123
|
+
# Author:: jlopezn@neonline.cl
|
124
|
+
#
|
125
|
+
# === Parameters
|
126
|
+
# * date - DateTime to be hashed
|
127
|
+
# * keys_case - defines the case for keys in the hash
|
128
|
+
# ==== keys_case
|
129
|
+
# * :camelcase - CamelCase
|
130
|
+
# * :underscore - underscore_case
|
131
|
+
#
|
132
|
+
# Returns:: Hash with the :year, :month, :day keys
|
133
|
+
def date_to_hash(date, keys_case)
|
134
|
+
{
|
135
|
+
get_attribute_key("day", keys_case) => date.day,
|
136
|
+
get_attribute_key("month", keys_case) => date.month,
|
137
|
+
get_attribute_key("year", keys_case) => date.year
|
138
|
+
}
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
data/lib/locales/es.yml
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
# Sample localization file for English. Add more files in this directory for other locales.
|
2
|
+
# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
|
3
|
+
|
4
|
+
es-CL:
|
5
|
+
|
6
|
+
bing:
|
7
|
+
|
8
|
+
constants:
|
9
|
+
|
10
|
+
common:
|
11
|
+
time_zones:
|
12
|
+
abu_dhabi_muscat: 'Abu Dhabi y Muscat'
|
13
|
+
adelaide: 'Adelaide, Australia'
|
14
|
+
alaska: 'Alaska'
|
15
|
+
almaty_novosibirsk: 'Almaty y Novosibirsk'
|
16
|
+
amsterdam_berlin_bern_rome_stockholm_vienna: 'Amsterdam, Berlin, Bern, Rome, Stockholm, y Vienna'
|
17
|
+
arizona: 'Arizona'
|
18
|
+
astana_dhaka: 'Astana y Dhaka'
|
19
|
+
athens_buckarest_istanbul: 'Athens, Istanbul, Beirut, y Minsk'
|
20
|
+
atlantic_time_canada: 'Atlantic Time y Canada'
|
21
|
+
auckland_wellington: 'Auckland y Wellington, New Zealand'
|
22
|
+
azores: 'Azores'
|
23
|
+
baghdad: 'Baghdad'
|
24
|
+
baku_tbilisi_yerevan: 'Baku, Tbilisi, y Yerevan'
|
25
|
+
bangkok_hanoi_jakarta: 'Bangkok, Hanoi, y Jakarta'
|
26
|
+
beijing_chongqing_hong_kong_urumqi: 'Beijing, Chongqing, Hong Kong, y Urumqi'
|
27
|
+
belgrade_bratislava_budapest_ljubljana_prague: 'Belgrade, Bratislava, Budapest, Ljubljana, y Prague'
|
28
|
+
bogota_lima_quito: 'Bogota, Lima, y Quito'
|
29
|
+
brasilia: 'Brasilia'
|
30
|
+
brisbane: 'Brisbane'
|
31
|
+
brussels_copenhagen_madrid_paris: 'Brussels, Copenhagen, Madrid, y Paris'
|
32
|
+
bucharest: 'Bucharest'
|
33
|
+
buenos_aires_georgetown: 'Buenos Aires y Georgetown'
|
34
|
+
cairo: 'Cairo'
|
35
|
+
canberra_melbourne_sydney: 'Canberra, Melbourne, y Sydney'
|
36
|
+
cape_verde_island: 'Cape Verde Island'
|
37
|
+
caracas_la_paz: 'Caracas y La Paz (Bolivia)'
|
38
|
+
casablanca_monrovia: 'Casablanca y Monrovia'
|
39
|
+
central_america: 'Central America'
|
40
|
+
central_time_u_s_canada: 'Central Time U.S. y Canada'
|
41
|
+
chennai_kolkata_mumbai_new_delhi: 'Chennai, Kolkata, Mumbai, y New Delhi'
|
42
|
+
chihuahua_la_paz_mazatlan: 'Chihuahua, La Paz (Mexico), y Mazatlan'
|
43
|
+
darwin: 'Darwin'
|
44
|
+
eastern_time_u_s_canada: 'Eastern Time U.S. y Canada'
|
45
|
+
ekaterinburg: 'Ekaterinburg'
|
46
|
+
fiji_kamchatka_marshall_island: 'Fiji, Kamchatka, y Marshall Island'
|
47
|
+
greenland: 'Greenland'
|
48
|
+
greenwich_mean_time_dublin_edinburgh_lisbon_london: 'Greenwich Mean Time, Dublin, Edinburgh, Lisbon, y London'
|
49
|
+
guadalajara_mexico_city_monterrey: 'Guadalajara, Mexico City, y Monterrey'
|
50
|
+
guam_port_moresby: 'Guam y Port Moresby'
|
51
|
+
harare_pretoria: 'Harare y Pretoria'
|
52
|
+
hawaii: 'Hawaii'
|
53
|
+
helsinki_kyiv_riga_sofia_tallinn_vilnius: 'Helsinki, Kyiv, Riga, Sofia, Tallinn, y Vilnius'
|
54
|
+
hobart: 'Hobart'
|
55
|
+
indiana_east: 'Indiana (East)'
|
56
|
+
international_date_line_west: 'International Date Line (West)'
|
57
|
+
irkutsk_ulaan_bataar: 'Irkutsk y Ulaanbaatar'
|
58
|
+
islandamabad_karachi_tashkent: 'Islamabad, Karachi, y Tashkent'
|
59
|
+
jerusalem: 'Jerusalem'
|
60
|
+
kabul: 'Kabul'
|
61
|
+
kathmandu: 'Kathmandu'
|
62
|
+
krasnoyarsk: 'Krasnoyarsk'
|
63
|
+
kuala_lumpur_singapore: 'Kuala Lumpur y Singapore'
|
64
|
+
kuwait_riyadh: 'Kuwait y Riyadh'
|
65
|
+
magadan_solomon_island_new_caledonia: 'Magadan, Solomon Islands, y New Caledonia'
|
66
|
+
mid_atlantic: 'Mid-Atlantic'
|
67
|
+
midway_islandand_samoa: 'Midway Island y Samoa'
|
68
|
+
moscow_st_petersburg_volgograd: 'Moscow, St Petersburg, y Volgograd'
|
69
|
+
mountain_time_u_s_canada: 'Mountain Time U.S. y Canada'
|
70
|
+
nairobi: 'Nairobi'
|
71
|
+
newfoundland: 'Newfoundland'
|
72
|
+
nukualofa: 'Nuku'alofa'
|
73
|
+
osaka_sapporo_tokyo: 'Osaka, Sapporo, y Tokyo'
|
74
|
+
pacific_time_u_s_canada_tijuana: 'Pacific Time, U.S. y Canada, y Tijuana'
|
75
|
+
perth: 'Perth'
|
76
|
+
rangoon: 'Rangoon'
|
77
|
+
santiago: 'Santiago'
|
78
|
+
sarajevo_skopje_warsaw_zagreb: 'Sarajevo, Skopie, Warsaw, y Zagreb'
|
79
|
+
saskatchewan: 'Saskatchewan'
|
80
|
+
seoul: 'Seoul'
|
81
|
+
sri_jayawardenepura: 'Sri Jayawardenepura'
|
82
|
+
taipei: 'Taipei'
|
83
|
+
tehran: 'Tehran'
|
84
|
+
vladivostok: 'Vladivostok'
|
85
|
+
west_central_africa: 'West Central Africa'
|
86
|
+
yakutsk: 'Yakutsk'
|
87
|
+
ad_languages:
|
88
|
+
danish: 'Danish'
|
89
|
+
dutch: 'Dutch'
|
90
|
+
english: 'English'
|
91
|
+
finnish: 'Finnish'
|
92
|
+
french: 'French'
|
93
|
+
german: 'German'
|
94
|
+
italian: 'Italian'
|
95
|
+
norwegian: 'Norwegian'
|
96
|
+
portuguese: 'Portuguese'
|
97
|
+
spanish: 'Spanish'
|
98
|
+
swedish: 'Swedish'
|
99
|
+
traditional_chinese: 'Traditional Chinese'
|
100
|
+
codes:
|
101
|
+
danish: 'DA'
|
102
|
+
dutch: 'NL'
|
103
|
+
english: 'EN'
|
104
|
+
finnish: 'FI'
|
105
|
+
french: 'FR'
|
106
|
+
german: 'DE'
|
107
|
+
italian: 'IT'
|
108
|
+
norwegian: 'NO'
|
109
|
+
portuguese: 'PT'
|
110
|
+
spanish: 'ES'
|
111
|
+
swedish: 'SV'
|
112
|
+
traditional_chinese: 'ZH'
|
113
|
+
market_country:
|
114
|
+
danish: 'Denmark'
|
115
|
+
dutch: 'Netherlands'
|
116
|
+
english: 'Australia Canada India Indonesia Ireland Malaysia New Zealand Philippines Singapore Thailand United Kingdom United States Vietnam'
|
117
|
+
finnish: 'Finland '
|
118
|
+
french: 'Belgium Canada France'
|
119
|
+
german: 'Austria Germany Switzerland'
|
120
|
+
italian: 'Italy'
|
121
|
+
norwegian: 'Norway'
|
122
|
+
portuguese: 'Brazil'
|
123
|
+
spanish: 'Argentina Chile Colombia Mexico Peru Spain Venezuela'
|
124
|
+
swedish: 'Sweden'
|
125
|
+
traditional_chinese: 'Hong Kong Taiwan'
|
126
|
+
|
127
|
+
campaign_management:
|
128
|
+
budget_limit_type:
|
129
|
+
monthly_budget_spend_until_depleted: 'MonthlyBudgetSpendUntilDepleted'
|
130
|
+
daily_budget_accelerated: 'DailyBudgetAccelerated'
|
131
|
+
daily_budget_standard: 'DailyBudgetStandard'
|
132
|
+
campaign_status:
|
133
|
+
active: 'Activa'
|
134
|
+
paused: 'Pausada'
|
135
|
+
budget_paused: 'Pausada por presupuesto'
|
136
|
+
budget_and_manual_paused: 'Pausada por presupuesto y manual'
|
137
|
+
deleted: 'Deleted'
|
138
|
+
ad_distribution:
|
139
|
+
search: 'Búsqueda'
|
140
|
+
content: 'Contenido'
|
141
|
+
ad_rotation_type:
|
142
|
+
optimize_for_clicks: 'Optimizado por clicks'
|
143
|
+
rotate_ads_evenly: 'Rotar anuncios parejo'
|
144
|
+
bidding_model:
|
145
|
+
keyword: 'Keywords'
|
146
|
+
site_placement: 'Posición en sitio'
|
147
|
+
pricing_model:
|
148
|
+
cpc: 'Cpc'
|
149
|
+
cpm: 'Cpm'
|
150
|
+
ad_group_status:
|
151
|
+
draft: 'Borrador'
|
152
|
+
active: 'Activo'
|
153
|
+
paused: 'Pausado'
|
154
|
+
deleted: 'Eliminado'
|
155
|
+
ad_status:
|
156
|
+
inactive: 'Inactivo'
|
157
|
+
Active: 'Activo'
|
158
|
+
paused: 'Pausado'
|
159
|
+
deleted: 'Eliminado'
|
160
|
+
ad_type:
|
161
|
+
text: 'Texto'
|
162
|
+
image: 'Imágen'
|
163
|
+
mobile: 'Mobil'
|
164
|
+
rich_search: 'Búsqueda enriquecida'
|
165
|
+
product: 'Producto'
|
166
|
+
keyword_editorial_status:
|
167
|
+
active: 'Activo'
|
168
|
+
disapproved: 'Desaprovado'
|
169
|
+
inactive: 'Inactivo'
|
170
|
+
keyword_status:
|
171
|
+
active: 'Activo'
|
172
|
+
paused: 'Pausado'
|
173
|
+
deleted: 'Borrado'
|
174
|
+
inactive: 'Inactivo'
|
@@ -0,0 +1,134 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'test_helper'
|
3
|
+
|
4
|
+
# Public : Test Case for general purpose methods, helper and modules
|
5
|
+
#
|
6
|
+
# Author:: jlopezn@neonline.cl
|
7
|
+
class BingAdsApiTest < ActiveSupport::TestCase
|
8
|
+
|
9
|
+
test "truth" do
|
10
|
+
assert_kind_of Module, BingAdsApi
|
11
|
+
end
|
12
|
+
|
13
|
+
test "load config" do
|
14
|
+
config = BingAdsApi::Config.instance
|
15
|
+
assert !config.nil?, "Config class not instantiated"
|
16
|
+
assert !config.config.nil?, "Config file not loaded"
|
17
|
+
end
|
18
|
+
|
19
|
+
test "config constants" do
|
20
|
+
config = BingAdsApi::Config.instance
|
21
|
+
|
22
|
+
assert !config.common_constants.nil?, "No common constants"
|
23
|
+
assert !config.campaign_management_constants.nil?, "No campaign management constants"
|
24
|
+
assert !config.reporting_constants.nil?, "No reporting constants"
|
25
|
+
end
|
26
|
+
|
27
|
+
test "config common constants" do
|
28
|
+
config = BingAdsApi::Config.instance
|
29
|
+
assert !config.common_constants['time_zones'].nil?, "No time_zones common constants"
|
30
|
+
assert !config.common_constants['time_zones']['santiago'].nil?, "No time_zones santiago "
|
31
|
+
end
|
32
|
+
|
33
|
+
test "get sandbox wsdl" do
|
34
|
+
config = BingAdsApi::Config.instance
|
35
|
+
|
36
|
+
assert !config.service_wsdl(:sandbox, :campaign_management).nil?,
|
37
|
+
"No wsdl for sandbox and campaign_management"
|
38
|
+
assert !config.service_wsdl(:sandbox, :reporting).nil?,
|
39
|
+
"No wsdl for sandbox and reporting"
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
test "get production wsdl" do
|
44
|
+
config = BingAdsApi::Config.instance
|
45
|
+
|
46
|
+
assert !config.service_wsdl(:production, :campaign_management).nil?,
|
47
|
+
"No wsdl for production and campaign_management"
|
48
|
+
assert !config.service_wsdl(:production, :reporting).nil?,
|
49
|
+
"No wsdl for production and reporting"
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
test "create client proxy" do
|
55
|
+
options = {
|
56
|
+
:username => "desarrollo_neonline",
|
57
|
+
:password => "neonline2013",
|
58
|
+
:developer_token => "BBD37VB98",
|
59
|
+
:customer_id => "21021746",
|
60
|
+
:account_id => "5978083",
|
61
|
+
:wsdl_url => "https://api.sandbox.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v9/CampaignManagementService.svc?singleWsdl"
|
62
|
+
}
|
63
|
+
client = BingAdsApi::ClientProxy.new(options)
|
64
|
+
#puts client.inspect
|
65
|
+
assert !client.nil?, "Client proxy not created"
|
66
|
+
|
67
|
+
#puts client.service
|
68
|
+
assert !client.service.nil?, "Service client not created"
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
test "create client proxy with additional settings" do
|
73
|
+
options = {
|
74
|
+
:username => "desarrollo_neonline",
|
75
|
+
:password => "neonline2013",
|
76
|
+
:developer_token => "BBD37VB98",
|
77
|
+
:customer_id => "21021746",
|
78
|
+
:account_id => "5978083",
|
79
|
+
:wsdl_url => "https://api.sandbox.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v9/CampaignManagementService.svc?singleWsdl",
|
80
|
+
:proxy => {
|
81
|
+
:logger => Rails.logger,
|
82
|
+
:encoding => "UTF-8"
|
83
|
+
}
|
84
|
+
}
|
85
|
+
client = BingAdsApi::ClientProxy.new(options)
|
86
|
+
#puts client.inspect
|
87
|
+
assert !client.nil?, "Client proxy not created"
|
88
|
+
|
89
|
+
#puts client.service
|
90
|
+
assert !client.service.nil?, "Service client not created"
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
test "call service" do
|
95
|
+
options = {
|
96
|
+
:username => "desarrollo_neonline",
|
97
|
+
:password => "neonline2013",
|
98
|
+
:developer_token => "BBD37VB98",
|
99
|
+
:customer_id => "21021746",
|
100
|
+
:account_id => "5978083",
|
101
|
+
:wsdl_url => "https://api.sandbox.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v9/CampaignManagementService.svc?singleWsdl"
|
102
|
+
}
|
103
|
+
|
104
|
+
client = BingAdsApi::ClientProxy.new(options)
|
105
|
+
assert !client.nil?, "Client proxy not created"
|
106
|
+
|
107
|
+
response = client.service.call(:get_campaigns_by_account_id,
|
108
|
+
message: { Account_id: client.account_id})
|
109
|
+
#puts response.inspect
|
110
|
+
assert response, "No responde received"
|
111
|
+
end
|
112
|
+
|
113
|
+
test "create and call from config" do
|
114
|
+
config = BingAdsApi::Config.instance
|
115
|
+
options = {
|
116
|
+
:username => "desarrollo_neonline",
|
117
|
+
:password => "neonline2013",
|
118
|
+
:developer_token => "BBD37VB98",
|
119
|
+
:customer_id => "21021746",
|
120
|
+
:account_id => "5978083",
|
121
|
+
:wsdl_url => config.service_wsdl(:sandbox, :campaign_management)
|
122
|
+
}
|
123
|
+
|
124
|
+
client = BingAdsApi::ClientProxy.new(options)
|
125
|
+
assert !client.nil?, "Client proxy not created"
|
126
|
+
|
127
|
+
response = client.service.call(:get_campaigns_by_account_id,
|
128
|
+
message: { Account_id: client.account_id})
|
129
|
+
#puts response.inspect
|
130
|
+
assert response, "No responde received"
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|