bing_ads_ruby_sdk 1.0.0 → 1.3.2
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.
- checksums.yaml +5 -5
- data/.circleci/config.yml +52 -0
- data/.github/delete-merged-branch-config.yml +6 -0
- data/.github/stale.yml +19 -0
- data/.gitignore +2 -0
- data/README.md +25 -5
- data/bing_ads_ruby_sdk.gemspec +6 -5
- data/changelog.md +27 -2
- data/lib/bing_ads_ruby_sdk/api.rb +3 -1
- data/lib/bing_ads_ruby_sdk/configuration.rb +2 -1
- data/lib/bing_ads_ruby_sdk/header.rb +8 -4
- data/lib/bing_ads_ruby_sdk/http_client.rb +19 -9
- data/lib/bing_ads_ruby_sdk/oauth2/authorization_handler.rb +17 -10
- data/lib/bing_ads_ruby_sdk/services/base.rb +6 -6
- data/lib/bing_ads_ruby_sdk/services/campaign_management.rb +3 -0
- data/lib/bing_ads_ruby_sdk/version.rb +2 -2
- data/lib/bing_ads_ruby_sdk/wsdl/v13/production/ad_insight.xml +1 -0
- data/lib/bing_ads_ruby_sdk/wsdl/v13/production/bulk.xml +1 -0
- data/lib/bing_ads_ruby_sdk/wsdl/v13/production/campaign_management.xml +1 -0
- data/lib/bing_ads_ruby_sdk/wsdl/v13/production/customer_billing.xml +1 -0
- data/lib/bing_ads_ruby_sdk/wsdl/v13/production/customer_management.xml +1 -0
- data/lib/bing_ads_ruby_sdk/wsdl/v13/production/reporting.xml +1 -0
- data/lib/bing_ads_ruby_sdk/wsdl/v13/sandbox/ad_insight.xml +3037 -0
- data/lib/bing_ads_ruby_sdk/wsdl/v13/sandbox/bulk.xml +1 -0
- data/lib/bing_ads_ruby_sdk/wsdl/v13/sandbox/campaign_management.xml +1 -0
- data/lib/bing_ads_ruby_sdk/wsdl/v13/sandbox/customer_billing.xml +1 -0
- data/lib/bing_ads_ruby_sdk/wsdl/v13/sandbox/customer_management.xml +1 -0
- data/lib/bing_ads_ruby_sdk/wsdl/v13/sandbox/reporting.xml +1 -0
- data/lib/bing_ads_ruby_sdk/wsdl/{v12 → v13}/test/ad_insight.xml +1440 -1468
- data/lib/bing_ads_ruby_sdk/wsdl/{v12 → v13}/test/bulk.xml +83 -147
- data/lib/bing_ads_ruby_sdk/wsdl/{v12 → v13}/test/campaign_management.xml +711 -417
- data/lib/bing_ads_ruby_sdk/wsdl/{v12 → v13}/test/customer_billing.xml +62 -112
- data/lib/bing_ads_ruby_sdk/wsdl/{v12 → v13}/test/customer_management.xml +231 -176
- data/lib/bing_ads_ruby_sdk/wsdl/{v12 → v13}/test/reporting.xml +110 -158
- data/lib/bing_ads_ruby_sdk/wsdl/wsdl_source.txt +18 -18
- data/spec/bing_ads_ruby_sdk/api_spec.rb +17 -0
- data/spec/bing_ads_ruby_sdk/errors/error_handler_spec.rb +479 -0
- data/spec/bing_ads_ruby_sdk/errors/errors_spec.rb +13 -0
- data/spec/bing_ads_ruby_sdk/header_spec.rb +60 -0
- data/spec/bing_ads_ruby_sdk/http_client_spec.rb +44 -0
- data/spec/bing_ads_ruby_sdk/oauth2/fs_store_spec.rb +20 -0
- data/spec/bing_ads_ruby_sdk/postprocessors/cast_long_arrays_spec.rb +30 -0
- data/spec/bing_ads_ruby_sdk/postprocessors/snakize_spec.rb +40 -0
- data/spec/bing_ads_ruby_sdk/preprocessors/camelize_spec.rb +40 -0
- data/spec/bing_ads_ruby_sdk/preprocessors/order_spec.rb +119 -0
- data/spec/bing_ads_ruby_sdk/services/bulk_spec.rb +56 -0
- data/spec/bing_ads_ruby_sdk/services/campaign_management_spec.rb +307 -0
- data/spec/bing_ads_ruby_sdk/services/customer_management_spec.rb +97 -0
- data/spec/bing_ads_ruby_sdk_spec.rb +5 -0
- data/spec/examples/1_customer_creation/customer_spec.rb +35 -0
- data/spec/examples/2_with_customer/budget_spec.rb +54 -0
- data/spec/examples/2_with_customer/campaigns_spec.rb +27 -0
- data/spec/examples/2_with_customer/customer_management_spec.rb +190 -0
- data/spec/examples/2_with_customer/uet_tags_spec.rb +42 -0
- data/spec/examples/3_with_uet_tag/conversion_goal_spec.rb +40 -0
- data/spec/examples/3_with_uet_tag/uet_tags_spec.rb +56 -0
- data/spec/examples/4_with_conversion_goal/conversion_goals_spec.rb +75 -0
- data/spec/examples/5_with_campaign/ad_extension_spec.rb +238 -0
- data/spec/examples/5_with_campaign/ad_group_spec.rb +35 -0
- data/spec/examples/5_with_campaign/campaign_criterions_spec.rb +74 -0
- data/spec/examples/5_with_campaign/campaign_spec.rb +71 -0
- data/spec/examples/6_with_ad_group/ad_group_spec.rb +71 -0
- data/spec/examples/6_with_ad_group/ads_spec.rb +113 -0
- data/spec/examples/6_with_ad_group/keywords_spec.rb +108 -0
- data/spec/examples/examples.rb +76 -0
- data/spec/fixtures/bulk/download_campaigns_by_account_ids/standard.xml +23 -0
- data/spec/fixtures/bulk/download_campaigns_by_account_ids/standard_response.xml +11 -0
- data/spec/fixtures/bulk/get_bulk_download_status/standard.xml +14 -0
- data/spec/fixtures/bulk/get_bulk_download_status/standard_response.xml +15 -0
- data/spec/fixtures/campaign_management/add_ad_extensions/standard.xml +21 -0
- data/spec/fixtures/campaign_management/add_ad_extensions/standard_response.xml +17 -0
- data/spec/fixtures/campaign_management/add_conversion_goals/standard.xml +27 -0
- data/spec/fixtures/campaign_management/add_conversion_goals/standard_response.xml +14 -0
- data/spec/fixtures/campaign_management/add_shared_entity/standard.xml +16 -0
- data/spec/fixtures/campaign_management/add_shared_entity/standard_response.xml +13 -0
- data/spec/fixtures/campaign_management/add_uet_tags/standard.xml +19 -0
- data/spec/fixtures/campaign_management/add_uet_tags/standard_response.xml +21 -0
- data/spec/fixtures/campaign_management/get_ad_extension_ids_by_account_id/standard.xml +15 -0
- data/spec/fixtures/campaign_management/get_ad_extension_ids_by_account_id/standard_response.xml +13 -0
- data/spec/fixtures/campaign_management/get_ad_extensions_associations/standard.xml +19 -0
- data/spec/fixtures/campaign_management/get_ad_extensions_associations/standard_response.xml +47 -0
- data/spec/fixtures/campaign_management/get_budgets_by_ids/standard.xml +12 -0
- data/spec/fixtures/campaign_management/get_budgets_by_ids/standard_response.xml +20 -0
- data/spec/fixtures/campaign_management/get_campaigns_by_account_id/standard.xml +14 -0
- data/spec/fixtures/campaign_management/get_campaigns_by_account_id/standard_response.xml +84 -0
- data/spec/fixtures/campaign_management/get_conversion_goals_by_ids/standard.xml +18 -0
- data/spec/fixtures/campaign_management/get_conversion_goals_by_ids/standard_response.xml +61 -0
- data/spec/fixtures/campaign_management/get_shared_entities_by_account_id/standard.xml +14 -0
- data/spec/fixtures/campaign_management/get_shared_entities_by_account_id/standard_response.xml +20 -0
- data/spec/fixtures/campaign_management/get_shared_entity_associations_by_entity_ids/standard.xml +18 -0
- data/spec/fixtures/campaign_management/get_shared_entity_associations_by_entity_ids/standard_response.xml +19 -0
- data/spec/fixtures/campaign_management/get_uet_tags_by_ids/standard.xml +16 -0
- data/spec/fixtures/campaign_management/get_uet_tags_by_ids/standard_response.xml +21 -0
- data/spec/fixtures/campaign_management/set_ad_extensions_associations/standard.xml +21 -0
- data/spec/fixtures/campaign_management/set_ad_extensions_associations/standard_response.xml +11 -0
- data/spec/fixtures/campaign_management/set_shared_entity_associations/standard.xml +21 -0
- data/spec/fixtures/campaign_management/set_shared_entity_associations/standard_response.xml +11 -0
- data/spec/fixtures/campaign_management/update_conversion_goals/standard.xml +27 -0
- data/spec/fixtures/campaign_management/update_conversion_goals/standard_response.xml +11 -0
- data/spec/fixtures/campaign_management/update_uet_tags/standard.xml +20 -0
- data/spec/fixtures/campaign_management/update_uet_tags/standard_response.xml +11 -0
- data/spec/fixtures/customer_management/find_accounts_or_customers_info/standard.xml +15 -0
- data/spec/fixtures/customer_management/find_accounts_or_customers_info/standard_response.xml +21 -0
- data/spec/fixtures/customer_management/get_account/standard.xml +14 -0
- data/spec/fixtures/customer_management/get_account/standard_response.xml +43 -0
- data/spec/fixtures/customer_management/signup_customer/standard.xml +30 -0
- data/spec/fixtures/customer_management/signup_customer/standard_response.xml +15 -0
- data/spec/fixtures/customer_management/update_account/standard.xml +19 -0
- data/spec/fixtures/customer_management/update_account/standard_response.xml +11 -0
- data/spec/spec_helper.rb +33 -0
- data/spec/support/spec_helpers.rb +45 -0
- data/tasks/bing_ads_ruby_sdk.rake +5 -6
- metadata +202 -27
- data/.travis.yml +0 -5
- data/lib/bing_ads_ruby_sdk/wsdl/v12/production/ad_insight.xml +0 -1
- data/lib/bing_ads_ruby_sdk/wsdl/v12/production/bulk.xml +0 -1
- data/lib/bing_ads_ruby_sdk/wsdl/v12/production/campaign_management.xml +0 -1
- data/lib/bing_ads_ruby_sdk/wsdl/v12/production/customer_billing.xml +0 -1
- data/lib/bing_ads_ruby_sdk/wsdl/v12/production/customer_management.xml +0 -1
- data/lib/bing_ads_ruby_sdk/wsdl/v12/production/reporting.xml +0 -1
- data/lib/bing_ads_ruby_sdk/wsdl/v12/sandbox/ad_insight.xml +0 -1
- data/lib/bing_ads_ruby_sdk/wsdl/v12/sandbox/bulk.xml +0 -1
- data/lib/bing_ads_ruby_sdk/wsdl/v12/sandbox/campaign_management.xml +0 -1
- data/lib/bing_ads_ruby_sdk/wsdl/v12/sandbox/customer_billing.xml +0 -1
- data/lib/bing_ads_ruby_sdk/wsdl/v12/sandbox/customer_management.xml +0 -1
- data/lib/bing_ads_ruby_sdk/wsdl/v12/sandbox/reporting.xml +0 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require_relative '../examples'
|
|
2
|
+
|
|
3
|
+
RSpec.describe 'Conversion goals methods' do
|
|
4
|
+
include_context 'use api'
|
|
5
|
+
|
|
6
|
+
it 'returns a list of Conversion goal Ids' do
|
|
7
|
+
conversion_goals = api.campaign_management.add_conversion_goals(
|
|
8
|
+
conversion_goals: {
|
|
9
|
+
event_goal: {
|
|
10
|
+
conversion_window_in_minutes: 43_200, # 30days
|
|
11
|
+
count_type: 'All',
|
|
12
|
+
name: "Acceptance Test Conversion goal #{random}",
|
|
13
|
+
revenue: {
|
|
14
|
+
currency_code: 'EUR',
|
|
15
|
+
type: 'FixedValue',
|
|
16
|
+
value: 5.20,
|
|
17
|
+
},
|
|
18
|
+
scope: 'Account',
|
|
19
|
+
status: 'Active',
|
|
20
|
+
tag_id: Examples.uet_tag_id,
|
|
21
|
+
action_operator: 'Equals',
|
|
22
|
+
action_expression: 'display_phone',
|
|
23
|
+
category_operator: 'Equals',
|
|
24
|
+
category_expression: 'contact_form',
|
|
25
|
+
label_operator: 'Equals',
|
|
26
|
+
label_expression: 'lower_button',
|
|
27
|
+
value_operator: 'Equals',
|
|
28
|
+
value: '1'
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
expect(conversion_goals).to include(
|
|
34
|
+
conversion_goal_ids: [a_kind_of(Integer)],
|
|
35
|
+
partial_errors: ''
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
puts "Please fill in examples.rb with conversion_goal_id: #{conversion_goals[:conversion_goal_ids].first}"
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require_relative '../examples'
|
|
2
|
+
|
|
3
|
+
RSpec.describe 'CampaignManagement service' do
|
|
4
|
+
include_context 'use api'
|
|
5
|
+
|
|
6
|
+
describe 'UET methods' do
|
|
7
|
+
let(:get_uet_tags_by_ids) do
|
|
8
|
+
api.campaign_management.get_uet_tags_by_ids(
|
|
9
|
+
tag_ids: [
|
|
10
|
+
{ long: Examples.uet_tag_id }
|
|
11
|
+
]
|
|
12
|
+
)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe '#get_uet_tags_by_ids' do
|
|
16
|
+
it 'returns a list of UET tags' do
|
|
17
|
+
expect(get_uet_tags_by_ids).to contain_exactly(
|
|
18
|
+
{
|
|
19
|
+
description: a_kind_of(String),
|
|
20
|
+
id: a_kind_of(String),
|
|
21
|
+
name: a_string_starting_with('Acceptance Test UET Tag'),
|
|
22
|
+
tracking_no_script: a_string_starting_with("<img src=\"//bat.bing.com/action/"),
|
|
23
|
+
tracking_script: a_string_starting_with('<script>(function(w,d,t,r,u)'),
|
|
24
|
+
tracking_status: 'Unverified',
|
|
25
|
+
customer_share: nil
|
|
26
|
+
}
|
|
27
|
+
)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe '#update_uet_tags' do
|
|
32
|
+
subject do
|
|
33
|
+
api.campaign_management.update_uet_tags({
|
|
34
|
+
uet_tags: [
|
|
35
|
+
{
|
|
36
|
+
uet_tag: {
|
|
37
|
+
name: "Acceptance Test UET Tag - #{random}",
|
|
38
|
+
id: Examples.uet_tag_id,
|
|
39
|
+
description: "UET Tag Description - #{random}",
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
})
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it 'updates the UET tag fields' do
|
|
47
|
+
is_expected.to eq(partial_errors: '')
|
|
48
|
+
|
|
49
|
+
expect(get_uet_tags_by_ids.first).to include(
|
|
50
|
+
name: "Acceptance Test UET Tag - #{random}",
|
|
51
|
+
description: "UET Tag Description - #{random}"
|
|
52
|
+
)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
require_relative '../examples'
|
|
2
|
+
|
|
3
|
+
RSpec.describe 'Conversion goals methods' do
|
|
4
|
+
include_context 'use api'
|
|
5
|
+
|
|
6
|
+
let(:a_conversion_goal) do
|
|
7
|
+
{
|
|
8
|
+
conversion_window_in_minutes: a_kind_of(String),
|
|
9
|
+
count_type: a_kind_of(String),
|
|
10
|
+
id: a_kind_of(String),
|
|
11
|
+
name: a_string_starting_with('Acceptance Test Conversion goal'),
|
|
12
|
+
revenue: a_kind_of(Hash),
|
|
13
|
+
scope: a_kind_of(String),
|
|
14
|
+
status: a_kind_of(String),
|
|
15
|
+
tag_id: Examples.uet_tag_id.to_s,
|
|
16
|
+
tracking_status: a_kind_of(String),
|
|
17
|
+
type: 'Event',
|
|
18
|
+
action_expression: a_kind_of(String),
|
|
19
|
+
action_operator: a_kind_of(String),
|
|
20
|
+
category_expression: a_kind_of(String),
|
|
21
|
+
category_operator: a_kind_of(String),
|
|
22
|
+
label_expression: a_kind_of(String),
|
|
23
|
+
label_operator: a_kind_of(String),
|
|
24
|
+
value: a_kind_of(String),
|
|
25
|
+
value_operator: a_kind_of(String),
|
|
26
|
+
exclude_from_bidding: nil
|
|
27
|
+
}
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe '#get_conversion_goals_by_ids' do
|
|
31
|
+
it 'returns a list of conversion goals' do
|
|
32
|
+
expect(api.campaign_management.get_conversion_goals_by_ids(
|
|
33
|
+
conversion_goal_types: 'Event',
|
|
34
|
+
conversion_goal_ids: [{ long: Examples.conversion_goal_id }]
|
|
35
|
+
)).to contain_exactly(a_conversion_goal)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe '#get_conversion_goals_by_tag_ids' do
|
|
40
|
+
it 'returns a list of conversion_goals' do
|
|
41
|
+
expect(api.campaign_management.call(:get_conversion_goals_by_tag_ids, {
|
|
42
|
+
conversion_goal_types: 'Event',
|
|
43
|
+
tag_ids: [long: Examples.uet_tag_id]
|
|
44
|
+
})).to include(
|
|
45
|
+
conversion_goals: {
|
|
46
|
+
conversion_goal: a_collection_including(a_conversion_goal)
|
|
47
|
+
},
|
|
48
|
+
partial_errors: ""
|
|
49
|
+
)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
describe '#update_conversion_goals' do
|
|
54
|
+
it 'updates the conversion goals' do
|
|
55
|
+
expect(
|
|
56
|
+
api.campaign_management.update_conversion_goals(
|
|
57
|
+
conversion_goals: {
|
|
58
|
+
event_goal: {
|
|
59
|
+
id: Examples.conversion_goal_id,
|
|
60
|
+
name: "Acceptance Test Conversion goal #{random}",
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
).to eq(partial_errors: '')
|
|
64
|
+
|
|
65
|
+
updated_conversion = api.campaign_management.get_conversion_goals_by_ids(
|
|
66
|
+
conversion_goal_types: 'Event',
|
|
67
|
+
conversion_goal_ids: [{ long: Examples.conversion_goal_id }]
|
|
68
|
+
).first
|
|
69
|
+
|
|
70
|
+
expect(updated_conversion).to include(
|
|
71
|
+
name:"Acceptance Test Conversion goal #{random}"
|
|
72
|
+
)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../examples'
|
|
4
|
+
|
|
5
|
+
RSpec.describe "AdExtension methods" do
|
|
6
|
+
include_context "use api"
|
|
7
|
+
|
|
8
|
+
def create_add_ad_extensions
|
|
9
|
+
Examples.build_api.campaign_management.add_ad_extensions(
|
|
10
|
+
account_id: Examples.account_id,
|
|
11
|
+
ad_extensions: [
|
|
12
|
+
{
|
|
13
|
+
call_ad_extension: {
|
|
14
|
+
country_code: "NZ",
|
|
15
|
+
is_call_only: false,
|
|
16
|
+
phone_number: SecureRandom.random_number(999_999_999)
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
callout_ad_extension: {
|
|
21
|
+
text: Examples.random[0..11]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
sitelink_ad_extension: {
|
|
26
|
+
description_1: "Description 1 - #{Examples.random}"[0..34],
|
|
27
|
+
description_2: "Description 2 - #{Examples.random}"[0..34],
|
|
28
|
+
display_text: "Display Text #{Examples.random}"[0..24],
|
|
29
|
+
final_mobile_urls: [ { string: "http://mobile.example.com" } ],
|
|
30
|
+
final_urls: [ { string: "http://www.example.com" } ],
|
|
31
|
+
tracking_url_template: "{lpurl}"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def set_ad_extensions_associations(ad_extension_ids)
|
|
39
|
+
Examples.build_api.campaign_management.set_ad_extensions_associations(
|
|
40
|
+
account_id: Examples.account_id,
|
|
41
|
+
ad_extension_id_to_entity_id_associations: ad_extension_ids.map do |id|
|
|
42
|
+
{
|
|
43
|
+
ad_extension_id_to_entity_id_association: {
|
|
44
|
+
ad_extension_id: id,
|
|
45
|
+
entity_id: Examples.campaign_id
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
end,
|
|
49
|
+
association_type: "Campaign"
|
|
50
|
+
)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def ad_extension_ids(creation_response)
|
|
54
|
+
creation_response[:ad_extension_identities][:ad_extension_identity].map do |ext|
|
|
55
|
+
ext[:id].to_i
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def get_ad_extensions_associations
|
|
60
|
+
api.campaign_management.get_ad_extensions_associations(
|
|
61
|
+
account_id: Examples.account_id,
|
|
62
|
+
ad_extension_type: "CallAdExtension SitelinkAdExtension CalloutAdExtension",
|
|
63
|
+
association_type: "Campaign",
|
|
64
|
+
entity_ids: [{ long: Examples.campaign_id }]
|
|
65
|
+
)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
context "with shared ad extensions" do
|
|
69
|
+
before(:all) do
|
|
70
|
+
# we use a global var to create ad extensions once, its enough
|
|
71
|
+
$created_ad_extension_response = create_add_ad_extensions
|
|
72
|
+
set_ad_extensions_associations(ad_extension_ids($created_ad_extension_response))
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
describe "#add_ad_extensions" do
|
|
76
|
+
it "returns AdExtension ids" do
|
|
77
|
+
expect($created_ad_extension_response).to include(
|
|
78
|
+
ad_extension_identities: {
|
|
79
|
+
ad_extension_identity: [
|
|
80
|
+
{ id: a_kind_of(String), version: "1" },
|
|
81
|
+
{ id: a_kind_of(String), version: "1" },
|
|
82
|
+
{ id: a_kind_of(String), version: "1" },
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
nested_partial_errors: ""
|
|
86
|
+
)
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
describe "#get_ad_extensions_associations" do
|
|
91
|
+
let(:call_ad_extension) do
|
|
92
|
+
{
|
|
93
|
+
ad_extension: {
|
|
94
|
+
device_preference: nil,
|
|
95
|
+
forward_compatibility_map: "",
|
|
96
|
+
id: match(/[0-9]*/),
|
|
97
|
+
scheduling: nil,
|
|
98
|
+
status: a_kind_of(String),
|
|
99
|
+
type: "CallAdExtension",
|
|
100
|
+
version: match(/[0-9]*/),
|
|
101
|
+
country_code: a_kind_of(String),
|
|
102
|
+
is_call_only: "false",
|
|
103
|
+
is_call_tracking_enabled: "false",
|
|
104
|
+
phone_number: match(/[0-9]*/),
|
|
105
|
+
require_toll_free_tracking_number: nil,
|
|
106
|
+
},
|
|
107
|
+
association_type: "Campaign",
|
|
108
|
+
editorial_status: a_kind_of(String),
|
|
109
|
+
entity_id: Examples.campaign_id.to_s
|
|
110
|
+
}
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
let(:callout_ad_extension) do
|
|
114
|
+
{
|
|
115
|
+
ad_extension: {
|
|
116
|
+
device_preference: nil,
|
|
117
|
+
forward_compatibility_map: "",
|
|
118
|
+
id: match(/[0-9]*/),
|
|
119
|
+
scheduling: nil,
|
|
120
|
+
status: a_kind_of(String),
|
|
121
|
+
type: "CalloutAdExtension",
|
|
122
|
+
version: match(/[0-9]*/),
|
|
123
|
+
text: a_kind_of(String)
|
|
124
|
+
},
|
|
125
|
+
association_type: "Campaign",
|
|
126
|
+
editorial_status: a_kind_of(String),
|
|
127
|
+
entity_id: Examples.campaign_id.to_s
|
|
128
|
+
}
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
let(:sitelink_ad_extension) do
|
|
132
|
+
{
|
|
133
|
+
ad_extension: {
|
|
134
|
+
device_preference: nil,
|
|
135
|
+
forward_compatibility_map: "",
|
|
136
|
+
id: match(/[0-9]*/),
|
|
137
|
+
status: a_kind_of(String),
|
|
138
|
+
type: "SitelinkAdExtension",
|
|
139
|
+
version: match(/[0-9]*/),
|
|
140
|
+
description1: a_kind_of(String),
|
|
141
|
+
description2: a_kind_of(String),
|
|
142
|
+
destination_url: nil,
|
|
143
|
+
display_text: a_kind_of(String),
|
|
144
|
+
final_app_urls: nil,
|
|
145
|
+
final_url_suffix: nil,
|
|
146
|
+
final_mobile_urls: {
|
|
147
|
+
string: a_kind_of(String)
|
|
148
|
+
},
|
|
149
|
+
final_urls: {
|
|
150
|
+
string: a_kind_of(String)
|
|
151
|
+
},
|
|
152
|
+
scheduling: nil,
|
|
153
|
+
tracking_url_template: a_kind_of(String),
|
|
154
|
+
url_custom_parameters: nil
|
|
155
|
+
},
|
|
156
|
+
association_type: "Campaign",
|
|
157
|
+
editorial_status: "Active",
|
|
158
|
+
entity_id: Examples.campaign_id.to_s
|
|
159
|
+
}
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def get_association(associations, type)
|
|
163
|
+
associations.select { |record| record[:ad_extension][:type] == type }.first
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
it "returns a list of Associations" do
|
|
167
|
+
fetched_associations = get_ad_extensions_associations
|
|
168
|
+
|
|
169
|
+
# These are split apart to make it easier to figure out which one is missing
|
|
170
|
+
expect(get_association(fetched_associations, "CallAdExtension"))
|
|
171
|
+
.to include(call_ad_extension)
|
|
172
|
+
|
|
173
|
+
expect(get_association(fetched_associations, "CalloutAdExtension"))
|
|
174
|
+
.to include(callout_ad_extension)
|
|
175
|
+
|
|
176
|
+
expect(get_association(fetched_associations, "SitelinkAdExtension"))
|
|
177
|
+
.to include(sitelink_ad_extension)
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
describe "#get_ad_extension_ids_by_account_id" do
|
|
182
|
+
it "returns a list of IDs" do
|
|
183
|
+
fetched_ad_extension_ids = api.campaign_management.get_ad_extension_ids_by_account_id(
|
|
184
|
+
account_id: Examples.account_id,
|
|
185
|
+
ad_extension_type: 'SitelinkAdExtension CallAdExtension CalloutAdExtension'
|
|
186
|
+
)
|
|
187
|
+
ad_extension_ids($created_ad_extension_response).each do |id|
|
|
188
|
+
expect(fetched_ad_extension_ids).to include id
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
describe "#get_ad_extensions_by_ids" do
|
|
194
|
+
it "returns AdExtensions" do
|
|
195
|
+
extensions = api.campaign_management.get_ad_extensions_by_ids(
|
|
196
|
+
account_id: Examples.account_id,
|
|
197
|
+
ad_extension_ids: ad_extension_ids($created_ad_extension_response).map { |id| { long: id } },
|
|
198
|
+
ad_extension_type: 'SitelinkAdExtension CallAdExtension CalloutAdExtension'
|
|
199
|
+
)
|
|
200
|
+
expect(extensions).to be_an(Array)
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
describe "#delete_ad_extensions" do
|
|
206
|
+
let(:response) { create_add_ad_extensions }
|
|
207
|
+
|
|
208
|
+
it "returns no errors" do
|
|
209
|
+
expect(api.campaign_management.call(:delete_ad_extensions,
|
|
210
|
+
account_id: Examples.account_id,
|
|
211
|
+
ad_extension_ids: [ { long: ad_extension_ids(response).first }]
|
|
212
|
+
)).to eq(partial_errors: "")
|
|
213
|
+
end
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
describe "#delete_ad_extensions_associations" do
|
|
217
|
+
before do
|
|
218
|
+
response = create_add_ad_extensions
|
|
219
|
+
set_ad_extensions_associations(ad_extension_ids(response))
|
|
220
|
+
end
|
|
221
|
+
let(:ad_extension_id) do
|
|
222
|
+
get_ad_extensions_associations.first[:ad_extension][:id]
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
it "currently raises an error" do
|
|
226
|
+
expect(api.campaign_management.call(:delete_ad_extensions_associations,
|
|
227
|
+
account_id: Examples.account_id,
|
|
228
|
+
ad_extension_id_to_entity_id_associations: [
|
|
229
|
+
ad_extension_id_to_entity_id_association: {
|
|
230
|
+
ad_extension_id: ad_extension_id,
|
|
231
|
+
entity_id: Examples.campaign_id,
|
|
232
|
+
}
|
|
233
|
+
],
|
|
234
|
+
association_type: "Campaign"
|
|
235
|
+
)).to eq(partial_errors: "")
|
|
236
|
+
end
|
|
237
|
+
end
|
|
238
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require_relative '../examples'
|
|
2
|
+
|
|
3
|
+
RSpec.describe 'AdGroup methods' do
|
|
4
|
+
include_context 'use api'
|
|
5
|
+
|
|
6
|
+
describe '#add_ad_groups' do
|
|
7
|
+
it 'returns created AdGroup ids' do
|
|
8
|
+
ad_groups = api.campaign_management.call(:add_ad_groups,
|
|
9
|
+
campaign_id: Examples.campaign_id,
|
|
10
|
+
ad_groups: {
|
|
11
|
+
ad_group: {
|
|
12
|
+
name: "AcceptanceTestAdGroup - #{random}",
|
|
13
|
+
language: 'French',
|
|
14
|
+
start_date: {
|
|
15
|
+
day: '1',
|
|
16
|
+
month: '1',
|
|
17
|
+
year: '2049',
|
|
18
|
+
},
|
|
19
|
+
end_date: {
|
|
20
|
+
day: '1',
|
|
21
|
+
month: '2',
|
|
22
|
+
year: '2049',
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
)
|
|
27
|
+
expect(ad_groups).to include(
|
|
28
|
+
ad_group_ids: [a_kind_of(Integer)],
|
|
29
|
+
partial_errors: ''
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
puts "Please fill in examples.rb with ad_group_id: #{ad_groups[:ad_group_ids].first}"
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
require_relative '../examples'
|
|
2
|
+
|
|
3
|
+
RSpec.describe 'CampaignCriterion methods' do
|
|
4
|
+
include_context 'use api'
|
|
5
|
+
|
|
6
|
+
def add_campaign_criterions(location_id)
|
|
7
|
+
api.campaign_management.call(:add_campaign_criterions,
|
|
8
|
+
campaign_criterions: [
|
|
9
|
+
{
|
|
10
|
+
negative_campaign_criterion: {
|
|
11
|
+
campaign_id: Examples.campaign_id,
|
|
12
|
+
location_criterion: {
|
|
13
|
+
location_id: location_id
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
criterion_type: 'Targets'
|
|
19
|
+
)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe '#add_campaign_criterions' do
|
|
23
|
+
it 'returns CampaignCriterion ids' do
|
|
24
|
+
expect(add_campaign_criterions(190)).to include(
|
|
25
|
+
campaign_criterion_ids: [a_kind_of(Integer)],
|
|
26
|
+
nested_partial_errors: ''
|
|
27
|
+
)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe '#delete_campaign_criterions' do
|
|
32
|
+
it 'returns no errors' do
|
|
33
|
+
response = add_campaign_criterions(191)
|
|
34
|
+
|
|
35
|
+
expect(api.campaign_management.call(:delete_campaign_criterions,
|
|
36
|
+
campaign_criterion_ids: [
|
|
37
|
+
{ long: response[:campaign_criterion_ids].first }
|
|
38
|
+
],
|
|
39
|
+
campaign_id: Examples.campaign_id,
|
|
40
|
+
criterion_type: 'Targets'
|
|
41
|
+
)).to eq(
|
|
42
|
+
partial_errors: ''
|
|
43
|
+
)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
describe '#get_campaign_criterions_by_ids' do
|
|
48
|
+
it 'returns CampaignCriterions' do
|
|
49
|
+
response = add_campaign_criterions(193)
|
|
50
|
+
criterion_id = response[:campaign_criterion_ids].first.to_s
|
|
51
|
+
|
|
52
|
+
criterions = api.campaign_management.get_campaign_criterions_by_ids(
|
|
53
|
+
campaign_criterion_ids: [{ long: criterion_id }],
|
|
54
|
+
campaign_id: Examples.campaign_id,
|
|
55
|
+
criterion_type: 'Age DayTime Device Gender Location LocationIntent Radius'
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
expect(criterions).to include(
|
|
59
|
+
campaign_id: Examples.campaign_id.to_s,
|
|
60
|
+
criterion: {
|
|
61
|
+
type: 'LocationCriterion',
|
|
62
|
+
display_name: a_kind_of(String),
|
|
63
|
+
enclosed_location_ids: nil,
|
|
64
|
+
location_id: '193',
|
|
65
|
+
location_type: a_kind_of(String),
|
|
66
|
+
},
|
|
67
|
+
forward_compatibility_map: nil,
|
|
68
|
+
id: criterion_id,
|
|
69
|
+
status: a_kind_of(String),
|
|
70
|
+
type: 'NegativeCampaignCriterion'
|
|
71
|
+
)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|