adzerk 0.1 → 0.1.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.
@@ -7,13 +7,14 @@ describe "Flight API" do
7
7
  @@advertiser = $adzerk::Advertiser.new
8
8
  @@channel = $adzerk::Channel.new
9
9
  @@campaign = $adzerk::Campaign.new
10
+ @@priority = $adzerk::Priority.new
10
11
 
11
12
  before(:all) do
12
13
  new_advertiser = {
13
14
  'Title' => "Test"
14
15
  }
15
16
  response = @@advertiser.create(new_advertiser)
16
- $brandId = JSON.parse(response.body)["Id"]
17
+ $advertiserId = JSON.parse(response.body)["Id"]
17
18
 
18
19
  new_channel = {
19
20
  'Title' => 'Test Channel ' + rand(1000000).to_s,
@@ -21,18 +22,27 @@ describe "Flight API" do
21
22
  'Engine' => 'CPM',
22
23
  'Keywords' => 'test',
23
24
  'CPM' => '10.00',
24
- 'AdTypes' => [0,1,2,3,4]
25
+ 'AdTypes' => [1,2,3,4]
25
26
  }
26
27
  response = @@channel.create(new_channel)
27
28
  $channelId = JSON.parse(response.body)["Id"]
28
29
 
30
+ new_priority = {
31
+ 'Name' => "High Priority Test",
32
+ 'ChannelId' => $channelId,
33
+ 'Weight' => 1,
34
+ 'IsDeleted' => false
35
+ }
36
+ response = @@priority.create(new_priority)
37
+ $priority_id = JSON.parse(response.body)["Id"].to_s
38
+
29
39
  new_campaign = {
30
40
  'Name' => 'Test campaign ' + rand(1000000).to_s,
31
41
  'StartDate' => "1/1/2011",
32
42
  'EndDate' => "12/31/2011",
33
43
  'IsActive' => false,
34
44
  'Price' => '10.00',
35
- 'BrandId' => $brandId,
45
+ 'AdvertiserId' => $advertiserId,
36
46
  'Flights' => [],
37
47
  'IsDeleted' => false
38
48
  }
@@ -59,7 +69,7 @@ describe "Flight API" do
59
69
 
60
70
  new_flight = {
61
71
  'NoEndDate' => false,
62
- 'ChannelId' => $channelId,
72
+ 'PriorityId' => $priority_id,
63
73
  'Name' => $flight_Name,
64
74
  'StartDate' => $flight_StartDate,
65
75
  'EndDate' => $flight_EndDate,
@@ -79,7 +89,7 @@ describe "Flight API" do
79
89
  response = @@flight.create(new_flight)
80
90
  $flight_id = JSON.parse(response.body)["Id"].to_s
81
91
  JSON.parse(response.body)["NoEndDate"].should == false
82
- JSON.parse(response.body)["ChannelId"].should == $channelId
92
+ JSON.parse(response.body)["PriorityId"].to_s.should == $priority_id
83
93
  JSON.parse(response.body)["Name"].should == $flight_Name
84
94
  # JSON.parse(response.body)["StartDate"].should == "/Date(1293840000000+0000)/"
85
95
  # JSON.parse(response.body)["EndDate"].should == "/Date(1325307600000-0500)/"
@@ -99,7 +109,7 @@ describe "Flight API" do
99
109
 
100
110
  it "should list a specific flight" do
101
111
  response = @@flight.get($flight_id)
102
- response.body.should == '{"Id":' + $flight_id + ',"StartDate":"\\/Date(1293840000000+0000)\\/","EndDate":"\\/Date(1325289600000+0000)\\/","Price":15.00,"OptionType":1,"Impressions":10000,"IsUnlimited":false,"IsNoDuplicates":false,"IsFullSpeed":false,"Keywords":"test, test2","Name":"' + $flight_Name + '","CampaignId":' + $campaignId.to_s + ',"ChannelId":0,"IsDeleted":false,"IsActive":true}'
112
+ response.body.should == '{"Id":' + $flight_id + ',"StartDate":"\\/Date(1293840000000+0000)\\/","EndDate":"\\/Date(1325289600000+0000)\\/","Price":15.00,"OptionType":1,"Impressions":10000,"IsUnlimited":false,"IsNoDuplicates":false,"IsFullSpeed":false,"Keywords":"test, test2","Name":"' + $flight_Name + '","CampaignId":' + $campaignId.to_s + ',"PriorityId":' + $priority_id + ',"IsDeleted":false,"IsActive":true,"GeoTargeting":[]}'
103
113
  end
104
114
 
105
115
  it "should update a flight" do
@@ -122,7 +132,7 @@ describe "Flight API" do
122
132
  new_flight = {
123
133
  'Id' => $flight_id,
124
134
  'NoEndDate' => false,
125
- 'ChannelId' => $channelId,
135
+ 'PriorityId' => $priority_id,
126
136
  'Name' => $u_flight_Name,
127
137
  'StartDate' => $u_flight_StartDate,
128
138
  'EndDate' => $u_flight_EndDate,
@@ -142,7 +152,7 @@ describe "Flight API" do
142
152
  response = @@flight.update(new_flight)
143
153
  $flight_id = JSON.parse(response.body)["Id"].to_s
144
154
  JSON.parse(response.body)["NoEndDate"].should == false
145
- JSON.parse(response.body)["ChannelId"].should == $channelId
155
+ JSON.parse(response.body)["PriorityId"].to_s.should == $priority_id
146
156
  JSON.parse(response.body)["Name"].should == $u_flight_Name
147
157
  # JSON.parse(response.body)["StartDate"].should == "/Date(1293840000000+0000)/"
148
158
  # JSON.parse(response.body)["EndDate"].should == "/Date(1325307600000-0500)/"
@@ -166,7 +176,7 @@ describe "Flight API" do
166
176
  ## Can't test this right now because of paging issues
167
177
  # result["Items"].last["Id"].to_s.should == $flight_id
168
178
  # result["Items"].last["NoEndDate"].should == false
169
- # result["Items"].last["ChannelId"].should == $channelId
179
+ # result["Items"].last["PriorityId"].should == $priorityId
170
180
  # result["Items"].last["Name"].should == $flight_Name
171
181
  # result["Items"].last["StartDate"].should == "/Date(1293858000000-0500)/"
172
182
  # result["Items"].last["EndDate"].should == "/Date(1325307600000-0500)/"
@@ -184,7 +194,7 @@ describe "Flight API" do
184
194
  # result["Items"].last["IsDeleted"].should == $flight_IsDeleted
185
195
  end
186
196
 
187
- it "should not get if campaignId or channelId is forbidden" do
197
+ it "should not get if campaignId or priorityId is forbidden" do
188
198
  response = @@flight.get($flight_id)
189
199
  true.should == !response.body.scan(/Object/).nil?
190
200
  end
@@ -196,13 +206,13 @@ describe "Flight API" do
196
206
 
197
207
  it "should not get individual deleted flight" do
198
208
  response = @@flight.get($flight_id)
199
- response.body.should == '{"Id":0,"ChannelId":0,"IsDeleted":false,"IsActive":false}'
209
+ response.body.should == '{"Id":0,"PriorityId":0,"IsDeleted":false,"IsActive":false}'
200
210
  end
201
211
 
202
212
  it "should not create/update if campaignId is forbidden" do
203
213
  new_flight = {
204
214
  'NoEndDate' => false,
205
- 'ChannelId' => $channelId,
215
+ 'PriorityId' => $priority_id,
206
216
  'Name' => $flight_Name,
207
217
  'StartDate' => $flight_StartDate,
208
218
  'EndDate' => $flight_EndDate,
@@ -225,7 +235,7 @@ describe "Flight API" do
225
235
  new_flight = {
226
236
  'Id' => $flight_id,
227
237
  'NoEndDate' => false,
228
- 'ChannelId' => $channelId,
238
+ 'PriorityId' => $priority_id,
229
239
  'Name' => $flight_Name,
230
240
  'StartDate' => $flight_StartDate,
231
241
  'EndDate' => $flight_EndDate,
@@ -246,10 +256,10 @@ describe "Flight API" do
246
256
  true.should == !response.body.scan(/Object/).nil?
247
257
  end
248
258
 
249
- it "should not create/update if channelId is forbidden" do
259
+ it "should not create/update if priorityId is forbidden" do
250
260
  new_flight = {
251
261
  'NoEndDate' => false,
252
- 'ChannelId' => '123',
262
+ 'PriorityId' => '123',
253
263
  'Name' => $flight_Name,
254
264
  'StartDate' => $flight_StartDate,
255
265
  'EndDate' => $flight_EndDate,
@@ -272,7 +282,7 @@ describe "Flight API" do
272
282
  new_flight = {
273
283
  'Id' => $flight_id,
274
284
  'NoEndDate' => false,
275
- 'ChannelId' => '123',
285
+ 'PriorityId' => '123',
276
286
  'Name' => $flight_Name,
277
287
  'StartDate' => $flight_StartDate,
278
288
  'EndDate' => $flight_EndDate,
@@ -293,4 +303,69 @@ describe "Flight API" do
293
303
  true.should == !response.body.scan(/Object/).nil?
294
304
  end
295
305
 
306
+ it "should list the coutries, regions, and metros for geo-targeting" do
307
+ response = @@flight.countries()
308
+ true.should == !response.body.scan(/Object/).nil?
309
+ response = @@flight.regions("NC")
310
+ true.should == !response.body.scan(/Object/).nil?
311
+ end
312
+
313
+ it "should create a flight with geotargeting" do
314
+ $geo = [{
315
+ #'LocationId' => nil,
316
+ 'CountryCode' => 'US',
317
+ 'Region' => 'NC',
318
+ 'MetroCode' => '560'
319
+ }]
320
+
321
+ new_flight = {
322
+ 'NoEndDate' => false,
323
+ 'PriorityId' => $priority_id,
324
+ 'Name' => $flight_Name,
325
+ 'StartDate' => $flight_StartDate,
326
+ 'EndDate' => $flight_EndDate,
327
+ 'NoEndDate' => $flight_NoEndDate,
328
+ 'Price' => $flight_Price,
329
+ 'OptionType' => $flight_OptionType,
330
+ 'Impressions' => $flight_Impressions,
331
+ 'IsUnlimited' => $flight_IsUnlimited,
332
+ 'IsFullSpeed' => $flight_IsFullSpeed,
333
+ 'Keywords' => $flight_Keywords,
334
+ 'UserAgentKeywords' => $flight_UserAgentKeywords,
335
+ 'WeightOverride' => $flight_WeightOverride,
336
+ 'CampaignId' => $flight_CampaignId,
337
+ 'IsActive' => $flight_IsActive,
338
+ 'IsDeleted' => $flight_IsDeleted,
339
+ 'GeoTargeting' => $geo
340
+ }
341
+ response = @@flight.create(new_flight)
342
+ $flight_id = JSON.parse(response.body)["Id"].to_s
343
+ JSON.parse(response.body)["NoEndDate"].should == false
344
+ JSON.parse(response.body)["PriorityId"].to_s.should == $priority_id
345
+ JSON.parse(response.body)["Name"].should == $flight_Name
346
+ #JSON.parse(response.body)["StartDate"].should == "/Date(1293840000000+0000)/"
347
+ #JSON.parse(response.body)["EndDate"].should == "/Date(1325307600000-0500)/"
348
+ JSON.parse(response.body)["NoEndDate"].should == $flight_NoEndDate
349
+ JSON.parse(response.body)["Price"].should == 15.0
350
+ JSON.parse(response.body)["OptionType"].should == $flight_OptionType
351
+ JSON.parse(response.body)["Impressions"].should == $flight_Impressions
352
+ JSON.parse(response.body)["IsUnlimited"].should == $flight_IsUnlimited
353
+ JSON.parse(response.body)["IsFullSpeed"].should == $flight_IsFullSpeed
354
+ JSON.parse(response.body)["Keywords"].should == $flight_Keywords
355
+ JSON.parse(response.body)["UserAgentKeywords"].should == $flight_UserAgentKeywords
356
+ JSON.parse(response.body)["WeightOverride"].should == $flight_WeightOverride
357
+ JSON.parse(response.body)["CampaignId"].should == $flight_CampaignId
358
+ JSON.parse(response.body)["IsActive"].should == $flight_IsActive
359
+ JSON.parse(response.body)["IsDeleted"].should == $flight_IsDeleted
360
+ JSON.parse(response.body)["GeoTargeting"].first["CountryCode"].should == "US"
361
+ JSON.parse(response.body)["GeoTargeting"].first["Region"].should == "NC"
362
+ JSON.parse(response.body)["GeoTargeting"].first["MetroCode"].should == 560
363
+ $location_id = JSON.parse(response.body)["GeoTargeting"].first["LocationId"].to_s
364
+ end
365
+
366
+ it "should get a flight with geotargeting" do
367
+ response = @@flight.get($flight_id)
368
+ #response.body.should == '{"Id":' + $flight_id + ',"StartDate":"\\/Date(1293840000000+0000)\\/","EndDate":"\\/Date(1325289600000+0000)\\/","Price":15.00,"OptionType":1,"Impressions":10000,"IsUnlimited":false,"IsNoDuplicates":false,"IsFullSpeed":false,"Keywords":"test, test2","Name":"' + $flight_Name + '","CampaignId":' + $campaignId.to_s + ',"PriorityId":0,"IsDeleted":false,"IsActive":true,"GeoTargeting":[{"LocationId":' + $location_id + ',"CountryCode":"US","Region":"NC","MetroCode":560}]}'
369
+ end
370
+
296
371
  end
@@ -4,6 +4,7 @@ describe "Invitation API" do
4
4
 
5
5
  $invitation_url = 'http://www.adzerk.com/'
6
6
  @@invite = $adzerk::Invitation.new
7
+ @@advertiser = $adzerk::Advertiser.new
7
8
  $email = "test+apitest@adzerk.com"
8
9
 
9
10
  before(:all) do
@@ -16,30 +17,39 @@ describe "Invitation API" do
16
17
  }
17
18
  response = site.create(new_site)
18
19
  $siteId = JSON.parse(response.body)["Id"].to_s
20
+ new_advertiser = {
21
+ 'Title' => "Test"
22
+ }
23
+ response = @@advertiser.create(new_advertiser)
24
+ $advertiserId = JSON.parse(response.body)["Id"].to_s
19
25
  end
20
26
 
21
27
  it "should create a new publisher invitation" do
22
28
 
23
29
  invitation = {
24
30
  'Email' => $email,
25
- 'SiteId' => $siteId
31
+ 'SiteId' => $siteId,
32
+ 'AdvertiserId' => $advertiserId
26
33
  }
27
34
 
28
35
  response = @@invite.invite_publisher(invitation)
29
36
  response.body.should_not == ""
30
37
  response.body.length.should > 10
38
+ response.body.length.should < 100
31
39
  end
32
40
 
33
41
  it "should create a new advertiser invitation" do
34
42
 
35
43
  invitation = {
36
44
  'Email' => $email,
37
- 'SiteId' => $siteId
45
+ 'SiteId' => $siteId,
46
+ 'AdvertiserId' => $advertiserId
38
47
  }
39
48
 
40
49
  response = @@invite.invite_advertiser(invitation)
41
50
  response.body.should_not == ""
42
51
  response.body.length.should > 10
52
+ response.body.length.should < 100
43
53
  end
44
54
 
45
55
  end
@@ -8,7 +8,7 @@ describe "Login_API" do
8
8
  it "should list all logins" do
9
9
  result = @@login.list()
10
10
  result.length.should > 0
11
- # result["Items"].last["Id"].to_s.should == $site_id
11
+ #result["Items"].last["Id"].to_s.should == $site_id
12
12
  end
13
13
 
14
14
  it "should create a new login" do
@@ -29,24 +29,33 @@ describe "Login_API" do
29
29
 
30
30
  it "should list a specific login" do
31
31
  response = @@login.get($login_id)
32
- response.body.should == '{"Id":' + $login_id.to_s + ',"Email":"'+ $email + '","Password":"' + $password + '","Name":"' + $fullname + '"}'
32
+ response.body.should == '{"Id":' + $login_id.to_s + ',"Email":"'+ $email + '","Password":"","Name":"' + $fullname + '"}'
33
33
  end
34
34
 
35
35
  it "should update a login" do
36
- $email = "test+" + rand(10000).to_s + "@adzerk.com"
37
- $password = "somepassword"
38
- $fullname = "test person"
39
36
  new_login = {
40
37
  'Id' => $login_id,
41
- 'Email' => $email,
42
- 'Password' => $password,
43
38
  'Name' => $fullname
44
39
  }
45
40
  response = @@login.update(new_login)
46
41
  $login_id = JSON.parse(response.body)["Id"].to_s
47
42
  JSON.parse(response.body)["Email"].should == $email
48
- JSON.parse(response.body)["Password"].should == $password
43
+ JSON.parse(response.body)["Password"].should == ""
49
44
  JSON.parse(response.body)["Name"].should == $fullname
50
45
  end
51
-
46
+
47
+ it "should not be able update a login's password or email" do
48
+ new_login = {
49
+ 'Id' => $login_id,
50
+ 'Name' => $fullname,
51
+ 'Password' => "password",
52
+ 'Email' => "test@test.com"
53
+ }
54
+ response = @@login.update(new_login)
55
+ $login_id = JSON.parse(response.body)["Id"].to_s
56
+ JSON.parse(response.body)["Email"].should == $email
57
+ JSON.parse(response.body)["Password"].should == ""
58
+ JSON.parse(response.body)["Name"].should == $fullname
59
+ end
60
+
52
61
  end
@@ -0,0 +1,105 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Priority API" do
4
+
5
+ $priority_url = 'http://www.adzerk.com'
6
+ @@channel = $adzerk::Channel.new
7
+ @@priority = $adzerk::Priority.new
8
+
9
+ before(:all) do
10
+ new_channel = {
11
+ 'Title' => 'Test Channel ' + rand(1000000).to_s,
12
+ 'Commission' => '0',
13
+ 'Engine' => 'CPM',
14
+ 'Keywords' => 'test',
15
+ 'CPM' => '10.00',
16
+ 'AdTypes' => [1,2,3,4]
17
+ }
18
+ response = @@channel.create(new_channel)
19
+ $channelId = JSON.parse(response.body)["Id"].to_s
20
+ end
21
+
22
+ it "should create a new priority" do
23
+ $priority_name = 'Test priority ' + rand(1000000).to_s
24
+ $priority_channelId = $channelId
25
+ $priority_weight = 1
26
+ $priority_isDeleted = false
27
+
28
+ new_priority = {
29
+ 'Name' => $priority_name,
30
+ 'ChannelId' => $priority_channelId,
31
+ 'Weight' => $priority_weight,
32
+ 'IsDeleted' => $priority_isDeleted
33
+ }
34
+
35
+ response = @@priority.create(new_priority)
36
+ $priority_id = JSON.parse(response.body)["Id"].to_s
37
+ $priority_name.should == JSON.parse(response.body)["Name"]
38
+ $priority_channelId.to_f.should == JSON.parse(response.body)["ChannelId"]
39
+ $priority_weight.should == JSON.parse(response.body)["Weight"]
40
+ $priority_isDeleted.should == JSON.parse(response.body)["IsDeleted"]
41
+ end
42
+
43
+ it "should list a specific priority" do
44
+ response = @@priority.get($priority_id)
45
+ response.body.should == '{"Id":' + $priority_id + ',"Name":"' + $priority_name + '","ChannelId":' + $priority_channelId.to_s + ',"Weight":' + $priority_weight.to_s + ',"IsDeleted":' + $priority_isDeleted.to_s + '}'
46
+ end
47
+
48
+ it "should update a priority" do
49
+ new_priority = {
50
+ 'Id' => $priority_id,
51
+ 'Name' => $priority_name,
52
+ 'ChannelId' => $priority_channelId,
53
+ 'Weight' => $priority_weight,
54
+ 'IsDeleted' => $priority_isDeleted
55
+ }
56
+
57
+ response = @@priority.update(new_priority)
58
+ $priority_name.should == JSON.parse(response.body)["Name"]
59
+ $priority_channelId.to_f.should == JSON.parse(response.body)["ChannelId"]
60
+ $priority_weight.should == JSON.parse(response.body)["Weight"]
61
+ $priority_isDeleted.should == JSON.parse(response.body)["IsDeleted"]
62
+ end
63
+
64
+ it "should list all priorities" do
65
+ result = @@priority.list()
66
+ result.length.should > 0
67
+ result["Items"].last["Id"].to_s.should == $priority_id
68
+ result["Items"].last["Name"].should == $priority_name
69
+ result["Items"].last["ChannelId"].to_s.should == $priority_channelId
70
+ result["Items"].last["Weight"].should == $priority_weight
71
+ result["Items"].last["IsDeleted"].should == $priority_isDeleted
72
+ end
73
+
74
+ it "should delete a new priority" do
75
+ response = @@priority.delete($priority_id)
76
+ response.body.should == 'OK'
77
+ end
78
+
79
+ it "should not list deleted priorities" do
80
+ result = @@priority.list()
81
+ result["Items"].each do |r|
82
+ r["Id"].to_s.should_not == $priority_id
83
+ end
84
+ end
85
+
86
+ it "should not get individual deleted priority" do
87
+ response = @@priority.get $priority_id
88
+ response.body.should == '{"Id":0,"ChannelId":0,"Weight":0,"IsDeleted":false}'
89
+ end
90
+
91
+ it "should not update deleted priorities" do
92
+ u_priority = {
93
+ 'Id' => $priority_id,
94
+ 'Name' => $priority_name,
95
+ 'ChannelId' => $priority_channelId,
96
+ 'Weight' => $priority_weight,
97
+ 'IsDeleted' => $priority_isDeleted,
98
+ }
99
+
100
+ response = @@priority.update(u_priority)
101
+ response.body.should == '{"Id":0,"ChannelId":0,"Weight":0,"IsDeleted":false}'
102
+ end
103
+
104
+ end
105
+
@@ -6,10 +6,13 @@
6
6
  'creative_api_spec.rb',
7
7
  'creative_map_api_spec.rb',
8
8
  'flight_api_spec.rb',
9
+ 'invitation_api_spec.rb',
9
10
  'login_api_spec.rb',
10
11
  'publisher_api_spec.rb',
11
12
  'report_api_spec.rb',
12
- 'site_api_spec.rb'
13
+ 'site_api_spec.rb',
14
+ 'priority_api_spec.rb',
15
+ 'channel_site_map_api_spec.rb'
13
16
  ]
14
17
 
15
18
  task :runall do
@@ -13,7 +13,13 @@ require "../lib/adzerk/Creative"
13
13
  require "../lib/adzerk/CreativeMap"
14
14
  require "../lib/adzerk/Advertiser"
15
15
  require "../lib/adzerk/Invitation"
16
+ require "../lib/adzerk/Priority"
17
+ require "../lib/adzerk/ChannelSiteMap"
16
18
 
17
- # api_key = '0223F375AE09CA4E55A82FFA241A23282485'
18
- api_key = '114D8867A8C4DA4650AA838A7B9F6B01B7D1'
19
+ api_key = ENV["ADZERK_API_KEY"] || 'yourapikey'
19
20
  $adzerk = Adzerk.new(api_key)
21
+
22
+ RSpec.configure do |config|
23
+ config.color_enabled = true
24
+ end
25
+