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,20 +1,20 @@
1
+ require 'rubygems'
2
+ require 'rake'
1
3
  @files = [
2
4
  'advertiser_api_spec.rb',
3
5
  'campaign_api_spec.rb',
4
6
  'channel_api_spec.rb',
5
- 'channel_api_security_spec.rb',
7
+ 'channel_site_map_api_spec.rb',
6
8
  'creative_api_spec.rb',
7
9
  'creative_map_api_spec.rb',
8
10
  'flight_api_spec.rb',
9
11
  'invitation_api_spec.rb',
10
12
  'login_api_spec.rb',
11
13
  'publisher_api_spec.rb',
12
- 'report_api_spec.rb',
13
- 'csv_export_spec.rb',
14
+ #'report_api_spec.rb',
15
+ 'security_api_spec.rb',
14
16
  'site_api_spec.rb',
15
- 'priority_api_spec.rb',
16
- 'zone_api_spec.rb',
17
- 'channel_site_map_api_spec.rb'
17
+ 'zone_api_spec.rb'
18
18
  ]
19
19
 
20
20
  task :runall do
@@ -22,7 +22,7 @@ task :runall do
22
22
  cmd = 'rspec '
23
23
 
24
24
  @files.each do |file|
25
- cmd += file +' '
25
+ cmd += 'test/' + file +' '
26
26
  end
27
27
 
28
28
  sh "#{cmd}"
@@ -1,37 +1,31 @@
1
- require 'spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "Report API" do
4
-
5
- $report_url = 'http://www.adzerk.com/'
6
- @@report = $adzerk::Reporting.new
4
+
5
+ before do
6
+ @reports = Adzerk::Client.new(API_KEY).reports
7
+ end
7
8
 
8
9
  it "create a report" do
9
- $startdate = "1/15/2011"
10
- $enddate = "12/31/2011"
11
- $groupby = ["month"]
12
- $top30 = false
13
- $exclude3rd = false
14
- $istotal = true
15
- $params = []
16
10
  new_report = {
17
- 'StartDate' => $startdate,
18
- 'EndDate' => $enddate,
19
- 'GroupBy' => $groupby,
20
- 'Top30countries' => $top30,
21
- 'Exclude3rdParty' => $exclude3rd,
22
- 'IsTotal' => $istotal,
23
- 'Parameters' => $params
11
+ :start_date => "1/15/2011",
12
+ :end_date => "12/31/2011",
13
+ :group_by => ['month'],
14
+ 'Top30countries' => false,
15
+ :exclude_3rd_party => false,
16
+ :is_total => true,
17
+ :parameters => []
24
18
  }
25
- response = @@report.create_report(new_report)
26
- # response.body.should == '{"StartDate":"\/Date(1295067600000-0500)\/","EndDate":"\/Date(1325307600000-0500)\/","Critiera":[],"LoginId":0,"Records":[],"OptionRecords":[],"IsTotal":true,"Grouping":["month"],"TotalImpressions":0,"TotalClicks":0,"TotalCTR":0}'
19
+ report = @reports.create_report(new_report)
20
+ report[:is_total].should eq(true)
21
+ report[:grouping].should eq(["month"])
27
22
  end
28
23
 
29
-
30
24
  it "should pull a saved custom report" do
25
+ pending
31
26
  $savedReportId = 5280
32
- response = @@report.get($savedReportId.to_s)
33
-
27
+ response = @reports.retrieve_report($savedReportId.to_s)
34
28
  csv_report = response.body
35
- end
29
+ end
36
30
  end
37
31
 
@@ -0,0 +1,21 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+ require 'net/http'
3
+
4
+ describe "Channel API security" do
5
+
6
+ it "should reject unauthenticated GET requests" do
7
+ uri = URI.parse(ENV['ADZERK_API_HOST'] + 'channel/')
8
+ http = Net::HTTP.new(uri.host, uri.port)
9
+ request = Net::HTTP::Get.new(uri.request_uri)
10
+ http.request(request).response.code.should_not == 200
11
+ end
12
+
13
+ it "should reject GET requests with null API keys" do
14
+ uri = URI.parse(ENV['ADZERK_API_HOST'] + 'channel/')
15
+ http = Net::HTTP.new(uri.host, uri.port)
16
+ request = Net::HTTP::Get.new(uri.request_uri)
17
+ request.add_field "X-Adzerk-ApiKey", ""
18
+ http.request(request).response.code.should_not == 200
19
+ end
20
+
21
+ end
@@ -1,77 +1,63 @@
1
- require 'spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "Site API" do
4
-
5
- $site_url = 'http://www.adzerk.com'
6
- @@site = $adzerk::Site.new
7
-
4
+
5
+ before(:each) do
6
+ @site_url = 'http://www.adzerk.com'
7
+ @client = Adzerk::Client.new(API_KEY)
8
+ end
9
+
8
10
  it "should create a new site" do
9
11
  $site_title = 'Test Site ' + rand(1000000).to_s
10
12
  new_site = {
11
13
  'Title' => $site_title,
12
- 'Url' => $site_url
14
+ 'Url' => @site_url
13
15
  }
14
- response = @@site.create(new_site)
15
- $site_id = JSON.parse(response.body)["Id"].to_s
16
- $site_title.should == JSON.parse(response.body)["Title"]
17
- $site_url.should == JSON.parse(response.body)["Url"]
18
- $site_pub_id = JSON.parse(response.body)["PublisherAccountId"].to_s
16
+ site = @client.sites.create(:title => $site_title, :url => @site_url)
17
+ $site_id = site[:id].to_s
18
+ $site_title.should == site[:title]
19
+ @site_url.should == site[:url]
20
+ $site_pub_id = site[:publisher_account_id].to_s
19
21
  end
20
-
22
+
21
23
  it "should list a specific site" do
22
- response = @@site.get($site_id)
23
- response.body.should == '{"Id":' + $site_id + ',"Title":"' + $site_title + '","Url":"' + $site_url + '","PublisherAccountId":' + $site_pub_id + ',"IsDeleted":false}'
24
+ site = @client.sites.get($site_id)
25
+ site[:id].should eq($site_id.to_i)
26
+ site[:title].should eq($site_title)
27
+ site[:url].should eq(@site_url)
28
+ site[:publisher_account_id].should eq($site_pub_id.to_i)
24
29
  end
25
30
 
26
31
  it "should update a site" do
27
32
  $site_title = 'Test Site ' + rand(1000000).to_s
28
- updated_site = {
29
- 'Id' => $site_id,
30
- 'Title' => $site_title + "test",
31
- 'Url' => $site_url + "test"
32
- }
33
- response = @@site.update(updated_site)
34
- $site_id = JSON.parse(response.body)["Id"].to_s
35
- ($site_title + "test").should == JSON.parse(response.body)["Title"]
36
- ($site_url + "test").should == JSON.parse(response.body)["Url"]
37
- $site_pub_id = JSON.parse(response.body)["PublisherAccountId"].to_s
33
+ site = @client.sites.update(:id => $site_id,
34
+ :title => $site_title + "test",
35
+ :url => @site_url + "test")
36
+ $site_id = site[:id].to_s
37
+ ($site_title + "test").should == site[:title]
38
+ (@site_url + "test").should == site[:url]
39
+ $site_pub_id = site[:publisher_account_id].to_s
38
40
  end
39
41
 
40
42
  it "should list all sites" do
41
- result = @@site.list()
43
+ result = @client.sites.list
42
44
  result.length.should > 0
43
- result["Items"].last["Id"].to_s.should == $site_id
44
- result["Items"].last["Title"].should == $site_title + "test"
45
- result["Items"].last["Url"].should == $site_url + "test"
46
- result["Items"].last["PublisherAccountId"].to_s.should == $site_pub_id
45
+ result[:items].last[:id].to_s.should == $site_id
46
+ result[:items].last[:title].should == $site_title + "test"
47
+ result[:items].last[:url].should == @site_url + "test"
48
+ result[:items].last[:publisher_account_id].to_s.should == $site_pub_id
47
49
  end
48
50
 
49
51
  it "should delete a new site" do
50
- response = @@site.delete($site_id)
51
- response.body.should == 'OK'
52
+ response = @client.sites.delete($site_id)
53
+ response.body.should == '"Successfully deleted."'
52
54
  end
53
55
 
54
56
  it "should not list deleted sites" do
55
- result = @@site.list()
56
- result["Items"].each do |r|
57
- r["Id"].to_s.should_not == $site_id
57
+ result = @client.sites.list
58
+ result[:items].each do |site|
59
+ site[:id].to_s.should_not == $site_id
58
60
  end
59
61
  end
60
62
 
61
- it "should not get individual deleted sites" do
62
- response = @@site.get($site_id)
63
- response.body.should == '{"Id":0,"PublisherAccountId":0,"IsDeleted":false}'
64
- end
65
-
66
- it "should not update deleted sites" do
67
- $site_title = 'Test Site ' + rand(1000000).to_s
68
- updated_site = {
69
- 'Id' => $site_id,
70
- 'Title' => $site_title,
71
- 'Url' => $site_url
72
- }
73
- response = @@site.update(updated_site)
74
- response.body.should == '{"Id":0,"PublisherAccountId":0,"IsDeleted":false}'
75
- end
76
-
77
- end
63
+ end
@@ -1,24 +1,11 @@
1
1
  require "rspec"
2
2
  require "json"
3
3
  require "net/http"
4
- require "../lib/Adzerk"
5
- require "../lib/adzerk/Site"
6
- require "../lib/adzerk/Zone"
7
- require "../lib/adzerk/Publisher"
8
- require "../lib/adzerk/Channel"
9
- require "../lib/adzerk/Campaign"
10
- require "../lib/adzerk/Flight"
11
- require "../lib/adzerk/Login"
12
- require "../lib/adzerk/Reporting"
13
- require "../lib/adzerk/Creative"
14
- require "../lib/adzerk/CreativeMap"
15
- require "../lib/adzerk/Advertiser"
16
- require "../lib/adzerk/Invitation"
17
- require "../lib/adzerk/Priority"
18
- require "../lib/adzerk/ChannelSiteMap"
4
+ $:.push File.expand_path("../lib", __FILE__)
5
+ require "adzerk"
19
6
 
20
- api_key = ENV["ADZERK_API_KEY"] || 'yourapikey'
21
- $adzerk = Adzerk.new(api_key)
7
+ API_KEY = ENV['ADZERK_API_KEY'] || 'your_api_key'
8
+ # $adzerk = Adzerk.new(API_KEY)
22
9
 
23
10
  RSpec.configure do |config|
24
11
  config.color_enabled = true
@@ -1,89 +1,63 @@
1
- require './spec_helper.rb'
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "Zone API" do
4
-
5
- @@zone = $adzerk::Zone.new
6
- @@site = $adzerk::Site.new
7
-
4
+
5
+
8
6
  before(:all) do
7
+ @client = Adzerk::Client.new(API_KEY)
8
+ @zones = @client.zones
9
+ @sites = @client.sites
9
10
  new_site = {
10
11
  'Title' => 'Test Site ' + rand(1000000).to_s,
11
12
  'Url' => 'http://www.adzerk.com'
12
13
  }
13
- response = @@site.create(new_site)
14
- $site_id = JSON.parse(response.body)["Id"]
14
+ site = @sites.create(new_site)
15
+ $site_id = site[:id]
15
16
  end
16
-
17
+
17
18
  it "should create a new zone" do
18
19
  $name = 'Test Zone ' + rand(1000000).to_s
19
- new_zone = {
20
- 'Name' => $name,
21
- 'SiteId' => $site_id,
22
- 'IsDeleted' => false
23
- }
24
- response = @@zone.create(new_zone)
25
- $zone_id = JSON.parse(response.body)["Id"].to_s
26
- JSON.parse(response.body)["Name"].should == $name
27
- JSON.parse(response.body)["SiteId"].should == $site_id
28
- JSON.parse(response.body)["IsDeleted"].should == false
20
+ zone = @zones.create(:name => $name,
21
+ :site_id => $site_id,
22
+ :is_deleted => false)
23
+ $zone_id = zone[:id].to_s
24
+ zone[:name].should == $name
25
+ zone[:site_id].should == $site_id
26
+ zone[:is_deleted].should == false
29
27
  end
30
-
28
+
31
29
  it "should list a specific zone" do
32
- response = @@zone.get($zone_id)
33
- response.body.should == '{"Id":' + $zone_id + ',"Name":"' + $name + '","SiteId":' + $site_id.to_s + ',"IsDeleted":false}'
30
+ zone = @zones.get($zone_id)
31
+ zone[:id].should eq($zone_id.to_i)
32
+ zone[:name].should eq($name)
33
+ zone[:site_id].should eq($site_id)
34
+ zone[:is_deleted].should eq(false)
34
35
  end
35
36
 
36
37
  it "should update a zone" do
37
38
  $name = 'Test Zone ' + rand(1000000).to_s
38
- updated_zone = {
39
- 'Id' => $zone_id,
40
- 'Name' => $name,
41
- 'SiteId' => $site_id,
42
- 'IsDeleted' => false
43
- }
44
- response = @@zone.update(updated_zone)
45
- JSON.parse(response.body)["Id"].to_s.should == $zone_id
46
- JSON.parse(response.body)["Name"].should == $name
47
- JSON.parse(response.body)["SiteId"].should == $site_id
48
- JSON.parse(response.body)["IsDeleted"].should == false
39
+ zone = @zones.update(:id => $zone_id,
40
+ :name => $name,
41
+ :site_id => $site_id,
42
+ :is_deleted => false)
43
+ zone[:id].should eq($zone_id.to_i)
44
+ zone[:name].should eq($name)
45
+ zone[:site_id].should eq($site_id)
46
+ zone[:is_deleted].should eq(false)
49
47
  end
50
48
 
51
49
  it "should list all zones" do
52
- result = @@zone.list()
50
+ result = @zones.list
53
51
  result.length.should > 0
54
- result["Items"].last["Id"].to_s.should == $zone_id
55
- result["Items"].last["Name"].should == $name
56
- result["Items"].last["SiteId"].should == $site_id
57
- result["Items"].last["IsDeleted"].should == false
52
+ result[:items].last[:id].to_s.should == $zone_id
53
+ result[:items].last[:name].should == $name
54
+ result[:items].last[:site_id].should == $site_id
55
+ result[:items].last[:is_deleted].should == false
58
56
  end
59
57
 
60
58
  it "should delete a new zone" do
61
- response = @@zone.delete($zone_id)
62
- response.body.should == 'OK'
63
- end
64
-
65
- it "should not list deleted zones" do
66
- result = @@zone.list()
67
- result["Items"].each do |r|
68
- r["Id"].to_s.should_not == $zone_id
69
- end
70
- end
71
-
72
- it "should not get individual deleted zones" do
73
- response = @@zone.get($zone_id)
74
- response.body.should == '{"Id":0,"SiteId":0}'
75
- end
76
-
77
- it "should not update deleted zones" do
78
- $name = 'Test Zone ' + rand(1000000).to_s
79
- updated_zone = {
80
- 'Id' => $zone_id,
81
- 'Name' => $name,
82
- 'SiteId' => $site_id,
83
- 'IsDeleted' => false
84
- }
85
- response = @@zone.update(updated_zone)
86
- response.body.should == '{"Id":0,"SiteId":0}'
59
+ response = @zones.delete($zone_id)
60
+ response.body.should == '"Successfully deleted"'
87
61
  end
88
62
 
89
- end
63
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adzerk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: '0.2'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,38 +9,77 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-19 00:00:00.000000000 Z
13
- dependencies: []
12
+ date: 2012-12-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &70242664708400 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - =
20
+ - !ruby/object:Gem::Version
21
+ version: 2.11.0
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70242664708400
25
+ - !ruby/object:Gem::Dependency
26
+ name: json
27
+ requirement: &70242664707900 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - =
31
+ - !ruby/object:Gem::Version
32
+ version: 1.7.5
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70242664707900
36
+ - !ruby/object:Gem::Dependency
37
+ name: rest-client
38
+ requirement: &70242664707440 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - =
42
+ - !ruby/object:Gem::Version
43
+ version: 1.6.7
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70242664707440
47
+ - !ruby/object:Gem::Dependency
48
+ name: activesupport
49
+ requirement: &70242664706980 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - =
53
+ - !ruby/object:Gem::Version
54
+ version: 3.2.8
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *70242664706980
14
58
  description: Ruby library for the Adzerk API
15
59
  email: kacy@adzerk.com
16
60
  executables: []
17
61
  extensions: []
18
62
  extra_rdoc_files: []
19
63
  files:
20
- - lib/Adzerk.rb
21
- - lib/adzerk/Advertiser.rb
22
- - lib/adzerk/Campaign.rb
23
- - lib/adzerk/Channel.rb
24
- - lib/adzerk/ChannelSiteMap.rb
25
- - lib/adzerk/Creative.rb
26
- - lib/adzerk/CreativeMap.rb
27
- - lib/adzerk/Flight.rb
28
- - lib/adzerk/Invitation.rb
29
- - lib/adzerk/Login.rb
30
- - lib/adzerk/Priority.rb
31
- - lib/adzerk/Publisher.rb
32
- - lib/adzerk/Reporting.rb
33
- - lib/adzerk/Site.rb
34
- - lib/adzerk/Zone.rb
64
+ - lib/adzerk.rb
65
+ - lib/adzerk/advertiser.rb
66
+ - lib/adzerk/api_endpoint.rb
67
+ - lib/adzerk/channel_site_map.rb
68
+ - lib/adzerk/client.rb
69
+ - lib/adzerk/creative.rb
70
+ - lib/adzerk/creative_map.rb
71
+ - lib/adzerk/flight.rb
72
+ - lib/adzerk/invitation.rb
73
+ - lib/adzerk/publisher.rb
74
+ - lib/adzerk/reporting.rb
75
+ - lib/adzerk/util.rb
76
+ - lib/adzerk/version.rb
35
77
  - test/advertiser_api_spec.rb
36
78
  - test/campaign_api_spec.rb
37
- - test/channel_api_security_spec.rb
38
79
  - test/channel_api_spec.rb
39
80
  - test/channel_site_map_api_spec.rb
40
81
  - test/creative_api_spec.rb
41
82
  - test/creative_map_api_spec.rb
42
- - test/csv_export_spec.rb
43
- - test/delivery-test.rb
44
83
  - test/flight_api_spec.rb
45
84
  - test/invitation_api_spec.rb
46
85
  - test/login_api_spec.rb
@@ -48,10 +87,9 @@ files:
48
87
  - test/publisher_api_spec.rb
49
88
  - test/rakefile.rb
50
89
  - test/report_api_spec.rb
90
+ - test/security_api_spec.rb
51
91
  - test/site_api_spec.rb
52
92
  - test/spec_helper.rb
53
- - test/test.rb
54
- - test/test2.rb
55
93
  - test/zone_api_spec.rb
56
94
  homepage: http://adzerk.com
57
95
  licenses: []