adzerk 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,33 +1,47 @@
1
1
  module Adzerk
2
2
  class Publisher
3
-
3
+
4
4
  def create(data={})
5
5
  uri = URI.parse($host + 'publisher')
6
6
  data = { 'publisher' => data.to_json }
7
7
  Adzerk.post_request(uri, data)
8
8
  end
9
-
9
+
10
10
  def get(id)
11
11
  uri = URI.parse($host + 'publisher/' + id)
12
12
  Adzerk.get_request(uri)
13
13
  end
14
-
14
+
15
15
  def list()
16
16
  uri = URI.parse($host + 'publisher')
17
17
  response = Adzerk.get_request(uri)
18
18
  JSON.parse(response.body)
19
19
  end
20
-
20
+
21
21
  def update(data={})
22
22
  uri = URI.parse($host + 'publisher/' + data["Id"].to_s)
23
23
  data = { 'publisher' => data.to_json }
24
24
  Adzerk.put_request(uri, data)
25
25
  end
26
-
26
+
27
27
  def delete(id)
28
28
  uri = URI.parse($host + 'publisher/' + id + '/delete')
29
29
  Adzerk.get_request(uri)
30
30
  end
31
-
31
+
32
+ def earnings(data={})
33
+ uri = URI.parse($host + '/earnings')
34
+ data = { 'earnings' => data.to_json }
35
+ response = Adzerk.post_request(uri, data)
36
+ JSON.parse(response.body)
37
+ end
38
+
39
+ def payments(data={})
40
+ uri = URI.parse($host + '/payments')
41
+ data = { 'payments' => data.to_json }
42
+ response = Adzerk.post_request(uri, data)
43
+ JSON.parse(response.body)
44
+ end
45
+
32
46
  end
33
47
  end
@@ -6,6 +6,11 @@ module Adzerk
6
6
  data = { 'criteria' => data.to_json }
7
7
  Adzerk.post_request(uri, data)
8
8
  end
9
-
9
+
10
+ def get(id)
11
+ uri = URI.parse($host + 'report/' + id)
12
+ Adzerk.get_request(uri)
13
+ end
14
+
10
15
  end
11
- end
16
+ end
@@ -0,0 +1,89 @@
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,4 +1,4 @@
1
- require 'spec_helper'
1
+ require './spec_helper'
2
2
 
3
3
  describe "Publisher API" do
4
4
 
@@ -144,4 +144,71 @@ describe "Publisher API" do
144
144
  response.body.should == '{"Id":0,"IsDeleted":false}'
145
145
  end
146
146
 
147
+ it "should retrieve publisher earnings" do
148
+ earnings = {
149
+ 'Channel' => 'all'
150
+ }
151
+ #response = @@publisher.earnings earnings
152
+ #response.first.length.should == 12
153
+ end
154
+
155
+ it "should retrieve publisher earnings for previous month" do
156
+ earnings = {
157
+ 'Channel' => 'all',
158
+ 'Month' => 'previous'
159
+ }
160
+ #response = @@publisher.earnings earnings
161
+ #response.first.length.should == 12
162
+ end
163
+
164
+ it "should retrieve publisher earnings for individual channel" do
165
+ earnings = {
166
+ 'Channel' => '1127'
167
+ }
168
+ #response = @@publisher.earnings earnings
169
+ #response.first.length.should == 12
170
+ end
171
+
172
+ it "should retrieve publisher payments for a network" do
173
+ payments = { }
174
+ response = @@publisher.payments payments
175
+ response.first.length.should == 5
176
+ puts response
177
+ end
178
+
179
+ it "should retrieve publisher payments for a network with start and end date" do
180
+ payments = {
181
+ 'StartDate' => '01/01/2000',
182
+ 'EndDate' => '03/01/2000'
183
+ }
184
+ response = @@publisher.payments payments
185
+ response.first.should == nil
186
+ puts response
187
+ end
188
+
189
+ it "should retrieve publisher payments for a network with only start date" do
190
+ payments = {
191
+ 'StartDate' => '01/01/2012'
192
+ }
193
+ response = @@publisher.payments payments
194
+ response.first.length.should == 5
195
+ puts response
196
+ end
197
+
198
+ it "should retrieve publisher payments for a site" do
199
+ payments = {
200
+ 'SiteId' => 6872
201
+ }
202
+ response = @@publisher.payments payments
203
+ puts response
204
+ end
205
+
206
+ it "should retrieve publisher payments for a publisher" do
207
+ payments = {
208
+ 'PublisherAccountId' => 644
209
+ }
210
+ response = @@publisher.payments payments
211
+ puts response
212
+ end
213
+
147
214
  end
@@ -10,6 +10,7 @@
10
10
  'login_api_spec.rb',
11
11
  'publisher_api_spec.rb',
12
12
  'report_api_spec.rb',
13
+ 'csv_export_spec.rb',
13
14
  'site_api_spec.rb',
14
15
  'priority_api_spec.rb',
15
16
  'zone_api_spec.rb',
@@ -26,5 +26,12 @@ describe "Report API" do
26
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
27
  end
28
28
 
29
-
30
- end
29
+
30
+ it "should pull a saved custom report" do
31
+ $savedReportId = 5280
32
+ response = @@report.get($savedReportId.to_s)
33
+
34
+ csv_report = response.body
35
+ end
36
+ end
37
+
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.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-26 00:00:00.000000000 Z
12
+ date: 2012-07-19 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Ruby library for the Adzerk API
15
15
  email: kacy@adzerk.com
@@ -39,6 +39,7 @@ files:
39
39
  - test/channel_site_map_api_spec.rb
40
40
  - test/creative_api_spec.rb
41
41
  - test/creative_map_api_spec.rb
42
+ - test/csv_export_spec.rb
42
43
  - test/delivery-test.rb
43
44
  - test/flight_api_spec.rb
44
45
  - test/invitation_api_spec.rb