soapy_bing 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/Gemfile +1 -0
  4. data/README.md +18 -18
  5. data/Rakefile +1 -0
  6. data/lib/soapy_bing.rb +5 -1
  7. data/lib/soapy_bing/account.rb +1 -0
  8. data/lib/soapy_bing/accounts.rb +13 -17
  9. data/lib/soapy_bing/ads.rb +18 -41
  10. data/lib/soapy_bing/ads/campaign_performance_report.rb +49 -0
  11. data/lib/soapy_bing/ads/campaigns.rb +106 -0
  12. data/lib/soapy_bing/ads/parsers/bulk_csv_parser.rb +34 -0
  13. data/lib/soapy_bing/ads/parsers/report_csv_parser.rb +45 -0
  14. data/lib/soapy_bing/ads/report.rb +93 -0
  15. data/lib/soapy_bing/campaign_management.rb +21 -0
  16. data/lib/soapy_bing/country_codes.rb +17 -0
  17. data/lib/soapy_bing/country_codes.yml +727 -0
  18. data/lib/soapy_bing/customer.rb +1 -0
  19. data/lib/soapy_bing/helpers.rb +1 -1
  20. data/lib/soapy_bing/helpers/zip_downloader.rb +1 -0
  21. data/lib/soapy_bing/oauth_credentials.rb +1 -0
  22. data/lib/soapy_bing/param_guard.rb +1 -0
  23. data/lib/soapy_bing/service.rb +69 -0
  24. data/lib/soapy_bing/service_operation.rb +62 -0
  25. data/lib/soapy_bing/version.rb +2 -1
  26. data/lib/soapy_bing/wsdl/ad_insight.wsdl +1 -0
  27. data/lib/soapy_bing/wsdl/bulk.wsdl +1 -0
  28. data/lib/soapy_bing/wsdl/campaign_management.wsdl +1 -0
  29. data/lib/soapy_bing/wsdl/customer_billing.wsdl +1 -0
  30. data/lib/soapy_bing/wsdl/customer_management.wsdl +1 -0
  31. data/lib/soapy_bing/wsdl/reporting.wsdl +1 -0
  32. data/lib/tasks/console.rake +1 -0
  33. data/lib/tasks/coverage.rake +1 -0
  34. data/lib/tasks/spec.rake +1 -0
  35. data/lib/tasks/upate_wsdl_files.rake +23 -0
  36. data/lib/tasks/update_country_codes.rake +24 -0
  37. data/soapy_bing.gemspec +2 -1
  38. data/spec/fixtures/ads/campaign_performance_report.csv +37 -0
  39. data/spec/fixtures/ads/campaign_performance_report.json +170 -0
  40. data/spec/fixtures/ads/campaigns_by_account_id.csv +7 -0
  41. data/spec/fixtures/{bulk/campaigns.json → ads/campaigns_by_account_id.json} +496 -240
  42. data/spec/fixtures/ads/campaigns_by_campaign_ids.csv +5 -0
  43. data/spec/fixtures/ads/campaigns_by_campaign_ids.json +910 -0
  44. data/spec/fixtures/vcr_cassettes/SoapyBing_Accounts/_list/returns_a_list_of_SoapyBing_Account_objects.yml +27 -27
  45. data/spec/fixtures/vcr_cassettes/SoapyBing_Ads/_campaigns/by_account_id/returns_parsed_rows.yml +301 -0
  46. data/spec/fixtures/vcr_cassettes/SoapyBing_Ads/_campaigns/by_campaign_ids/returns_parsed_rows.yml +300 -0
  47. data/spec/fixtures/vcr_cassettes/SoapyBing_CampaignManagement/_get_geo_locations/returns_a_list_of_geo_locations_hashes.yml +154 -0
  48. data/spec/fixtures/vcr_cassettes/campaign_performance_report/with_pending_status.yml +65 -94
  49. data/spec/fixtures/vcr_cassettes/campaign_performance_report/with_successful_empty_response.yml +511 -0
  50. data/spec/fixtures/vcr_cassettes/campaign_performance_report/with_successful_response.yml +384 -0
  51. data/spec/integration/soapy_bing/accounts_spec.rb +1 -0
  52. data/spec/integration/soapy_bing/ads_campaigns_spec.rb +85 -0
  53. data/spec/integration/soapy_bing/campaign_management_spec.rb +22 -0
  54. data/spec/integration/soapy_bing/oauth_credentials_spec.rb +1 -0
  55. data/spec/simplecov_setup.rb +1 -0
  56. data/spec/soapy_bing/account_spec.rb +6 -2
  57. data/spec/soapy_bing/accounts_spec.rb +47 -0
  58. data/spec/soapy_bing/ads/campaign_performance_report_spec.rb +79 -0
  59. data/spec/soapy_bing/ads/campaigns_spec.rb +99 -0
  60. data/spec/soapy_bing/ads/{bulk/parsers/csv_parser_spec.rb → parsers/bulk_csv_parser_spec.rb} +5 -4
  61. data/spec/soapy_bing/ads/{reports/parsers/csv_parser_spec.rb → parsers/report_csv_parser_spec.rb} +6 -4
  62. data/spec/soapy_bing/country_codes_spec.rb +39 -0
  63. data/spec/soapy_bing/helpers/zip_downloader_spec.rb +2 -0
  64. data/spec/soapy_bing/oauth_credentials_spec.rb +6 -2
  65. data/spec/soapy_bing/param_guard_spec.rb +2 -0
  66. data/spec/soapy_bing/service_spec.rb +56 -0
  67. data/spec/spec_helper.rb +1 -0
  68. data/spec/support/dotenv.rb +1 -0
  69. data/spec/support/vcr.rb +75 -6
  70. metadata +74 -118
  71. data/lib/soapy_bing/ads/bulk.rb +0 -3
  72. data/lib/soapy_bing/ads/bulk/campaigns.rb +0 -65
  73. data/lib/soapy_bing/ads/bulk/parsers.rb +0 -2
  74. data/lib/soapy_bing/ads/bulk/parsers/csv_parser.rb +0 -35
  75. data/lib/soapy_bing/ads/reports.rb +0 -4
  76. data/lib/soapy_bing/ads/reports/base.rb +0 -74
  77. data/lib/soapy_bing/ads/reports/campaign_performance_report.rb +0 -24
  78. data/lib/soapy_bing/ads/reports/parsers.rb +0 -2
  79. data/lib/soapy_bing/ads/reports/parsers/csv_parser.rb +0 -46
  80. data/lib/soapy_bing/helpers/class_name.rb +0 -10
  81. data/lib/soapy_bing/soap.rb +0 -4
  82. data/lib/soapy_bing/soap/request.rb +0 -10
  83. data/lib/soapy_bing/soap/request/base.rb +0 -38
  84. data/lib/soapy_bing/soap/request/download_campaigns_by_account_ids_request.rb +0 -17
  85. data/lib/soapy_bing/soap/request/get_accounts_info_request.rb +0 -17
  86. data/lib/soapy_bing/soap/request/get_ad_groups_by_campaign_id_request.rb +0 -17
  87. data/lib/soapy_bing/soap/request/get_ads_by_ad_group_id_request.rb +0 -17
  88. data/lib/soapy_bing/soap/request/get_bulk_download_status_request.rb +0 -17
  89. data/lib/soapy_bing/soap/request/get_targets_by_campaign_ids_request.rb +0 -17
  90. data/lib/soapy_bing/soap/request/poll_generate_report_request.rb +0 -34
  91. data/lib/soapy_bing/soap/request/submit_generate_report_request.rb +0 -17
  92. data/lib/soapy_bing/soap/response.rb +0 -14
  93. data/lib/soapy_bing/soap/response/base.rb +0 -17
  94. data/lib/soapy_bing/soap/response/download_campaigns_by_account_ids_response.rb +0 -12
  95. data/lib/soapy_bing/soap/response/get_accounts_info_response.rb +0 -12
  96. data/lib/soapy_bing/soap/response/get_ad_groups_by_campaign_id_response.rb +0 -12
  97. data/lib/soapy_bing/soap/response/get_ads_by_ad_group_id_response.rb +0 -12
  98. data/lib/soapy_bing/soap/response/get_bulk_download_status_response.rb +0 -17
  99. data/lib/soapy_bing/soap/response/get_targets_by_campaign_ids_response.rb +0 -12
  100. data/lib/soapy_bing/soap/response/payload.rb +0 -28
  101. data/lib/soapy_bing/soap/response/poll_generate_report_response.rb +0 -14
  102. data/lib/soapy_bing/soap/response/report_status.rb +0 -34
  103. data/lib/soapy_bing/soap/response/submit_generate_report_response.rb +0 -12
  104. data/lib/soapy_bing/soap/template_renderer.rb +0 -22
  105. data/lib/soapy_bing/soap/templates/download_campaigns_by_account_ids.xml.erb +0 -22
  106. data/lib/soapy_bing/soap/templates/get_accounts_info.xml.erb +0 -12
  107. data/lib/soapy_bing/soap/templates/get_ad_groups_by_campaign_id.xml.erb +0 -15
  108. data/lib/soapy_bing/soap/templates/get_ads_by_ad_group_id.xml.erb +0 -15
  109. data/lib/soapy_bing/soap/templates/get_bulk_download_status.xml.erb +0 -15
  110. data/lib/soapy_bing/soap/templates/get_targets_by_campaign_ids.xml.erb +0 -20
  111. data/lib/soapy_bing/soap/templates/poll_generate_report.xml.erb +0 -18
  112. data/lib/soapy_bing/soap/templates/submit_generate_report.xml.erb +0 -46
  113. data/spec/fixtures/bulk/campaigns.csv +0 -8
  114. data/spec/fixtures/get_ad_groups_by_campaign_id.json +0 -587
  115. data/spec/fixtures/get_ads_by_ad_group_id.json +0 -218
  116. data/spec/fixtures/get_targets_by_campaign_ids.json +0 -81
  117. data/spec/fixtures/reports/campaign_performance_report.csv +0 -37
  118. data/spec/fixtures/reports/campaign_performance_report.json +0 -146
  119. data/spec/fixtures/soap_templates/simple.xml.erb +0 -2
  120. data/spec/fixtures/vcr_cassettes/SoapyBing_Ads/_get_ad_groups_by_campaign_id/1_1_1.yml +0 -150
  121. data/spec/fixtures/vcr_cassettes/SoapyBing_Ads/_get_ads_by_ad_group_id/1_2_1.yml +0 -141
  122. data/spec/fixtures/vcr_cassettes/SoapyBing_Ads/_get_targets_by_campaign_ids/1_3_1.yml +0 -111
  123. data/spec/fixtures/vcr_cassettes/SoapyBing_Ads_Bulk_Campaigns/_result_file_url/returns_result_file_url.yml +0 -216
  124. data/spec/fixtures/vcr_cassettes/campaign_performance_report/with_successful_status.yml +0 -284
  125. data/spec/integration/soapy_bing/ads/bulk/campaigns_spec.rb +0 -35
  126. data/spec/integration/soapy_bing/ads/reports/campaign_performance_report_spec.rb +0 -40
  127. data/spec/integration/soapy_bing/ads_spec.rb +0 -32
  128. data/spec/soapy_bing/ads/reports/campaign_performance_report_spec.rb +0 -42
  129. data/spec/soapy_bing/ads_spec.rb +0 -33
  130. data/spec/soapy_bing/helpers/class_name_spec.rb +0 -15
  131. data/spec/soapy_bing/soap/request/base_spec.rb +0 -55
  132. data/spec/soapy_bing/soap/request/poll_generate_report_request_spec.rb +0 -60
  133. data/spec/soapy_bing/soap/response/base_spec.rb +0 -13
  134. data/spec/soapy_bing/soap/response/get_bulk_download_status_response_spec.rb +0 -60
  135. data/spec/soapy_bing/soap/response/payload_spec.rb +0 -48
  136. data/spec/soapy_bing/soap/response/poll_generate_report_response_spec.rb +0 -26
  137. data/spec/soapy_bing/soap/response/report_status_spec.rb +0 -92
  138. data/spec/soapy_bing/soap/response/submit_generate_report_response_spec.rb +0 -20
  139. data/spec/soapy_bing/soap/template_renderer_spec.rb +0 -25
@@ -0,0 +1,384 @@
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
+ - Wed, 07 Jun 2017 22:12:19 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: Wed, 07 Jun 2017 22:12:19 GMT
46
+ - request:
47
+ method: post
48
+ uri: https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/V11/ReportingService.svc
49
+ body:
50
+ encoding: UTF-8
51
+ string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
52
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="https://bingads.microsoft.com/Reporting/v11"
53
+ xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header><tns:Action>SubmitGenerateReport</tns:Action><tns:AuthenticationToken>bing-ads-oauth-authentication-token</tns:AuthenticationToken><tns:DeveloperToken>bing-ads-developer-token</tns:DeveloperToken><tns:CustomerAccountId>bing-ads-account-id</tns:CustomerAccountId></env:Header><env:Body><tns:SubmitGenerateReportRequest><tns:ReportRequest
54
+ xsi:type="tns:CampaignPerformanceReportRequest"><tns:Format>Csv</tns:Format><tns:Language>English</tns:Language><tns:ReportName>MyReport</tns:ReportName><tns:ReturnOnlyCompletedData>false</tns:ReturnOnlyCompletedData><tns:Aggregation>Hourly</tns:Aggregation><tns:Columns><tns:CampaignPerformanceReportColumn>TimePeriod</tns:CampaignPerformanceReportColumn><tns:CampaignPerformanceReportColumn>Impressions</tns:CampaignPerformanceReportColumn><tns:CampaignPerformanceReportColumn>Clicks</tns:CampaignPerformanceReportColumn><tns:CampaignPerformanceReportColumn>Spend</tns:CampaignPerformanceReportColumn></tns:Columns><tns:Scope><tns:AccountIds
55
+ xmlns:a1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"><a1:long>bing-ads-account-id</a1:long></tns:AccountIds></tns:Scope><tns:Time><tns:CustomDateRangeEnd><tns:Day>14</tns:Day><tns:Month>5</tns:Month><tns:Year>2017</tns:Year></tns:CustomDateRangeEnd><tns:CustomDateRangeStart><tns:Day>14</tns:Day><tns:Month>5</tns:Month><tns:Year>2017</tns:Year></tns:CustomDateRangeStart></tns:Time></tns:ReportRequest></tns:SubmitGenerateReportRequest></env:Body></env:Envelope>
56
+ headers:
57
+ Soapaction:
58
+ - '"SubmitGenerateReport"'
59
+ Content-Type:
60
+ - text/xml;charset=UTF-8
61
+ Content-Length:
62
+ - '2682'
63
+ Accept-Encoding:
64
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
65
+ Accept:
66
+ - "*/*"
67
+ User-Agent:
68
+ - Ruby
69
+ response:
70
+ status:
71
+ code: 200
72
+ message: OK
73
+ headers:
74
+ Content-Type:
75
+ - text/xml; charset=utf-8
76
+ Vary:
77
+ - Accept-Encoding
78
+ Server:
79
+ - Microsoft-IIS/8.5
80
+ X-Powered-By:
81
+ - ASP.NET
82
+ Date:
83
+ - Wed, 07 Jun 2017 22:12:20 GMT
84
+ Content-Length:
85
+ - '347'
86
+ body:
87
+ encoding: ASCII-8BIT
88
+ string: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><h:TrackingId
89
+ xmlns:h="https://bingads.microsoft.com/Reporting/v11">bing-ads-report-tracking-id</h:TrackingId></s:Header><s:Body><SubmitGenerateReportResponse
90
+ xmlns="https://bingads.microsoft.com/Reporting/v11"><ReportRequestId>bing-ads-report-request-id</ReportRequestId></SubmitGenerateReportResponse></s:Body></s:Envelope>
91
+ http_version:
92
+ recorded_at: Wed, 07 Jun 2017 22:12:20 GMT
93
+ - request:
94
+ method: post
95
+ uri: https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/V11/ReportingService.svc
96
+ body:
97
+ encoding: UTF-8
98
+ string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
99
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="https://bingads.microsoft.com/Reporting/v11"
100
+ xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header><tns:Action>PollGenerateReport</tns:Action><tns:AuthenticationToken>bing-ads-oauth-authentication-token</tns:AuthenticationToken><tns:DeveloperToken>bing-ads-developer-token</tns:DeveloperToken><tns:CustomerAccountId>bing-ads-account-id</tns:CustomerAccountId></env:Header><env:Body><tns:PollGenerateReportRequest><tns:ReportRequestId>bing-ads-report-request-id</tns:ReportRequestId></tns:PollGenerateReportRequest></env:Body></env:Envelope>
101
+ headers:
102
+ Soapaction:
103
+ - '"PollGenerateReport"'
104
+ Content-Type:
105
+ - text/xml;charset=UTF-8
106
+ Content-Length:
107
+ - '1666'
108
+ Accept-Encoding:
109
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
110
+ Accept:
111
+ - "*/*"
112
+ User-Agent:
113
+ - Ruby
114
+ response:
115
+ status:
116
+ code: 200
117
+ message: OK
118
+ headers:
119
+ Content-Type:
120
+ - text/xml; charset=utf-8
121
+ Vary:
122
+ - Accept-Encoding
123
+ Server:
124
+ - Microsoft-IIS/8.5
125
+ X-Powered-By:
126
+ - ASP.NET
127
+ Date:
128
+ - Wed, 07 Jun 2017 22:12:20 GMT
129
+ Content-Length:
130
+ - '407'
131
+ body:
132
+ encoding: ASCII-8BIT
133
+ string: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><h:TrackingId
134
+ xmlns:h="https://bingads.microsoft.com/Reporting/v11">bing-ads-report-tracking-id</h:TrackingId></s:Header><s:Body><PollGenerateReportResponse
135
+ xmlns="https://bingads.microsoft.com/Reporting/v11"><ReportRequestStatus xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><ReportDownloadUrl
136
+ i:nil="true"/><Status>Pending</Status></ReportRequestStatus></PollGenerateReportResponse></s:Body></s:Envelope>
137
+ http_version:
138
+ recorded_at: Wed, 07 Jun 2017 22:12:22 GMT
139
+ - request:
140
+ method: post
141
+ uri: https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/V11/ReportingService.svc
142
+ body:
143
+ encoding: UTF-8
144
+ string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
145
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="https://bingads.microsoft.com/Reporting/v11"
146
+ xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header><tns:Action>SubmitGenerateReport</tns:Action><tns:AuthenticationToken>bing-ads-oauth-authentication-token</tns:AuthenticationToken><tns:DeveloperToken>bing-ads-developer-token</tns:DeveloperToken><tns:CustomerAccountId>bing-ads-account-id</tns:CustomerAccountId></env:Header><env:Body><tns:SubmitGenerateReportRequest><tns:ReportRequest
147
+ xsi:type="tns:CampaignPerformanceReportRequest"><tns:Format>Csv</tns:Format><tns:Language>English</tns:Language><tns:ReportName>MyReport</tns:ReportName><tns:ReturnOnlyCompletedData>false</tns:ReturnOnlyCompletedData><tns:Aggregation>Hourly</tns:Aggregation><tns:Columns><tns:CampaignPerformanceReportColumn>TimePeriod</tns:CampaignPerformanceReportColumn><tns:CampaignPerformanceReportColumn>Impressions</tns:CampaignPerformanceReportColumn><tns:CampaignPerformanceReportColumn>Clicks</tns:CampaignPerformanceReportColumn><tns:CampaignPerformanceReportColumn>Spend</tns:CampaignPerformanceReportColumn></tns:Columns><tns:Scope><tns:AccountIds
148
+ xmlns:a1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"><a1:long>bing-ads-account-id</a1:long></tns:AccountIds></tns:Scope><tns:Time><tns:CustomDateRangeEnd><tns:Day>14</tns:Day><tns:Month>5</tns:Month><tns:Year>2017</tns:Year></tns:CustomDateRangeEnd><tns:CustomDateRangeStart><tns:Day>14</tns:Day><tns:Month>5</tns:Month><tns:Year>2017</tns:Year></tns:CustomDateRangeStart></tns:Time></tns:ReportRequest></tns:SubmitGenerateReportRequest></env:Body></env:Envelope>
149
+ headers:
150
+ Soapaction:
151
+ - '"SubmitGenerateReport"'
152
+ Content-Type:
153
+ - text/xml;charset=UTF-8
154
+ Content-Length:
155
+ - '2682'
156
+ Accept-Encoding:
157
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
158
+ Accept:
159
+ - "*/*"
160
+ User-Agent:
161
+ - Ruby
162
+ response:
163
+ status:
164
+ code: 200
165
+ message: OK
166
+ headers:
167
+ Content-Type:
168
+ - text/xml; charset=utf-8
169
+ Vary:
170
+ - Accept-Encoding
171
+ Server:
172
+ - Microsoft-IIS/8.5
173
+ X-Powered-By:
174
+ - ASP.NET
175
+ Date:
176
+ - Wed, 07 Jun 2017 22:12:24 GMT
177
+ Content-Length:
178
+ - '348'
179
+ body:
180
+ encoding: ASCII-8BIT
181
+ string: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><h:TrackingId
182
+ xmlns:h="https://bingads.microsoft.com/Reporting/v11">bing-ads-report-tracking-id</h:TrackingId></s:Header><s:Body><SubmitGenerateReportResponse
183
+ xmlns="https://bingads.microsoft.com/Reporting/v11"><ReportRequestId>bing-ads-report-request-id</ReportRequestId></SubmitGenerateReportResponse></s:Body></s:Envelope>
184
+ http_version:
185
+ recorded_at: Wed, 07 Jun 2017 22:12:25 GMT
186
+ - request:
187
+ method: post
188
+ uri: https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/V11/ReportingService.svc
189
+ body:
190
+ encoding: UTF-8
191
+ string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
192
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="https://bingads.microsoft.com/Reporting/v11"
193
+ xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header><tns:Action>PollGenerateReport</tns:Action><tns:AuthenticationToken>bing-ads-oauth-authentication-token</tns:AuthenticationToken><tns:DeveloperToken>bing-ads-developer-token</tns:DeveloperToken><tns:CustomerAccountId>bing-ads-account-id</tns:CustomerAccountId></env:Header><env:Body><tns:PollGenerateReportRequest><tns:ReportRequestId>bing-ads-report-request-id</tns:ReportRequestId></tns:PollGenerateReportRequest></env:Body></env:Envelope>
194
+ headers:
195
+ Soapaction:
196
+ - '"PollGenerateReport"'
197
+ Content-Type:
198
+ - text/xml;charset=UTF-8
199
+ Content-Length:
200
+ - '1666'
201
+ Accept-Encoding:
202
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
203
+ Accept:
204
+ - "*/*"
205
+ User-Agent:
206
+ - Ruby
207
+ response:
208
+ status:
209
+ code: 200
210
+ message: OK
211
+ headers:
212
+ Content-Type:
213
+ - text/xml; charset=utf-8
214
+ Vary:
215
+ - Accept-Encoding
216
+ Server:
217
+ - Microsoft-IIS/8.5
218
+ X-Powered-By:
219
+ - ASP.NET
220
+ Date:
221
+ - Wed, 07 Jun 2017 22:12:25 GMT
222
+ Content-Length:
223
+ - '408'
224
+ body:
225
+ encoding: ASCII-8BIT
226
+ string: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><h:TrackingId
227
+ xmlns:h="https://bingads.microsoft.com/Reporting/v11">bing-ads-report-tracking-id</h:TrackingId></s:Header><s:Body><PollGenerateReportResponse
228
+ xmlns="https://bingads.microsoft.com/Reporting/v11"><ReportRequestStatus xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><ReportDownloadUrl
229
+ i:nil="true"/><Status>Pending</Status></ReportRequestStatus></PollGenerateReportResponse></s:Body></s:Envelope>
230
+ http_version:
231
+ recorded_at: Wed, 07 Jun 2017 22:12:26 GMT
232
+ - request:
233
+ method: post
234
+ uri: https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/V11/ReportingService.svc
235
+ body:
236
+ encoding: UTF-8
237
+ string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
238
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="https://bingads.microsoft.com/Reporting/v11"
239
+ xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header><tns:Action>SubmitGenerateReport</tns:Action><tns:AuthenticationToken>bing-ads-oauth-authentication-token</tns:AuthenticationToken><tns:DeveloperToken>bing-ads-developer-token</tns:DeveloperToken><tns:CustomerAccountId>bing-ads-account-id</tns:CustomerAccountId></env:Header><env:Body><tns:SubmitGenerateReportRequest><tns:ReportRequest
240
+ xsi:type="tns:CampaignPerformanceReportRequest"><tns:Format>Csv</tns:Format><tns:Language>English</tns:Language><tns:ReportName>MyReport</tns:ReportName><tns:ReturnOnlyCompletedData>false</tns:ReturnOnlyCompletedData><tns:Aggregation>Hourly</tns:Aggregation><tns:Columns><tns:CampaignPerformanceReportColumn>TimePeriod</tns:CampaignPerformanceReportColumn><tns:CampaignPerformanceReportColumn>Impressions</tns:CampaignPerformanceReportColumn><tns:CampaignPerformanceReportColumn>Clicks</tns:CampaignPerformanceReportColumn><tns:CampaignPerformanceReportColumn>Spend</tns:CampaignPerformanceReportColumn></tns:Columns><tns:Scope><tns:AccountIds
241
+ xmlns:a1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"><a1:long>bing-ads-account-id</a1:long></tns:AccountIds></tns:Scope><tns:Time><tns:CustomDateRangeEnd><tns:Day>14</tns:Day><tns:Month>5</tns:Month><tns:Year>2017</tns:Year></tns:CustomDateRangeEnd><tns:CustomDateRangeStart><tns:Day>14</tns:Day><tns:Month>5</tns:Month><tns:Year>2017</tns:Year></tns:CustomDateRangeStart></tns:Time></tns:ReportRequest></tns:SubmitGenerateReportRequest></env:Body></env:Envelope>
242
+ headers:
243
+ Soapaction:
244
+ - '"SubmitGenerateReport"'
245
+ Content-Type:
246
+ - text/xml;charset=UTF-8
247
+ Content-Length:
248
+ - '2682'
249
+ Accept-Encoding:
250
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
251
+ Accept:
252
+ - "*/*"
253
+ User-Agent:
254
+ - Ruby
255
+ response:
256
+ status:
257
+ code: 200
258
+ message: OK
259
+ headers:
260
+ Content-Type:
261
+ - text/xml; charset=utf-8
262
+ Vary:
263
+ - Accept-Encoding
264
+ Server:
265
+ - Microsoft-IIS/8.5
266
+ X-Powered-By:
267
+ - ASP.NET
268
+ Date:
269
+ - Wed, 07 Jun 2017 22:12:28 GMT
270
+ Content-Length:
271
+ - '345'
272
+ body:
273
+ encoding: ASCII-8BIT
274
+ string: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><h:TrackingId
275
+ xmlns:h="https://bingads.microsoft.com/Reporting/v11">bing-ads-report-tracking-id</h:TrackingId></s:Header><s:Body><SubmitGenerateReportResponse
276
+ xmlns="https://bingads.microsoft.com/Reporting/v11"><ReportRequestId>bing-ads-report-request-id</ReportRequestId></SubmitGenerateReportResponse></s:Body></s:Envelope>
277
+ http_version:
278
+ recorded_at: Wed, 07 Jun 2017 22:12:29 GMT
279
+ - request:
280
+ method: post
281
+ uri: https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/V11/ReportingService.svc
282
+ body:
283
+ encoding: UTF-8
284
+ string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
285
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="https://bingads.microsoft.com/Reporting/v11"
286
+ xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header><tns:Action>PollGenerateReport</tns:Action><tns:AuthenticationToken>bing-ads-oauth-authentication-token</tns:AuthenticationToken><tns:DeveloperToken>bing-ads-developer-token</tns:DeveloperToken><tns:CustomerAccountId>bing-ads-account-id</tns:CustomerAccountId></env:Header><env:Body><tns:PollGenerateReportRequest><tns:ReportRequestId>bing-ads-report-request-id</tns:ReportRequestId></tns:PollGenerateReportRequest></env:Body></env:Envelope>
287
+ headers:
288
+ Soapaction:
289
+ - '"PollGenerateReport"'
290
+ Content-Type:
291
+ - text/xml;charset=UTF-8
292
+ Content-Length:
293
+ - '1666'
294
+ Accept-Encoding:
295
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
296
+ Accept:
297
+ - "*/*"
298
+ User-Agent:
299
+ - Ruby
300
+ response:
301
+ status:
302
+ code: 200
303
+ message: OK
304
+ headers:
305
+ Content-Type:
306
+ - text/xml; charset=utf-8
307
+ Vary:
308
+ - Accept-Encoding
309
+ Server:
310
+ - Microsoft-IIS/8.5
311
+ X-Powered-By:
312
+ - ASP.NET
313
+ Date:
314
+ - Wed, 07 Jun 2017 22:12:29 GMT
315
+ Content-Length:
316
+ - '1531'
317
+ body:
318
+ encoding: ASCII-8BIT
319
+ string: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><h:TrackingId
320
+ xmlns:h="https://bingads.microsoft.com/Reporting/v11">bing-ads-report-tracking-id</h:TrackingId></s:Header><s:Body><PollGenerateReportResponse
321
+ xmlns="https://bingads.microsoft.com/Reporting/v11"><ReportRequestStatus xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><ReportDownloadUrl>https://dvsrdl.api.bingads.microsoft.com/ReportDownload/Download.aspx?q=bing-ads-report-download-id</ReportDownloadUrl><Status>Success</Status></ReportRequestStatus></PollGenerateReportResponse></s:Body></s:Envelope>
322
+ http_version:
323
+ recorded_at: Wed, 07 Jun 2017 22:12:31 GMT
324
+ - request:
325
+ method: get
326
+ uri: https://dvsrdl.api.bingads.microsoft.com/ReportDownload/Download.aspx?q=bing-ads-report-download-id
327
+ body:
328
+ encoding: US-ASCII
329
+ string: ''
330
+ headers:
331
+ Accept-Encoding:
332
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
333
+ Accept:
334
+ - "*/*"
335
+ User-Agent:
336
+ - Ruby
337
+ response:
338
+ status:
339
+ code: 200
340
+ message: OK
341
+ headers:
342
+ Cache-Control:
343
+ - private
344
+ Content-Length:
345
+ - '920'
346
+ Content-Type:
347
+ - application/x-zip-compressed
348
+ Server:
349
+ - Microsoft-IIS/8.5
350
+ Content-Disposition:
351
+ - attachment; filename="MyReport.zip"
352
+ X-Aspnet-Version:
353
+ - 4.0.30319
354
+ X-Powered-By:
355
+ - ASP.NET
356
+ Date:
357
+ - Wed, 07 Jun 2017 22:12:32 GMT
358
+ body:
359
+ encoding: ASCII-8BIT
360
+ string: !binary |-
361
+ UEsDBBQAAAAIAI95x0o7OJxUQgIAAFIFAAAVAFIAMzAwMDAwMDA3NjgzNzM0
362
+ MDguY3N2TlUwAE5VQ1gVADMAMAAwADAAMAAwADAAMAA3ADYAOAAzADcAMwA0
363
+ ADAAOAAuAGMAcwB2AHVwGgAB0h3aWjMwMDAwMDAwNzY4MzczNDA4LmNzdoRU
364
+ S47UMBDdI3EHq1cgMW6X/86uNYhhJBqNYMSCXeg2TUQ6aTnpQXMkzsACiQtx
365
+ BVzlQUI4gkXs2H71XO+V7Z/fvq/exNOYZva6PcaGbe/LcPX40e+F2w4XzBr0
366
+ WgpwuIJT7P045Pl3berG84Szr9ppZpfj8dTHOe7Z5q7t+vZDH9nz9r5hdu0o
367
+ nvnGmEYIdrNlT662t0//GfpyPKf/xD6kuTkcUjy0czcODYX193+svuj6OWYm
368
+ nLoZ5zjMXduz62H3sGfOcW4bNqdzpKjxy9QwqfN/Hl1l4jF17ZBBcfVshey5
369
+ uz6eUpymvOGUR5d9t/uMP29PcdgjCWZ8IcwF6Dwr8ie1N7kD4XzuguU6VDhA
370
+ nDEFF6DgnKlwkvhswXmKFJp7XQEVEQLiITMioeJQb0wUwSPOB6R1i3S0ofaY
371
+ mFPYGsOVq2AW9wkoWhvKQnJZoxwiA5qhIFCeXMsKhes6OBIsKEueDfwbhfFa
372
+ EUp6SpL72jZAAqXRFPCYJCju68QAlSlBpllX2ATUMKoCeQZSFtiCTFBkJ7aK
373
+ KqYcV7XO0hg6I06iHhO4WaCjGlhLHlNFneFu4SiRPqtkORzYBVhUSwp9sQ0E
374
+ WuQlt6IGUqk0mQhOUBgYDgvOYFrKG1uMDiQPuFT1QaaKgBVFFOUgBQ/17rLc
375
+ jXLmtVDlivBQCyq1cA4DrKXTnS9RnaUkjuCoPiTH5Lthy63/8ZWenG23S+M0
376
+ fsT3KeW3hF4YzjZ9z1J3+DRPLD8CMd3FPcfX5RcAAAD//wMAUEsBAi0AFAAA
377
+ AAgAj3nHSjs4nFRCAgAAUgUAABUAeAAAAAAAAAAAAAAAAAAAADMwMDAwMDAw
378
+ NzY4MzczNDA4LmNzdk5VMgBOVUNYFQAAADMAMAAwADAAMAAwADAAMAA3ADYA
379
+ OAAzADcAMwA0ADAAOAAuAGMAcwB2AAoAIAAAAAAAAQAYANfPkSfb39IB18+R
380
+ J9vf0gGQWpEn29/SAXVwGgAB0h3aWjMwMDAwMDAwNzY4MzczNDA4LmNzdlBL
381
+ BQYAAAAAAQABALsAAADHAgAAAAA=
382
+ http_version:
383
+ recorded_at: Wed, 07 Jun 2017 22:12:32 GMT
384
+ recorded_with: VCR 3.0.3
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  RSpec.describe SoapyBing::Accounts do
3
4
  subject(:instance) { described_class.new }
4
5
 
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe SoapyBing::Ads do
4
+ subject(:ads) { described_class.new }
5
+
6
+ def fixtured_payload(path)
7
+ JSON.parse(File.read(File.join('spec', 'fixtures', 'ads', "#{path}.json")))
8
+ end
9
+
10
+ let(:polling_settings) do
11
+ # disable poll sleeping on playback
12
+ { sleep: VCR.current_cassette.recording? ? 120 : 0 }
13
+ end
14
+
15
+ describe '#campaigns', :vcr do
16
+ let(:entities) { %w[Campaigns] }
17
+
18
+ context 'by account_id' do
19
+ it 'returns parsed rows' do
20
+ expect(
21
+ ads.campaigns(entities, polling_settings: polling_settings)
22
+ ).to eq fixtured_payload('campaigns_by_account_id')
23
+ end
24
+ end
25
+
26
+ context 'by campaign_ids' do
27
+ let(:campaign_ids) { [90868686, 90876598] }
28
+
29
+ it 'returns parsed rows' do
30
+ expect(
31
+ ads.campaigns(
32
+ entities,
33
+ campaign_ids: campaign_ids,
34
+ polling_settings: polling_settings
35
+ )
36
+ ).to eq fixtured_payload('campaigns_by_campaign_ids')
37
+ end
38
+ end
39
+ end
40
+
41
+ describe '#campaign_performance_report' do
42
+ let(:date) { '2016-10-14' }
43
+ let(:settings) do
44
+ # CampaignName is considered to be a sensitive data, lets not record it
45
+ { columns: %w[TimePeriod Impressions Clicks Spend] }
46
+ end
47
+ let(:params) do
48
+ {
49
+ date_start: date,
50
+ date_end: date,
51
+ settings: settings,
52
+ polling_settings: polling_settings
53
+ }
54
+ end
55
+
56
+ context 'when there is a successful empty response during polling' do
57
+ it 'responds with empty report rows',
58
+ vcr: { cassette_name: 'campaign_performance_report/with_successful_empty_response' } do
59
+ expect(ads.campaign_performance_report(params)).to eq []
60
+ end
61
+ end
62
+
63
+ context 'when there is a successful response during polling' do
64
+ let(:date) { '2017-05-14' }
65
+
66
+ it 'responds with report rows',
67
+ vcr: { cassette_name: 'campaign_performance_report/with_successful_response' } do
68
+ expect(ads.campaign_performance_report(params)).to eq(
69
+ fixtured_payload('campaign_performance_report')
70
+ )
71
+ end
72
+ end
73
+
74
+ context 'when there is only pending responses during polling' do
75
+ let(:polling_settings) { { tries: 1, sleep: 0 } }
76
+
77
+ it 'throws exception PollingTimeoutError',
78
+ vcr: { cassette_name: 'campaign_performance_report/with_pending_status' } do
79
+ expect { ads.campaign_performance_report(params) }.to(
80
+ raise_error(SoapyBing::Ads::NotCompleted)
81
+ )
82
+ end
83
+ end
84
+ end
85
+ end