adzerk 0.3 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/adzerk/reporting.rb +8 -3
- data/lib/adzerk/version.rb +1 -1
- data/test/report_api_spec.rb +35 -11
- data/test/security_api_spec.rb +2 -2
- data/test/spec_helper.rb +1 -0
- data/test/zone_api_spec.rb +1 -5
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c665786700652cfe78709f0f64edb8e33a18bdc0
|
4
|
+
data.tar.gz: 25d623fe18b1754b64ead8d06067ed9707fc5daf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 398edffd5fd4cf6e1e16bac11a7acfe9cb5958aa2c734a02bfe6dd429a431bcb48000d09821dd40a7778d8ea12c6fa99f29dfd6c2bb84733b1769394310e92ee
|
7
|
+
data.tar.gz: 22e1343320f3228ac3002cb96cd54630b1f714f1bafc35007d4631364ef75ace5c59c08d8ff81c604dc5c209fe6ca24895f6b97d601848973095de3d318724d0
|
data/lib/adzerk/reporting.rb
CHANGED
@@ -13,9 +13,14 @@ module Adzerk
|
|
13
13
|
parse_response(client.post_request('report', data))
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
17
|
-
|
18
|
-
client.
|
16
|
+
def create_queued_report(data={})
|
17
|
+
data = { 'criteria' => camelize_data(data).to_json }
|
18
|
+
parse_response(client.post_request('report/queue', data))
|
19
|
+
end
|
20
|
+
|
21
|
+
def retrieve_queued_report(id)
|
22
|
+
url = 'report/queue/' + id
|
23
|
+
parse_response(client.get_request(url))
|
19
24
|
end
|
20
25
|
end
|
21
26
|
end
|
data/lib/adzerk/version.rb
CHANGED
data/test/report_api_spec.rb
CHANGED
@@ -4,10 +4,8 @@ describe "Report API" do
|
|
4
4
|
|
5
5
|
before do
|
6
6
|
@reports = Adzerk::Client.new(API_KEY).reports
|
7
|
-
end
|
8
7
|
|
9
|
-
|
10
|
-
new_report = {
|
8
|
+
$new_report = {
|
11
9
|
:start_date => "1/15/2011",
|
12
10
|
:end_date => "12/31/2011",
|
13
11
|
:group_by => ['month'],
|
@@ -16,16 +14,42 @@ describe "Report API" do
|
|
16
14
|
:is_total => true,
|
17
15
|
:parameters => []
|
18
16
|
}
|
19
|
-
report = @reports.create_report(new_report)
|
20
|
-
expect(report[:is_total]).to eq(true)
|
21
|
-
expect(report[:grouping]).to eq(["month"])
|
22
17
|
end
|
23
18
|
|
24
|
-
it "should
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
19
|
+
it "should create a report" do
|
20
|
+
report = @reports.create_report($new_report)
|
21
|
+
expect(report.has_key? :id).to be true
|
22
|
+
expect(report[:is_total]).to be true
|
23
|
+
expect(report[:grouping]).to eq ["month"]
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should create a queued report" do
|
27
|
+
response = @reports.create_queued_report($new_report)
|
28
|
+
$saved_report_id = response[:id]
|
29
|
+
expect($saved_report_id).to_not be_nil
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should poll for the result of a queued report" do
|
33
|
+
response = @reports.retrieve_queued_report($saved_report_id)
|
34
|
+
expect(response[:id]).to eq $saved_report_id
|
35
|
+
expect([1,2,3]).to include response[:status]
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should return a status of 1 if the report isn't ready yet" do
|
39
|
+
bigger_report = $new_report.update(start_date: "1/1/2010", end_date: "10/1/2014")
|
40
|
+
report_id = @reports.create_queued_report(bigger_report)[:id]
|
41
|
+
# immediately poll for the result
|
42
|
+
response = @reports.retrieve_queued_report(report_id)
|
43
|
+
expect(response[:status]).to eq 1
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should retrieve a queued report if available" do
|
47
|
+
# use $saved_report_id from 3 tests ago, wait a couple seconds to make sure the report is ready
|
48
|
+
sleep 2
|
49
|
+
response = @reports.retrieve_queued_report($saved_report_id)
|
50
|
+
expect(response[:status]).to eq 2
|
51
|
+
expect(response[:result][:is_total]).to be true
|
52
|
+
expect(response[:result][:grouping]).to eq ["month"]
|
29
53
|
end
|
30
54
|
end
|
31
55
|
|
data/test/security_api_spec.rb
CHANGED
@@ -4,14 +4,14 @@ require 'net/http'
|
|
4
4
|
describe "Channel API security" do
|
5
5
|
|
6
6
|
it "should reject unauthenticated GET requests" do
|
7
|
-
uri = URI.parse(
|
7
|
+
uri = URI.parse(API_HOST + 'channel/')
|
8
8
|
http = Net::HTTP.new(uri.host, uri.port)
|
9
9
|
request = Net::HTTP::Get.new(uri.request_uri)
|
10
10
|
expect(http.request(request).response.code).not_to eq(200)
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should reject GET requests with null API keys" do
|
14
|
-
uri = URI.parse(
|
14
|
+
uri = URI.parse(API_HOST + 'channel/')
|
15
15
|
http = Net::HTTP.new(uri.host, uri.port)
|
16
16
|
request = Net::HTTP::Get.new(uri.request_uri)
|
17
17
|
request.add_field "X-Adzerk-ApiKey", ""
|
data/test/spec_helper.rb
CHANGED
data/test/zone_api_spec.rb
CHANGED
@@ -2,7 +2,6 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
2
|
|
3
3
|
describe "Zone API" do
|
4
4
|
|
5
|
-
|
6
5
|
before(:all) do
|
7
6
|
@client = Adzerk::Client.new(API_KEY)
|
8
7
|
@zones = @client.zones
|
@@ -49,10 +48,7 @@ describe "Zone API" do
|
|
49
48
|
it "should list all zones" do
|
50
49
|
result = @zones.list
|
51
50
|
expect(result.length).to be > 0
|
52
|
-
expect(result[:items].
|
53
|
-
expect(result[:items].last[:name]).to eq($name)
|
54
|
-
expect(result[:items].last[:site_id]).to eq($site_id)
|
55
|
-
expect(result[:items].last[:is_deleted]).to eq(false)
|
51
|
+
expect(result[:items].any? {|zone| zone[:id].to_s == $zone_id}).to be true
|
56
52
|
end
|
57
53
|
|
58
54
|
it "should delete a new zone" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adzerk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.4'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kacy Fortner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -56,14 +56,14 @@ dependencies:
|
|
56
56
|
name: activesupport
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 3.2.8
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 3.2.8
|
69
69
|
description: Ruby library for the Adzerk API
|
@@ -120,17 +120,17 @@ require_paths:
|
|
120
120
|
- lib
|
121
121
|
required_ruby_version: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
|
-
- -
|
123
|
+
- - ">="
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
|
-
- -
|
128
|
+
- - ">="
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: '0'
|
131
131
|
requirements: []
|
132
132
|
rubyforge_project:
|
133
|
-
rubygems_version: 2.
|
133
|
+
rubygems_version: 2.2.2
|
134
134
|
signing_key:
|
135
135
|
specification_version: 4
|
136
136
|
summary: Adzerk API
|