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.
- 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
@@ -1,25 +1,25 @@
|
|
1
1
|
For the records and future maintenance, here are the urls where we got the wsdl files:
|
2
2
|
|
3
3
|
PRODUCTION:
|
4
|
-
ad_insight: https://adinsight.api.bingads.microsoft.com/Api/Advertiser/AdInsight/
|
5
|
-
bulk: https://bulk.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/
|
6
|
-
campaign_management: https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/
|
7
|
-
customer_billing: https://clientcenter.api.bingads.microsoft.com/Api/Billing/
|
8
|
-
customer_management: https://clientcenter.api.bingads.microsoft.com/Api/CustomerManagement/
|
9
|
-
reporting: https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/
|
4
|
+
ad_insight: https://adinsight.api.bingads.microsoft.com/Api/Advertiser/AdInsight/v13/AdInsightService.svc?singleWsdl
|
5
|
+
bulk: https://bulk.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v13/BulkService.svc?singleWsdl
|
6
|
+
campaign_management: https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v13/CampaignManagementService.svc?singleWsdl
|
7
|
+
customer_billing: https://clientcenter.api.bingads.microsoft.com/Api/Billing/v13/CustomerBillingService.svc?singleWsdl
|
8
|
+
customer_management: https://clientcenter.api.bingads.microsoft.com/Api/CustomerManagement/v13/CustomerManagementService.svc?singleWsdl
|
9
|
+
reporting: https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/v13/ReportingService.svc?singleWsdl
|
10
10
|
|
11
11
|
SANDBOX:
|
12
|
-
ad_insight: https://adinsight.api.sandbox.bingads.microsoft.com/Api/Advertiser/AdInsight/
|
13
|
-
bulk: https://bulk.api.sandbox.bingads.microsoft.com/Api/Advertiser/CampaignManagement/
|
14
|
-
campaign_management: https://campaign.api.sandbox.bingads.microsoft.com/Api/Advertiser/CampaignManagement/
|
15
|
-
customer_billing: https://clientcenter.api.sandbox.bingads.microsoft.com/Api/Billing/
|
16
|
-
customer_management: https://clientcenter.api.sandbox.bingads.microsoft.com/Api/CustomerManagement/
|
17
|
-
reporting: https://reporting.api.sandbox.bingads.microsoft.com/Api/Advertiser/Reporting/
|
12
|
+
ad_insight: https://adinsight.api.sandbox.bingads.microsoft.com/Api/Advertiser/AdInsight/v13/AdInsightService.svc?singleWsdl
|
13
|
+
bulk: https://bulk.api.sandbox.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v13/BulkService.svc?singleWsdl
|
14
|
+
campaign_management: https://campaign.api.sandbox.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v13/CampaignManagementService.svc?singleWsdl
|
15
|
+
customer_billing: https://clientcenter.api.sandbox.bingads.microsoft.com/Api/Billing/v13/CustomerBillingService.svc?singleWsdl
|
16
|
+
customer_management: https://clientcenter.api.sandbox.bingads.microsoft.com/Api/CustomerManagement/v13/CustomerManagementService.svc?singleWsdl
|
17
|
+
reporting: https://reporting.api.sandbox.bingads.microsoft.com/Api/Advertiser/Reporting/v13/ReportingService.svc?singleWsdl
|
18
18
|
|
19
19
|
TEST:
|
20
|
-
ad_insight: https://adinsight.api.bingads.microsoft.com/Api/Advertiser/AdInsight/
|
21
|
-
bulk: https://bulk.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/
|
22
|
-
campaign_management: https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/
|
23
|
-
customer_billing: https://clientcenter.api.bingads.microsoft.com/Api/Billing/
|
24
|
-
customer_management: https://clientcenter.api.bingads.microsoft.com/Api/CustomerManagement/
|
25
|
-
reporting: https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/
|
20
|
+
ad_insight: https://adinsight.api.bingads.microsoft.com/Api/Advertiser/AdInsight/v13/AdInsightService.svc?singleWsdl
|
21
|
+
bulk: https://bulk.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v13/BulkService.svc?singleWsdl
|
22
|
+
campaign_management: https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v13/CampaignManagementService.svc?singleWsdl
|
23
|
+
customer_billing: https://clientcenter.api.bingads.microsoft.com/Api/Billing/v13/CustomerBillingService.svc?singleWsdl
|
24
|
+
customer_management: https://clientcenter.api.bingads.microsoft.com/Api/CustomerManagement/v13/CustomerManagementService.svc?singleWsdl
|
25
|
+
reporting: https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/v13/ReportingService.svc?singleWsdl
|
@@ -0,0 +1,17 @@
|
|
1
|
+
RSpec.describe BingAdsRubySdk::Api do
|
2
|
+
subject do
|
3
|
+
described_class.new(
|
4
|
+
environment: :test,
|
5
|
+
oauth_store: SpecHelpers.default_store,
|
6
|
+
client_id: 'client_id',
|
7
|
+
developer_token: 'developer_token'
|
8
|
+
)
|
9
|
+
end
|
10
|
+
|
11
|
+
it { expect(subject.ad_insight).to be_a(BingAdsRubySdk::Services::AdInsight) }
|
12
|
+
it { expect(subject.bulk).to be_a(BingAdsRubySdk::Services::Bulk) }
|
13
|
+
it { expect(subject.campaign_management).to be_a(BingAdsRubySdk::Services::CampaignManagement) }
|
14
|
+
it { expect(subject.customer_billing).to be_a(BingAdsRubySdk::Services::CustomerBilling) }
|
15
|
+
it { expect(subject.customer_management).to be_a(BingAdsRubySdk::Services::CustomerManagement) }
|
16
|
+
it { expect(subject.reporting).to be_a(BingAdsRubySdk::Services::Reporting) }
|
17
|
+
end
|
@@ -0,0 +1,479 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe BingAdsRubySdk::Errors::ErrorHandler do
|
4
|
+
let(:general_error) { BingAdsRubySdk::Errors::GeneralError }
|
5
|
+
let(:subject) { described_class.new(api_response).call }
|
6
|
+
|
7
|
+
def shared_expectations
|
8
|
+
expect { subject }.to raise_error do |error|
|
9
|
+
expect(error).to be_a(error_class)
|
10
|
+
expect(error).to have_attributes(error_attributes)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'when there is no fault' do
|
15
|
+
let(:api_response) do
|
16
|
+
{
|
17
|
+
is_migrated: 'false',
|
18
|
+
nested_partial_errors: ''
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
it { is_expected.to be nil }
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when there is a fault' do
|
26
|
+
let(:api_response) do
|
27
|
+
{
|
28
|
+
faultcode: 's:Server',
|
29
|
+
faultstring:
|
30
|
+
'Invalid client data. Check the SOAP fault details',
|
31
|
+
detail: detail
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
let(:batch_error) do
|
36
|
+
{
|
37
|
+
batch_error: {
|
38
|
+
code: '0000',
|
39
|
+
details: 'Batch error details',
|
40
|
+
error_code: 'ErrorCode',
|
41
|
+
field_path: '{lpurl}',
|
42
|
+
index: '0',
|
43
|
+
message: 'Batch error message',
|
44
|
+
type: 'reserved for internal use'
|
45
|
+
}
|
46
|
+
}
|
47
|
+
end
|
48
|
+
let(:batch_error_list) { [batch_error] }
|
49
|
+
|
50
|
+
let(:editorial_error_list) do
|
51
|
+
[
|
52
|
+
# Inherits from BatchError
|
53
|
+
batch_error[:batch_error].merge(
|
54
|
+
appealable: true,
|
55
|
+
disapproved_text: 'The text that caused the entity to ...',
|
56
|
+
location: 'ElementName',
|
57
|
+
publisher_country: 'New Zealand',
|
58
|
+
reason_code: 4
|
59
|
+
)
|
60
|
+
]
|
61
|
+
end
|
62
|
+
|
63
|
+
let(:operation_errors) do
|
64
|
+
[{
|
65
|
+
operation_error: {
|
66
|
+
code: '4503',
|
67
|
+
details: 'Invalid API Campaign Criterion Type : 0 on API tier',
|
68
|
+
error_code: 'TypeInvalid',
|
69
|
+
message: "The campaign criterion ..."
|
70
|
+
}
|
71
|
+
}]
|
72
|
+
end
|
73
|
+
|
74
|
+
let(:error_message) do
|
75
|
+
'Bing Ads API error - Invalid client data. Check the SOAP fault details'
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'of type ApiFaultDetail' do
|
79
|
+
let(:detail) do
|
80
|
+
{
|
81
|
+
api_fault_detail: {
|
82
|
+
tracking_id: '14f89175-e806-4822-8aa7-32b0c7734e11',
|
83
|
+
batch_errors: '',
|
84
|
+
operation_errors: operation_errors
|
85
|
+
}
|
86
|
+
}
|
87
|
+
end
|
88
|
+
|
89
|
+
let(:error_attributes) do
|
90
|
+
{
|
91
|
+
batch_errors: [],
|
92
|
+
operation_errors: operation_errors,
|
93
|
+
message: "TypeInvalid - The campaign criterion ..."
|
94
|
+
}
|
95
|
+
end
|
96
|
+
|
97
|
+
let(:error_class) { BingAdsRubySdk::Errors::ApiFaultDetail }
|
98
|
+
|
99
|
+
it('raises an error') { shared_expectations }
|
100
|
+
end
|
101
|
+
|
102
|
+
context 'of type AdApiFaultDetail' do
|
103
|
+
let(:detail) do
|
104
|
+
{
|
105
|
+
ad_api_fault_detail: {
|
106
|
+
tracking_id: '14f89175-e806-4822-8aa7-32b0c7734e11',
|
107
|
+
errors: errors
|
108
|
+
}
|
109
|
+
}
|
110
|
+
end
|
111
|
+
|
112
|
+
let(:errors) do
|
113
|
+
[{
|
114
|
+
ad_api_error: {
|
115
|
+
code: '0000',
|
116
|
+
detail: 'Details about error',
|
117
|
+
error_code: 'ErrorCode',
|
118
|
+
message: 'Fault message'
|
119
|
+
}
|
120
|
+
}]
|
121
|
+
end
|
122
|
+
|
123
|
+
let(:error_class) { BingAdsRubySdk::Errors::AdApiFaultDetail }
|
124
|
+
let(:error_attributes) do
|
125
|
+
{
|
126
|
+
errors: errors,
|
127
|
+
message: 'ErrorCode - Fault message'
|
128
|
+
}
|
129
|
+
end
|
130
|
+
|
131
|
+
it('raises an error') { shared_expectations }
|
132
|
+
end
|
133
|
+
|
134
|
+
context 'of type EditorialApiFaultDetail' do
|
135
|
+
let(:detail) do
|
136
|
+
{
|
137
|
+
editorial_api_fault_detail: {
|
138
|
+
tracking_id: '14f89175-e806-4822-8aa7-32b0c7734e11',
|
139
|
+
batch_errors: batch_error_list,
|
140
|
+
editorial_errors: editorial_error_list,
|
141
|
+
operation_errors: operation_errors
|
142
|
+
}
|
143
|
+
}
|
144
|
+
end
|
145
|
+
|
146
|
+
let(:error_class) { BingAdsRubySdk::Errors::EditorialApiFaultDetail }
|
147
|
+
|
148
|
+
let(:error_attributes) do
|
149
|
+
{
|
150
|
+
batch_errors: batch_error_list,
|
151
|
+
editorial_errors: editorial_error_list,
|
152
|
+
operation_errors: operation_errors,
|
153
|
+
message: error_message
|
154
|
+
}
|
155
|
+
end
|
156
|
+
|
157
|
+
context 'when all the lists have errors' do
|
158
|
+
let(:error_message) do
|
159
|
+
'API raised 3 errors, including: ErrorCode - Batch error message'
|
160
|
+
end
|
161
|
+
it('raises an error') { shared_expectations }
|
162
|
+
end
|
163
|
+
|
164
|
+
context 'when some of the lists are empty' do
|
165
|
+
let(:batch_error_list) { [] }
|
166
|
+
let(:editorial_error_list) { [] }
|
167
|
+
let(:error_message) do
|
168
|
+
"TypeInvalid - The campaign criterion ..."
|
169
|
+
end
|
170
|
+
|
171
|
+
it('raises an error') { shared_expectations }
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
context 'of type ApiBatchFault' do
|
176
|
+
let(:detail) do
|
177
|
+
{
|
178
|
+
api_batch_fault: {
|
179
|
+
tracking_id: '14f89175-e806-4822-8aa7-32b0c7734e11',
|
180
|
+
batch_errors: batch_error_list
|
181
|
+
}
|
182
|
+
}
|
183
|
+
end
|
184
|
+
|
185
|
+
let(:error_class) { BingAdsRubySdk::Errors::ApiBatchFault }
|
186
|
+
let(:error_attributes) do
|
187
|
+
{
|
188
|
+
batch_errors: batch_error_list,
|
189
|
+
message: 'ErrorCode - Batch error message'
|
190
|
+
}
|
191
|
+
end
|
192
|
+
|
193
|
+
it('raises an error') { shared_expectations }
|
194
|
+
end
|
195
|
+
|
196
|
+
context 'of type ApiFault' do
|
197
|
+
let(:detail) do
|
198
|
+
{
|
199
|
+
api_fault: {
|
200
|
+
tracking_id: '14f89175-e806-4822-8aa7-32b0c7734e11',
|
201
|
+
operation_errors: operation_errors
|
202
|
+
}
|
203
|
+
}
|
204
|
+
end
|
205
|
+
|
206
|
+
let(:error_attributes) do
|
207
|
+
{
|
208
|
+
operation_errors: operation_errors,
|
209
|
+
message: "TypeInvalid - The campaign criterion ..."
|
210
|
+
}
|
211
|
+
end
|
212
|
+
let(:error_class) { BingAdsRubySdk::Errors::ApiFault }
|
213
|
+
|
214
|
+
it('raises an error') { shared_expectations }
|
215
|
+
end
|
216
|
+
|
217
|
+
context 'of type InvalidCredentials' do
|
218
|
+
let(:api_response) do
|
219
|
+
{
|
220
|
+
code: '105',
|
221
|
+
detail: nil,
|
222
|
+
error_code: 'InvalidCredentials',
|
223
|
+
message: 'Authentication failed. Either supplied ...'
|
224
|
+
}
|
225
|
+
end
|
226
|
+
|
227
|
+
let(:error_class) { general_error }
|
228
|
+
|
229
|
+
let(:error_attributes) do
|
230
|
+
{
|
231
|
+
raw_response: api_response,
|
232
|
+
message: "InvalidCredentials - #{api_response[:message]}"
|
233
|
+
}
|
234
|
+
end
|
235
|
+
|
236
|
+
it('raises an error') { shared_expectations }
|
237
|
+
end
|
238
|
+
|
239
|
+
context 'of an unknown type' do
|
240
|
+
let(:detail) do
|
241
|
+
{
|
242
|
+
new_fault_unknown_to_sdk: {
|
243
|
+
tracking_id: '14f89175-e806-4822-8aa7-32b0c7734e11',
|
244
|
+
new_field: 'value'
|
245
|
+
}
|
246
|
+
}
|
247
|
+
end
|
248
|
+
|
249
|
+
let(:error_class) { general_error }
|
250
|
+
|
251
|
+
let(:error_attributes) do
|
252
|
+
{
|
253
|
+
raw_response: api_response,
|
254
|
+
message: error_message
|
255
|
+
}
|
256
|
+
end
|
257
|
+
|
258
|
+
it('raises an error') { shared_expectations }
|
259
|
+
end
|
260
|
+
|
261
|
+
context 'when there are no details' do
|
262
|
+
let(:detail) { nil }
|
263
|
+
let(:error_class) { general_error }
|
264
|
+
let(:error_attributes) do
|
265
|
+
{
|
266
|
+
raw_response: api_response,
|
267
|
+
message: error_message
|
268
|
+
}
|
269
|
+
end
|
270
|
+
|
271
|
+
it('raises an error') { shared_expectations }
|
272
|
+
end
|
273
|
+
|
274
|
+
context 'when there is no error_code' do
|
275
|
+
let(:detail) do
|
276
|
+
{
|
277
|
+
api_fault: {
|
278
|
+
tracking_id: '14f89175-e806-4822-8aa7-32b0c7734e11',
|
279
|
+
batch_errors: '',
|
280
|
+
operation_errors: {
|
281
|
+
operation_error: {
|
282
|
+
code: '1001',
|
283
|
+
details: '',
|
284
|
+
message: 'The user is not authorized to perform this action.'
|
285
|
+
}
|
286
|
+
}
|
287
|
+
}
|
288
|
+
}
|
289
|
+
end
|
290
|
+
let(:error_class) { BingAdsRubySdk::Errors::ApiFault }
|
291
|
+
let(:error_attributes) do
|
292
|
+
{
|
293
|
+
raw_response: api_response,
|
294
|
+
message: 'The user is not authorized to perform this action.'
|
295
|
+
}
|
296
|
+
end
|
297
|
+
|
298
|
+
it('raises an error') { shared_expectations }
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
context 'when there is a deserialization error' do
|
303
|
+
# rubocop:disable Metrics/LineLength
|
304
|
+
let(:api_response) do
|
305
|
+
{
|
306
|
+
faultcode: 'a:DeserializationFailed',
|
307
|
+
faultstring: "The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter https://bingads.microsoft.com/CampaignManagement/v11:CampaignId. The InnerException message was 'There was an error deserializing the object of type System.Int64. The value '' cannot be parsed as the type 'Int64'.'. Please see InnerException for more details.",
|
308
|
+
detail: {
|
309
|
+
exception_detail: {
|
310
|
+
help_link: nil,
|
311
|
+
inner_exception: {
|
312
|
+
help_link: nil,
|
313
|
+
inner_exception: {
|
314
|
+
help_link: nil,
|
315
|
+
inner_exception: {
|
316
|
+
help_link: nil,
|
317
|
+
inner_exception: nil,
|
318
|
+
message: 'Input string was not in a correct format.',
|
319
|
+
stack_trace: " at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)\r\n at System.Number.ParseInt64(String value, NumberStyles options, NumberFormatInfo numfmt)\r\n at System.Xml.XmlConverter.ToInt64(String value)",
|
320
|
+
type: 'System.FormatException'
|
321
|
+
},
|
322
|
+
message: "The value '' cannot be parsed as the type 'Int64'.",
|
323
|
+
stack_trace: " at System.Xml.XmlConverter.ToInt64(String value)\r\n at System.Xml.XmlDictionaryReader.ReadElementContentAsLong()\r\n at System.Runtime.Serialization.LongDataContract.ReadXmlValue(XmlReaderDelegator reader, XmlObjectSerializerReadContext context)\r\n at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)",
|
324
|
+
type: 'System.Xml.XmlException'
|
325
|
+
},
|
326
|
+
message: "There was an error deserializing the object of type System.Int64. The value '' cannot be parsed as the type 'Int64'.",
|
327
|
+
stack_trace: " at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)\r\n at System.Runtime.Serialization.DataContractSerializer.ReadObject(XmlDictionaryReader reader, Boolean verifyObjectName)\r\n at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.PartInfo.ReadObject(XmlDictionaryReader reader, XmlObjectSerializer serializer)\r\n at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part, Boolean isRequest)",
|
328
|
+
type: 'System.Runtime.Serialization.SerializationException'
|
329
|
+
},
|
330
|
+
message: "The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter https://bingads.microsoft.com/CampaignManagement/v11:CampaignId. The InnerException message was 'There was an error deserializing the object of type System.Int64. The value '' cannot be parsed as the type 'Int64'.'. Please see InnerException for more details.",
|
331
|
+
stack_trace: " at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part, Boolean isRequest)\r\n at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameters(XmlDictionaryReader reader, PartInfo[] parts, Object[] parameters, Boolean isRequest)\r\n at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, String action, MessageDescription messageDescription, Object[] parameters, Boolean isRequest)\r\n at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(Message message, Object[] parameters, Boolean isRequest)\r\n at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeRequest(Message message, Object[] parameters)\r\n at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc& rpc)\r\n at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)\r\n at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)\r\n at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)\r\n at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)",
|
332
|
+
type: 'System.ServiceModel.Dispatcher.NetDispatcherFaultException'
|
333
|
+
}
|
334
|
+
}
|
335
|
+
}
|
336
|
+
end
|
337
|
+
# rubocop:enable Metrics/LineLength
|
338
|
+
|
339
|
+
let(:error_class) { BingAdsRubySdk::Errors::GeneralError }
|
340
|
+
let(:error_attributes) do
|
341
|
+
{
|
342
|
+
raw_response: api_response,
|
343
|
+
message: "Bing Ads API error - The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter https://bingads.microsoft.com/CampaignManagement/v11:CampaignId. The InnerException message was 'There was an error deserializing the object of type System.Int64. The value '' cannot be parsed as the type 'Int64'.'. Please see InnerException for more details."
|
344
|
+
}
|
345
|
+
end
|
346
|
+
|
347
|
+
it('raises an error') { shared_expectations }
|
348
|
+
end
|
349
|
+
|
350
|
+
context 'when there are nested partial errors' do
|
351
|
+
let(:api_response) do
|
352
|
+
{
|
353
|
+
campaign_criterion_ids: [],
|
354
|
+
is_migrated: 'false',
|
355
|
+
nested_partial_errors: {
|
356
|
+
batch_error_collection: [
|
357
|
+
{
|
358
|
+
batch_errors: nil,
|
359
|
+
code: '1043',
|
360
|
+
details: 'Criterion already exists',
|
361
|
+
error_code: 'AlreadyExists',
|
362
|
+
field_path: nil,
|
363
|
+
forward_compatibility_map: nil,
|
364
|
+
index: '0',
|
365
|
+
message: 'The specified entity already exists.',
|
366
|
+
type: 'BatchErrorCollection'
|
367
|
+
}
|
368
|
+
]
|
369
|
+
}
|
370
|
+
}
|
371
|
+
end
|
372
|
+
|
373
|
+
context 'when the default behaviour is used' do
|
374
|
+
let(:error_class) { BingAdsRubySdk::Errors::NestedPartialError }
|
375
|
+
let(:error_attributes) do
|
376
|
+
{
|
377
|
+
raw_response: api_response,
|
378
|
+
message: 'AlreadyExists - The specified entity already exists.'
|
379
|
+
}
|
380
|
+
end
|
381
|
+
|
382
|
+
it('raises an error') { shared_expectations }
|
383
|
+
end
|
384
|
+
|
385
|
+
context 'when the ignore partial errors switch is on' do
|
386
|
+
it 'should return the NestedPartialError as a Hash'
|
387
|
+
end
|
388
|
+
end
|
389
|
+
|
390
|
+
context 'when there are partial errors - multiple batch_errors' do
|
391
|
+
let(:api_response) do
|
392
|
+
{
|
393
|
+
campaign_ids: [],
|
394
|
+
partial_errors: {
|
395
|
+
batch_error: [
|
396
|
+
{
|
397
|
+
code: '4701',
|
398
|
+
details: nil,
|
399
|
+
error_code: 'UnsupportedBiddingScheme',
|
400
|
+
field_path: nil,
|
401
|
+
forward_compatibility_map: nil,
|
402
|
+
index: '0',
|
403
|
+
message: 'The bidding...',
|
404
|
+
type: 'BatchError'
|
405
|
+
},
|
406
|
+
{
|
407
|
+
code: '4701',
|
408
|
+
details: nil,
|
409
|
+
error_code: 'UnsupportedBiddingScheme',
|
410
|
+
field_path: nil,
|
411
|
+
forward_compatibility_map: nil,
|
412
|
+
index: '1',
|
413
|
+
message: 'The bidding...',
|
414
|
+
type: 'BatchError'
|
415
|
+
}
|
416
|
+
]
|
417
|
+
}
|
418
|
+
}
|
419
|
+
end
|
420
|
+
|
421
|
+
context 'when the default behaviour is used' do
|
422
|
+
let(:error_class) { BingAdsRubySdk::Errors::PartialError }
|
423
|
+
|
424
|
+
let(:error_attributes) do
|
425
|
+
{
|
426
|
+
raw_response: api_response,
|
427
|
+
message: 'API raised 2 errors, including: UnsupportedBiddingScheme - The bidding...'
|
428
|
+
}
|
429
|
+
end
|
430
|
+
|
431
|
+
it('raises an error') { shared_expectations }
|
432
|
+
end
|
433
|
+
|
434
|
+
context 'when the ignore partial errors switch is on' do
|
435
|
+
it 'should return the PartialError as a Hash'
|
436
|
+
end
|
437
|
+
end
|
438
|
+
|
439
|
+
context 'when there are partial errors - one batch_error' do
|
440
|
+
let(:api_response) do
|
441
|
+
{
|
442
|
+
campaign_ids: [],
|
443
|
+
partial_errors: {
|
444
|
+
batch_error: {
|
445
|
+
code: '4701',
|
446
|
+
details: nil,
|
447
|
+
error_code: 'UnsupportedBiddingScheme',
|
448
|
+
field_path: nil,
|
449
|
+
forward_compatibility_map: nil,
|
450
|
+
index: '0',
|
451
|
+
message: 'The bidding...',
|
452
|
+
type: 'BatchError'
|
453
|
+
},
|
454
|
+
}
|
455
|
+
}
|
456
|
+
end
|
457
|
+
|
458
|
+
context 'when the default behaviour is used' do
|
459
|
+
let(:error_class) { BingAdsRubySdk::Errors::PartialError }
|
460
|
+
|
461
|
+
let(:error_attributes) do
|
462
|
+
{
|
463
|
+
raw_response: api_response,
|
464
|
+
message: 'UnsupportedBiddingScheme - The bidding...'
|
465
|
+
}
|
466
|
+
end
|
467
|
+
|
468
|
+
it('raises an error') { shared_expectations }
|
469
|
+
|
470
|
+
it "contains a collection of batch_error" do
|
471
|
+
expect { subject }.to raise_error do |error|
|
472
|
+
expect(error).to respond_to(:batch_error)
|
473
|
+
expect(error.batch_error).to be_a(Array)
|
474
|
+
expect(error.batch_error.size).to eq(1)
|
475
|
+
end
|
476
|
+
end
|
477
|
+
end
|
478
|
+
end
|
479
|
+
end
|