bing_ads_ruby_sdk 1.5.0 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +21 -5
- data/Rakefile +1 -1
- data/bing_ads_ruby_sdk.gemspec +9 -1
- data/changelog.md +3 -0
- data/lib/Rakefile +4 -0
- data/lib/bing_ads_ruby_sdk/errors/errors.rb +1 -1
- data/lib/bing_ads_ruby_sdk/railtie.rb +13 -0
- data/{tasks → lib/bing_ads_ruby_sdk/tasks}/bing_ads_ruby_sdk.rake +1 -1
- data/lib/bing_ads_ruby_sdk/version.rb +1 -1
- data/lib/bing_ads_ruby_sdk.rb +1 -0
- metadata +6 -85
- data/.circleci/config.yml +0 -54
- data/.github/.keep +0 -0
- data/.github/renovate.json +0 -225
- data/.gitignore +0 -19
- data/.rspec +0 -4
- data/spec/bing_ads_ruby_sdk/api_spec.rb +0 -17
- data/spec/bing_ads_ruby_sdk/errors/error_handler_spec.rb +0 -477
- data/spec/bing_ads_ruby_sdk/errors/errors_spec.rb +0 -13
- data/spec/bing_ads_ruby_sdk/header_spec.rb +0 -60
- data/spec/bing_ads_ruby_sdk/http_client_spec.rb +0 -42
- data/spec/bing_ads_ruby_sdk/oauth2/fs_store_spec.rb +0 -19
- data/spec/bing_ads_ruby_sdk/postprocessors/cast_long_arrays_spec.rb +0 -29
- data/spec/bing_ads_ruby_sdk/postprocessors/snakize_spec.rb +0 -39
- data/spec/bing_ads_ruby_sdk/preprocessors/camelize_spec.rb +0 -39
- data/spec/bing_ads_ruby_sdk/preprocessors/order_spec.rb +0 -130
- data/spec/bing_ads_ruby_sdk/services/bulk_spec.rb +0 -51
- data/spec/bing_ads_ruby_sdk/services/campaign_management_spec.rb +0 -314
- data/spec/bing_ads_ruby_sdk/services/customer_management_spec.rb +0 -96
- data/spec/bing_ads_ruby_sdk_spec.rb +0 -5
- data/spec/examples/1_customer_creation/customer_spec.rb +0 -35
- data/spec/examples/2_with_customer/budget_spec.rb +0 -52
- data/spec/examples/2_with_customer/campaigns_spec.rb +0 -26
- data/spec/examples/2_with_customer/customer_management_spec.rb +0 -188
- data/spec/examples/2_with_customer/uet_tags_spec.rb +0 -42
- data/spec/examples/3_with_uet_tag/conversion_goal_spec.rb +0 -40
- data/spec/examples/3_with_uet_tag/uet_tags_spec.rb +0 -56
- data/spec/examples/4_with_conversion_goal/conversion_goals_spec.rb +0 -76
- data/spec/examples/5_with_campaign/ad_extension_spec.rb +0 -235
- data/spec/examples/5_with_campaign/ad_group_spec.rb +0 -34
- data/spec/examples/5_with_campaign/campaign_criterions_spec.rb +0 -72
- data/spec/examples/5_with_campaign/campaign_spec.rb +0 -70
- data/spec/examples/6_with_ad_group/ad_group_spec.rb +0 -70
- data/spec/examples/6_with_ad_group/ads_spec.rb +0 -110
- data/spec/examples/6_with_ad_group/keywords_spec.rb +0 -105
- data/spec/examples/examples.rb +0 -75
- data/spec/fixtures/bulk/download_campaigns_by_account_ids/standard.xml +0 -23
- data/spec/fixtures/bulk/download_campaigns_by_account_ids/standard_response.xml +0 -11
- data/spec/fixtures/bulk/get_bulk_download_status/standard.xml +0 -14
- data/spec/fixtures/bulk/get_bulk_download_status/standard_response.xml +0 -15
- data/spec/fixtures/campaign_management/add_ad_extensions/standard.xml +0 -21
- data/spec/fixtures/campaign_management/add_ad_extensions/standard_response.xml +0 -17
- data/spec/fixtures/campaign_management/add_conversion_goals/standard.xml +0 -27
- data/spec/fixtures/campaign_management/add_conversion_goals/standard_response.xml +0 -14
- data/spec/fixtures/campaign_management/add_shared_entity/standard.xml +0 -16
- data/spec/fixtures/campaign_management/add_shared_entity/standard_response.xml +0 -13
- data/spec/fixtures/campaign_management/add_uet_tags/standard.xml +0 -19
- data/spec/fixtures/campaign_management/add_uet_tags/standard_response.xml +0 -21
- data/spec/fixtures/campaign_management/get_ad_extension_ids_by_account_id/standard.xml +0 -15
- data/spec/fixtures/campaign_management/get_ad_extension_ids_by_account_id/standard_response.xml +0 -13
- data/spec/fixtures/campaign_management/get_ad_extensions_associations/standard.xml +0 -19
- data/spec/fixtures/campaign_management/get_ad_extensions_associations/standard_response.xml +0 -47
- data/spec/fixtures/campaign_management/get_budgets_by_ids/standard.xml +0 -12
- data/spec/fixtures/campaign_management/get_budgets_by_ids/standard_response.xml +0 -20
- data/spec/fixtures/campaign_management/get_campaigns_by_account_id/standard.xml +0 -14
- data/spec/fixtures/campaign_management/get_campaigns_by_account_id/standard_response.xml +0 -84
- data/spec/fixtures/campaign_management/get_conversion_goals_by_ids/standard.xml +0 -18
- data/spec/fixtures/campaign_management/get_conversion_goals_by_ids/standard_response.xml +0 -61
- data/spec/fixtures/campaign_management/get_shared_entities_by_account_id/standard.xml +0 -14
- data/spec/fixtures/campaign_management/get_shared_entities_by_account_id/standard_response.xml +0 -20
- data/spec/fixtures/campaign_management/get_shared_entity_associations_by_entity_ids/standard.xml +0 -18
- data/spec/fixtures/campaign_management/get_shared_entity_associations_by_entity_ids/standard_response.xml +0 -19
- data/spec/fixtures/campaign_management/get_uet_tags_by_ids/standard.xml +0 -16
- data/spec/fixtures/campaign_management/get_uet_tags_by_ids/standard_response.xml +0 -21
- data/spec/fixtures/campaign_management/set_ad_extensions_associations/standard.xml +0 -21
- data/spec/fixtures/campaign_management/set_ad_extensions_associations/standard_response.xml +0 -11
- data/spec/fixtures/campaign_management/set_shared_entity_associations/standard.xml +0 -21
- data/spec/fixtures/campaign_management/set_shared_entity_associations/standard_response.xml +0 -11
- data/spec/fixtures/campaign_management/update_conversion_goals/standard.xml +0 -27
- data/spec/fixtures/campaign_management/update_conversion_goals/standard_response.xml +0 -11
- data/spec/fixtures/campaign_management/update_uet_tags/standard.xml +0 -20
- data/spec/fixtures/campaign_management/update_uet_tags/standard_response.xml +0 -11
- data/spec/fixtures/customer_management/find_accounts_or_customers_info/standard.xml +0 -15
- data/spec/fixtures/customer_management/find_accounts_or_customers_info/standard_response.xml +0 -21
- data/spec/fixtures/customer_management/get_account/standard.xml +0 -14
- data/spec/fixtures/customer_management/get_account/standard_response.xml +0 -43
- data/spec/fixtures/customer_management/signup_customer/standard.xml +0 -30
- data/spec/fixtures/customer_management/signup_customer/standard_response.xml +0 -15
- data/spec/fixtures/customer_management/update_account/standard.xml +0 -19
- data/spec/fixtures/customer_management/update_account/standard_response.xml +0 -11
- data/spec/spec_helper.rb +0 -33
- data/spec/support/spec_helpers.rb +0 -46
@@ -1,477 +0,0 @@
|
|
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
|
-
let(:api_response) do
|
304
|
-
{
|
305
|
-
faultcode: "a:DeserializationFailed",
|
306
|
-
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.",
|
307
|
-
detail: {
|
308
|
-
exception_detail: {
|
309
|
-
help_link: nil,
|
310
|
-
inner_exception: {
|
311
|
-
help_link: nil,
|
312
|
-
inner_exception: {
|
313
|
-
help_link: nil,
|
314
|
-
inner_exception: {
|
315
|
-
help_link: nil,
|
316
|
-
inner_exception: nil,
|
317
|
-
message: "Input string was not in a correct format.",
|
318
|
-
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)",
|
319
|
-
type: "System.FormatException"
|
320
|
-
},
|
321
|
-
message: "The value '' cannot be parsed as the type 'Int64'.",
|
322
|
-
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)",
|
323
|
-
type: "System.Xml.XmlException"
|
324
|
-
},
|
325
|
-
message: "There was an error deserializing the object of type System.Int64. The value '' cannot be parsed as the type 'Int64'.",
|
326
|
-
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)",
|
327
|
-
type: "System.Runtime.Serialization.SerializationException"
|
328
|
-
},
|
329
|
-
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.",
|
330
|
-
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)",
|
331
|
-
type: "System.ServiceModel.Dispatcher.NetDispatcherFaultException"
|
332
|
-
}
|
333
|
-
}
|
334
|
-
}
|
335
|
-
end
|
336
|
-
|
337
|
-
let(:error_class) { BingAdsRubySdk::Errors::GeneralError }
|
338
|
-
let(:error_attributes) do
|
339
|
-
{
|
340
|
-
raw_response: api_response,
|
341
|
-
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."
|
342
|
-
}
|
343
|
-
end
|
344
|
-
|
345
|
-
it("raises an error") { shared_expectations }
|
346
|
-
end
|
347
|
-
|
348
|
-
context "when there are nested partial errors" do
|
349
|
-
let(:api_response) do
|
350
|
-
{
|
351
|
-
campaign_criterion_ids: [],
|
352
|
-
is_migrated: "false",
|
353
|
-
nested_partial_errors: {
|
354
|
-
batch_error_collection: [
|
355
|
-
{
|
356
|
-
batch_errors: nil,
|
357
|
-
code: "1043",
|
358
|
-
details: "Criterion already exists",
|
359
|
-
error_code: "AlreadyExists",
|
360
|
-
field_path: nil,
|
361
|
-
forward_compatibility_map: nil,
|
362
|
-
index: "0",
|
363
|
-
message: "The specified entity already exists.",
|
364
|
-
type: "BatchErrorCollection"
|
365
|
-
}
|
366
|
-
]
|
367
|
-
}
|
368
|
-
}
|
369
|
-
end
|
370
|
-
|
371
|
-
context "when the default behaviour is used" do
|
372
|
-
let(:error_class) { BingAdsRubySdk::Errors::NestedPartialError }
|
373
|
-
let(:error_attributes) do
|
374
|
-
{
|
375
|
-
raw_response: api_response,
|
376
|
-
message: "AlreadyExists - The specified entity already exists."
|
377
|
-
}
|
378
|
-
end
|
379
|
-
|
380
|
-
it("raises an error") { shared_expectations }
|
381
|
-
end
|
382
|
-
|
383
|
-
context "when the ignore partial errors switch is on" do
|
384
|
-
it "should return the NestedPartialError as a Hash"
|
385
|
-
end
|
386
|
-
end
|
387
|
-
|
388
|
-
context "when there are partial errors - multiple batch_errors" do
|
389
|
-
let(:api_response) do
|
390
|
-
{
|
391
|
-
campaign_ids: [],
|
392
|
-
partial_errors: {
|
393
|
-
batch_error: [
|
394
|
-
{
|
395
|
-
code: "4701",
|
396
|
-
details: nil,
|
397
|
-
error_code: "UnsupportedBiddingScheme",
|
398
|
-
field_path: nil,
|
399
|
-
forward_compatibility_map: nil,
|
400
|
-
index: "0",
|
401
|
-
message: "The bidding...",
|
402
|
-
type: "BatchError"
|
403
|
-
},
|
404
|
-
{
|
405
|
-
code: "4701",
|
406
|
-
details: nil,
|
407
|
-
error_code: "UnsupportedBiddingScheme",
|
408
|
-
field_path: nil,
|
409
|
-
forward_compatibility_map: nil,
|
410
|
-
index: "1",
|
411
|
-
message: "The bidding...",
|
412
|
-
type: "BatchError"
|
413
|
-
}
|
414
|
-
]
|
415
|
-
}
|
416
|
-
}
|
417
|
-
end
|
418
|
-
|
419
|
-
context "when the default behaviour is used" do
|
420
|
-
let(:error_class) { BingAdsRubySdk::Errors::PartialError }
|
421
|
-
|
422
|
-
let(:error_attributes) do
|
423
|
-
{
|
424
|
-
raw_response: api_response,
|
425
|
-
message: "API raised 2 errors, including: UnsupportedBiddingScheme - The bidding..."
|
426
|
-
}
|
427
|
-
end
|
428
|
-
|
429
|
-
it("raises an error") { shared_expectations }
|
430
|
-
end
|
431
|
-
|
432
|
-
context "when the ignore partial errors switch is on" do
|
433
|
-
it "should return the PartialError as a Hash"
|
434
|
-
end
|
435
|
-
end
|
436
|
-
|
437
|
-
context "when there are partial errors - one batch_error" do
|
438
|
-
let(:api_response) do
|
439
|
-
{
|
440
|
-
campaign_ids: [],
|
441
|
-
partial_errors: {
|
442
|
-
batch_error: {
|
443
|
-
code: "4701",
|
444
|
-
details: nil,
|
445
|
-
error_code: "UnsupportedBiddingScheme",
|
446
|
-
field_path: nil,
|
447
|
-
forward_compatibility_map: nil,
|
448
|
-
index: "0",
|
449
|
-
message: "The bidding...",
|
450
|
-
type: "BatchError"
|
451
|
-
}
|
452
|
-
}
|
453
|
-
}
|
454
|
-
end
|
455
|
-
|
456
|
-
context "when the default behaviour is used" do
|
457
|
-
let(:error_class) { BingAdsRubySdk::Errors::PartialError }
|
458
|
-
|
459
|
-
let(:error_attributes) do
|
460
|
-
{
|
461
|
-
raw_response: api_response,
|
462
|
-
message: "UnsupportedBiddingScheme - The bidding..."
|
463
|
-
}
|
464
|
-
end
|
465
|
-
|
466
|
-
it("raises an error") { shared_expectations }
|
467
|
-
|
468
|
-
it "contains a collection of batch_error" do
|
469
|
-
expect { subject }.to raise_error do |error|
|
470
|
-
expect(error).to respond_to(:batch_error)
|
471
|
-
expect(error.batch_error).to be_a(Array)
|
472
|
-
expect(error.batch_error.size).to eq(1)
|
473
|
-
end
|
474
|
-
end
|
475
|
-
end
|
476
|
-
end
|
477
|
-
end
|
@@ -1,13 +0,0 @@
|
|
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
|
@@ -1,60 +0,0 @@
|
|
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
|
@@ -1,42 +0,0 @@
|
|
1
|
-
RSpec.describe BingAdsRubySdk::HttpClient do
|
2
|
-
describe ".post" do
|
3
|
-
let(:request) do
|
4
|
-
double(:request,
|
5
|
-
url: "http://bing_url.com/foo",
|
6
|
-
content: "body",
|
7
|
-
headers: "headers")
|
8
|
-
end
|
9
|
-
let(:excon) { double(:excon) }
|
10
|
-
|
11
|
-
before do
|
12
|
-
expect(::Excon).to receive(:new).and_return(excon)
|
13
|
-
expect(excon).to receive(:post).with(
|
14
|
-
path: "/foo",
|
15
|
-
body: "body",
|
16
|
-
headers: "headers"
|
17
|
-
).and_return(response)
|
18
|
-
end
|
19
|
-
|
20
|
-
context "successful request" do
|
21
|
-
let(:response) { double(:response, body: "soap xml") }
|
22
|
-
it "returns response's body" do
|
23
|
-
expect(described_class.post(request)).to eq("soap xml")
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe ".close_http_connections" do
|
29
|
-
let(:connection1) { double("connection1") }
|
30
|
-
let(:connection2) { double("connection2") }
|
31
|
-
it "closes existing connections" do
|
32
|
-
expect(described_class).to receive(:http_connections).and_return({
|
33
|
-
"url1" => connection1,
|
34
|
-
"url2" => connection2
|
35
|
-
})
|
36
|
-
expect(connection1).to receive :reset
|
37
|
-
expect(connection2).to receive :reset
|
38
|
-
|
39
|
-
described_class.close_http_connections
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
RSpec.describe BingAdsRubySdk::OAuth2::FsStore do
|
2
|
-
after do
|
3
|
-
File.unlink("./.abc") if File.file?("./.abc")
|
4
|
-
end
|
5
|
-
let(:store) { described_class.new(".abc") }
|
6
|
-
|
7
|
-
context "when not empty" do
|
8
|
-
before { store.write(a: 1, b: "2") }
|
9
|
-
it "writes and read properly" do
|
10
|
-
expect(store.read).to eq("a" => 1, "b" => "2")
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
context "when empty" do
|
15
|
-
it "reads properly" do
|
16
|
-
expect(store.read).to be nil
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe BingAdsRubySdk::Postprocessors::CastLongArrays do
|
4
|
-
def action(params)
|
5
|
-
described_class.new(params).call
|
6
|
-
end
|
7
|
-
|
8
|
-
it "casts and simplifies long arrays" do
|
9
|
-
expect(action({
|
10
|
-
long: "foo",
|
11
|
-
bar_bar: {
|
12
|
-
long: ["1", "2"]
|
13
|
-
},
|
14
|
-
foos: [
|
15
|
-
{
|
16
|
-
bar: {
|
17
|
-
long: ["3", "4"]
|
18
|
-
}
|
19
|
-
}
|
20
|
-
]
|
21
|
-
})).to eq({
|
22
|
-
long: "foo",
|
23
|
-
bar_bar: [1, 2],
|
24
|
-
foos: [
|
25
|
-
{bar: [3, 4]}
|
26
|
-
]
|
27
|
-
})
|
28
|
-
end
|
29
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe BingAdsRubySdk::Postprocessors::Snakize do
|
4
|
-
def action(params)
|
5
|
-
described_class.new(params).call
|
6
|
-
end
|
7
|
-
|
8
|
-
it "changes keys to snake version" do
|
9
|
-
expect(action({
|
10
|
-
"Foo" => "foo",
|
11
|
-
"BarBar" => {
|
12
|
-
"BazBaz" => "baz"
|
13
|
-
},
|
14
|
-
"Coucou" => [
|
15
|
-
{
|
16
|
-
"Bisou" => 1
|
17
|
-
}
|
18
|
-
]
|
19
|
-
})).to eq({
|
20
|
-
foo: "foo",
|
21
|
-
bar_bar: {
|
22
|
-
baz_baz: "baz"
|
23
|
-
},
|
24
|
-
coucou: [
|
25
|
-
{
|
26
|
-
bisou: 1
|
27
|
-
}
|
28
|
-
]
|
29
|
-
})
|
30
|
-
end
|
31
|
-
|
32
|
-
it "handles properly 'long' tag name" do
|
33
|
-
expect(action({
|
34
|
-
"long" => "1"
|
35
|
-
})).to eq({
|
36
|
-
long: "1"
|
37
|
-
})
|
38
|
-
end
|
39
|
-
end
|