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,16 +0,0 @@
1
- module Adzerk
2
- class Reporting
3
-
4
- def create_report(data={})
5
- uri = URI.parse($host + 'report')
6
- data = { 'criteria' => data.to_json }
7
- Adzerk.post_request(uri, data)
8
- end
9
-
10
- def get(id)
11
- uri = URI.parse($host + 'report/' + id)
12
- Adzerk.get_request(uri)
13
- end
14
-
15
- end
16
- end
@@ -1,35 +0,0 @@
1
- require 'rest_client'
2
-
3
- module Adzerk
4
- class Site
5
-
6
- def create(data={})
7
- uri = URI.parse($host + 'site')
8
- data = { 'site' => data.to_json }
9
- Adzerk.post_request(uri, data)
10
- end
11
-
12
- def get(id)
13
- uri = URI.parse($host + 'site/' + id)
14
- Adzerk.get_request(uri)
15
- end
16
-
17
- def list()
18
- uri = URI.parse($host + 'site')
19
- response = Adzerk.get_request(uri)
20
- JSON.parse(response.body)
21
- end
22
-
23
- def update(data={})
24
- uri = URI.parse($host + 'site/' + data["Id"].to_s)
25
- data = { 'site' => data.to_json }
26
- Adzerk.put_request(uri, data)
27
- end
28
-
29
- def delete(id)
30
- uri = URI.parse($host + 'site/' + id + '/delete')
31
- Adzerk.get_request(uri)
32
- end
33
-
34
- end
35
- end
@@ -1,35 +0,0 @@
1
- require 'rest_client'
2
-
3
- module Adzerk
4
- class Zone
5
-
6
- def create(data={})
7
- uri = URI.parse($host + 'zone')
8
- data = { 'zone' => data.to_json }
9
- Adzerk.post_request(uri, data)
10
- end
11
-
12
- def get(id)
13
- uri = URI.parse($host + 'zone/' + id)
14
- Adzerk.get_request(uri)
15
- end
16
-
17
- def list()
18
- uri = URI.parse($host + 'zone')
19
- response = Adzerk.get_request(uri)
20
- JSON.parse(response.body)
21
- end
22
-
23
- def update(data={})
24
- uri = URI.parse($host + 'zone/' + data["Id"].to_s)
25
- data = { 'zone' => data.to_json }
26
- Adzerk.put_request(uri, data)
27
- end
28
-
29
- def delete(id)
30
- uri = URI.parse($host + 'zone/' + id + '/delete')
31
- Adzerk.get_request(uri)
32
- end
33
-
34
- end
35
- end
@@ -1,51 +0,0 @@
1
- require './spec_helper'
2
- require 'net/http'
3
- describe "Channel API security" do
4
-
5
- channel_url = 'http://www.adzerk.com'
6
- channel = $adzerk::Channel.new
7
-
8
- it "should reject unauthenticated GET requests" do
9
- uri = URI.parse(ENV['ADZERK_API_HOST'] + 'channel/')
10
- http = Net::HTTP.new(uri.host, uri.port)
11
- request = Net::HTTP::Get.new(uri.request_uri)
12
- http.request(request).response.code.should_not == 200
13
- end
14
-
15
- it "should reject GET requests with null API keys" do
16
- uri = URI.parse(ENV['ADZERK_API_HOST'] + 'channel/')
17
- http = Net::HTTP.new(uri.host, uri.port)
18
- request = Net::HTTP::Get.new(uri.request_uri)
19
- request.add_field "X-Adzerk-ApiKey", ""
20
- http.request(request).response.code.should_not == 200
21
- end
22
-
23
- it "should reject GET requests with SQL injection attack as API keys" do
24
- uri = URI.parse(ENV['ADZERK_API_HOST'] + 'channel/')
25
- http = Net::HTTP.new(uri.host, uri.port)
26
- request = Net::HTTP::Get.new(uri.request_uri)
27
- request.add_field "X-Adzerk-ApiKey", "hi' or 1=1--"
28
- http.request(request).response.code.should_not == 200
29
- end
30
-
31
- it "should reject an attempt to delete a channel not of the same network" do
32
- channel.delete("14").response.code.should_not == 200
33
- end
34
-
35
-
36
- it "should reject an attempt to update a channel not of the same network" do
37
- updated_channel = {
38
- 'Id' => 14,
39
- 'Title' => "The Impossible Dream",
40
- 'Commission' => 0,
41
- 'Engine' => "CPM",
42
- 'Keywords' => "bigfoot",
43
- 'CPM' => "10.00",
44
- 'AdTypes' => [1,2,3,4]
45
- }
46
- channel.update(updated_channel).response.code.should_not == 200
47
- end
48
-
49
- end
50
-
51
-
@@ -1,89 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "(Saved) Report API" do
4
-
5
- $report_url = 'http://www.adzerk.com/'
6
- @@report = $adzerk::Reporting.new
7
- $savedReportId = 5290
8
- @@response = @@report.get($savedReportId.to_s)
9
- @@csv_export = @@response.body
10
- @@first_data_line = ""
11
-
12
- before(:all) do
13
- @@csv_export.each_line do |line|
14
- if line.start_with?("6/9/2012")
15
- @@first_data_line = line
16
- end
17
- end
18
- end
19
-
20
- it "should pull a saved custom report" do
21
- @@response.code.should == "200"
22
- end
23
-
24
- it "should contain start and end date headers" do
25
- @@csv_export.should include("Start Date")
26
- @@csv_export.should include("End Date")
27
- end
28
-
29
- it "should include column header for brand" do
30
- @@csv_export.should include("Brand")
31
- end
32
-
33
- it "should include column header for date" do
34
- @@csv_export.should include("Date")
35
- end
36
-
37
- it "should include column header for campaign" do
38
- @@csv_export.should include("Campaign")
39
- end
40
-
41
- it "should include column header for option" do
42
- @@csv_export.should include("Option")
43
- end
44
-
45
- it "should include column header for creative" do
46
- @@csv_export.should include("Channel")
47
- end
48
-
49
- it "should include column header for priority" do
50
- @@csv_export.should include("Priority")
51
- end
52
-
53
- it "should include column header for adtype" do
54
- @@csv_export.should include("AdType")
55
- end
56
-
57
- it "should include column header for site" do
58
- @@csv_export.should include("Site")
59
- end
60
-
61
- it "should include column header for country" do
62
- @@csv_export.should include("Country")
63
- end
64
-
65
- it "should include column header for impressions" do
66
- @@csv_export.should include("Impressions")
67
- end
68
-
69
- it "should include column header for clicks" do
70
- @@csv_export.should include("Clicks")
71
- end
72
-
73
- it "should include column header for click-through-rate" do
74
- @@csv_export.should include("CTR")
75
- end
76
-
77
- it "should include column header for revenue" do
78
- @@csv_export.should include("Revenue")
79
- end
80
-
81
- it "should have data lines with every data column present" do
82
-
83
- fields = @@first_data_line.split(',')
84
-
85
- fields.count.should eq(15)
86
-
87
- end
88
-
89
- end
@@ -1,132 +0,0 @@
1
- require './spec_helper.rb'
2
-
3
- describe "Testing out delivery" do
4
-
5
- @@flight = $adzerk::Flight.new
6
- @@advertiser = $adzerk::Advertiser.new
7
- @@channel = $adzerk::Channel.new
8
- @@campaign = $adzerk::Campaign.new
9
- @@priority = $adzerk::Priority.new
10
- @@map = $adzerk::CreativeMap.new
11
- @@publisher = $adzerk::Publisher.new
12
-
13
- before(:all) do
14
- new_advertiser = {
15
- 'Title' => "Test"
16
- }
17
- response = @@advertiser.create(new_advertiser)
18
- $advertiserId = JSON.parse(response.body)["Id"]
19
-
20
- new_channel = {
21
- 'Title' => 'Test Channel ' + rand(1000000).to_s,
22
- 'Commission' => '0',
23
- 'Engine' => 'CPM',
24
- 'Keywords' => 'test',
25
- 'CPM' => '10.00',
26
- 'AdTypes' => [1,2,3,4]
27
- }
28
- response = @@channel.create(new_channel)
29
- $channelId = JSON.parse(response.body)["Id"]
30
-
31
- new_priority = {
32
- 'Name' => "High Priority Test",
33
- 'ChannelId' => $channelId,
34
- 'Weight' => 1,
35
- 'IsDeleted' => false
36
- }
37
- response = @@priority.create(new_priority)
38
- $priority_id = JSON.parse(response.body)["Id"].to_s
39
-
40
- new_campaign = {
41
- 'Name' => 'Test campaign ' + rand(1000000).to_s,
42
- 'StartDate' => "1/1/2011",
43
- 'EndDate' => "12/31/2011",
44
- 'IsActive' => true,
45
- 'Price' => '10.00',
46
- 'AdvertiserId' => $advertiserId,
47
- 'Flights' => [],
48
- 'IsDeleted' => false
49
- }
50
- response = @@campaign.create(new_campaign)
51
- $campaignId = JSON.parse(response.body)["Id"]
52
-
53
- rand = rand(1000000).to_s
54
- new_publisher = {
55
- 'FirstName' => 'Test ' + rand,
56
- 'LastName' => 'Person ' + rand,
57
- 'CompanyName' => 'Company ' + rand,
58
- 'Address' => {
59
- 'Line1' => rand + 'st',
60
- 'Line2' => 'Apt. ' + rand,
61
- 'City' => rand + 'ville',
62
- 'StateProvince' => 'NC',
63
- 'PostalCode' => rand.to_s,
64
- 'Country' => 'USA'
65
- },
66
- 'PaymentOption' => "1",
67
- 'PaypalEmail' => 'Test' + rand + '@test.com'
68
- }
69
- response = @@publisher.create(new_publisher)
70
- $publisherId = JSON.parse(response.body)["Id"].to_s
71
- end
72
-
73
- it "should create a flight" do
74
- new_flight = {
75
- 'NoEndDate' => false,
76
- 'PriorityId' => $priority_id,
77
- 'Name' => 'Test flight ' + rand(1000000).to_s,
78
- 'StartDate' => "1/1/2011",
79
- 'EndDate' => "12/31/2011",
80
- 'NoEndDate' => false,
81
- 'Price' => "15.00",
82
- 'OptionType' => 1,
83
- 'Impressions' => 100000,
84
- 'IsUnlimited' => false,
85
- 'IsFullSpeed' => false,
86
- 'Keywords' => "test, test",
87
- 'UserAgentKeywords' => "test, test",
88
- 'WeightOverride' => nil,
89
- 'CampaignId' => $campaignId,
90
- 'IsActive' => true,
91
- 'IsDeleted' => false
92
- }
93
- response = @@flight.create(new_flight)
94
- $flightId = JSON.parse(response.body)["Id"].to_s
95
- puts response.body
96
- end
97
-
98
- it "should create a creative and creative map and attach to flight" do
99
- new_creative = {
100
- 'CampaignId' => $campaignId,
101
- 'FlightId' => $flightId,
102
- 'SizeOverride' => false,
103
- 'Iframe' => false,
104
- 'PublisherAccountId' => $publisherId,
105
- 'Impressions' => 100000,
106
- 'Percentage' => 50,
107
- 'SiteId' => nil,
108
- 'ZoneId' => nil,
109
- 'DistributionType' => 1,
110
- 'IsActive' => true,
111
- 'IsDeleted' => false,
112
- 'Creative' => {
113
- 'Title' => 'Test Creative ' + rand(1000).to_s,
114
- 'Url' => 'http://adzerk.com/',
115
- 'Body' => 'test',
116
- 'AdvertiserId' => $advertiserId,
117
- 'AdTypeId' => 18,
118
- 'IsHTMLJS' => false,
119
- 'ScriptBody' => '',
120
- 'IsActive' => true,
121
- 'Alt' => 'test',
122
- 'IsDeleted' => false,
123
- 'IsSync' => false
124
- }
125
- }
126
- response = @@map.create(new_creative)
127
- puts response.body
128
- returned = Adzerk.uploadCreative(JSON.parse(response.body)["Creative"]["Id"].to_s, "250x250.gif")
129
- puts returned.body
130
- end
131
-
132
- end
@@ -1,43 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Creative API" do
4
-
5
- $creative_url = 'http://www.adzerk.com'
6
- @@creative = $adzerk::Creative.new
7
- @@advertiser = $adzerk::Advertiser.new
8
-
9
- before(:all) do
10
- new_advertiser = {
11
- 'Title' => "Test"
12
- }
13
- response = @@advertiser.create(new_advertiser)
14
- $advertiserId = JSON.parse(response.body)["Id"]
15
- end
16
-
17
- it "should create a creative" do
18
- $Title = 'Test creative ' + rand(1000000).to_s
19
- $ImageName = ""
20
- $Url = "http://adzerk.com"
21
- $AdvertiserId = $advertiserId
22
- $AdTypeId = 18
23
- $IsActive = true
24
- $Alt = "test alt"
25
- $IsDeleted = false
26
- $IsSync = false
27
-
28
- new_creative = {
29
- 'Title' => $Title,
30
- 'ImageName' => $ImageName,
31
- 'Url' => $Url,
32
- 'AdvertiserId' => $AdvertiserId,
33
- 'AdTypeId' => $AdTypeId,
34
- 'IsActive' => $IsActive,
35
- 'Alt' => $Alt,
36
- 'IsDeleted' => $IsDeleted,
37
- 'IsSync' => $IsSync
38
- }
39
- response = @@creative.create(new_creative, '250x250.gif')
40
- puts response
41
-
42
- end
43
- end
@@ -1,175 +0,0 @@
1
- # Create Campaign
2
- # Create Flight
3
- # Disable Campaign
4
- # Re-enable Campaign
5
- # Check in DB to see if flight has AddToBalancer == true
6
-
7
-
8
- require './spec_helper.rb'
9
-
10
- describe 'test for chris' do
11
- @@map = $adzerk::CreativeMap.new
12
- @@campaign = $adzerk::Campaign.new
13
- @@flight = $adzerk::Flight.new
14
- @@site = $adzerk::Site.new
15
- @@advertiser = $adzerk::Advertiser.new
16
- @@creative = $adzerk::Creative.new
17
- @@channel = $adzerk::Channel.new
18
- @@priority = $adzerk::Priority.new
19
-
20
-
21
- before(:all) do
22
- new_site = {
23
- 'Title' => 'Test Site ' + rand(1000000).to_s,
24
- 'Url' => 'http://www.adzerk.com'
25
- }
26
- response = @@site.create(new_site)
27
- $siteId = JSON.parse(response.body)["Id"]
28
-
29
- new_advertiser = {
30
- 'Title' => "Test"
31
- }
32
- response = @@advertiser.create(new_advertiser)
33
- $advertiserId = JSON.parse(response.body)["Id"]
34
-
35
- new_channel = {
36
- 'Title' => 'Test Channel ' + rand(1000000).to_s,
37
- 'Commission' => '0',
38
- 'Engine' => 'CPM',
39
- 'Keywords' => 'test',
40
- 'CPM' => '10.00',
41
- 'AdTypes' => [1,2,3,4]
42
- }
43
- response = @@channel.create(new_channel)
44
- $channelId = JSON.parse(response.body)["Id"]
45
-
46
- new_priority = {
47
- 'Name' => "High Priority Test",
48
- 'ChannelId' => $channelId,
49
- 'Weight' => 1,
50
- 'IsDeleted' => false
51
- }
52
- response = @@priority.create(new_priority)
53
- $priority_id = JSON.parse(response.body)["Id"].to_s
54
-
55
- new_campaign = {
56
- 'Name' => 'Test campaign ' + rand(1000000).to_s,
57
- 'StartDate' => "1/1/2011",
58
- 'EndDate' => "12/31/2011",
59
- 'IsActive' => true,
60
- 'Price' => '10.00',
61
- 'AdvertiserId' => $advertiserId,
62
- 'Flights' => [],
63
- 'IsDeleted' => false
64
- }
65
- response = @@campaign.create(new_campaign)
66
- $campaignId = JSON.parse(response.body)["Id"]
67
- puts "CampaignId: " + $campaignId.to_s
68
-
69
- new_flight = {
70
- 'NoEndDate' => false,
71
- 'PriorityId' => $priority_id,
72
- 'Name' => 'Test flight ' + rand(1000000).to_s,
73
- 'StartDate' => "1/1/2011",
74
- 'EndDate' => "12/31/2011",
75
- 'NoEndDate' => false,
76
- 'Price' => '15.00',
77
- 'OptionType' => 1,
78
- 'Impressions' => 10000,
79
- 'IsUnlimited' => false,
80
- 'IsFullSpeed' => false,
81
- 'Keywords' => "test, test2",
82
- 'UserAgentKeywords' => nil,
83
- 'WeightOverride' => nil,
84
- 'CampaignId' => $campaignId,
85
- 'IsActive' => true,
86
- 'IsDeleted' => false
87
- }
88
- response = @@flight.create(new_flight)
89
- $flightId = JSON.parse(response.body)["Id"]
90
- puts "FlightId: " + $flightId.to_s
91
- end
92
-
93
- it "should disable the campaign" do
94
- campaign = {
95
- 'Id' => $campaignId,
96
- 'IsActive' => false
97
- }
98
- response = @@campaign.update(campaign)
99
- end
100
-
101
- it "should enable the campaign" do
102
- campaign = {
103
- 'Id' => $campaignId,
104
- 'IsActive' => true
105
- }
106
- response = @@campaign.update(campaign)
107
- end
108
-
109
- #it "should work" do
110
- #update = {
111
- #'Id' => 21897,
112
- #'CampaignId' => 6789,
113
- #'FlightId' => 13975,
114
- #'SizeOverride' => nil,
115
- #'Iframe' => nil,
116
- #'DistributionType' => 1,
117
- #'PublisherAccountId' => 2246,
118
- #'Impressions' => 0,
119
- #'Percentage' => 0,
120
- #'SiteId' => 14499,
121
- #'ZoneId' => 1921,
122
- #'IsActive' => true,
123
- #'IsDeleted' => nil,
124
- #'Creative' => {
125
- #'Id' => 14618,
126
- #'ScriptBody' => 'Test4',
127
- #'IsHTMLJS' => true,
128
- #'Title' => 'HTML Test!'
129
- #'Url' => 'http://adzerk.com'
130
- #}
131
- #}
132
- #response = @@map.update(update)
133
- #puts response.body
134
- #end
135
-
136
- #@@advertiser = $adzerk::Advertiser.new
137
- #it "should update an advertiser" do
138
- #updated_advertiser = {
139
- #'Id' => 4194,
140
- #'Title' => 'Advertiser Test',
141
- #'IsDeleted' => nil,
142
- #'IsActive' => true
143
- #}
144
- #response = @@advertiser.update(updated_advertiser)
145
- #puts response.body
146
- #end
147
-
148
- #it "should" do
149
- #r = @@flight.get("14023")
150
- #puts r.body
151
- #end
152
-
153
- #it "should test Nick's creative issue" do
154
- #create = {
155
- #'Title' => "banner_5000",
156
- #'ImageName' => '',
157
- #'Url' => 'http:\/\/www.cnn.com',
158
- #'Body' => "banner_5000",
159
- #'Alt' => "banner_5000",
160
- #'AdvertiserId' => $advertiserId,
161
- #'AdvertiserId' => 3921,
162
- #'AdTypeId' => 4,
163
- #'SiteId' => 14749,
164
- #'IsActive' => true,
165
- #'IsDeleted' => false,
166
- #'IsHTMLJS' => false,
167
- #'IsSync' => false
168
- #'ScriptBody' => ''
169
- #}
170
- #response = @@creative.create(create, '250x250.gif')
171
- #puts response.body
172
-
173
- #end
174
-
175
- end