adzerk 0.3 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fbf807615b442c107c0adf872c51fa3d91b55044
4
- data.tar.gz: c22fccc8609e2999a14f218f4a892f96eb6c98ff
3
+ metadata.gz: c665786700652cfe78709f0f64edb8e33a18bdc0
4
+ data.tar.gz: 25d623fe18b1754b64ead8d06067ed9707fc5daf
5
5
  SHA512:
6
- metadata.gz: 689ca16190cb2b8880252e0d5120ddfcedecd8a463c7b1260111eb9b7bf50c7cff095a29359d6aa094c123f79e0d911c8f9cd4c34cdb01ad1bf2e55f3e85458a
7
- data.tar.gz: 686c57f7c0150b20f068550f07a3bc0ab0221a3e5841cd655703dab2b34946e1b0ea5495683ea013f3c5699282bc1000d3c77f76120d4eff79cd336c147ccf0a
6
+ metadata.gz: 398edffd5fd4cf6e1e16bac11a7acfe9cb5958aa2c734a02bfe6dd429a431bcb48000d09821dd40a7778d8ea12c6fa99f29dfd6c2bb84733b1769394310e92ee
7
+ data.tar.gz: 22e1343320f3228ac3002cb96cd54630b1f714f1bafc35007d4631364ef75ace5c59c08d8ff81c604dc5c209fe6ca24895f6b97d601848973095de3d318724d0
@@ -13,9 +13,14 @@ module Adzerk
13
13
  parse_response(client.post_request('report', data))
14
14
  end
15
15
 
16
- def retrieve_report(id)
17
- url = 'report/' + id
18
- client.get_request(url)
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
@@ -1,3 +1,3 @@
1
1
  module Adzerk
2
- VERSION = "0.3"
2
+ VERSION = "0.4"
3
3
  end
@@ -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
- it "create a report" do
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 pull a saved custom report" do
25
- pending
26
- $savedReportId = 5280
27
- response = @reports.retrieve_report($savedReportId.to_s)
28
- csv_report = response.body
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
 
@@ -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(ENV['ADZERK_API_HOST'] + 'channel/')
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(ENV['ADZERK_API_HOST'] + 'channel/')
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", ""
@@ -5,6 +5,7 @@ $:.push File.expand_path("../lib", __FILE__)
5
5
  require "adzerk"
6
6
 
7
7
  API_KEY = ENV['ADZERK_API_KEY'] || 'your_api_key'
8
+ API_HOST = ENV["ADZERK_API_HOST"] || 'http://api.adzerk.net/v1/'
8
9
  # $adzerk = Adzerk.new(API_KEY)
9
10
 
10
11
  RSpec.configure do |config|
@@ -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].last[:id].to_s).to eq($zone_id)
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.3'
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-17 00:00:00.000000000 Z
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.0.14
133
+ rubygems_version: 2.2.2
134
134
  signing_key:
135
135
  specification_version: 4
136
136
  summary: Adzerk API