adzerk 0.1.4 → 0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. data/lib/adzerk.rb +15 -0
  2. data/lib/adzerk/advertiser.rb +9 -0
  3. data/lib/adzerk/api_endpoint.rb +41 -0
  4. data/lib/adzerk/channel_site_map.rb +53 -0
  5. data/lib/adzerk/client.rb +80 -0
  6. data/lib/adzerk/creative.rb +17 -0
  7. data/lib/adzerk/creative_map.rb +38 -0
  8. data/lib/adzerk/flight.rb +12 -0
  9. data/lib/adzerk/invitation.rb +23 -0
  10. data/lib/adzerk/publisher.rb +17 -0
  11. data/lib/adzerk/reporting.rb +21 -0
  12. data/lib/adzerk/util.rb +37 -0
  13. data/lib/adzerk/version.rb +3 -0
  14. data/test/advertiser_api_spec.rb +57 -82
  15. data/test/campaign_api_spec.rb +150 -271
  16. data/test/channel_api_spec.rb +72 -79
  17. data/test/channel_site_map_api_spec.rb +43 -94
  18. data/test/creative_api_spec.rb +82 -251
  19. data/test/creative_map_api_spec.rb +291 -375
  20. data/test/flight_api_spec.rb +165 -493
  21. data/test/invitation_api_spec.rb +18 -41
  22. data/test/login_api_spec.rb +24 -49
  23. data/test/priority_api_spec.rb +53 -83
  24. data/test/publisher_api_spec.rb +71 -142
  25. data/test/rakefile.rb +7 -7
  26. data/test/report_api_spec.rb +18 -24
  27. data/test/security_api_spec.rb +21 -0
  28. data/test/site_api_spec.rb +37 -51
  29. data/test/spec_helper.rb +4 -17
  30. data/test/zone_api_spec.rb +38 -64
  31. metadata +61 -23
  32. data/lib/Adzerk.rb +0 -55
  33. data/lib/adzerk/Advertiser.rb +0 -39
  34. data/lib/adzerk/Campaign.rb +0 -33
  35. data/lib/adzerk/Channel.rb +0 -33
  36. data/lib/adzerk/ChannelSiteMap.rb +0 -44
  37. data/lib/adzerk/Creative.rb +0 -43
  38. data/lib/adzerk/CreativeMap.rb +0 -33
  39. data/lib/adzerk/Flight.rb +0 -44
  40. data/lib/adzerk/Invitation.rb +0 -17
  41. data/lib/adzerk/Login.rb +0 -28
  42. data/lib/adzerk/Priority.rb +0 -34
  43. data/lib/adzerk/Publisher.rb +0 -47
  44. data/lib/adzerk/Reporting.rb +0 -16
  45. data/lib/adzerk/Site.rb +0 -35
  46. data/lib/adzerk/Zone.rb +0 -35
  47. data/test/channel_api_security_spec.rb +0 -51
  48. data/test/csv_export_spec.rb +0 -89
  49. data/test/delivery-test.rb +0 -132
  50. data/test/test.rb +0 -43
  51. data/test/test2.rb +0 -175
@@ -1,97 +1,79 @@
1
- require './spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "Creative Flight API" do
4
-
5
- $creative_url = 'http://www.adzerk.com'
6
- @@map = $adzerk::CreativeMap.new
7
- @@creative = $adzerk::Creative.new
8
- @@advertiser = $adzerk::Advertiser.new
9
- @@channel = $adzerk::Channel.new
10
- @@campaign = $adzerk::Campaign.new
11
- @@site = $adzerk::Site.new
12
- @@flight = $adzerk::Flight.new
13
- @@priority = $adzerk::Priority.new
14
- @@zone = $adzerk::Zone.new
15
-
4
+
5
+
16
6
  before(:all) do
17
- new_advertiser = {
18
- 'Title' => "Test"
19
- }
20
- response = @@advertiser.create(new_advertiser)
21
- $advertiserId = JSON.parse(response.body)["Id"]
22
-
23
- new_channel = {
24
- 'Title' => 'Test Channel ' + rand(1000000).to_s,
25
- 'Commission' => '0',
26
- 'Engine' => 'CPM',
27
- 'Keywords' => 'test',
28
- 'CPM' => '10.00',
29
- 'AdTypes' => [1,2,3,4]
30
- }
31
- response = @@channel.create(new_channel)
32
- $channelId = JSON.parse(response.body)["Id"]
7
+ client = Adzerk::Client.new(API_KEY)
8
+ @creative_maps = client.creative_maps
9
+ @advertisers = client.advertisers
10
+ @channels = client.channels
11
+ @campaigns = client.campaigns
12
+ @sites = client.sites
13
+ @flights = client.flights
14
+ @priorities = client.priorities
15
+ @zones = client.zones
33
16
 
34
- new_priority = {
35
- 'Name' => "High Priority Test",
36
- 'ChannelId' => $channelId,
37
- 'Weight' => 1,
38
- 'IsDeleted' => false
39
- }
40
- response = @@priority.create(new_priority)
41
- $priority_id = JSON.parse(response.body)["Id"].to_s
42
-
43
- new_campaign = {
44
- 'Name' => 'Test campaign ' + rand(1000000).to_s,
45
- 'StartDate' => "1/1/2011",
46
- 'EndDate' => "12/31/2011",
47
- 'IsActive' => false,
48
- 'Price' => '10.00',
49
- 'AdvertiserId' => $advertiserId,
50
- 'Flights' => [],
51
- 'IsDeleted' => false
52
- }
53
- response = @@campaign.create(new_campaign)
54
- $campaignId = JSON.parse(response.body)["Id"]
55
-
56
- new_flight = {
57
- 'NoEndDate' => false,
58
- 'PriorityId' => $priority_id,
59
- 'Name' => 'Test flight ' + rand(1000000).to_s,
60
- 'StartDate' => "1/1/2011",
61
- 'EndDate' => "12/31/2011",
62
- 'NoEndDate' => false,
63
- 'Price' => '15.00',
64
- 'OptionType' => 1,
65
- 'Impressions' => 10000,
66
- 'IsUnlimited' => false,
67
- 'IsFullSpeed' => false,
68
- 'Keywords' => "test, test2",
69
- 'UserAgentKeywords' => nil,
70
- 'WeightOverride' => nil,
71
- 'CampaignId' => $campaignId,
72
- 'IsActive' => true,
73
- 'IsDeleted' => false
74
- }
75
- response = @@flight.create(new_flight)
76
- $flightId = JSON.parse(response.body)["Id"]
77
-
78
- new_site = {
79
- 'Title' => 'Test Site ' + rand(1000000).to_s,
80
- 'Url' => 'http://www.adzerk.com'
81
- }
82
- response = @@site.create(new_site)
83
- $siteId = JSON.parse(response.body)["Id"]
84
-
85
- new_zone = {
86
- 'Name' => 'Test Zone ' + rand(10000000).to_s,
87
- 'SiteId' => $siteId,
17
+ advertiser = @advertisers.create(:title => "test")
18
+ @advertiser_id = advertiser[:id].to_s
19
+
20
+ channel = @channels.create(:title => 'Test Channel ' + rand(1000000).to_s,
21
+ :commission => '0.0',
22
+ :engine => 'CPM',
23
+ :keywords => 'test',
24
+ 'CPM' => '10.00',
25
+ :ad_types => [1,2,3,4])
26
+ @channel_id = channel[:id].to_s
27
+
28
+ priority = @priorities.create(:name => "High Priority Test",
29
+ :channel_id => @channel_id,
30
+ :weight => 1,
31
+ :is_deleted => false)
32
+ @priority_id = priority[:id].to_s
33
+
34
+ campaign = @campaigns.
35
+ create(:name => 'Test campaign ' + rand(1000000).to_s,
36
+ :start_date => "1/1/2011",
37
+ :end_date => "12/31/2011",
38
+ :is_active => false,
39
+ :price => '10.00',
40
+ :advertiser_id => @advertiser_id,
41
+ :flights => [],
42
+ :is_deleted => false)
43
+ @campaign_id = campaign[:id]
44
+
45
+ new_flight = {
46
+ :no_end_date => false,
47
+ :priority_id => @priority_id,
48
+ :name => 'Test flight ' + rand(1000000).to_s,
49
+ :start_date => "1/1/2011",
50
+ :endDate => "12/31/2011",
51
+ :noEndDate => false,
52
+ :price => '15.00',
53
+ :option_type => 1,
54
+ :impressions => 10000,
55
+ :is_unlimited => false,
56
+ :is_full_speed => false,
57
+ :keywords => "test, test2",
58
+ :user_agent_keywords => nil,
59
+ :weight_override => nil,
60
+ :campaign_id => @campaign_id,
61
+ :is_active => true,
62
+ :is_deleted => false
88
63
  }
89
- response = @@zone.create(new_zone)
90
- $zoneId = JSON.parse(response.body)["Id"]
64
+ flight = @flights.create(new_flight)
65
+ @flight_id = flight[:id]
91
66
 
67
+ site = @sites.create(:title => 'Test Site ' + rand(1000000).to_s,
68
+ :url => 'http://www.adzerk.com')
69
+ @site_id = site[:id]
70
+
71
+ zone = @zones.create(:name => 'Test Zone ' + rand(10000000).to_s,
72
+ :site_id => @site_id)
73
+ @zone_id = zone[:id]
92
74
  end
93
-
94
- it "should create a creative" do
75
+
76
+ it "should create a creative map" do
95
77
  $Title = 'Test creative ' + rand(1000000).to_s
96
78
  $ImageName = "test.jpg"
97
79
  $Url = "http://adzerk.com"
@@ -106,332 +88,266 @@ describe "Creative Flight API" do
106
88
  $SizeOverride = false
107
89
  $Iframe = false
108
90
  $PublisherAccountId = 372
109
- $ScriptBody = '<html>'
91
+ $ScriptBody = '<html>'
110
92
  $Impressions = 100000
111
93
  $Percentage = 50
112
- $DistributionType = 1
94
+ $DistributionType = 1
113
95
  $IsHTMLJS = true
114
96
  $IsActive = true
115
97
  $Alt = "test alt"
116
98
  $IsDeleted = false
117
99
  $IsSync = false
118
-
100
+
119
101
  new_creative = {
120
- 'CampaignId' => $CampaignId,
121
- 'FlightId' => $FlightId,
122
- 'SizeOverride' => $SizeOverride,
123
- 'Iframe' => $Iframe,
124
- 'PublisherAccountId' => $PublisherAccountId,
125
- 'Impressions' => $Impressions,
126
- 'Percentage' => $Percentage,
127
- 'SiteId' => $SiteId,
128
- 'ZoneId' => $ZoneId,
129
- 'DistributionType' => $DistributionType,
130
- 'IsActive' => $IsActive,
131
- 'IsDeleted' => $IsDeleted,
132
- 'Creative' => {
133
- 'Title' => $Title,
134
- 'Url' => $Url,
135
- 'Body' => $Body,
136
- 'AdvertiserId' => $AdvertiserId,
137
- 'AdTypeId' => $AdTypeId,
138
- 'IsHTMLJS' => $IsHTMLJS,
139
- 'ScriptBody' => $ScriptBody,
140
- 'IsActive' => $IsActive,
141
- 'Alt' => $Alt,
142
- 'IsDeleted' => $IsDeleted,
143
- 'IsSync' => $IsSync
102
+ :campaign_id => @campaign_id,
103
+ :flight_id => @flight_id,
104
+ :size_override => false,
105
+ :iframe => false,
106
+ :impressions => 100000,
107
+ :percentage => 50,
108
+ :siteId => @site_id,
109
+ :zoneId => @zone_id,
110
+ :distributionType => 1,
111
+ :isActive => true,
112
+ :isDeleted => false,
113
+ :creative => {
114
+ :title => "Creative Title",
115
+ :url => "http://www.adzerk.com",
116
+ :body => "Test Body",
117
+ :advertiser_id => @advertiser_id,
118
+ :ad_type_id => 18,
119
+ 'IsHTMLJS' => true,
120
+ :script_body => "<html></html>",
121
+ :is_active => true,
122
+ :alt => "alt text",
123
+ :is_deleted => false,
124
+ :is_sync => false
144
125
  }
145
126
  }
146
- response = @@map.create(new_creative)
147
- Adzerk.uploadCreative(JSON.parse(response.body)["Creative"]["Id"].to_s, "250x250.gif")
148
- $map_id= JSON.parse(response.body)["Id"].to_s
149
- JSON.parse(response.body)["Creative"]["Title"].should == $Title
150
- JSON.parse(response.body)["Creative"]["Url"].should == $Url
151
- JSON.parse(response.body)["Creative"]["Body"].should == $Body
152
- JSON.parse(response.body)["Creative"]["AdvertiserId"].should == $AdvertiserId
153
- JSON.parse(response.body)["CampaignId"].should == $CampaignId
154
- JSON.parse(response.body)["FlightId"].should == $FlightId
155
- JSON.parse(response.body)["Creative"]["AdTypeId"].should == $AdTypeId
156
- JSON.parse(response.body)["ZoneId"].should == $zoneId
157
- JSON.parse(response.body)["SiteId"].should == $siteId
158
- JSON.parse(response.body)["SizeOverride"].should == $SizeOverride
159
- JSON.parse(response.body)["PublisherAccountId"].should == $PublisherAccountId
160
- JSON.parse(response.body)["Impressions"].should == $Impressions
161
- JSON.parse(response.body)["Percentage"].should == $Percentage
162
- JSON.parse(response.body)["DistributionType"].should == $DistributionType
163
- JSON.parse(response.body)["Creative"]["IsHTMLJS"].should == $IsHTMLJS
164
- JSON.parse(response.body)["Creative"]["ScriptBody"].should == $ScriptBody
165
- JSON.parse(response.body)["Creative"]["IsActive"].should == $IsActive
166
- JSON.parse(response.body)["Creative"]["Alt"].should == $Alt
167
- JSON.parse(response.body)["IsDeleted"].should == $IsDeleted
168
- JSON.parse(response.body)["Creative"]["IsSync"].should == $IsSync
169
- $creative_id_id = JSON.parse(response.body)["Creative"]["Id"]
170
- end
171
-
172
- it "should list all creatives for a flight" do
173
- response = @@map.list($FlightId)
174
- entry = response["Items"].last.to_json
175
- $map_id = JSON.parse(entry)["Id"]
176
- JSON.parse(entry)["Creative"]["Title"].should == $Title
177
- JSON.parse(entry)["Creative"]["Url"].should == $Url
178
- JSON.parse(entry)["Creative"]["Body"].should == $Body
179
- JSON.parse(entry)["Creative"]["AdvertiserId"].should == $AdvertiserId
180
- JSON.parse(entry)["CampaignId"].should == $CampaignId
181
- JSON.parse(entry)["FlightId"].should == $FlightId
182
- JSON.parse(entry)["Creative"]["AdTypeId"].should == $AdTypeId
183
- JSON.parse(entry)["ZoneId"].should == $ZoneId
184
- JSON.parse(entry)["SiteId"].should == $SiteId
185
- #JSON.parse(entry)["SizeOverride"].should == $SizeOverride
186
- #JSON.parse(entry)["PublisherAccountId"].should == $PublisherAccountId
187
- #JSON.parse(entry)["Impressions"].should == $Impressions
188
- JSON.parse(entry)["Percentage"].should == $Percentage
189
- JSON.parse(entry)["DistributionType"].should == $DistributionType
190
- JSON.parse(entry)["Creative"]["IsHTMLJS"].should == $IsHTMLJS
191
- JSON.parse(entry)["Creative"]["ScriptBody"].should == $ScriptBody
192
- JSON.parse(entry)["Creative"]["IsActive"].should == $IsActive
193
- JSON.parse(entry)["Creative"]["Alt"].should == $Alt
194
- JSON.parse(entry)["IsDeleted"].should == $IsDeleted
195
- JSON.parse(entry)["Creative"]["IsSync"].should == $IsSync
127
+ creative_map = @creative_maps.create(new_creative)
128
+ creative_map[:creative][:title].should eq("Creative Title")
129
+ creative_map[:creative][:url].should eq("http://www.adzerk.com")
130
+ creative_map[:campaign_id].should eq(@campaign_id)
131
+ creative_map[:flight_id].should eq(@flight_id)
132
+ creative_map[:zone_id].should eq(@zone_id)
133
+ creative_map[:site_id].should eq(@site_id)
134
+ creative_map[:creative][:is_htmljs]
135
+ creative_map[:creative][:script_body].should eq("<html></html>")
136
+ $creative_id_id = creative_map[:creative][:id]
196
137
  end
197
-
198
- it "should get a specific creative" do
199
- response = @@map.get($map_id, $flightId)
200
- JSON.parse(response.body)["Id"].should == $map_id
201
- JSON.parse(response.body)["Creative"]["Title"].should == $Title
202
- JSON.parse(response.body)["Creative"]["Url"].should == $Url
203
- JSON.parse(response.body)["Creative"]["Body"].should == $Body
204
- JSON.parse(response.body)["Creative"]["AdvertiserId"].should == $AdvertiserId
205
- JSON.parse(response.body)["CampaignId"].should == $CampaignId
206
- JSON.parse(response.body)["FlightId"].should == $FlightId
207
- JSON.parse(response.body)["Creative"]["AdTypeId"].should == $AdTypeId
208
- JSON.parse(response.body)["ZoneId"].should == $ZoneId
209
- JSON.parse(response.body)["SiteId"].should == $SiteId
210
- #JSON.parse(response.body)["SizeOverride"].should == $SizeOverride
211
- #JSON.parse(response.body)["PublisherAccountId"].should == $PublisherAccountId
212
- #JSON.parse(response.body)["Impressions"].should == $Impressions
213
- JSON.parse(response.body)["Creative"]["IsHTMLJS"].should == $IsHTMLJS
214
- JSON.parse(response.body)["Creative"]["ScriptBody"].should == $ScriptBody
215
- JSON.parse(response.body)["Percentage"].should == $Percentage
216
- JSON.parse(response.body)["DistributionType"].should == $DistributionType
217
- JSON.parse(response.body)["Creative"]["IsActive"].should == $IsActive
218
- JSON.parse(response.body)["Creative"]["Alt"].should == $Alt
219
- JSON.parse(response.body)["IsDeleted"].should == $IsDeleted
220
- JSON.parse(response.body)["Creative"]["IsSync"].should == $IsSync
221
- @@creativeId = JSON.parse(response.body)["Creative"]["Id"]
138
+
139
+ it "should list all creatives maps for a flight" do
140
+ creative_maps = @creative_maps.list(@flight_id)
141
+ creative_map = creative_maps[:items].last
142
+ $map_id= creative_map[:id]
143
+ creative_map[:creative][:title].should eq("Creative Title")
144
+ creative_map[:creative][:url].should eq("http://www.adzerk.com")
145
+ creative_map[:campaign_id].should eq(@campaign_id)
146
+ creative_map[:flight_id].should eq(@flight_id)
147
+ creative_map[:zone_id].should eq(@zone_id)
148
+ creative_map[:site_id].should eq(@site_id)
149
+ creative_map[:creative][:is_htmljs]
150
+ creative_map[:creative][:script_body].should eq("<html></html>")
222
151
  end
223
-
152
+
153
+ it "should get a specific creative map" do
154
+ creative_map = @creative_maps.get($map_id, @flight_id)
155
+ creative_map[:creative][:title].should eq("Creative Title")
156
+ creative_map[:creative][:url].should eq("http://www.adzerk.com")
157
+ creative_map[:campaign_id].should eq(@campaign_id)
158
+ creative_map[:flight_id].should eq(@flight_id)
159
+ creative_map[:zone_id].should eq(@zone_id)
160
+ creative_map[:site_id].should eq(@site_id)
161
+ creative_map[:creative][:is_htmljs]
162
+ creative_map[:creative][:script_body].should eq("<html></html>")
163
+ end
164
+
224
165
  it "should update a specific creative" do
225
166
  updated_creative = {
226
- 'Id' => $map_id,
227
- 'CampaignId' => $CampaignId,
228
- 'FlightId' => $FlightId,
229
- 'SizeOverride' => $SizeOverride,
230
- 'Iframe' => $Iframe,
231
- 'PublisherAccountId' => $PublisherAccountId,
232
- 'Impressions' => $Impressions + 100,
233
- 'Percentage' => $Percentage,
234
- 'SiteId' => $SiteId,
235
- 'ZoneId' => $zoneId,
236
- 'IsActive' => $IsActive,
237
- 'IsDeleted' => $IsDeleted,
238
- 'Creative' => {
239
- 'Id' => @@creativeId
167
+ :id => $map_id,
168
+ :campaign_id => @campaign_id,
169
+ :flight_id => @flight_id,
170
+ :size_override => false,
171
+ :iframe => false,
172
+ :impressions => 200000,
173
+ :percentage => 50,
174
+ :site_id => @site_id,
175
+ :zone_id => @zone_id,
176
+ :is_active => true,
177
+ :is_deleted => false,
178
+ :creative => {
179
+ :id => $creative_id_id
240
180
  }
241
181
  }
242
- response = @@map.create(updated_creative)
243
- Adzerk.uploadCreative(JSON.parse(response.body)["Creative"]["Id"].to_s, "250x250.gif")
244
- JSON.parse(response.body)["Creative"]["Title"].should == $Title
245
- JSON.parse(response.body)["Creative"]["Url"].should == $Url
246
- JSON.parse(response.body)["Creative"]["Body"].should == $Body
247
- JSON.parse(response.body)["Creative"]["AdvertiserId"].should == $AdvertiserId
248
- JSON.parse(response.body)["CampaignId"].should == $CampaignId
249
- JSON.parse(response.body)["FlightId"].should == $FlightId
250
- JSON.parse(response.body)["Creative"]["AdTypeId"].should == $AdTypeId
251
- JSON.parse(response.body)["ZoneId"].should == $zoneId
252
- JSON.parse(response.body)["SiteId"].should == $SiteId
253
- JSON.parse(response.body)["SizeOverride"].should == $SizeOverride
254
- JSON.parse(response.body)["PublisherAccountId"].should == $PublisherAccountId
255
- JSON.parse(response.body)["Impressions"].should == $Impressions + 100
256
- JSON.parse(response.body)["Percentage"].should == $Percentage
257
- JSON.parse(response.body)["Creative"]["IsActive"].should == $IsActive
258
- JSON.parse(response.body)["Creative"]["Alt"].should == $Alt
259
- JSON.parse(response.body)["IsDeleted"].should == $IsDeleted
260
- JSON.parse(response.body)["Creative"]["IsSync"].should == $IsSync
182
+ creative_map = @creative_maps.update(updated_creative)
183
+ creative_map[:impressions].should eq(200000)
261
184
  end
262
185
 
263
186
  it "should update the scriptBody tag on a nested creative" do
264
187
  updated_creative = {
265
- 'Id' => $map_id,
266
- 'CampaignId' => $CampaignId,
267
- 'FlightId' => $FlightId,
268
- 'ZoneId' => $ZoneId,
269
- 'SizeOverride' => $SizeOverride,
270
- 'Iframe' => $Iframe,
271
- 'PublisherAccountId' => $PublisherAccountId,
272
- 'Impressions' => $Impressions,
273
- 'Percentage' => $Percentage,
274
- 'SiteId' => $SiteId,
275
- 'IsActive' => $IsActive,
276
- 'IsDeleted' => nil,
277
- 'Creative' => {
278
- 'Id' => @@creativeId,
279
- 'IsHTMLJS' => true,
280
- 'ScriptBody' => '<html></html>',
281
- 'Title' => 'test'
188
+ :id => $map_id,
189
+ :campaign_id => @campaign_id,
190
+ :flight_id => @flight_id,
191
+ :size_override => false,
192
+ :iframe => false,
193
+ :impressions => 200000,
194
+ :percentage => 50,
195
+ :site_id => @site_id,
196
+ :zone_id => @zone_id,
197
+ :is_active => true,
198
+ :is_deleted => false,
199
+ :creative => {
200
+ :id => $creative_id_id,
201
+ :script_body => '<html>New Body</html>',
282
202
  }
283
203
  }
284
- response = @@map.update(updated_creative)
285
- response.body.scan(/Exception/).should == []
204
+ creative_map = @creative_maps.update(updated_creative)
205
+ creative_map[:creative][:script_body].should eq('<html>New Body</html>')
286
206
  end
287
-
207
+
288
208
  it "should delete the creatives after creating it" do
289
- response = @@map.delete($map_id, $FlightId)
290
- response.body.should == "OK"
209
+ response = @creative_maps.delete($map_id, @flight_id)
210
+ response.body.should == "\"This creative map has been deleted\""
291
211
  end
292
-
293
- it "should not create a map when campaignId is forbidden" do
294
- map = {
295
- 'CampaignId' => '123',
296
- 'FlightId' => $FlightId,
297
- 'SizeOverride' => $SizeOverride,
298
- 'Iframe' => $Iframe,
299
- 'PublisherAccountId' => $PublisherAccountId,
300
- 'Impressions' => $Impressions,
301
- 'SiteId' => $SiteId,
302
- 'Percentage' => $Percentage,
303
- 'IsActive' => $IsActive,
304
- 'IsDeleted' => $IsDeleted
305
- }
306
- response = @@map.create(map)
307
- response.body.scan(/This campaign is not part/).should_not == []
212
+
213
+ it "should not get a map in a different network" do
214
+ creative_map = @creative_maps.get(123, @flight_id)
215
+ creative_map[:message].should == "This flight is not part of your network"
308
216
  end
309
-
310
- it "should not create a map when flightId is forbidden" do
311
- map = {
312
- 'CampaignId' => $CampaignId,
313
- 'FlightId' => '123',
314
- 'SizeOverride' => $SizeOverride,
315
- 'Iframe' => $Iframe,
316
- 'PublisherAccountId' => $PublisherAccountId,
317
- 'Impressions' => $Impressions,
318
- 'SiteId' => $SiteId,
319
- 'Percentage' => $Percentage,
320
- 'IsActive' => $IsActive,
321
- 'IsDeleted' => $IsDeleted
322
- }
323
- response = @@map.create(map)
324
- response.body.scan(/This flight is not part/).should_not == []
217
+
218
+ it "should not get a map that's been deleted" do
219
+ creative_map = @creative_maps.get($map_id, @flight_id)
220
+ creative_map[:message].should == "This creative map has been deleted"
325
221
  end
326
-
327
- it "should create a map when there is no creative object, just id" do
328
- map = {
329
- 'CampaignId' => $CampaignId,
330
- 'FlightId' => $FlightId,
331
- 'SizeOverride' => $SizeOverride,
332
- 'Iframe' => $Iframe,
333
- 'PublisherAccountId' => $PublisherAccountId,
334
- 'Impressions' => $Impressions,
335
- 'SiteId' => $SiteId,
336
- 'Percentage' => $Percentage,
337
- 'IsActive' => $IsActive,
338
- 'IsDeleted' => $IsDeleted,
339
- 'Creative' => {
340
- 'Id' => @@creativeId
222
+
223
+ it "should not update a map that's in a different network" do
224
+ creative_map = @creative_maps.update(
225
+ :id => $map_id,
226
+ :campaign_id => @campaign_id,
227
+ :flight_id => 123,
228
+ :size_override => false,
229
+ :iframe => false,
230
+ :impressions => 200000,
231
+ :percentage => 50,
232
+ :site_id => @site_id,
233
+ :zone_id => @zone_id,
234
+ :is_active => true,
235
+ :is_deleted => false,
236
+ :creative => {
237
+ :id => $creative_id_id
341
238
  }
342
- }
343
- response = @@map.create(map)
344
- response.body.scan(/Exception/).should == []
239
+ )
240
+ creative_map[:message].should == "This flight is not part of your network"
345
241
  end
346
242
 
347
- it "should not create a map when there is no creative object, just id that belongs to a different advertiser" do
348
- map = {
349
- 'CampaignId' => $CampaignId,
350
- 'FlightId' => $FlightId,
351
- 'SizeOverride' => $SizeOverride,
352
- 'Iframe' => $Iframe,
353
- 'PublisherAccountId' => $PublisherAccountId,
354
- 'Impressions' => $Impressions,
355
- 'SiteId' => $SiteId,
356
- 'Percentage' => $Percentage,
357
- 'IsActive' => $IsActive,
358
- 'IsDeleted' => $IsDeleted,
359
- 'Creative' => {
360
- 'Id' => 1234
243
+ it "should not update a map that's been deleted" do
244
+ creative_map = @creative_maps.update(
245
+ :id => $map_id,
246
+ :campaign_id => @campaign_id,
247
+ :flight_id => @flight_id,
248
+ :size_override => false,
249
+ :iframe => false,
250
+ :impressions => 200000,
251
+ :percentage => 50,
252
+ :site_id => @site_id,
253
+ :zone_id => @zone_id,
254
+ :is_active => true,
255
+ :is_deleted => false,
256
+ :creative => {
257
+ :id => $creative_id_id
361
258
  }
362
- }
363
- response = @@map.create(map)
364
- response.body.scan(/That creative belongs to an advertiser/).should_not == []
259
+ )
260
+ creative_map[:message].should == "This creative map has been deleted"
365
261
  end
366
262
 
367
- it "should create a map with and invalid siteId" do
368
- new_creative = {
369
- 'CampaignId' => $CampaignId,
370
- 'FlightId' => $FlightId,
371
- 'ZoneId' => $ZoneId,
372
- 'SizeOverride' => $SizeOverride,
373
- 'Iframe' => $Iframe,
374
- 'PublisherAccountId' => $PublisherAccountId,
375
- 'Impressions' => $Impressions,
376
- 'Percentage' => $Percentage,
377
- 'SiteId' => 0,
378
- 'IsActive' => $IsActive,
379
- 'IsDeleted' => $IsDeleted,
380
- 'Creative' => {
381
- 'Title' => $Title,
382
- 'Url' => $Url,
383
- 'Body' => $Body,
384
- 'AdvertiserId' => $AdvertiserId,
385
- 'AdTypeId' => $AdTypeId,
386
- 'IsActive' => $IsActive,
387
- 'Alt' => $Alt,
388
- 'IsDeleted' => $IsDeleted,
389
- 'IsSync' => $IsSync
263
+ it "should fail when creating a map for a campaign in a different network" do
264
+ creative_map = @creative_maps.create(
265
+ :campaign_id => 123,
266
+ :flight_id => @flight_id,
267
+ :size_override => false,
268
+ :iframe => false,
269
+ :impressions => 100000,
270
+ :percentage => 50,
271
+ :siteId => @site_id,
272
+ :zoneId => @zone_id,
273
+ :distributionType => 1,
274
+ :isActive => true,
275
+ :isDeleted => false,
276
+ :creative => {
277
+ :title => "Creative Title",
278
+ :url => "http://www.adzerk.com",
279
+ :body => "Test Body",
280
+ :advertiser_id => @advertiser_id,
281
+ :ad_type_id => 18,
282
+ 'IsHTMLJS' => true,
283
+ :script_body => "<html></html>",
284
+ :is_active => true,
285
+ :alt => "alt text",
286
+ :is_deleted => false,
287
+ :is_sync => false
390
288
  }
391
- }
392
- response = @@map.create(new_creative)
393
- response.body.scan(/This site does not belong to your network/).should_not == []
289
+ )
290
+ creative_map[:message].should == "This campaign is not part of your network"
394
291
  end
395
292
 
396
- it "should test if IsHTMLJS is getting written over" do
397
- creative = {
398
- 'Title' => 'Test Creative ' + rand(1000).to_s,
399
- 'Url' => 'http://adzerk.com/',
400
- 'Body' => 'test',
401
- 'AdvertiserId' => $advertiserId,
402
- 'AdTypeId' => 18,
403
- 'IsHTMLJS' => true,
404
- 'ScriptBody' => '<html>test</html>',
405
- 'IsActive' => true,
406
- 'Alt' => 'test',
407
- 'IsDeleted' => false,
408
- 'IsSync' => false
409
- }
410
- response = @@creative.create(creative, '250x250.gif')
411
- creativeId = JSON.parse(response.body)["Id"]
412
- JSON.parse(response.body)["IsHTMLJS"].should == true
413
- JSON.parse(response.body)["ScriptBody"].should == '<html>test</html>'
414
-
415
- map = {
416
- 'CampaignId' => $campaignId,
417
- 'FlightId' => $flightId,
418
- 'ZoneId' => $zoneId,
419
- 'SizeOverride' => $SizeOverride,
420
- 'Iframe' => $Iframe,
421
- 'PublisherAccountId' => $PublisherAccountId,
422
- 'Impressions' => $Impressions,
423
- 'Percentage' => $Percentage,
424
- 'SiteId' => $siteId,
425
- 'IsActive' => $IsActive,
426
- 'IsDeleted' => $IsDeleted,
427
- 'Creative' => {
428
- 'Id' => creativeId
293
+ it "should fail when creating a map for a site in a different network" do
294
+ creative_map = @creative_maps.create(
295
+ :campaign_id => @campaign_id,
296
+ :flight_id => @flight_id,
297
+ :size_override => false,
298
+ :iframe => false,
299
+ :impressions => 100000,
300
+ :percentage => 50,
301
+ :siteId => 123,
302
+ :zoneId => @zone_id,
303
+ :distributionType => 1,
304
+ :isActive => true,
305
+ :isDeleted => false,
306
+ :creative => {
307
+ :title => "Creative Title",
308
+ :url => "http://www.adzerk.com",
309
+ :body => "Test Body",
310
+ :advertiser_id => @advertiser_id,
311
+ :ad_type_id => 18,
312
+ 'IsHTMLJS' => true,
313
+ :script_body => "<html></html>",
314
+ :is_active => true,
315
+ :alt => "alt text",
316
+ :is_deleted => false,
317
+ :is_sync => false
429
318
  }
430
- }
431
- map_response = @@map.create(map)
319
+ )
320
+ creative_map[:message].should == "This site does not belong to your network"
321
+ end
432
322
 
433
- JSON.parse(map_response.body)["Creative"]["IsHTMLJS"].should == true
434
- JSON.parse(map_response.body)["Creative"]["ScriptBody"].should == '<html>test</html>'
323
+ it "should fail when creating a map for a zone in a different network" do
324
+ creative_map = @creative_maps.create(
325
+ :campaign_id => @campaign_id,
326
+ :flight_id => @flight_id,
327
+ :size_override => false,
328
+ :iframe => false,
329
+ :impressions => 100000,
330
+ :percentage => 50,
331
+ :siteId => @site_id,
332
+ :zoneId => 11,
333
+ :distributionType => 1,
334
+ :isActive => true,
335
+ :isDeleted => false,
336
+ :creative => {
337
+ :title => "Creative Title",
338
+ :url => "http://www.adzerk.com",
339
+ :body => "Test Body",
340
+ :advertiser_id => @advertiser_id,
341
+ :ad_type_id => 18,
342
+ 'IsHTMLJS' => true,
343
+ :script_body => "<html></html>",
344
+ :is_active => true,
345
+ :alt => "alt text",
346
+ :is_deleted => false,
347
+ :is_sync => false
348
+ }
349
+ )
350
+ creative_map[:message].should == "The site associated with that zone does not belong to your network"
435
351
  end
436
352
 
437
353
  end