soapy_bing 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.env +6 -0
- data/.gitignore +6 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/Gemfile +6 -0
- data/README.md +63 -0
- data/Rakefile +7 -0
- data/circle.yml +6 -0
- data/lib/soapy_bing/account.rb +12 -0
- data/lib/soapy_bing/ads/reports/base.rb +83 -0
- data/lib/soapy_bing/ads/reports/campaign_performance_report.rb +23 -0
- data/lib/soapy_bing/ads/reports/parsers/csv_parser.rb +45 -0
- data/lib/soapy_bing/ads/reports/parsers.rb +1 -0
- data/lib/soapy_bing/ads/reports.rb +3 -0
- data/lib/soapy_bing/ads.rb +22 -0
- data/lib/soapy_bing/helpers/class_name.rb +9 -0
- data/lib/soapy_bing/helpers.rb +1 -0
- data/lib/soapy_bing/oauth_credentials.rb +43 -0
- data/lib/soapy_bing/param_guard.rb +26 -0
- data/lib/soapy_bing/soap/request/base.rb +37 -0
- data/lib/soapy_bing/soap/request/poll_generate_report_request.rb +33 -0
- data/lib/soapy_bing/soap/request/submit_generate_report_request.rb +16 -0
- data/lib/soapy_bing/soap/request.rb +3 -0
- data/lib/soapy_bing/soap/response/base.rb +16 -0
- data/lib/soapy_bing/soap/response/payload.rb +15 -0
- data/lib/soapy_bing/soap/response/poll_generate_report_response.rb +13 -0
- data/lib/soapy_bing/soap/response/report_status.rb +33 -0
- data/lib/soapy_bing/soap/response/submit_generate_report_response.rb +11 -0
- data/lib/soapy_bing/soap/response.rb +5 -0
- data/lib/soapy_bing/soap/template_renderer.rb +21 -0
- data/lib/soapy_bing/soap/templates/poll_generate_report.erb.xml +18 -0
- data/lib/soapy_bing/soap/templates/submit_generate_report.erb.xml +46 -0
- data/lib/soapy_bing/soap.rb +3 -0
- data/lib/soapy_bing/version.rb +3 -0
- data/lib/soapy_bing.rb +11 -0
- data/lib/tasks/console.rake +5 -0
- data/lib/tasks/coverage.rake +6 -0
- data/lib/tasks/spec.rake +4 -0
- data/soapy_bing.gemspec +34 -0
- data/spec/fixtures/reports/campaign_performance_report.csv +37 -0
- data/spec/fixtures/reports/campaign_performance_report.json +146 -0
- data/spec/fixtures/soap_templates/simple.erb.xml +2 -0
- data/spec/fixtures/vcr_cassettes/campaign_performance_report/with_pending_status.yml +168 -0
- data/spec/fixtures/vcr_cassettes/campaign_performance_report/with_successful_status.yml +284 -0
- data/spec/fixtures/vcr_cassettes/oauth_credentials/access_token/with_successful_status.yml +42 -0
- data/spec/integration/soapy_bing/ads/reports/campaign_performance_report_spec.rb +39 -0
- data/spec/integration/soapy_bing/oauth_credentials_spec.rb +10 -0
- data/spec/simplecov_setup.rb +9 -0
- data/spec/soapy_bing/account_spec.rb +80 -0
- data/spec/soapy_bing/ads/reports/campaign_performance_report_spec.rb +41 -0
- data/spec/soapy_bing/ads/reports/parsers/csv_parser_spec.rb +31 -0
- data/spec/soapy_bing/ads_spec.rb +32 -0
- data/spec/soapy_bing/helpers/class_name_spec.rb +14 -0
- data/spec/soapy_bing/oauth_credentials_spec.rb +108 -0
- data/spec/soapy_bing/param_guard_spec.rb +43 -0
- data/spec/soapy_bing/soap/request/base_spec.rb +54 -0
- data/spec/soapy_bing/soap/request/poll_generate_report_request_spec.rb +59 -0
- data/spec/soapy_bing/soap/response/base_spec.rb +12 -0
- data/spec/soapy_bing/soap/response/payload_spec.rb +25 -0
- data/spec/soapy_bing/soap/response/poll_generate_report_response_spec.rb +25 -0
- data/spec/soapy_bing/soap/response/report_status_spec.rb +91 -0
- data/spec/soapy_bing/soap/response/submit_generate_report_response_spec.rb +19 -0
- data/spec/soapy_bing/soap/template_renderer_spec.rb +24 -0
- data/spec/spec_helper.rb +32 -0
- data/spec/support/dotenv.rb +3 -0
- data/spec/support/vcr.rb +101 -0
- metadata +305 -0
@@ -0,0 +1,284 @@
|
|
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
|
+
- '1317'
|
27
|
+
Content-Type:
|
28
|
+
- application/json
|
29
|
+
Server:
|
30
|
+
- Microsoft-IIS/8.5
|
31
|
+
X-Content-Type-Options:
|
32
|
+
- nosniff
|
33
|
+
Date:
|
34
|
+
- Fri, 13 Nov 2015 14:23:33 GMT
|
35
|
+
Connection:
|
36
|
+
- close
|
37
|
+
body:
|
38
|
+
encoding: UTF-8
|
39
|
+
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"}'
|
40
|
+
http_version:
|
41
|
+
recorded_at: Fri, 13 Nov 2015 14:23:34 GMT
|
42
|
+
- request:
|
43
|
+
method: post
|
44
|
+
uri: https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/V9/ReportingService.svc
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: |
|
48
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
49
|
+
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
50
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
51
|
+
xmlns:tns="https://bingads.microsoft.com/Reporting/v9"
|
52
|
+
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
|
53
|
+
xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
|
54
|
+
<env:Header>
|
55
|
+
<tns:CustomerAccountId>bing-ads-account-id</tns:CustomerAccountId>
|
56
|
+
<tns:CustomerId>bing-ads-customer-id</tns:CustomerId>
|
57
|
+
<tns:DeveloperToken>bing-ads-developer-token</tns:DeveloperToken>
|
58
|
+
<tns:AuthenticationToken>bing-ads-oauth-authentication-token</tns:AuthenticationToken>
|
59
|
+
</env:Header>
|
60
|
+
<env:Body>
|
61
|
+
<tns:SubmitGenerateReportRequest>
|
62
|
+
<tns:ReportRequest xmlns:i="http://www.w3.org/2001/XMLSchema-instance" i:type="tns:CampaignPerformanceReportRequest">
|
63
|
+
<tns:Format>Csv</tns:Format>
|
64
|
+
<tns:Language>English</tns:Language>
|
65
|
+
<tns:ReportName>MyReport</tns:ReportName>
|
66
|
+
<tns:ReturnOnlyCompleteData>false</tns:ReturnOnlyCompleteData>
|
67
|
+
<tns:Aggregation>HourOfDay</tns:Aggregation>
|
68
|
+
<tns:Columns>
|
69
|
+
<tns:CampaignPerformanceReportColumn>TimePeriod</tns:CampaignPerformanceReportColumn>
|
70
|
+
<tns:CampaignPerformanceReportColumn>Impressions</tns:CampaignPerformanceReportColumn>
|
71
|
+
<tns:CampaignPerformanceReportColumn>Clicks</tns:CampaignPerformanceReportColumn>
|
72
|
+
<tns:CampaignPerformanceReportColumn>Spend</tns:CampaignPerformanceReportColumn>
|
73
|
+
</tns:Columns>
|
74
|
+
<tns:Scope>
|
75
|
+
<tns:AccountIds>
|
76
|
+
<arr:long>bing-ads-account-id</arr:long>
|
77
|
+
</tns:AccountIds>
|
78
|
+
</tns:Scope>
|
79
|
+
<tns:Time>
|
80
|
+
<tns:CustomDateRangeEnd>
|
81
|
+
<tns:Day>14</tns:Day>
|
82
|
+
<tns:Month>10</tns:Month>
|
83
|
+
<tns:Year>2015</tns:Year>
|
84
|
+
</tns:CustomDateRangeEnd>
|
85
|
+
<tns:CustomDateRangeStart>
|
86
|
+
<tns:Day>14</tns:Day>
|
87
|
+
<tns:Month>10</tns:Month>
|
88
|
+
<tns:Year>2015</tns:Year>
|
89
|
+
</tns:CustomDateRangeStart>
|
90
|
+
</tns:Time>
|
91
|
+
</tns:ReportRequest>
|
92
|
+
</tns:SubmitGenerateReportRequest>
|
93
|
+
</env:Body>
|
94
|
+
</env:Envelope>
|
95
|
+
headers:
|
96
|
+
Content-Type:
|
97
|
+
- text/xml;charset=UTF-8
|
98
|
+
Soapaction:
|
99
|
+
- SubmitGenerateReport
|
100
|
+
response:
|
101
|
+
status:
|
102
|
+
code: 200
|
103
|
+
message: OK
|
104
|
+
headers:
|
105
|
+
Content-Length:
|
106
|
+
- '396'
|
107
|
+
Content-Type:
|
108
|
+
- text/xml; charset=utf-8
|
109
|
+
Server:
|
110
|
+
- Microsoft-IIS/8.0
|
111
|
+
X-Powered-By:
|
112
|
+
- ASP.NET
|
113
|
+
Date:
|
114
|
+
- Fri, 13 Nov 2015 14:23:35 GMT
|
115
|
+
body:
|
116
|
+
encoding: UTF-8
|
117
|
+
string: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><h:TrackingId
|
118
|
+
xmlns:h="https://bingads.microsoft.com/Reporting/v9">bing-ads-report-tracking-id</h:TrackingId></s:Header><s:Body><SubmitGenerateReportResponse
|
119
|
+
xmlns="https://bingads.microsoft.com/Reporting/v9"><ReportRequestId>bing-ads-report-request-id</ReportRequestId></SubmitGenerateReportResponse></s:Body></s:Envelope>
|
120
|
+
http_version:
|
121
|
+
recorded_at: Fri, 13 Nov 2015 14:23:35 GMT
|
122
|
+
- request:
|
123
|
+
method: post
|
124
|
+
uri: https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/V9/ReportingService.svc
|
125
|
+
body:
|
126
|
+
encoding: UTF-8
|
127
|
+
string: |
|
128
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
129
|
+
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
130
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
131
|
+
xmlns:tns="https://bingads.microsoft.com/Reporting/v9"
|
132
|
+
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
|
133
|
+
xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
|
134
|
+
<env:Header>
|
135
|
+
<tns:CustomerAccountId>bing-ads-account-id</tns:CustomerAccountId>
|
136
|
+
<tns:CustomerId>bing-ads-customer-id</tns:CustomerId>
|
137
|
+
<tns:DeveloperToken>bing-ads-developer-token</tns:DeveloperToken>
|
138
|
+
<tns:AuthenticationToken>bing-ads-oauth-authentication-token</tns:AuthenticationToken>
|
139
|
+
</env:Header>
|
140
|
+
<env:Body>
|
141
|
+
<tns:PollGenerateReportRequest>
|
142
|
+
<tns:ReportRequestId xsi:nil="false">bing-ads-report-request-id</tns:ReportRequestId>
|
143
|
+
</tns:PollGenerateReportRequest>
|
144
|
+
</env:Body>
|
145
|
+
</env:Envelope>
|
146
|
+
headers:
|
147
|
+
Content-Type:
|
148
|
+
- text/xml;charset=UTF-8
|
149
|
+
Soapaction:
|
150
|
+
- PollGenerateReport
|
151
|
+
response:
|
152
|
+
status:
|
153
|
+
code: 200
|
154
|
+
message: OK
|
155
|
+
headers:
|
156
|
+
Content-Length:
|
157
|
+
- '493'
|
158
|
+
Content-Type:
|
159
|
+
- text/xml; charset=utf-8
|
160
|
+
Server:
|
161
|
+
- Microsoft-IIS/8.0
|
162
|
+
X-Powered-By:
|
163
|
+
- ASP.NET
|
164
|
+
Date:
|
165
|
+
- Fri, 13 Nov 2015 14:23:36 GMT
|
166
|
+
body:
|
167
|
+
encoding: UTF-8
|
168
|
+
string: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><h:TrackingId
|
169
|
+
xmlns:h="https://bingads.microsoft.com/Reporting/v9">bing-ads-report-tracking-id</h:TrackingId></s:Header><s:Body><PollGenerateReportResponse
|
170
|
+
xmlns="https://bingads.microsoft.com/Reporting/v9"><ReportRequestStatus xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><ReportDownloadUrl
|
171
|
+
i:nil="true"/><Status>Pending</Status></ReportRequestStatus></PollGenerateReportResponse></s:Body></s:Envelope>
|
172
|
+
http_version:
|
173
|
+
recorded_at: Fri, 13 Nov 2015 14:23:36 GMT
|
174
|
+
- request:
|
175
|
+
method: post
|
176
|
+
uri: https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/V9/ReportingService.svc
|
177
|
+
body:
|
178
|
+
encoding: UTF-8
|
179
|
+
string: |
|
180
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
181
|
+
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
182
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
183
|
+
xmlns:tns="https://bingads.microsoft.com/Reporting/v9"
|
184
|
+
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
|
185
|
+
xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
|
186
|
+
<env:Header>
|
187
|
+
<tns:CustomerAccountId>bing-ads-account-id</tns:CustomerAccountId>
|
188
|
+
<tns:CustomerId>bing-ads-customer-id</tns:CustomerId>
|
189
|
+
<tns:DeveloperToken>bing-ads-developer-token</tns:DeveloperToken>
|
190
|
+
<tns:AuthenticationToken>bing-ads-oauth-authentication-token</tns:AuthenticationToken>
|
191
|
+
</env:Header>
|
192
|
+
<env:Body>
|
193
|
+
<tns:PollGenerateReportRequest>
|
194
|
+
<tns:ReportRequestId xsi:nil="false">bing-ads-report-request-id</tns:ReportRequestId>
|
195
|
+
</tns:PollGenerateReportRequest>
|
196
|
+
</env:Body>
|
197
|
+
</env:Envelope>
|
198
|
+
headers:
|
199
|
+
Content-Type:
|
200
|
+
- text/xml;charset=UTF-8
|
201
|
+
Soapaction:
|
202
|
+
- PollGenerateReport
|
203
|
+
response:
|
204
|
+
status:
|
205
|
+
code: 200
|
206
|
+
message: OK
|
207
|
+
headers:
|
208
|
+
Content-Length:
|
209
|
+
- '937'
|
210
|
+
Content-Type:
|
211
|
+
- text/xml; charset=utf-8
|
212
|
+
Server:
|
213
|
+
- Microsoft-IIS/8.0
|
214
|
+
X-Powered-By:
|
215
|
+
- ASP.NET
|
216
|
+
Date:
|
217
|
+
- Fri, 13 Nov 2015 14:23:42 GMT
|
218
|
+
body:
|
219
|
+
encoding: UTF-8
|
220
|
+
string: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><h:TrackingId
|
221
|
+
xmlns:h="https://bingads.microsoft.com/Reporting/v9">bing-ads-report-tracking-id</h:TrackingId></s:Header><s:Body><PollGenerateReportResponse
|
222
|
+
xmlns="https://bingads.microsoft.com/Reporting/v9"><ReportRequestStatus xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><ReportDownloadUrl>https://download.api.bingads.microsoft.com/ReportDownload/Download.aspx?q=bing-ads-report-download-id</ReportDownloadUrl><Status>Success</Status></ReportRequestStatus></PollGenerateReportResponse></s:Body></s:Envelope>
|
223
|
+
http_version:
|
224
|
+
recorded_at: Fri, 13 Nov 2015 14:23:42 GMT
|
225
|
+
- request:
|
226
|
+
method: get
|
227
|
+
uri: https://download.api.bingads.microsoft.com/ReportDownload/Download.aspx?q=bing-ads-report-download-id
|
228
|
+
body:
|
229
|
+
encoding: US-ASCII
|
230
|
+
string: ''
|
231
|
+
headers:
|
232
|
+
Accept-Encoding:
|
233
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
234
|
+
Accept:
|
235
|
+
- "*/*"
|
236
|
+
User-Agent:
|
237
|
+
- Ruby
|
238
|
+
response:
|
239
|
+
status:
|
240
|
+
code: 200
|
241
|
+
message: OK
|
242
|
+
headers:
|
243
|
+
Cache-Control:
|
244
|
+
- private
|
245
|
+
Content-Length:
|
246
|
+
- '875'
|
247
|
+
Content-Type:
|
248
|
+
- application/x-zip-compressed
|
249
|
+
Server:
|
250
|
+
- Microsoft-IIS/8.0
|
251
|
+
Content-Disposition:
|
252
|
+
- attachment; filename="MyReport.zip"
|
253
|
+
X-Aspnet-Version:
|
254
|
+
- 4.0.30319
|
255
|
+
X-Powered-By:
|
256
|
+
- ASP.NET
|
257
|
+
Date:
|
258
|
+
- Fri, 13 Nov 2015 14:23:43 GMT
|
259
|
+
body:
|
260
|
+
encoding: ASCII-8BIT
|
261
|
+
string: !binary |-
|
262
|
+
UEsDBBQAAAAIAPCYb0c2Z8CWHQIAAPkDAAAUAE8AMzAwMDAwMDYyNjA5ODY2
|
263
|
+
Ny5jc3ZOVS4ATlVDWBQAMwAwADAAMAAwADAAMAA2ADIANgAwADkAOAA2ADYA
|
264
|
+
NwAuAGMAcwB2AHVwGQABF2t/LTMwMDAwMDA2MjYwOTg2NjcuY3N2hFNLjtQw
|
265
|
+
EN0jcQcrK5CQ21X+JrvWIGAkGhCMWLAL3e4mIt1uJelBvUNwC24wZ2CBxNyE
|
266
|
+
C3AFXOWMxAoWieP3/F69sp3f339Ur+MxDZN40e5jI1bnMq3u37sjrjoiQC3A
|
267
|
+
LFCBJYow8S4dMvG2Hbp0Ggl93o6TuEj7Yx+nuBHL67br2/d9FI/bc3aABTh2
|
268
|
+
ENgY1Sgllivx4Onq6uE/xc/Safives663O2GuGunLh0aFoq0FZv2/NeSJ10/
|
269
|
+
xWxI0Ks0xcPUtb24PKzn0jns1DZiGk6RVenT2Ag0+TvPyPLlNrdTPaou98ch
|
270
|
+
jmMuNebZRd+tP9LHm2M8bEip8kT7WucBbF3nwaN0vH1AlHW0AgwS5azUgSgk
|
271
|
+
CrwnCr3Ng/WyRqLICaE2eQiGRDpIxyKCQHMpq8kcjQSKXJGBd5Yh9gSpPBGO
|
272
|
+
9CWcIYWTWZhxXmQphWWVNI7gQEVJg4SCBE5EIYBQepREdgY1A5pB0AzCDCKD
|
273
|
+
qmaQmyUUAsNBMcypgHsPnMFyl0BtektvrZGTy1CMaG2tiTH8hlq6Upfdy35a
|
274
|
+
zo76jir7gYUKhZoTBKYUU4q6RJShhOCeMXA/XBe99Nw48nl6FvvAB2Sl5e3D
|
275
|
+
ciieU2PxNRI5B5ZdKLfB8UqvpSq3QfMxG96R0rqvpZ1v4+3XX5+/3X75ecO/
|
276
|
+
xapbD2lMW/qLhnzV+S+QYtn3Yuh2H6ZR5Osah+u4kaL6AwAA//8DAFBLAQIt
|
277
|
+
ABQAAAAIAPCYb0c2Z8CWHQIAAPkDAAAUAHUAAAAAAAAAAAAAAAAAAAAzMDAw
|
278
|
+
MDAwNjI2MDk4NjY3LmNzdk5VMABOVUNYFAAAADMAMAAwADAAMAAwADAANgAy
|
279
|
+
ADYAMAA5ADgANgA2ADcALgBjAHMAdgAKACAAAAAAAAEAGAD8qUTvGyDRAfyp
|
280
|
+
RO8bINEBN3BD7xsg0QF1cBkAARdrfy0zMDAwMDAwNjI2MDk4NjY3LmNzdlBL
|
281
|
+
BQYAAAAAAQABALcAAACeAgAAAAA=
|
282
|
+
http_version:
|
283
|
+
recorded_at: Fri, 13 Nov 2015 14:23:43 GMT
|
284
|
+
recorded_with: VCR 3.0.0
|
@@ -0,0 +1,42 @@
|
|
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
|
+
- '1317'
|
27
|
+
Content-Type:
|
28
|
+
- application/json
|
29
|
+
Server:
|
30
|
+
- Microsoft-IIS/8.5
|
31
|
+
X-Content-Type-Options:
|
32
|
+
- nosniff
|
33
|
+
Date:
|
34
|
+
- Fri, 13 Nov 2015 14:23:33 GMT
|
35
|
+
Connection:
|
36
|
+
- close
|
37
|
+
body:
|
38
|
+
encoding: UTF-8
|
39
|
+
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"}'
|
40
|
+
http_version:
|
41
|
+
recorded_at: Fri, 13 Nov 2015 14:23:33 GMT
|
42
|
+
recorded_with: VCR 3.0.0
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
RSpec.describe SoapyBing::Ads::Reports::CampaignPerformanceReport do
|
4
|
+
let(:service) { SoapyBing::Ads.new }
|
5
|
+
let(:report) do
|
6
|
+
service.campaign_performance_report(
|
7
|
+
date_start: '2015-10-14',
|
8
|
+
date_end: '2015-10-14',
|
9
|
+
# CampaignName is considered to be a sensitive data, lets not record it
|
10
|
+
settings: { columns: %w(TimePeriod Impressions Clicks Spend) }
|
11
|
+
)
|
12
|
+
end
|
13
|
+
let(:payload_fixture_path) do
|
14
|
+
File.join('spec', 'fixtures', 'reports', 'campaign_performance_report.json')
|
15
|
+
end
|
16
|
+
let(:fixtured_payload) { JSON.load(File.read(payload_fixture_path)) }
|
17
|
+
|
18
|
+
describe '#rows' do
|
19
|
+
subject { report.rows }
|
20
|
+
|
21
|
+
context 'when there is a successfull response during polling', :integration do
|
22
|
+
it 'responds with report rows',
|
23
|
+
vcr: { cassette_name: 'campaign_performance_report/with_successful_status' } do
|
24
|
+
expect(subject).to eq fixtured_payload
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'when there is only pending responses during polling', :integration do
|
29
|
+
before { stub_const('SoapyBing::Soap::Request::PollGenerateReportRequest::POLLING_TRIES', 1) }
|
30
|
+
|
31
|
+
it 'throws exception PollingTimeoutError',
|
32
|
+
vcr: { cassette_name: 'campaign_performance_report/with_pending_status' } do
|
33
|
+
expect { subject }.to raise_error(
|
34
|
+
SoapyBing::Soap::Request::PollGenerateReportRequest::PollingTimeoutError
|
35
|
+
)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
RSpec.describe SoapyBing::OauthCredentials do
|
2
|
+
describe '#access_token' do
|
3
|
+
context 'on successful respose', :integration do
|
4
|
+
it 'responds with oauth access token',
|
5
|
+
vcr: { cassette_name: 'oauth_credentials/access_token/with_successful_status' } do
|
6
|
+
expect(subject.access_token).to eq 'bing-ads-oauth-authentication-token'
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
RSpec.describe SoapyBing::Account do
|
2
|
+
describe '#initialize' do
|
3
|
+
subject { described_class.new(account) }
|
4
|
+
|
5
|
+
context 'when account credentials passed explicitly' do
|
6
|
+
let(:account) do
|
7
|
+
{ developer_token: 'foo', account_id: 'baz', customer_id: 'qux' }
|
8
|
+
end
|
9
|
+
before do
|
10
|
+
allow(ENV).to receive(:[]).with('BING_ADS_DEVELOPER_TOKEN').and_return('foo_env')
|
11
|
+
allow(ENV).to receive(:[]).with('BING_ADS_ACCOUNT_ID').and_return('baz_env')
|
12
|
+
allow(ENV).to receive(:[]).with('BING_ADS_CUSTOMER_ID').and_return('qux_env')
|
13
|
+
end
|
14
|
+
|
15
|
+
it '#developer_token is set' do
|
16
|
+
expect(subject.developer_token).to eq 'foo'
|
17
|
+
end
|
18
|
+
|
19
|
+
it '#account_id is set' do
|
20
|
+
expect(subject.account_id).to eq 'baz'
|
21
|
+
end
|
22
|
+
|
23
|
+
it '#customer_id is set' do
|
24
|
+
expect(subject.customer_id).to eq 'qux'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'when account credentials passed via Enviromenment variables' do
|
29
|
+
let(:account) { {} }
|
30
|
+
before do
|
31
|
+
allow(ENV).to receive(:[]).with('BING_ADS_DEVELOPER_TOKEN').and_return('foo_env')
|
32
|
+
allow(ENV).to receive(:[]).with('BING_ADS_ACCOUNT_ID').and_return('baz_env')
|
33
|
+
allow(ENV).to receive(:[]).with('BING_ADS_CUSTOMER_ID').and_return('qux_env')
|
34
|
+
end
|
35
|
+
|
36
|
+
it '#developer_token is set' do
|
37
|
+
expect(subject.developer_token).to eq 'foo_env'
|
38
|
+
end
|
39
|
+
|
40
|
+
it '#account_id is set' do
|
41
|
+
expect(subject.account_id).to eq 'baz_env'
|
42
|
+
end
|
43
|
+
|
44
|
+
it '#customer_id is set' do
|
45
|
+
expect(subject.customer_id).to eq 'qux_env'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'when no credentials passed' do
|
50
|
+
let(:account) do
|
51
|
+
{ developer_token: 'foo', account_id: 'baz', customer_id: 'qux' }
|
52
|
+
end
|
53
|
+
before do
|
54
|
+
%w( BING_ADS_DEVELOPER_TOKEN
|
55
|
+
BING_ADS_ACCOUNT_ID
|
56
|
+
BING_ADS_CUSTOMER_ID ).each do |var|
|
57
|
+
allow(ENV).to receive(:[]).with(var).and_return(nil)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'throws exception on missing :developer_token' do
|
62
|
+
account.delete(:developer_token)
|
63
|
+
expect { subject }.to raise_error SoapyBing::ParamGuard::ParamRequiredError,
|
64
|
+
"developer_token have to be passed explicitly or via ENV['BING_ADS_DEVELOPER_TOKEN']"
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'throws exception on missing :account_id' do
|
68
|
+
account.delete(:account_id)
|
69
|
+
expect { subject }.to raise_error SoapyBing::ParamGuard::ParamRequiredError,
|
70
|
+
"account_id have to be passed explicitly or via ENV['BING_ADS_ACCOUNT_ID']"
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'throws exception on missing :customer_id' do
|
74
|
+
account.delete(:customer_id)
|
75
|
+
expect { subject }.to raise_error SoapyBing::ParamGuard::ParamRequiredError,
|
76
|
+
"customer_id have to be passed explicitly or via ENV['BING_ADS_CUSTOMER_ID']"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
RSpec.describe SoapyBing::Ads::Reports::CampaignPerformanceReport do
|
4
|
+
let(:report_options) { { oauth_credentials: nil, account: nil } }
|
5
|
+
subject { described_class.new report_options }
|
6
|
+
|
7
|
+
describe '#initialize' do
|
8
|
+
let(:wrong_date) { 'wrong_date' }
|
9
|
+
|
10
|
+
context 'when there is a wrong date format' do
|
11
|
+
before { report_options.merge!(date_start: wrong_date) }
|
12
|
+
|
13
|
+
let(:start_date) { 'wrong_date' }
|
14
|
+
it 'throws exception' do
|
15
|
+
expect { subject }.to raise_error(ArgumentError, 'invalid date')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#date_range' do
|
21
|
+
let(:date_start) { '2011-01-01' }
|
22
|
+
let(:date_end) { '2015-12-31' }
|
23
|
+
before { report_options.merge!(date_start: date_start, date_end: date_end) }
|
24
|
+
|
25
|
+
it 'is instance of Range' do
|
26
|
+
expect(subject.date_range).to be_an_instance_of Range
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'begin' do
|
30
|
+
it 'keeps initialized value' do
|
31
|
+
expect(subject.date_range.begin).to eq Date.parse(date_start)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'end' do
|
36
|
+
it 'keeps initialized value' do
|
37
|
+
expect(subject.date_range.end).to eq Date.parse(date_end)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'csv'
|
3
|
+
|
4
|
+
RSpec.describe SoapyBing::Ads::Reports::Parsers::CSVParser do
|
5
|
+
describe '#rows' do
|
6
|
+
subject { described_class.new(csv_data).rows }
|
7
|
+
context 'on valid CSV data' do
|
8
|
+
let(:csv_fixture_path) do
|
9
|
+
File.join('spec', 'fixtures', 'reports', 'campaign_performance_report.csv')
|
10
|
+
end
|
11
|
+
let(:csv_data) { File.read(csv_fixture_path) }
|
12
|
+
|
13
|
+
let(:json_fixture_path) do
|
14
|
+
File.join('spec', 'fixtures', 'reports', 'campaign_performance_report.json')
|
15
|
+
end
|
16
|
+
let(:json_data) { JSON.load(File.read(json_fixture_path)) }
|
17
|
+
|
18
|
+
it 'responds with array of Hashes' do
|
19
|
+
expect(subject).to eq json_data
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'on malformed CSV data 'do
|
24
|
+
let(:csv_data) { '"co", "' }
|
25
|
+
|
26
|
+
it 'throws exception CSV::MalformedCSVError' do
|
27
|
+
expect { subject }.to raise_error CSV::MalformedCSVError
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
RSpec.describe SoapyBing::Ads do
|
2
|
+
let(:oauth) do
|
3
|
+
{ client_id: 'foo', client_secret: 'bar', refresh_token: 'baz' }
|
4
|
+
end
|
5
|
+
let(:account) do
|
6
|
+
{ developer_token: 'foo', account_id: 'baz', customer_id: 'qux' }
|
7
|
+
end
|
8
|
+
subject { described_class.new(oauth: oauth, account: account) }
|
9
|
+
|
10
|
+
describe '#oauth_credentials' do
|
11
|
+
it 'is instance of SoapyBing::OauthCredentials' do
|
12
|
+
expect(subject.oauth_credentials).to be_an_instance_of SoapyBing::OauthCredentials
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#account' do
|
17
|
+
it 'is instance of SoapyBing::Account' do
|
18
|
+
expect(subject.account).to be_an_instance_of SoapyBing::Account
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#campaign_performance_report' do
|
23
|
+
subject do
|
24
|
+
described_class
|
25
|
+
.new(oauth: oauth, account: account)
|
26
|
+
.campaign_performance_report(date_start: '2015-01-01', date_end: '2015-01-01')
|
27
|
+
end
|
28
|
+
it 'is instance of SoapyBing::Ads::Reports::CampaignPerformanceReport' do
|
29
|
+
expect(subject).to be_an_instance_of SoapyBing::Ads::Reports::CampaignPerformanceReport
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
RSpec.describe SoapyBing::Helpers::ClassName do
|
2
|
+
describe '#class_name' do
|
3
|
+
subject do
|
4
|
+
stub_const(
|
5
|
+
'OUTERNS::INNERNS::MyClass',
|
6
|
+
Class.new.include(described_class)
|
7
|
+
).new.class_name
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'resolves class name' do
|
11
|
+
expect(subject).to eq 'MyClass'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|