adzerk 0.1

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.
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Invitation API" do
4
+
5
+ $invitation_url = 'http://www.adzerk.com/'
6
+ @@invite = $adzerk::Invitation.new
7
+ $email = "test+apitest@adzerk.com"
8
+
9
+ before(:all) do
10
+ site = $adzerk::Site.new
11
+ site_url = "http://adzerk.com"
12
+ site_title = 'Test Site ' + rand(1000000).to_s
13
+ new_site = {
14
+ 'Title' => site_title,
15
+ 'Url' => site_url
16
+ }
17
+ response = site.create(new_site)
18
+ $siteId = JSON.parse(response.body)["Id"].to_s
19
+ end
20
+
21
+ it "should create a new publisher invitation" do
22
+
23
+ invitation = {
24
+ 'Email' => $email,
25
+ 'SiteId' => $siteId
26
+ }
27
+
28
+ response = @@invite.invite_publisher(invitation)
29
+ response.body.should_not == ""
30
+ response.body.length.should > 10
31
+ end
32
+
33
+ it "should create a new advertiser invitation" do
34
+
35
+ invitation = {
36
+ 'Email' => $email,
37
+ 'SiteId' => $siteId
38
+ }
39
+
40
+ response = @@invite.invite_advertiser(invitation)
41
+ response.body.should_not == ""
42
+ response.body.length.should > 10
43
+ end
44
+
45
+ end
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Login_API" do
4
+
5
+ $login_url = 'http://www.adzerk.com/'
6
+ @@login = $adzerk::Login.new
7
+
8
+ it "should list all logins" do
9
+ result = @@login.list()
10
+ result.length.should > 0
11
+ # result["Items"].last["Id"].to_s.should == $site_id
12
+ end
13
+
14
+ it "should create a new login" do
15
+ $email = "test+" + rand(10000).to_s + "@adzerk.com"
16
+ $password = "somepassword"
17
+ $fullname = "test person"
18
+ new_login = {
19
+ 'Email' => $email,
20
+ 'Password' => $password,
21
+ 'Name' => $fullname
22
+ }
23
+ response = @@login.create(new_login)
24
+ $login_id = JSON.parse(response.body)["Id"].to_s
25
+ JSON.parse(response.body)["Email"].should == $email
26
+ JSON.parse(response.body)["Password"].should == $password
27
+ JSON.parse(response.body)["Name"].should == $fullname
28
+ end
29
+
30
+ it "should list a specific login" do
31
+ response = @@login.get($login_id)
32
+ response.body.should == '{"Id":' + $login_id.to_s + ',"Email":"'+ $email + '","Password":"' + $password + '","Name":"' + $fullname + '"}'
33
+ end
34
+
35
+ it "should update a login" do
36
+ $email = "test+" + rand(10000).to_s + "@adzerk.com"
37
+ $password = "somepassword"
38
+ $fullname = "test person"
39
+ new_login = {
40
+ 'Id' => $login_id,
41
+ 'Email' => $email,
42
+ 'Password' => $password,
43
+ 'Name' => $fullname
44
+ }
45
+ response = @@login.update(new_login)
46
+ $login_id = JSON.parse(response.body)["Id"].to_s
47
+ JSON.parse(response.body)["Email"].should == $email
48
+ JSON.parse(response.body)["Password"].should == $password
49
+ JSON.parse(response.body)["Name"].should == $fullname
50
+ end
51
+
52
+ end
@@ -0,0 +1,147 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Publisher API" do
4
+
5
+ @@publisher = $adzerk::Publisher.new
6
+
7
+ it "should create a new publisher" do
8
+ $rand = rand(1000000).to_s
9
+ $publisher_first = 'Test ' + $rand
10
+ $publisher_last = 'Person ' + $rand
11
+ $publisher_company = 'Company ' + $rand
12
+ $publisher_line1 = $rand + 'st'
13
+ $publisher_line2 = 'Apt. ' + $rand
14
+ $publisher_city = $rand + 'ville'
15
+ $publisher_state = 'NC'
16
+ $publisher_zip = $rand.to_s
17
+ $publisher_country = 'USA'
18
+ $publisher_payment_option = "1"
19
+ $publisher_paypal_email = 'Test' + $rand + '@test.com'
20
+ $new_publisher = {
21
+ 'FirstName' => $publisher_first,
22
+ 'LastName' => $publisher_last,
23
+ 'CompanyName' => $publisher_company,
24
+ 'Address' => {
25
+ 'Line1' => $publisher_line1,
26
+ 'Line2' => $publisher_line2,
27
+ 'City' => $publisher_city,
28
+ 'StateProvince' => $publisher_state,
29
+ 'PostalCode' => $publisher_zip,
30
+ 'Country' => $publisher_country
31
+ },
32
+ 'PaymentOption' => $publisher_payment_option,
33
+ 'PaypalEmail' => $publisher_paypal_email
34
+ }
35
+ response = @@publisher.create($new_publisher)
36
+ $publisher_id = JSON.parse(response.body)["Id"].to_s
37
+ $publisher_first.should == JSON.parse(response.body)["FirstName"]
38
+ $publisher_last.should == JSON.parse(response.body)["LastName"]
39
+ $publisher_company.should == JSON.parse(response.body)["CompanyName"]
40
+ JSON.parse(response.body)["PaymentOption"].should == "1"
41
+ $publisher_paypal_email.should == JSON.parse(response.body)["PaypalEmail"]
42
+
43
+ $address_id = JSON.parse(response.body)["Address"]["Id"].to_s
44
+ $publisher_line1.should == JSON.parse(response.body)["Address"]["Line1"]
45
+ $publisher_line2.should == JSON.parse(response.body)["Address"]["Line2"]
46
+ $publisher_city.should == JSON.parse(response.body)["Address"]["City"]
47
+ $publisher_state.should == JSON.parse(response.body)["Address"]["StateProvince"]
48
+ $publisher_zip.should == JSON.parse(response.body)["Address"]["PostalCode"]
49
+ $publisher_country.should == JSON.parse(response.body)["Address"]["Country"]
50
+ end
51
+
52
+ it "should list a specific publisher" do
53
+ response = @@publisher.get($publisher_id)
54
+ response.body.should == '{"Id":' + $publisher_id + ',"FirstName":"' + $publisher_first + '","LastName":"' + $publisher_last + '","CompanyName":"' + $publisher_company + '","Address":{"Id":' + $address_id + ',"Line1":"' + $publisher_line1 + '","Line2":"' + $publisher_line2 + '","City":"' + $publisher_city + '","StateProvince":"' + $publisher_state + '","PostalCode":"' + $publisher_zip + '","Country":"' + $publisher_country + '"},"PaypalEmail":"' + $publisher_paypal_email + '","PaymentOption":"PayPal","IsDeleted":false}'
55
+ end
56
+
57
+ it "should update a publisher" do
58
+ $new_publisher = {
59
+ 'Id' => $publisher_id,
60
+ 'FirstName' => $publisher_first + "test",
61
+ 'LastName' => $publisher_last + "test",
62
+ 'CompanyName' => $publisher_company + "test",
63
+ 'Address' => {
64
+ 'Line1' => $publisher_line1 + "test",
65
+ 'Line2' => $publisher_line2 + "test",
66
+ 'City' => $publisher_city + "test",
67
+ 'StateProvince' => $publisher_state + "test",
68
+ 'PostalCode' => $publisher_zip + "test",
69
+ 'Country' => $publisher_country + "test"
70
+ },
71
+ 'PaymentOption' => $publisher_payment_option,
72
+ 'PaypalEmail' => $publisher_paypal_email + "test"
73
+ }
74
+ response = @@publisher.update($new_publisher)
75
+ $publisher_id = JSON.parse(response.body)["Id"].to_s
76
+ ($publisher_first + "test").should == JSON.parse(response.body)["FirstName"]
77
+ ($publisher_last + "test").should == JSON.parse(response.body)["LastName"]
78
+ ($publisher_company + "test").should == JSON.parse(response.body)["CompanyName"]
79
+ JSON.parse(response.body)["PaymentOption"].should == "1"
80
+ ($publisher_paypal_email + "test").should == JSON.parse(response.body)["PaypalEmail"]
81
+
82
+ $address_id = JSON.parse(response.body)["Address"]["Id"].to_s
83
+ ($publisher_line1 + "test").should == JSON.parse(response.body)["Address"]["Line1"]
84
+ ($publisher_line2 + "test").should == JSON.parse(response.body)["Address"]["Line2"]
85
+ ($publisher_city + "test").should == JSON.parse(response.body)["Address"]["City"]
86
+ ($publisher_state + "test").should == JSON.parse(response.body)["Address"]["StateProvince"]
87
+ ($publisher_zip + "test").should == JSON.parse(response.body)["Address"]["PostalCode"]
88
+ ($publisher_country + "test").should == JSON.parse(response.body)["Address"]["Country"]
89
+ end
90
+
91
+ it "should list all publishers" do
92
+ result = @@publisher.list()
93
+ result.length.should > 0
94
+ result["Items"].last["Id"].to_s.should == $publisher_id
95
+ result["Items"].last["FirstName"].should == $publisher_first + "test"
96
+ result["Items"].last["LastName"].should == $publisher_last + "test"
97
+ result["Items"].last["CompanyName"].should == $publisher_company + "test"
98
+ result["Items"].last["PaymentOption"].should == "PayPal"
99
+ result["Items"].last["PaypalEmail"].should == $publisher_paypal_email + "test"
100
+
101
+ result["Items"].last["Address"]["Line1"].should == $publisher_line1 + "test"
102
+ result["Items"].last["Address"]["Line2"].should == $publisher_line2 + "test"
103
+ result["Items"].last["Address"]["City"].should == $publisher_city + "test"
104
+ result["Items"].last["Address"]["StateProvince"].should == $publisher_state + "test"
105
+ result["Items"].last["Address"]["PostalCode"].should == $publisher_zip + "test"
106
+ result["Items"].last["Address"]["Country"].should == $publisher_country + "test"
107
+ end
108
+
109
+ it "should delete a new publisher" do
110
+ response = @@publisher.delete($publisher_id)
111
+ response.body.should == 'OK'
112
+ end
113
+
114
+ it "should not list deleted publishers" do
115
+ result = @@publisher.list()
116
+ result["Items"].each do |r|
117
+ r["Id"].to_s.should_not == $publisher_id.to_s
118
+ end
119
+ end
120
+
121
+ it "should not get individual deleted publishers" do
122
+ response = @@publisher.get($publisher_id)
123
+ response.body.should == '{"Id":0,"IsDeleted":false}'
124
+ end
125
+
126
+ it "should not update deleted publishers" do
127
+ $updated_publisher = {
128
+ 'Id' => $publisher_id,
129
+ 'FirstName' => $publisher_first + "test",
130
+ 'LastName' => $publisher_last + "test",
131
+ 'CompanyName' => $publisher_company + "test",
132
+ 'Address' => {
133
+ 'Line1' => $publisher_line1 + "test",
134
+ 'Line2' => $publisher_line2 + "test",
135
+ 'City' => $publisher_city + "test",
136
+ 'StateProvince' => $publisher_state + "test",
137
+ 'PostalCode' => $publisher_zip + "test",
138
+ 'Country' => $publisher_country + "test"
139
+ },
140
+ 'PaymentOption' => $publisher_payment_option,
141
+ 'PaypalEmail' => $publisher_paypal_email + "test"
142
+ }
143
+ response = @@publisher.update($updated_publisher)
144
+ response.body.should == '{"Id":0,"IsDeleted":false}'
145
+ end
146
+
147
+ end
data/test/rakefile.rb ADDED
@@ -0,0 +1,26 @@
1
+ @files = [
2
+ 'advertiser_api_spec.rb',
3
+ 'campaign_api_spec.rb',
4
+ 'channel_api_spec.rb',
5
+ 'channel_api_security_spec.rb',
6
+ 'creative_api_spec.rb',
7
+ 'creative_map_api_spec.rb',
8
+ 'flight_api_spec.rb',
9
+ 'login_api_spec.rb',
10
+ 'publisher_api_spec.rb',
11
+ 'report_api_spec.rb',
12
+ 'site_api_spec.rb'
13
+ ]
14
+
15
+ task :runall do
16
+
17
+ cmd = 'rspec '
18
+
19
+ @files.each do |file|
20
+ cmd += file +' '
21
+ end
22
+
23
+ sh "#{cmd}"
24
+
25
+ end
26
+
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Report API" do
4
+
5
+ $report_url = 'http://www.adzerk.com/'
6
+ @@report = $adzerk::Reporting.new
7
+
8
+ 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
+ new_report = {
17
+ 'StartDate' => $startdate,
18
+ 'EndDate' => $enddate,
19
+ 'GroupBy' => $groupby,
20
+ 'Top30countries' => $top30,
21
+ 'Exclude3rdParty' => $exclude3rd,
22
+ 'IsTotal' => $istotal,
23
+ 'Parameters' => $params
24
+ }
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}'
27
+ end
28
+
29
+
30
+ end
@@ -0,0 +1,77 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Site API" do
4
+
5
+ $site_url = 'http://www.adzerk.com'
6
+ @@site = $adzerk::Site.new
7
+
8
+ it "should create a new site" do
9
+ $site_title = 'Test Site ' + rand(1000000).to_s
10
+ new_site = {
11
+ 'Title' => $site_title,
12
+ 'Url' => $site_url
13
+ }
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
19
+ end
20
+
21
+ 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
+ end
25
+
26
+ it "should update a site" do
27
+ $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
38
+ end
39
+
40
+ it "should list all sites" do
41
+ result = @@site.list()
42
+ 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
47
+ end
48
+
49
+ it "should delete a new site" do
50
+ response = @@site.delete($site_id)
51
+ response.body.should == 'OK'
52
+ end
53
+
54
+ 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
58
+ end
59
+ end
60
+
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
@@ -0,0 +1,19 @@
1
+ require "rspec"
2
+ require "json"
3
+ require "net/http"
4
+ require "../lib/Adzerk"
5
+ require "../lib/adzerk/Site"
6
+ require "../lib/adzerk/Publisher"
7
+ require "../lib/adzerk/Channel"
8
+ require "../lib/adzerk/Campaign"
9
+ require "../lib/adzerk/Flight"
10
+ require "../lib/adzerk/Login"
11
+ require "../lib/adzerk/Reporting"
12
+ require "../lib/adzerk/Creative"
13
+ require "../lib/adzerk/CreativeMap"
14
+ require "../lib/adzerk/Advertiser"
15
+ require "../lib/adzerk/Invitation"
16
+
17
+ # api_key = '0223F375AE09CA4E55A82FFA241A23282485'
18
+ api_key = '114D8867A8C4DA4650AA838A7B9F6B01B7D1'
19
+ $adzerk = Adzerk.new(api_key)
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: adzerk
3
+ version: !ruby/object:Gem::Version
4
+ hash: 9
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ version: "0.1"
10
+ platform: ruby
11
+ authors:
12
+ - Kacy Fortner
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-09-30 00:00:00 Z
18
+ dependencies: []
19
+
20
+ description: Ruby library for the Adzerk API
21
+ email: kacy@adzerk.com
22
+ executables: []
23
+
24
+ extensions: []
25
+
26
+ extra_rdoc_files: []
27
+
28
+ files:
29
+ - lib/Adzerk.rb
30
+ - lib/adzerk/Advertiser.rb
31
+ - lib/adzerk/Campaign.rb
32
+ - lib/adzerk/Channel.rb
33
+ - lib/adzerk/Creative.rb
34
+ - lib/adzerk/CreativeMap.rb
35
+ - lib/adzerk/Flight.rb
36
+ - lib/adzerk/Invitation.rb
37
+ - lib/adzerk/Login.rb
38
+ - lib/adzerk/Publisher.rb
39
+ - lib/adzerk/Reporting.rb
40
+ - lib/adzerk/Site.rb
41
+ - test/advertiser_api_spec.rb
42
+ - test/campaign_api_spec.rb
43
+ - test/channel_api_security_spec.rb
44
+ - test/channel_api_spec.rb
45
+ - test/creative_api_spec.rb
46
+ - test/creative_map_api_spec.rb
47
+ - test/flight_api_spec.rb
48
+ - test/invitation_api_spec.rb
49
+ - test/login_api_spec.rb
50
+ - test/publisher_api_spec.rb
51
+ - test/rakefile.rb
52
+ - test/report_api_spec.rb
53
+ - test/site_api_spec.rb
54
+ - test/spec_helper.rb
55
+ homepage: http://adzerk.com
56
+ licenses: []
57
+
58
+ post_install_message:
59
+ rdoc_options: []
60
+
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ hash: 3
69
+ segments:
70
+ - 0
71
+ version: "0"
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 3
78
+ segments:
79
+ - 0
80
+ version: "0"
81
+ requirements: []
82
+
83
+ rubyforge_project:
84
+ rubygems_version: 1.8.6
85
+ signing_key:
86
+ specification_version: 3
87
+ summary: Adzerk API
88
+ test_files: []
89
+