This repository has been archived by the owner on Jun 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from adwyze/bing-v12
Upgrade bing api to V12
- Loading branch information
Showing
26 changed files
with
1,223 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
|
||
# rspec failure tracking | ||
.rspec_status | ||
.idea/ | ||
|
||
# built gem files | ||
*.gem |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module Bing | ||
module Ads | ||
module API | ||
# Bing::Ads::API::V11 | ||
module V12 | ||
NAMESPACE_IDENTIFIER = :v12 | ||
|
||
def self.constants | ||
@_config || fail('Error loading bing ads gem') | ||
end | ||
|
||
def self.constants=(config) | ||
@_config = config | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
module Bing | ||
module Ads | ||
module API | ||
# Bing::Ads::API::V12::Constants | ||
module Constants | ||
root_v12_path = File.expand_path('../', __FILE__) | ||
|
||
campaign_management_path = File.join(root_v12_path, 'constants', 'campaign_management.yml') | ||
bulk_path = File.join(root_v12_path, 'constants', 'bulk.yml') | ||
languages_path = File.join(root_v12_path, 'constants', 'languages.yml') | ||
limits_path = File.join(root_v12_path, 'constants', 'limits.yml') | ||
time_zones_path = File.join(root_v12_path, 'constants', 'time_zones.yml') | ||
wsdl_path = File.join(root_v12_path, 'constants', 'wsdl.yml') | ||
|
||
Persey.init(:default) do | ||
source :yaml, campaign_management_path, :campaign_management | ||
source :yaml, bulk_path, :bulk | ||
source :yaml, languages_path, :languages | ||
source :yaml, limits_path, :limits | ||
source :yaml, time_zones_path, :time_zones | ||
source :yaml, wsdl_path, :wsdl | ||
env :default | ||
end | ||
|
||
Bing::Ads::API::V12.constants = Persey.config | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
download_entities: | ||
campaigns: 1 | ||
ad_groups: 2 | ||
ads: 3 | ||
keywords: 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
ad_distribution: | ||
search: Search | ||
content: Content | ||
ad_rotation: | ||
optimize_for_clicks: OptimizeForClicks | ||
rotate_ads_evenly: RotateAdsEvenly | ||
ad_group_status: | ||
draft: Draft | ||
active: Active | ||
paused: Paused | ||
deleted: Deleted | ||
ad_editorial_status: | ||
active: Active | ||
disapproved: Disapproved | ||
inactive: Inactive | ||
active_limited: ActiveLimited | ||
ad_status: | ||
inactive: Inactive | ||
active: Active | ||
paused: Paused | ||
deleted: Deleted | ||
ad_types: | ||
text_ad: TextAd | ||
image_ad: ImageAd | ||
product_ad: ProductAd | ||
app_install_ad: AppInstallAd | ||
expanded_text_ad: ExpandedTextAd | ||
dynamic_search_ad: DynamicSearchAd | ||
ad_types_for_get: | ||
text: Text | ||
image: Image | ||
product: Product | ||
app_install: AppInstall | ||
expanded_text: ExpandedText | ||
dynamic_search: DynamicSearch | ||
bidding_model: | ||
keyword: Keyword | ||
site_placement: SitePlacement | ||
bidding_scheme: | ||
manual_cpc: ManualCpcBiddingScheme | ||
enhanced_cpc: EnhancedCpcBiddingScheme | ||
inherit_from_parent: InheritFromParentBiddingScheme | ||
max_clicks: MaxClicksBiddingScheme | ||
max_conversions: MaxConversionsBiddingScheme | ||
target_cpa: TargetCpaBiddingScheme | ||
budget_limit_type: | ||
daily_budget_accelerated: DailyBudgetAccelerated | ||
daily_budget_standard: DailyBudgetStandard | ||
campaign_status: | ||
active: Active | ||
paused: Paused | ||
budget_paused: BudgetPaused | ||
budget_and_manual_paused: BudgetAndManualPaused | ||
deleted: Deleted | ||
keyword_editorial_statuses: | ||
active: Active | ||
disapproved: Disapproved | ||
inactive: Inactive | ||
keyword_statuses: | ||
active: Active | ||
paused: Paused | ||
deleted: Deleted | ||
inactive: Inactive | ||
match_types: | ||
broad: Broad | ||
exact: Exact | ||
phrase: Phrase | ||
network: | ||
owned_and_operated_and_syndicated_search: OwnedAndOperatedAndSyndicatedSearch | ||
owned_and_operated_only: OwnedAndOperatedOnly | ||
syndicated_search_only: SyndicatedSearchOnly | ||
remarketing_target_setting: | ||
bid_only: BidOnly | ||
target_and_bid: TargetAndBid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
danish: 'Danish' | ||
dutch: 'Dutch' | ||
english: 'English' | ||
finnish: 'Finnish' | ||
french: 'French' | ||
german: 'German' | ||
italian: 'Italian' | ||
norwegian: 'Norwegian' | ||
portuguese: 'Portuguese' | ||
spanish: 'Spanish' | ||
swedish: 'Swedish' | ||
traditional_chinese: 'TraditionalChinese' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
per_call: | ||
campaign: 100 | ||
ad_group: 1000 | ||
ad: 50 | ||
keyword: 1000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
abu_dhabi_muscat: 'AbuDhabiMuscat' | ||
adelaide: 'Adelaide' | ||
alaska: 'Alaska' | ||
almaty_novosibirsk: 'AlmatyNovosibirsk' | ||
amsterdam_berlin_bern_rome_stockholm_vienna: 'AmsterdamBerlinBernRomeStockholmVienna' | ||
arizona: 'Arizona' | ||
astana_dhaka: 'AstanaDhaka' | ||
athens_buckarest_istanbul: 'AthensBuckarestIstanbul' | ||
atlantic_time_canada: 'AtlanticTimeCanada' | ||
auckland_wellington: 'AucklandWellington' | ||
azores: 'Azores' | ||
baghdad: 'Baghdad' | ||
baku_tbilisi_yerevan: 'BakuTbilisiYerevan' | ||
bangkok_hanoi_jakarta: 'BangkokHanoiJakarta' | ||
beijing_chongqing_hong_kong_urumqi: 'BeijingChongqingHongKongUrumqi' | ||
belgrade_bratislava_budapest_ljubljana_prague: 'BelgradeBratislavaBudapestLjubljanaPrague' | ||
bogota_lima_quito: 'BogotaLimaQuito' | ||
brasilia: 'Brasilia' | ||
brisbane: 'Brisbane' | ||
brussels_copenhagen_madrid_paris: 'BrusselsCopenhagenMadridParis' | ||
bucharest: 'Bucharest' | ||
buenos_aires_georgetown: 'BuenosAiresGeorgetown' | ||
cairo: 'Cairo' | ||
canberra_melbourne_sydney: 'CanberraMelbourneSydney' | ||
cape_verde_island: 'CapeVerdeIsland' | ||
caracas_la_paz: 'CaracasLaPaz' | ||
casablanca_monrovia: 'CasablancaMonrovia' | ||
central_america: 'CentralAmerica' | ||
central_time_u_s_canada: 'CentralTimeUSCanada' | ||
chennai_kolkata_mumbai_new_delhi: 'ChennaiKolkataMumbaiNewDelhi' | ||
chihuahua_la_paz_mazatlan: 'ChihuahuaLaPazMazatlan' | ||
darwin: 'Darwin' | ||
eastern_time_u_s_canada: 'EasternTimeUSCanada' | ||
ekaterinburg: 'Ekaterinburg' | ||
fiji_kamchatka_marshall_island: 'FijiKamchatkaMarshallIsland' | ||
greenland: 'Greenland' | ||
greenwich_mean_time_dublin_edinburgh_lisbon_london: 'GreenwichMeanTimeDublinEdinburghLisbonLondon' | ||
guadalajara_mexico_city_monterrey: 'GuadalajaraMexicoCityMonterrey' | ||
guam_port_moresby: 'GuamPortMoresby' | ||
harare_pretoria: 'HararePretoria' | ||
hawaii: 'Hawaii' | ||
helsinki_kyiv_riga_sofia_tallinn_vilnius: 'HelsinkiKyivRigaSofiaTallinnVilnius' | ||
hobart: 'Hobart' | ||
indiana_east: 'IndianaEast' | ||
international_date_line_west: 'InternationalDateLineWest' | ||
irkutsk_ulaan_bataar: 'IrkutskUlaanBataar' | ||
islandamabad_karachi_tashkent: 'IslandamabadKarachiTashkent' | ||
jerusalem: 'Jerusalem' | ||
kabul: 'Kabul' | ||
kathmandu: 'Kathmandu' | ||
krasnoyarsk: 'Krasnoyarsk' | ||
kuala_lumpur_singapore: 'KualaLumpurSingapore' | ||
kuwait_riyadh: 'KuwaitRiyadh' | ||
solomon_island_new_caledonia: 'SolomonIslandNewCaledonia' | ||
mid_atlantic: 'MidAtlantic' | ||
midway_islandand_samoa: 'MidwayIslandAndSamoa' | ||
moscow_st_petersburg_volgograd: 'MoscowStPetersburgVolgograd' | ||
mountain_time_u_s_canada: 'MountainTimeUSCanada' | ||
nairobi: 'Nairobi' | ||
newfoundland: 'Newfoundland' | ||
nukualofa: 'Nukualofa' | ||
osaka_sapporo_tokyo: 'OsakaSapporoTokyo' | ||
pacific_time_u_s_canada_tijuana: 'PacificTimeUSCanadaTijuana' | ||
perth: 'Perth' | ||
rangoon: 'Rangoon' | ||
santiago: 'Santiago' | ||
sarajevo_skopje_warsaw_zagreb: 'SarajevoSkopjeWarsawZagreb' | ||
saskatchewan: 'Saskatchewan' | ||
seoul: 'Seoul' | ||
sri_jayawardenepura: 'SriJayawardenepura' | ||
taipei: 'Taipei' | ||
tehran: 'Tehran' | ||
vladivostok: 'Vladivostok' | ||
west_central_africa: 'WestCentralAfrica' | ||
yakutsk: 'Yakutsk' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
sandbox: | ||
customer_management: "https://clientcenter.api.bingads.microsoft.com/Api/CustomerManagement/v12/CustomerManagementService.svc?singleWsdl" | ||
campaign_management: "https://campaign.api.sandbox.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v12/CampaignManagementService.svc?singleWsdl" | ||
reporting: "https://reporting.api.sandbox.bingads.microsoft.com/Api/Advertiser/Reporting/v12/ReportingService.svc?singleWsdl" | ||
bulk: 'https://bulk.api.sandbox.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v12/BulkService.svc?singleWsdl' | ||
production: | ||
customer_management: "https://clientcenter.api.sandbox.bingads.microsoft.com/Api/CustomerManagement/v12/CustomerManagementService.svc?singleWsdl" | ||
campaign_management: "https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v12/CampaignManagementService.svc?singleWsdl" | ||
reporting: "https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/v12/ReportingService.svc?singleWsdl" | ||
bulk: 'https://bulk.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v12/BulkService.svc?singleWsdl' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
require_relative './data/ad_group' | ||
require_relative './data/expanded_text_ad' | ||
require_relative './data/campaign' | ||
require_relative './data/keyword' | ||
require_relative './data/report_request' | ||
require_relative './data/bulk_request' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
module Bing | ||
module Ads | ||
module API | ||
module V12 | ||
module Data | ||
# Bing::Ads::API::V12::Data::AdGroup | ||
class AdGroup | ||
|
||
# @order | ||
# https://msdn.microsoft.com/en-us/library/bing-ads-campaign-management-adgroup.aspx | ||
# Alphabetical | ||
KEYS_ORDER = %i[ | ||
ad_distribution | ||
ad_rotation | ||
bidding_scheme | ||
content_match_bid | ||
end_date | ||
forward_compatibility_map | ||
id | ||
language | ||
name | ||
native_bid_adjustment | ||
network | ||
remarketing_targeting_setting | ||
search_bid | ||
settings | ||
start_date | ||
status | ||
tracking_url_template | ||
url_custom_parameter | ||
].freeze | ||
|
||
def self.prepare(ad_group_raw) | ||
ad_group_raw[:ad_rotation] = { type: ad_group_raw[:ad_rotation] } if ad_group_raw[:ad_rotation] | ||
if ad_group_raw[:bidding_scheme] | ||
# TODO support MaxClicksBiddingScheme, MaxConversionsBiddingScheme and TargetCpaBiddingScheme | ||
ad_group_raw[:bidding_scheme] = { | ||
type: ad_group_raw[:bidding_scheme], | ||
'@xsi:type' => "#{Bing::Ads::API::V12::NAMESPACE_IDENTIFIER}:#{ad_group_raw[:bidding_scheme]}" | ||
} | ||
end | ||
ad_group_raw[:content_match_bid] = { amount: ad_group_raw[:content_match_bid] } if ad_group_raw[:content_match_bid] | ||
ad_group_raw[:end_date] = Bing::Ads::Utils.date_hash(ad_group_raw[:end_date]) if ad_group_raw[:end_date] | ||
ad_group_raw[:search_bid] = { amount: ad_group_raw[:search_bid] } if ad_group_raw[:search_bid] | ||
ad_group_raw[:start_date] = Bing::Ads::Utils.date_hash(ad_group_raw[:start_date]) if ad_group_raw[:start_date] | ||
# TODO UrlCustomParameters | ||
ad_group_raw = Bing::Ads::Utils.sort_keys(ad_group_raw) | ||
Bing::Ads::Utils.camelcase_keys(ad_group_raw) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
module Bing | ||
module Ads | ||
module API | ||
module V12 | ||
module Data | ||
class BulkRequest | ||
|
||
KEYS_ORDER = %i[ | ||
account_ids | ||
compression_type | ||
data_scope | ||
download_entities | ||
download_file_type | ||
format_version | ||
last_sync_time_in_utc | ||
].freeze | ||
|
||
class << self | ||
def prepare(bulk_request_row) | ||
bulk_request_row[:account_ids] = prepare_account_ids( | ||
account_ids: bulk_request_row[:account_ids] | ||
) | ||
bulk_request_row[:download_entities] = | ||
prepare_download_entities( | ||
levels: bulk_request_row.delete(:levels) | ||
) | ||
bulk_request_row.except!(:levels) | ||
bulk_request = Bing::Ads::Utils.sort_keys(bulk_request_row, KEYS_ORDER) | ||
Bing::Ads::Utils.camelcase_keys(bulk_request) | ||
end | ||
|
||
private | ||
|
||
def prepare_account_ids(account_ids:) | ||
{ | ||
'a1:long' => account_ids, | ||
'@xmlns:a1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays' | ||
} | ||
end | ||
|
||
def prepare_download_entities(levels:) | ||
levels = %w[campaign] if levels.nil? || levels.empty? | ||
entities = levels.map(&:pluralize).map(&:camelcase) | ||
{ download_entity: entities } | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.