soapy_bing 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/README.md +19 -0
  4. data/lib/soapy_bing/ads/reports/base.rb +1 -1
  5. data/lib/soapy_bing/ads.rb +23 -0
  6. data/lib/soapy_bing/soap/request/get_ad_groups_by_campaign_id_request.rb +17 -0
  7. data/lib/soapy_bing/soap/request/get_ads_by_ad_group_id_request.rb +17 -0
  8. data/lib/soapy_bing/soap/request/get_targets_by_campaign_ids_request.rb +17 -0
  9. data/lib/soapy_bing/soap/request.rb +3 -0
  10. data/lib/soapy_bing/soap/response/get_ad_groups_by_campaign_id_response.rb +12 -0
  11. data/lib/soapy_bing/soap/response/get_ads_by_ad_group_id_response.rb +12 -0
  12. data/lib/soapy_bing/soap/response/get_targets_by_campaign_ids_response.rb +12 -0
  13. data/lib/soapy_bing/soap/response.rb +5 -0
  14. data/lib/soapy_bing/soap/templates/get_ad_groups_by_campaign_id.erb.xml +15 -0
  15. data/lib/soapy_bing/soap/templates/get_ads_by_ad_group_id.erb.xml +15 -0
  16. data/lib/soapy_bing/soap/templates/get_targets_by_campaign_ids.erb.xml +20 -0
  17. data/lib/soapy_bing/version.rb +1 -1
  18. data/spec/fixtures/get_ad_groups_by_campaign_id.json +587 -0
  19. data/spec/fixtures/get_ads_by_ad_group_id.json +218 -0
  20. data/spec/fixtures/get_targets_by_campaign_ids.json +81 -0
  21. data/spec/fixtures/vcr_cassettes/SoapyBing_Ads/_get_ad_groups_by_campaign_id/1_1_1.yml +150 -0
  22. data/spec/fixtures/vcr_cassettes/SoapyBing_Ads/_get_ads_by_ad_group_id/1_2_1.yml +141 -0
  23. data/spec/fixtures/vcr_cassettes/SoapyBing_Ads/_get_targets_by_campaign_ids/1_3_1.yml +111 -0
  24. data/spec/integration/soapy_bing/ads_spec.rb +32 -0
  25. data/spec/soapy_bing/oauth_credentials_spec.rb +1 -1
  26. data/spec/soapy_bing/soap/request/base_spec.rb +1 -1
  27. data/spec/soapy_bing/soap/request/poll_generate_report_request_spec.rb +2 -2
  28. metadata +25 -2
@@ -0,0 +1,111 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://login.live.com/oauth20_token.srf
6
+ body:
7
+ encoding: UTF-8
8
+ string: client_id=bing-ads-oauth-client-id&client_secret=bing-ads-oauth-client-secret&grant_type=refresh_token&refresh_token=bing-ads-oauth-refresh-token
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Cache-Control:
22
+ - no-store
23
+ Pragma:
24
+ - no-cache
25
+ Content-Length:
26
+ - '1509'
27
+ Content-Type:
28
+ - application/json
29
+ Server:
30
+ - Microsoft-IIS/8.5
31
+ X-Content-Type-Options:
32
+ - nosniff
33
+ Strict-Transport-Security:
34
+ - max-age=31536000
35
+ X-Xss-Protection:
36
+ - 1; mode=block
37
+ Date:
38
+ - Tue, 19 Jul 2016 12:10:20 GMT
39
+ Connection:
40
+ - close
41
+ body:
42
+ encoding: UTF-8
43
+ string: '{"token_type":"bearer","expires_in":3600,"scope":"bingads.manage","access_token":"bing-ads-oauth-authentication-token","refresh_token":"bing-ads-oauth-refresh-token","user_id":"bing-ads-oauth-user-id"}'
44
+ http_version:
45
+ recorded_at: Tue, 19 Jul 2016 12:10:20 GMT
46
+ - request:
47
+ method: post
48
+ uri: https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V10/CampaignManagementService.svc
49
+ body:
50
+ encoding: UTF-8
51
+ string: |
52
+ <?xml version="1.0" encoding="UTF-8"?>
53
+ <env:Envelope xmlns:tns="https://bingads.microsoft.com/CampaignManagement/v10"
54
+ xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
55
+ xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
56
+ <env:Header>
57
+ <tns:CustomerAccountId>bing-ads-account-id</tns:CustomerAccountId>
58
+ <tns:CustomerId>bing-ads-customer-id</tns:CustomerId>
59
+ <tns:DeveloperToken>bing-ads-developer-token</tns:DeveloperToken>
60
+ <tns:AuthenticationToken>bing-ads-oauth-authentication-token</tns:AuthenticationToken>
61
+ </env:Header>
62
+ <env:Body>
63
+ <tns:GetTargetsByCampaignIdsRequest>
64
+ <tns:CampaignIds>
65
+ <arr:long>91834220</arr:long>
66
+ </tns:CampaignIds>
67
+ </tns:GetTargetsByCampaignIdsRequest>
68
+ </env:Body>
69
+ </env:Envelope>
70
+ headers:
71
+ Content-Type:
72
+ - text/xml;charset=UTF-8
73
+ Soapaction:
74
+ - GetTargetsByCampaignIds
75
+ response:
76
+ status:
77
+ code: 200
78
+ message: OK
79
+ headers:
80
+ Cache-Control:
81
+ - private
82
+ Content-Length:
83
+ - '1922'
84
+ Content-Type:
85
+ - text/xml; charset=utf-8
86
+ Server:
87
+ - Microsoft-IIS/8.5
88
+ X-Aspnet-Version:
89
+ - 4.0.30319
90
+ X-Powered-By:
91
+ - ASP.NET
92
+ Date:
93
+ - Tue, 19 Jul 2016 12:10:20 GMT
94
+ body:
95
+ encoding: UTF-8
96
+ string: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><h:TrackingId
97
+ xmlns:h="https://bingads.microsoft.com/CampaignManagement/v10">bing-ads-report-tracking-id</h:TrackingId></s:Header><s:Body><GetTargetsByCampaignIdsResponse
98
+ xmlns="https://bingads.microsoft.com/CampaignManagement/v10"><PartialErrors
99
+ xmlns:i="http://www.w3.org/2001/XMLSchema-instance"/><Targets xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><Target><Age
100
+ i:nil="true"/><DayTime i:nil="true"/><DeviceOS><Bids><DeviceOSTargetBid><BidAdjustment>0</BidAdjustment><DeviceName>Computers</DeviceName><OSNames
101
+ i:nil="true" xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/></DeviceOSTargetBid><DeviceOSTargetBid><BidAdjustment>-100</BidAdjustment><DeviceName>Smartphones</DeviceName><OSNames
102
+ i:nil="true" xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/></DeviceOSTargetBid><DeviceOSTargetBid><BidAdjustment>0</BidAdjustment><DeviceName>Tablets</DeviceName><OSNames
103
+ i:nil="true" xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/></DeviceOSTargetBid></Bids></DeviceOS><ForwardCompatibilityMap
104
+ xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic"/><Gender
105
+ i:nil="true"/><Id>462821758</Id><IsLibraryTarget>true</IsLibraryTarget><Location><CityTarget
106
+ i:nil="true"/><CountryTarget><Bids><CountryTargetBid><BidAdjustment>0</BidAdjustment><CountryAndRegion>AU</CountryAndRegion><IsExcluded>false</IsExcluded></CountryTargetBid><CountryTargetBid><BidAdjustment>0</BidAdjustment><CountryAndRegion>US</CountryAndRegion><IsExcluded>true</IsExcluded></CountryTargetBid></Bids></CountryTarget><IntentOption>PeopleIn</IntentOption><MetroAreaTarget
107
+ i:nil="true"/><PostalCodeTarget i:nil="true"/><RadiusTarget i:nil="true"/><StateTarget
108
+ i:nil="true"/></Location><Name>targetgroup1</Name></Target></Targets></GetTargetsByCampaignIdsResponse></s:Body></s:Envelope>
109
+ http_version:
110
+ recorded_at: Tue, 19 Jul 2016 12:10:21 GMT
111
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+ RSpec.describe SoapyBing::Ads do
3
+ let(:campaign_id) { 91834220 }
4
+ let(:ad_group_id) { 4464286758 }
5
+ let(:fixture_payload) { JSON.load(File.read(File.join('spec', 'fixtures', fixture_file))) }
6
+
7
+ subject(:instance) { described_class.new }
8
+
9
+ describe '#get_ad_groups_by_campaign_id', :vcr do
10
+ let(:fixture_file) { 'get_ad_groups_by_campaign_id.json' }
11
+
12
+ subject { instance.get_ad_groups_by_campaign_id(campaign_id) }
13
+
14
+ it { expect(subject).to eq(fixture_payload) }
15
+ end
16
+
17
+ describe '#get_ads_by_ad_group_id', :vcr do
18
+ let(:fixture_file) { 'get_ads_by_ad_group_id.json' }
19
+
20
+ subject { instance.get_ads_by_ad_group_id(ad_group_id) }
21
+
22
+ it { expect(subject).to eq(fixture_payload) }
23
+ end
24
+
25
+ describe '#get_targets_by_campaign_ids', :vcr do
26
+ let(:fixture_file) { 'get_targets_by_campaign_ids.json' }
27
+
28
+ subject { instance.get_targets_by_campaign_ids([campaign_id]) }
29
+
30
+ it { expect(subject).to eq(fixture_payload) }
31
+ end
32
+ end
@@ -79,7 +79,7 @@ RSpec.describe SoapyBing::OauthCredentials do
79
79
 
80
80
  describe '#access_token' do
81
81
  let(:credentials) { { client_id: 'foo', client_secret: 'bar', refresh_token: 'baz' } }
82
- let(:response) { double(:response) }
82
+ let(:response) { double(:response) } # rubocop:disable RSpec/VerifiedDoubles
83
83
 
84
84
  before do
85
85
  expect(response).to receive(:code).once.and_return(status_code)
@@ -28,7 +28,7 @@ RSpec.describe SoapyBing::Soap::Request::Base do
28
28
  describe '#default_body' do
29
29
  subject { my_custom_request.default_body }
30
30
  it 'renders request body template' do
31
- renderer = double('Renderer')
31
+ renderer = instance_double(SoapyBing::Soap::TemplateRenderer)
32
32
  expect(SoapyBing::Soap::TemplateRenderer).to receive(:new)
33
33
  .with(hash_including(req_context)).and_return(renderer)
34
34
  expect(renderer).to receive(:render).with('my_custom')
@@ -39,8 +39,8 @@ RSpec.describe SoapyBing::Soap::Request::PollGenerateReportRequest do
39
39
  described_class
40
40
  .new(
41
41
  context: {
42
- oauth: double(:oauth_credentials).as_null_object,
43
- account: double(:account).as_null_object
42
+ oauth: instance_double(SoapyBing::OauthCredentials).as_null_object,
43
+ account: instance_double(SoapyBing::Account).as_null_object
44
44
  }
45
45
  )
46
46
  .perform
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soapy_bing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ad2games GmbH
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-23 00:00:00.000000000 Z
11
+ date: 2016-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erubis
@@ -209,15 +209,24 @@ files:
209
209
  - lib/soapy_bing/soap.rb
210
210
  - lib/soapy_bing/soap/request.rb
211
211
  - lib/soapy_bing/soap/request/base.rb
212
+ - lib/soapy_bing/soap/request/get_ad_groups_by_campaign_id_request.rb
213
+ - lib/soapy_bing/soap/request/get_ads_by_ad_group_id_request.rb
214
+ - lib/soapy_bing/soap/request/get_targets_by_campaign_ids_request.rb
212
215
  - lib/soapy_bing/soap/request/poll_generate_report_request.rb
213
216
  - lib/soapy_bing/soap/request/submit_generate_report_request.rb
214
217
  - lib/soapy_bing/soap/response.rb
215
218
  - lib/soapy_bing/soap/response/base.rb
219
+ - lib/soapy_bing/soap/response/get_ad_groups_by_campaign_id_response.rb
220
+ - lib/soapy_bing/soap/response/get_ads_by_ad_group_id_response.rb
221
+ - lib/soapy_bing/soap/response/get_targets_by_campaign_ids_response.rb
216
222
  - lib/soapy_bing/soap/response/payload.rb
217
223
  - lib/soapy_bing/soap/response/poll_generate_report_response.rb
218
224
  - lib/soapy_bing/soap/response/report_status.rb
219
225
  - lib/soapy_bing/soap/response/submit_generate_report_response.rb
220
226
  - lib/soapy_bing/soap/template_renderer.rb
227
+ - lib/soapy_bing/soap/templates/get_ad_groups_by_campaign_id.erb.xml
228
+ - lib/soapy_bing/soap/templates/get_ads_by_ad_group_id.erb.xml
229
+ - lib/soapy_bing/soap/templates/get_targets_by_campaign_ids.erb.xml
221
230
  - lib/soapy_bing/soap/templates/poll_generate_report.erb.xml
222
231
  - lib/soapy_bing/soap/templates/submit_generate_report.erb.xml
223
232
  - lib/soapy_bing/version.rb
@@ -225,13 +234,20 @@ files:
225
234
  - lib/tasks/coverage.rake
226
235
  - lib/tasks/spec.rake
227
236
  - soapy_bing.gemspec
237
+ - spec/fixtures/get_ad_groups_by_campaign_id.json
238
+ - spec/fixtures/get_ads_by_ad_group_id.json
239
+ - spec/fixtures/get_targets_by_campaign_ids.json
228
240
  - spec/fixtures/reports/campaign_performance_report.csv
229
241
  - spec/fixtures/reports/campaign_performance_report.json
230
242
  - spec/fixtures/soap_templates/simple.erb.xml
243
+ - spec/fixtures/vcr_cassettes/SoapyBing_Ads/_get_ad_groups_by_campaign_id/1_1_1.yml
244
+ - spec/fixtures/vcr_cassettes/SoapyBing_Ads/_get_ads_by_ad_group_id/1_2_1.yml
245
+ - spec/fixtures/vcr_cassettes/SoapyBing_Ads/_get_targets_by_campaign_ids/1_3_1.yml
231
246
  - spec/fixtures/vcr_cassettes/campaign_performance_report/with_pending_status.yml
232
247
  - spec/fixtures/vcr_cassettes/campaign_performance_report/with_successful_status.yml
233
248
  - spec/fixtures/vcr_cassettes/oauth_credentials/access_token/with_successful_status.yml
234
249
  - spec/integration/soapy_bing/ads/reports/campaign_performance_report_spec.rb
250
+ - spec/integration/soapy_bing/ads_spec.rb
235
251
  - spec/integration/soapy_bing/oauth_credentials_spec.rb
236
252
  - spec/simplecov_setup.rb
237
253
  - spec/soapy_bing/account_spec.rb
@@ -278,13 +294,20 @@ signing_key:
278
294
  specification_version: 4
279
295
  summary: Simple client for the Bing Ads APIs
280
296
  test_files:
297
+ - spec/fixtures/get_ad_groups_by_campaign_id.json
298
+ - spec/fixtures/get_ads_by_ad_group_id.json
299
+ - spec/fixtures/get_targets_by_campaign_ids.json
281
300
  - spec/fixtures/reports/campaign_performance_report.csv
282
301
  - spec/fixtures/reports/campaign_performance_report.json
283
302
  - spec/fixtures/soap_templates/simple.erb.xml
303
+ - spec/fixtures/vcr_cassettes/SoapyBing_Ads/_get_ad_groups_by_campaign_id/1_1_1.yml
304
+ - spec/fixtures/vcr_cassettes/SoapyBing_Ads/_get_ads_by_ad_group_id/1_2_1.yml
305
+ - spec/fixtures/vcr_cassettes/SoapyBing_Ads/_get_targets_by_campaign_ids/1_3_1.yml
284
306
  - spec/fixtures/vcr_cassettes/campaign_performance_report/with_pending_status.yml
285
307
  - spec/fixtures/vcr_cassettes/campaign_performance_report/with_successful_status.yml
286
308
  - spec/fixtures/vcr_cassettes/oauth_credentials/access_token/with_successful_status.yml
287
309
  - spec/integration/soapy_bing/ads/reports/campaign_performance_report_spec.rb
310
+ - spec/integration/soapy_bing/ads_spec.rb
288
311
  - spec/integration/soapy_bing/oauth_credentials_spec.rb
289
312
  - spec/simplecov_setup.rb
290
313
  - spec/soapy_bing/account_spec.rb