bing_ads_ruby_sdk 1.0.0 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +52 -0
  3. data/.github/delete-merged-branch-config.yml +6 -0
  4. data/.github/stale.yml +19 -0
  5. data/.gitignore +2 -0
  6. data/README.md +25 -5
  7. data/bing_ads_ruby_sdk.gemspec +6 -5
  8. data/changelog.md +27 -2
  9. data/lib/bing_ads_ruby_sdk/api.rb +3 -1
  10. data/lib/bing_ads_ruby_sdk/configuration.rb +2 -1
  11. data/lib/bing_ads_ruby_sdk/header.rb +8 -4
  12. data/lib/bing_ads_ruby_sdk/http_client.rb +19 -9
  13. data/lib/bing_ads_ruby_sdk/oauth2/authorization_handler.rb +17 -10
  14. data/lib/bing_ads_ruby_sdk/services/base.rb +6 -6
  15. data/lib/bing_ads_ruby_sdk/services/campaign_management.rb +3 -0
  16. data/lib/bing_ads_ruby_sdk/version.rb +2 -2
  17. data/lib/bing_ads_ruby_sdk/wsdl/v13/production/ad_insight.xml +1 -0
  18. data/lib/bing_ads_ruby_sdk/wsdl/v13/production/bulk.xml +1 -0
  19. data/lib/bing_ads_ruby_sdk/wsdl/v13/production/campaign_management.xml +1 -0
  20. data/lib/bing_ads_ruby_sdk/wsdl/v13/production/customer_billing.xml +1 -0
  21. data/lib/bing_ads_ruby_sdk/wsdl/v13/production/customer_management.xml +1 -0
  22. data/lib/bing_ads_ruby_sdk/wsdl/v13/production/reporting.xml +1 -0
  23. data/lib/bing_ads_ruby_sdk/wsdl/v13/sandbox/ad_insight.xml +3037 -0
  24. data/lib/bing_ads_ruby_sdk/wsdl/v13/sandbox/bulk.xml +1 -0
  25. data/lib/bing_ads_ruby_sdk/wsdl/v13/sandbox/campaign_management.xml +1 -0
  26. data/lib/bing_ads_ruby_sdk/wsdl/v13/sandbox/customer_billing.xml +1 -0
  27. data/lib/bing_ads_ruby_sdk/wsdl/v13/sandbox/customer_management.xml +1 -0
  28. data/lib/bing_ads_ruby_sdk/wsdl/v13/sandbox/reporting.xml +1 -0
  29. data/lib/bing_ads_ruby_sdk/wsdl/{v12 → v13}/test/ad_insight.xml +1440 -1468
  30. data/lib/bing_ads_ruby_sdk/wsdl/{v12 → v13}/test/bulk.xml +83 -147
  31. data/lib/bing_ads_ruby_sdk/wsdl/{v12 → v13}/test/campaign_management.xml +711 -417
  32. data/lib/bing_ads_ruby_sdk/wsdl/{v12 → v13}/test/customer_billing.xml +62 -112
  33. data/lib/bing_ads_ruby_sdk/wsdl/{v12 → v13}/test/customer_management.xml +231 -176
  34. data/lib/bing_ads_ruby_sdk/wsdl/{v12 → v13}/test/reporting.xml +110 -158
  35. data/lib/bing_ads_ruby_sdk/wsdl/wsdl_source.txt +18 -18
  36. data/spec/bing_ads_ruby_sdk/api_spec.rb +17 -0
  37. data/spec/bing_ads_ruby_sdk/errors/error_handler_spec.rb +479 -0
  38. data/spec/bing_ads_ruby_sdk/errors/errors_spec.rb +13 -0
  39. data/spec/bing_ads_ruby_sdk/header_spec.rb +60 -0
  40. data/spec/bing_ads_ruby_sdk/http_client_spec.rb +44 -0
  41. data/spec/bing_ads_ruby_sdk/oauth2/fs_store_spec.rb +20 -0
  42. data/spec/bing_ads_ruby_sdk/postprocessors/cast_long_arrays_spec.rb +30 -0
  43. data/spec/bing_ads_ruby_sdk/postprocessors/snakize_spec.rb +40 -0
  44. data/spec/bing_ads_ruby_sdk/preprocessors/camelize_spec.rb +40 -0
  45. data/spec/bing_ads_ruby_sdk/preprocessors/order_spec.rb +119 -0
  46. data/spec/bing_ads_ruby_sdk/services/bulk_spec.rb +56 -0
  47. data/spec/bing_ads_ruby_sdk/services/campaign_management_spec.rb +307 -0
  48. data/spec/bing_ads_ruby_sdk/services/customer_management_spec.rb +97 -0
  49. data/spec/bing_ads_ruby_sdk_spec.rb +5 -0
  50. data/spec/examples/1_customer_creation/customer_spec.rb +35 -0
  51. data/spec/examples/2_with_customer/budget_spec.rb +54 -0
  52. data/spec/examples/2_with_customer/campaigns_spec.rb +27 -0
  53. data/spec/examples/2_with_customer/customer_management_spec.rb +190 -0
  54. data/spec/examples/2_with_customer/uet_tags_spec.rb +42 -0
  55. data/spec/examples/3_with_uet_tag/conversion_goal_spec.rb +40 -0
  56. data/spec/examples/3_with_uet_tag/uet_tags_spec.rb +56 -0
  57. data/spec/examples/4_with_conversion_goal/conversion_goals_spec.rb +75 -0
  58. data/spec/examples/5_with_campaign/ad_extension_spec.rb +238 -0
  59. data/spec/examples/5_with_campaign/ad_group_spec.rb +35 -0
  60. data/spec/examples/5_with_campaign/campaign_criterions_spec.rb +74 -0
  61. data/spec/examples/5_with_campaign/campaign_spec.rb +71 -0
  62. data/spec/examples/6_with_ad_group/ad_group_spec.rb +71 -0
  63. data/spec/examples/6_with_ad_group/ads_spec.rb +113 -0
  64. data/spec/examples/6_with_ad_group/keywords_spec.rb +108 -0
  65. data/spec/examples/examples.rb +76 -0
  66. data/spec/fixtures/bulk/download_campaigns_by_account_ids/standard.xml +23 -0
  67. data/spec/fixtures/bulk/download_campaigns_by_account_ids/standard_response.xml +11 -0
  68. data/spec/fixtures/bulk/get_bulk_download_status/standard.xml +14 -0
  69. data/spec/fixtures/bulk/get_bulk_download_status/standard_response.xml +15 -0
  70. data/spec/fixtures/campaign_management/add_ad_extensions/standard.xml +21 -0
  71. data/spec/fixtures/campaign_management/add_ad_extensions/standard_response.xml +17 -0
  72. data/spec/fixtures/campaign_management/add_conversion_goals/standard.xml +27 -0
  73. data/spec/fixtures/campaign_management/add_conversion_goals/standard_response.xml +14 -0
  74. data/spec/fixtures/campaign_management/add_shared_entity/standard.xml +16 -0
  75. data/spec/fixtures/campaign_management/add_shared_entity/standard_response.xml +13 -0
  76. data/spec/fixtures/campaign_management/add_uet_tags/standard.xml +19 -0
  77. data/spec/fixtures/campaign_management/add_uet_tags/standard_response.xml +21 -0
  78. data/spec/fixtures/campaign_management/get_ad_extension_ids_by_account_id/standard.xml +15 -0
  79. data/spec/fixtures/campaign_management/get_ad_extension_ids_by_account_id/standard_response.xml +13 -0
  80. data/spec/fixtures/campaign_management/get_ad_extensions_associations/standard.xml +19 -0
  81. data/spec/fixtures/campaign_management/get_ad_extensions_associations/standard_response.xml +47 -0
  82. data/spec/fixtures/campaign_management/get_budgets_by_ids/standard.xml +12 -0
  83. data/spec/fixtures/campaign_management/get_budgets_by_ids/standard_response.xml +20 -0
  84. data/spec/fixtures/campaign_management/get_campaigns_by_account_id/standard.xml +14 -0
  85. data/spec/fixtures/campaign_management/get_campaigns_by_account_id/standard_response.xml +84 -0
  86. data/spec/fixtures/campaign_management/get_conversion_goals_by_ids/standard.xml +18 -0
  87. data/spec/fixtures/campaign_management/get_conversion_goals_by_ids/standard_response.xml +61 -0
  88. data/spec/fixtures/campaign_management/get_shared_entities_by_account_id/standard.xml +14 -0
  89. data/spec/fixtures/campaign_management/get_shared_entities_by_account_id/standard_response.xml +20 -0
  90. data/spec/fixtures/campaign_management/get_shared_entity_associations_by_entity_ids/standard.xml +18 -0
  91. data/spec/fixtures/campaign_management/get_shared_entity_associations_by_entity_ids/standard_response.xml +19 -0
  92. data/spec/fixtures/campaign_management/get_uet_tags_by_ids/standard.xml +16 -0
  93. data/spec/fixtures/campaign_management/get_uet_tags_by_ids/standard_response.xml +21 -0
  94. data/spec/fixtures/campaign_management/set_ad_extensions_associations/standard.xml +21 -0
  95. data/spec/fixtures/campaign_management/set_ad_extensions_associations/standard_response.xml +11 -0
  96. data/spec/fixtures/campaign_management/set_shared_entity_associations/standard.xml +21 -0
  97. data/spec/fixtures/campaign_management/set_shared_entity_associations/standard_response.xml +11 -0
  98. data/spec/fixtures/campaign_management/update_conversion_goals/standard.xml +27 -0
  99. data/spec/fixtures/campaign_management/update_conversion_goals/standard_response.xml +11 -0
  100. data/spec/fixtures/campaign_management/update_uet_tags/standard.xml +20 -0
  101. data/spec/fixtures/campaign_management/update_uet_tags/standard_response.xml +11 -0
  102. data/spec/fixtures/customer_management/find_accounts_or_customers_info/standard.xml +15 -0
  103. data/spec/fixtures/customer_management/find_accounts_or_customers_info/standard_response.xml +21 -0
  104. data/spec/fixtures/customer_management/get_account/standard.xml +14 -0
  105. data/spec/fixtures/customer_management/get_account/standard_response.xml +43 -0
  106. data/spec/fixtures/customer_management/signup_customer/standard.xml +30 -0
  107. data/spec/fixtures/customer_management/signup_customer/standard_response.xml +15 -0
  108. data/spec/fixtures/customer_management/update_account/standard.xml +19 -0
  109. data/spec/fixtures/customer_management/update_account/standard_response.xml +11 -0
  110. data/spec/spec_helper.rb +33 -0
  111. data/spec/support/spec_helpers.rb +45 -0
  112. data/tasks/bing_ads_ruby_sdk.rake +5 -6
  113. metadata +202 -27
  114. data/.travis.yml +0 -5
  115. data/lib/bing_ads_ruby_sdk/wsdl/v12/production/ad_insight.xml +0 -1
  116. data/lib/bing_ads_ruby_sdk/wsdl/v12/production/bulk.xml +0 -1
  117. data/lib/bing_ads_ruby_sdk/wsdl/v12/production/campaign_management.xml +0 -1
  118. data/lib/bing_ads_ruby_sdk/wsdl/v12/production/customer_billing.xml +0 -1
  119. data/lib/bing_ads_ruby_sdk/wsdl/v12/production/customer_management.xml +0 -1
  120. data/lib/bing_ads_ruby_sdk/wsdl/v12/production/reporting.xml +0 -1
  121. data/lib/bing_ads_ruby_sdk/wsdl/v12/sandbox/ad_insight.xml +0 -1
  122. data/lib/bing_ads_ruby_sdk/wsdl/v12/sandbox/bulk.xml +0 -1
  123. data/lib/bing_ads_ruby_sdk/wsdl/v12/sandbox/campaign_management.xml +0 -1
  124. data/lib/bing_ads_ruby_sdk/wsdl/v12/sandbox/customer_billing.xml +0 -1
  125. data/lib/bing_ads_ruby_sdk/wsdl/v12/sandbox/customer_management.xml +0 -1
  126. data/lib/bing_ads_ruby_sdk/wsdl/v12/sandbox/reporting.xml +0 -1
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe BingAdsRubySdk::Errors::ApplicationFault do
4
+ describe '#fault_hash' do
5
+ context 'when creating an instance' do
6
+ subject(:create_instance) { described_class.new({ details: nil }) }
7
+
8
+ it 'instantiates without raising an exception' do
9
+ expect { create_instance }.not_to raise_error
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,60 @@
1
+ RSpec.describe BingAdsRubySdk::Header do
2
+ let(:oauth_store) { double(:oauth_store) }
3
+ let(:client_secret) { 'pa$$w0rd' }
4
+ let(:subject) do
5
+ described_class.new(
6
+ developer_token: '123abc',
7
+ client_id: '1a-2b-3c',
8
+ client_secret: client_secret,
9
+ store: oauth_store,
10
+ )
11
+ end
12
+ let(:auth_handler) do
13
+ double(:auth_handler, fetch_or_refresh: 'yes/we/can')
14
+ end
15
+
16
+ before do
17
+ expect(::BingAdsRubySdk::OAuth2::AuthorizationHandler).to receive(:new).with(
18
+ developer_token: '123abc',
19
+ client_id: '1a-2b-3c',
20
+ client_secret: client_secret,
21
+ store: oauth_store
22
+ ).and_return auth_handler
23
+ end
24
+
25
+ describe '.content' do
26
+ it do
27
+ expect(subject.content).to eq(
28
+ "AuthenticationToken" => 'yes/we/can',
29
+ "DeveloperToken" => '123abc',
30
+ "CustomerId" => nil,
31
+ "CustomerAccountId" => nil,
32
+ "ClientSecret" => client_secret
33
+ )
34
+ end
35
+
36
+ context "without client_secret" do
37
+ let(:client_secret) { nil }
38
+ it do
39
+ expect(subject.content).to eq(
40
+ "AuthenticationToken" => 'yes/we/can',
41
+ "DeveloperToken" => '123abc',
42
+ "CustomerId" => nil,
43
+ "CustomerAccountId" => nil
44
+ )
45
+ end
46
+ end
47
+
48
+ it 'sets customer' do
49
+ subject.set_customer(customer_id: 777, account_id: 666 )
50
+
51
+ expect(subject.content).to eq(
52
+ "AuthenticationToken" => 'yes/we/can',
53
+ "DeveloperToken" => '123abc',
54
+ "CustomerId" => 777,
55
+ "CustomerAccountId" => 666,
56
+ "ClientSecret" => client_secret
57
+ )
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,44 @@
1
+ RSpec.describe BingAdsRubySdk::HttpClient do
2
+
3
+ describe ".post" do
4
+ let(:request) do
5
+ double(:request,
6
+ url: "http://bing_url.com/foo",
7
+ content: "body",
8
+ headers: "headers"
9
+ )
10
+ end
11
+ let(:excon) { double(:excon) }
12
+
13
+ before do
14
+ expect(::Excon).to receive(:new).and_return(excon)
15
+ expect(excon).to receive(:post).with(
16
+ path: "/foo",
17
+ body: "body",
18
+ headers: "headers"
19
+ ).and_return(response)
20
+ end
21
+
22
+ context "successful request" do
23
+ let(:response) { double(:response, body: "soap xml") }
24
+ it "returns response's body" do
25
+ expect(described_class.post(request)).to eq("soap xml")
26
+ end
27
+ end
28
+ end
29
+
30
+ describe ".close_http_connections" do
31
+ let(:connection1) { double("connection1") }
32
+ let(:connection2) { double("connection2") }
33
+ it "closes existing connections" do
34
+ expect(described_class).to receive(:http_connections).and_return({
35
+ "url1" => connection1,
36
+ "url2" => connection2,
37
+ })
38
+ expect(connection1).to receive :reset
39
+ expect(connection2).to receive :reset
40
+
41
+ described_class.close_http_connections
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,20 @@
1
+
2
+ RSpec.describe BingAdsRubySdk::OAuth2::FsStore do
3
+ after do
4
+ File.unlink('./.abc') if File.file?('./.abc')
5
+ end
6
+ let(:store) { described_class.new('.abc') }
7
+
8
+ context "when not empty" do
9
+ before { store.write(a: 1, b: "2") }
10
+ it "writes and read properly" do
11
+ expect(store.read).to eq("a" => 1, "b" => "2")
12
+ end
13
+ end
14
+
15
+ context "when empty" do
16
+ it "reads properly" do
17
+ expect(store.read).to be nil
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe BingAdsRubySdk::Postprocessors::CastLongArrays do
4
+
5
+ def action(params)
6
+ described_class.new(params).call
7
+ end
8
+
9
+ it "casts and simplifies long arrays" do
10
+ expect(action({
11
+ long: "foo",
12
+ bar_bar: {
13
+ long: ['1', '2']
14
+ },
15
+ foos: [
16
+ {
17
+ bar: {
18
+ long: ['3', '4']
19
+ }
20
+ }
21
+ ]
22
+ })).to eq({
23
+ long: "foo",
24
+ bar_bar: [1, 2],
25
+ foos: [
26
+ { bar: [3, 4] }
27
+ ]
28
+ })
29
+ end
30
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe BingAdsRubySdk::Postprocessors::Snakize do
4
+
5
+ def action(params)
6
+ described_class.new(params).call
7
+ end
8
+
9
+ it "changes keys to snake version" do
10
+ expect(action({
11
+ "Foo" => "foo",
12
+ "BarBar" => {
13
+ "BazBaz" => "baz"
14
+ },
15
+ "Coucou" => [
16
+ {
17
+ "Bisou" => 1
18
+ }
19
+ ]
20
+ })).to eq({
21
+ foo: "foo",
22
+ bar_bar: {
23
+ baz_baz: "baz"
24
+ },
25
+ coucou: [
26
+ {
27
+ bisou: 1
28
+ }
29
+ ]
30
+ })
31
+ end
32
+
33
+ it "handles properly 'long' tag name" do
34
+ expect(action({
35
+ "long" => "1"
36
+ })).to eq({
37
+ long: "1"
38
+ })
39
+ end
40
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe BingAdsRubySdk::Preprocessors::Camelize do
4
+
5
+ def action(params)
6
+ described_class.new(params).call
7
+ end
8
+
9
+ it "changes keys to camelize version" do
10
+ expect(action({
11
+ foo: "foo",
12
+ bar_bar: {
13
+ baz_baz: "baz"
14
+ },
15
+ coucou: [
16
+ {
17
+ bisou: 1
18
+ }
19
+ ]
20
+ })).to eq({
21
+ "Foo" => "foo",
22
+ "BarBar" => {
23
+ "BazBaz" => "baz"
24
+ },
25
+ "Coucou" => [
26
+ {
27
+ "Bisou" => 1
28
+ }
29
+ ]
30
+ })
31
+ end
32
+
33
+ it "doesnt camelize 'long' tag name" do
34
+ expect(action({
35
+ long: "1"
36
+ })).to eq({
37
+ "long" => "1"
38
+ })
39
+ end
40
+ end
@@ -0,0 +1,119 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe BingAdsRubySdk::Preprocessors::Order do
4
+
5
+ def action
6
+ new_params = described_class.new(wrapper, unordered_params).call
7
+ expect(new_params.to_json).to eq(ordered_params.to_json)
8
+ end
9
+
10
+ context "nested hashes" do
11
+ let(:wrapper) do
12
+ SpecHelpers.wrapper(:customer_management, "SignupCustomer")
13
+ end
14
+
15
+ let(:unordered_params) {{
16
+ "Account" => {
17
+ "Name" => "test account",
18
+ "CurrencyCode" => "EUR",
19
+ "ParentCustomerId" => "1234"
20
+ },
21
+ "Customer" => {
22
+ "CustomerAddress" => "address",
23
+ "Industry" => "industry",
24
+ "MarketCountry" => "country"
25
+ },
26
+ "ParentCustomerId" => "1234"
27
+ }}
28
+
29
+ let(:ordered_params) {{
30
+ "Customer" => {
31
+ "Industry" => "industry",
32
+ "MarketCountry" => "country",
33
+ "CustomerAddress" => "address"
34
+ },
35
+ "Account" => {
36
+ "CurrencyCode" => "EUR",
37
+ "Name" => "test account",
38
+ "ParentCustomerId" => "1234"
39
+ },
40
+ "ParentCustomerId" => "1234"
41
+ }}
42
+
43
+ it("orders") { action }
44
+ end
45
+
46
+ context "arrays" do
47
+ let(:wrapper) do
48
+ SpecHelpers.wrapper(:campaign_management, "UpdateUetTags")
49
+ end
50
+
51
+ let(:unordered_params) {{
52
+ "UetTags" => [
53
+ {
54
+ "UetTag" => {
55
+ "Name" => 'mofo2',
56
+ "Description" => nil,
57
+ "Id" => '26034398'
58
+ }
59
+ }
60
+ ]
61
+ }}
62
+
63
+ let(:ordered_params) {{
64
+ "UetTags" => [
65
+ {
66
+ "UetTag" => {
67
+ "Description" => nil,
68
+ "Id" => '26034398',
69
+ "Name" => 'mofo2'
70
+ }
71
+ }
72
+ ]
73
+ }}
74
+
75
+ it("orders") { action }
76
+ end
77
+
78
+ context "abstract types" do
79
+ let(:wrapper) do
80
+ SpecHelpers.wrapper(:campaign_management, "AddConversionGoals")
81
+ end
82
+
83
+ let(:unordered_params) {{
84
+ "ConversionGoals" => [
85
+ {
86
+ "EventGoal" => {
87
+ "ActionExpression" => 'contact_form',
88
+ "ActionOperator" => 'Equals',
89
+ "ConversionWindowInMinutes" => 43200,
90
+ "CountType" => "Unique",
91
+ "Name" => "contact_form",
92
+ "Revenue" => { "Type" => "NoValue" },
93
+ "Type" => "Event",
94
+ "TagId" => 26003317
95
+ }
96
+ }
97
+ ]
98
+ }}
99
+
100
+ let(:ordered_params) {{
101
+ "ConversionGoals" => [
102
+ {
103
+ "EventGoal" => {
104
+ "ConversionWindowInMinutes" => 43200,
105
+ "CountType" => "Unique",
106
+ "Name" => "contact_form",
107
+ "Revenue" => { "Type" => "NoValue" },
108
+ "TagId" => 26003317,
109
+ "Type" => "Event",
110
+ "ActionExpression" => 'contact_form',
111
+ "ActionOperator" => 'Equals',
112
+ }
113
+ }
114
+ ]
115
+ }}
116
+
117
+ it("orders") { action }
118
+ end
119
+ end
@@ -0,0 +1,56 @@
1
+ RSpec.describe BingAdsRubySdk::Services::Bulk do
2
+
3
+ let(:service_name) { described_class.service }
4
+ let(:soap_client) { SpecHelpers.soap_client(service_name) }
5
+ let(:expected_xml) { SpecHelpers.request_xml_for(service_name, action, filename) }
6
+ let(:mocked_response) { SpecHelpers.response_xml_for(service_name, action, filename) }
7
+
8
+ let(:service) { described_class.new(soap_client) }
9
+
10
+ before do
11
+ expect(BingAdsRubySdk::HttpClient).to receive(:post) do |req|
12
+ expect(Nokogiri::XML(req.content).to_xml).to eq expected_xml.to_xml
13
+ mocked_response
14
+ end
15
+ end
16
+
17
+ describe "download_campaigns_by_account_ids" do
18
+ let(:action) { 'download_campaigns_by_account_ids' }
19
+ let(:filename) { 'standard' }
20
+
21
+ it "returns expected result" do
22
+ expect(
23
+ service.download_campaigns_by_account_ids(
24
+ account_ids: [{ long: 150168726 }],
25
+ data_scope: "EntityData",
26
+ download_file_type: "Csv",
27
+ compression_type: "Zip",
28
+ download_entities: [
29
+ { download_entity: "Campaigns" }
30
+ ],
31
+ format_version: "6.0"
32
+ )
33
+ ).to eq({
34
+ download_request_id: "618504973441"
35
+ })
36
+ end
37
+ end
38
+
39
+ describe "get_bulk_download_status" do
40
+ let(:action) { 'get_bulk_download_status' }
41
+ let(:filename) { 'standard' }
42
+
43
+ it "returns expected result" do
44
+ expect(
45
+ service.get_bulk_download_status(request_id: 618504973441)
46
+ ).to include(
47
+ request_status: 'Completed',
48
+ result_file_url: "cool_url"
49
+ )
50
+ end
51
+ end
52
+ end
53
+
54
+
55
+
56
+
@@ -0,0 +1,307 @@
1
+ RSpec.describe BingAdsRubySdk::Services::CampaignManagement do
2
+
3
+ let(:service_name) { described_class.service }
4
+ let(:soap_client) { SpecHelpers.soap_client(service_name) }
5
+ let(:expected_xml) { SpecHelpers.request_xml_for(service_name, action, filename) }
6
+ let(:mocked_response) { SpecHelpers.response_xml_for(service_name, action, filename) }
7
+
8
+ let(:service) { described_class.new(soap_client) }
9
+
10
+ before do
11
+ expect(BingAdsRubySdk::HttpClient).to receive(:post) do |req|
12
+ expect(Nokogiri::XML(req.content).to_xml).to eq expected_xml.to_xml
13
+ mocked_response
14
+ end
15
+ end
16
+
17
+ describe "get_campaigns_by_account_id" do
18
+ let(:action) { 'get_campaigns_by_account_id' }
19
+ let(:filename) { 'standard' }
20
+
21
+ it "returns expected result" do
22
+ expect(
23
+ service.get_campaigns_by_account_id(account_id: 150168726)
24
+ ).to contain_exactly(
25
+ a_hash_including(name: "20200015 - 20200015 - SN - B - Activité - Stations_Service - Geoloc - ETA"),
26
+ a_hash_including(name: "20200015 - 20200015 - SN - E - Produits - Stations_Service - Geoloc - ETA"),
27
+ a_hash_including(name: "20200015 - SN - X - Station Service #1 - Geozone_custom - 5KW - V3 - ETA")
28
+ )
29
+ end
30
+ end
31
+
32
+ describe "get_budgets_by_ids" do
33
+ let(:action) { 'get_budgets_by_ids' }
34
+ let(:filename) { 'standard' }
35
+
36
+ it "returns expected result" do
37
+ expect(
38
+ service.get_budgets_by_ids
39
+ ).to contain_exactly(
40
+ a_hash_including(name: "budget_DEFAULT"),
41
+ )
42
+ end
43
+ end
44
+
45
+ describe "add_uet_tags" do
46
+ let(:action) { 'add_uet_tags' }
47
+ let(:filename) { 'standard' }
48
+
49
+ it "returns expected result" do
50
+ expect(
51
+ service.add_uet_tags({ uet_tags: [ { uet_tag: { name: 'SDK-test', description: nil }}]})
52
+ ).to include({
53
+ uet_tags: a_hash_including({
54
+ uet_tag: a_collection_containing_exactly(
55
+ a_hash_including(name: "SDK-test")
56
+ )
57
+ }),
58
+ partial_errors: ""
59
+ })
60
+ end
61
+ end
62
+
63
+ describe "update_uet_tags" do
64
+ let(:action) { 'update_uet_tags' }
65
+ let(:filename) { 'standard' }
66
+
67
+ it "returns expected result" do
68
+ expect(
69
+ service.update_uet_tags({ uet_tags: [ { uet_tag: { name: 'updated SDK-test', id: 96031109, description: nil}}]})
70
+ ).to eq({
71
+ partial_errors: ""
72
+ })
73
+ end
74
+ end
75
+
76
+ describe "get_uet_tags_by_ids" do
77
+ let(:action) { 'get_uet_tags_by_ids' }
78
+ let(:filename) { 'standard' }
79
+
80
+ it "returns expected result" do
81
+ expect(
82
+ service.get_uet_tags_by_ids(tag_ids: [{ long: 96031109 }])
83
+ ).to contain_exactly(
84
+ a_hash_including(name: "updated SDK-test")
85
+ )
86
+ end
87
+ end
88
+
89
+ describe "add_conversion_goals" do
90
+ let(:action) { 'add_conversion_goals' }
91
+ let(:filename) { 'standard' }
92
+
93
+ it "returns expected result" do
94
+ expect(
95
+ service.add_conversion_goals(conversion_goals: [{
96
+ event_goal: {
97
+ action_expression: 'contact_form',
98
+ action_operator: 'Equals',
99
+ conversion_window_in_minutes: 43200,
100
+ count_type: "Unique",
101
+ name: "sdk test",
102
+ revenue: { "type": "NoValue" },
103
+ type: "Event",
104
+ tag_id: 96031109
105
+ }
106
+ }])).to eq({
107
+ conversion_goal_ids: [46068449],
108
+ partial_errors: ""
109
+ })
110
+ end
111
+ end
112
+
113
+ describe "update_conversion_goals" do
114
+ let(:action) { 'update_conversion_goals' }
115
+ let(:filename) { 'standard' }
116
+
117
+ it "returns expected result" do
118
+ expect(
119
+ service.update_conversion_goals(conversion_goals: [{
120
+ event_goal: {
121
+ id: 46068449,
122
+ action_expression: 'contact_form',
123
+ action_operator: 'Equals',
124
+ conversion_window_in_minutes: 43200,
125
+ count_type: "Unique",
126
+ name: "updated sdk test",
127
+ revenue: { "type": "NoValue" },
128
+ tag_id: 96031109
129
+ }
130
+ }])).to eq({
131
+ partial_errors: ""
132
+ })
133
+ end
134
+ end
135
+
136
+ describe "get_conversion_goals_by_ids" do
137
+ let(:action) { 'get_conversion_goals_by_ids' }
138
+ let(:filename) { 'standard' }
139
+
140
+ it "returns expected result" do
141
+ expect(
142
+ service.get_conversion_goals_by_ids(
143
+ conversion_goal_types: "Event",
144
+ conversion_goal_ids: [{ long: 46068449 }, { long: 46068448 }]
145
+ )
146
+ ).to contain_exactly(
147
+ a_hash_including(name: "updated sdk test"),
148
+ a_hash_including(name: "random")
149
+ )
150
+ end
151
+ end
152
+
153
+ describe "add_ad_extensions" do
154
+ let(:action) { 'add_ad_extensions' }
155
+ let(:filename) { 'standard' }
156
+
157
+ it "returns expected result" do
158
+ expect(
159
+ service.add_ad_extensions(
160
+ account_id: 150168726,
161
+ ad_extensions: [
162
+ {
163
+ call_ad_extension: {
164
+ scheduling: {},
165
+ country_code: "NZ",
166
+ phone_number: "0123456699",
167
+ }
168
+ }
169
+ ]
170
+ )).to include({
171
+ ad_extension_identities: a_hash_including({
172
+ ad_extension_identity: a_collection_containing_exactly(
173
+ a_hash_including(id: "8177660966625")
174
+ )
175
+ }),
176
+ nested_partial_errors: ""
177
+ })
178
+ end
179
+ end
180
+
181
+ describe "get_ad_extension_ids_by_account_id" do
182
+ let(:action) { 'get_ad_extension_ids_by_account_id' }
183
+ let(:filename) { 'standard' }
184
+
185
+ it "returns expected result" do
186
+ expect(
187
+ service.get_ad_extension_ids_by_account_id(
188
+ account_id: 150168726,
189
+ ad_extension_type: "CallAdExtension SitelinkAdExtension CalloutAdExtension"
190
+ )
191
+ ).to eq([
192
+ 8177660966625
193
+ ])
194
+ end
195
+ end
196
+
197
+ describe "set_ad_extensions_associations" do
198
+ let(:action) { 'set_ad_extensions_associations' }
199
+ let(:filename) { 'standard' }
200
+
201
+ it "returns expected result" do
202
+ expect(
203
+ service.set_ad_extensions_associations(
204
+ account_id: 150168726,
205
+ ad_extension_id_to_entity_id_associations: [{
206
+ ad_extension_id_to_entity_id_association: {
207
+ ad_extension_id: 8177660966942,
208
+ entity_id: 349704437
209
+ }
210
+ }],
211
+ association_type: "Campaign"
212
+ )).to eq({
213
+ partial_errors: ""
214
+ })
215
+ end
216
+ end
217
+
218
+ describe "get_ad_extensions_associations" do
219
+ let(:action) { 'get_ad_extensions_associations' }
220
+ let(:filename) { 'standard' }
221
+
222
+ it "returns expected result" do
223
+ expect(
224
+ service.get_ad_extensions_associations(
225
+ account_id: 150168726,
226
+ association_type: "Campaign",
227
+ ad_extension_type: "CalloutAdExtension",
228
+ entity_ids: [ { long: 349704437 }]
229
+ )
230
+ ).to contain_exactly(
231
+ a_hash_including(
232
+ ad_extension: a_hash_including(id: '8177650858590', text: "Informations Et Contact")
233
+ ),
234
+ a_hash_including(
235
+ ad_extension: a_hash_including(id: '8177660966942', text: "CalloutText")
236
+ )
237
+ )
238
+ end
239
+ end
240
+
241
+ describe "add_shared_entity" do
242
+ let(:action) { 'add_shared_entity' }
243
+ let(:filename) { 'standard' }
244
+
245
+ it "returns expected result" do
246
+ expect(
247
+ service.add_shared_entity(
248
+ negative_keyword_list: {
249
+ name: 'sdk list'
250
+ }
251
+ )).to eq({
252
+ list_item_ids: "",
253
+ partial_errors: "",
254
+ shared_entity_id: "229798145242911"
255
+ })
256
+ end
257
+ end
258
+
259
+ describe "get_shared_entities_by_account_id" do
260
+ let(:action) { 'get_shared_entities_by_account_id' }
261
+ let(:filename) { 'standard' }
262
+
263
+ it "returns expected result" do
264
+ expect(
265
+ service.get_shared_entities_by_account_id(
266
+ shared_entity_type: "NegativeKeywordList"
267
+ )).to contain_exactly(
268
+ a_hash_including(id: '229798145242911', name: "sdk list")
269
+ )
270
+ end
271
+ end
272
+
273
+ describe "get_shared_entity_associations_by_entity_ids" do
274
+ let(:action) { 'get_shared_entity_associations_by_entity_ids' }
275
+ let(:filename) { 'standard' }
276
+
277
+ it "returns expected result" do
278
+ expect(
279
+ service.get_shared_entity_associations_by_entity_ids({
280
+ entity_ids: [{ long: 349704435 }],
281
+ entity_type: "Campaign",
282
+ shared_entity_type: "NegativeKeywordList"
283
+ })).to eq([
284
+ { entity_id: "349704435", entity_type: "Campaign", shared_entity_id: "223200992903993", shared_entity_type: "NegativeKeywordList" }
285
+ ])
286
+ end
287
+ end
288
+
289
+ describe "set_shared_entity_associations" do
290
+ let(:action) { 'set_shared_entity_associations' }
291
+ let(:filename) { 'standard' }
292
+
293
+ it "returns expected result" do
294
+ expect(
295
+ service.set_shared_entity_associations(
296
+ associations: [{
297
+ shared_entity_association: {
298
+ entity_id: "349704435",
299
+ entity_type: "Account",
300
+ shared_entity_id: "223200992903993",
301
+ shared_entity_type: "PlacementExclusionList"
302
+ },
303
+ }]
304
+ )).to eq({ partial_errors: "" })
305
+ end
306
+ end
307
+ end