adzerk 0.9 → 0.14
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.
- checksums.yaml +5 -5
- data/lib/adzerk/client.rb +9 -7
- data/lib/adzerk/version.rb +1 -1
- data/test/campaign_api_spec.rb +5 -4
- data/test/category_api_spec.rb +0 -1
- data/test/creative_map_api_spec.rb +1 -32
- data/test/flight_api_spec.rb +2 -5
- data/test/geo_targeting_api_spec.rb +0 -1
- data/test/login_api_spec.rb +11 -3
- data/test/priority_api_spec.rb +1 -1
- data/test/report_api_spec.rb +4 -4
- data/test/site_zone_targeting_api_spec.rb +0 -1
- metadata +33 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: dfcb33e06a66b4728d0a27e69c41a240a3d3f73ce3af93056fdbb794e6b1361c
|
4
|
+
data.tar.gz: d6b9c3113f6120d074a517643a56fb4cb1fc2b98b98abe016cb31cbebcadad32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f549e8160c19e563cdb4aa4c54b085a833b62b6588227c2540f7e58471805ed88f79680f3d3a32c125639e98a7502b55fe9dee2b4736c560322a10ef5aa5aa61
|
7
|
+
data.tar.gz: 2be8a73fb39675f73bd02e13ddd6165f2402005b561b03ab94cf546fd4702c8fcf5105b1240cd7b0a8b71dcb214064764e6d7ce249bee12f2e87d7947533ceaa
|
data/lib/adzerk/client.rb
CHANGED
@@ -63,16 +63,17 @@ module Adzerk
|
|
63
63
|
def create_creative(data={}, image_path='')
|
64
64
|
response = RestClient.post(@config[:host] + 'creative',
|
65
65
|
{:creative => camelize_data(data).to_json},
|
66
|
-
|
67
|
-
|
68
|
-
:accept => :json)
|
66
|
+
:X_Adzerk_ApiKey => @api_key,
|
67
|
+
:accept => :json)
|
69
68
|
response = upload_creative(JSON.parse(response)["Id"], image_path) unless image_path.empty?
|
70
69
|
response
|
71
70
|
end
|
72
71
|
|
73
|
-
def upload_creative(id, image_path)
|
72
|
+
def upload_creative(id, image_path, size_override: false)
|
74
73
|
image = File.new(image_path, 'rb')
|
75
|
-
|
74
|
+
url = @config[:host] + 'creative/' + id.to_s + '/upload'
|
75
|
+
url += '?sizeOverride=true' if size_override
|
76
|
+
RestClient.post(url,
|
76
77
|
{:image => image},
|
77
78
|
"X-Adzerk-ApiKey" => @api_key,
|
78
79
|
:accept => :mime)
|
@@ -82,9 +83,10 @@ module Adzerk
|
|
82
83
|
http = Net::HTTP.new(uri.host, uri.port)
|
83
84
|
http.use_ssl = uri.scheme == 'https'
|
84
85
|
response = http.request(request)
|
85
|
-
if response.kind_of? Net::HTTPClientError
|
86
|
+
if response.kind_of? Net::HTTPClientError or response.kind_of? Net::HTTPServerError
|
86
87
|
error_response = JSON.parse(response.body)
|
87
|
-
|
88
|
+
msg = error_response["message"] || error_response["Error"]
|
89
|
+
raise Adzerk::ApiError.new(msg)
|
88
90
|
end
|
89
91
|
response
|
90
92
|
end
|
data/lib/adzerk/version.rb
CHANGED
data/test/campaign_api_spec.rb
CHANGED
@@ -73,7 +73,8 @@ describe "Campaign API" do
|
|
73
73
|
:name => "Test",
|
74
74
|
:priority_id => $priority_id,
|
75
75
|
:impressions => 10000,
|
76
|
-
:is_deleted => false
|
76
|
+
:is_deleted => false,
|
77
|
+
:goal_type => 1
|
77
78
|
}]
|
78
79
|
new1_campaign = {
|
79
80
|
:name => $campaign_name,
|
@@ -88,8 +89,6 @@ describe "Campaign API" do
|
|
88
89
|
campaign = @campaigns.create(new1_campaign)
|
89
90
|
$campaign_id_1 = campaign[:id].to_s
|
90
91
|
expect($campaign_name).to eq(campaign[:name])
|
91
|
-
# JSON.parse(response.body)["StartDate"].should == "/Date(1293858000000-0500)/"
|
92
|
-
# JSON.parse(response.body)["EndDate"].should == "/Date(1325307600000-0500)/"
|
93
92
|
expect($campaign_is_active).to eq(campaign[:is_active])
|
94
93
|
expect(campaign[:is_deleted]).to eq(false)
|
95
94
|
expect($campaign_price.to_f).to eq(campaign[:price])
|
@@ -154,7 +153,9 @@ describe "Campaign API" do
|
|
154
153
|
}
|
155
154
|
|
156
155
|
expect{ @campaigns.create(new_campaign) }.to raise_error("This advertiser is not part of your network")
|
156
|
+
end
|
157
157
|
|
158
|
+
it "should not update a campaign with a new advertiserId" do
|
158
159
|
updated_campaign = {
|
159
160
|
:id => $campaign_id,
|
160
161
|
:name => 'Test campaign ' + rand(1000000).to_s,
|
@@ -167,7 +168,7 @@ describe "Campaign API" do
|
|
167
168
|
:is_deleted => false
|
168
169
|
}
|
169
170
|
|
170
|
-
expect{ @campaigns.update(updated_campaign) }.to raise_error("This advertiser
|
171
|
+
expect{ @campaigns.update(updated_campaign) }.to raise_error("This campaign belongs to advertiser #{$advertiserId}; a different advertiser cannot be specified.")
|
171
172
|
end
|
172
173
|
|
173
174
|
it "should not retrieve a campaign with a advertiserId that doesn't belong to it" do
|
data/test/category_api_spec.rb
CHANGED
@@ -332,7 +332,7 @@ describe "Creative Flight API" do
|
|
332
332
|
end
|
333
333
|
|
334
334
|
it "should not get a map in a different network" do
|
335
|
-
expect{ @creative_maps.get(123, @flight_id) }.to raise_error
|
335
|
+
expect{ @creative_maps.get(123, @flight_id) }.to raise_error Adzerk::ApiError
|
336
336
|
end
|
337
337
|
|
338
338
|
it "should get a map that's been deleted" do
|
@@ -382,37 +382,6 @@ describe "Creative Flight API" do
|
|
382
382
|
}.to raise_error "This creative map has been deleted"
|
383
383
|
end
|
384
384
|
|
385
|
-
it "should fail when creating a map for a campaign in a different network" do
|
386
|
-
expect {
|
387
|
-
creative_map = @creative_maps.create(
|
388
|
-
:campaign_id => 123,
|
389
|
-
:flight_id => @flight_id,
|
390
|
-
:size_override => false,
|
391
|
-
:iframe => false,
|
392
|
-
:impressions => 100000,
|
393
|
-
:percentage => 50,
|
394
|
-
:siteId => @site_id,
|
395
|
-
:zoneId => @zone_id,
|
396
|
-
:distributionType => 1,
|
397
|
-
:isActive => true,
|
398
|
-
:isDeleted => false,
|
399
|
-
:creative => {
|
400
|
-
:title => "Creative Title",
|
401
|
-
:url => "http://www.adzerk.com",
|
402
|
-
:body => "Test Body",
|
403
|
-
:advertiser_id => @advertiser_id,
|
404
|
-
:ad_type_id => 18,
|
405
|
-
'IsHTMLJS' => true,
|
406
|
-
:script_body => "<html></html>",
|
407
|
-
:is_active => true,
|
408
|
-
:alt => "alt text",
|
409
|
-
:is_deleted => false,
|
410
|
-
:is_sync => false
|
411
|
-
}
|
412
|
-
)
|
413
|
-
}.to raise_error "This campaign is not part of your network"
|
414
|
-
end
|
415
|
-
|
416
385
|
it "should fail when creating a map for a site in a different network" do
|
417
386
|
expect {
|
418
387
|
creative_map = @creative_maps.create(
|
data/test/flight_api_spec.rb
CHANGED
@@ -66,7 +66,6 @@ describe "Flight API" do
|
|
66
66
|
$flight_GoalType = 1
|
67
67
|
|
68
68
|
new_flight = {
|
69
|
-
:no_end_date => false,
|
70
69
|
:priority_id => $priority_id,
|
71
70
|
:name => $flight_Name,
|
72
71
|
:start_date => $flight_StartDate,
|
@@ -110,7 +109,6 @@ describe "Flight API" do
|
|
110
109
|
|
111
110
|
it "should fail to create a flight without a goal type" do
|
112
111
|
flight_without_goal_type = {
|
113
|
-
:no_end_date => false,
|
114
112
|
:priority_id => $priority_id,
|
115
113
|
:name => $flight_Name,
|
116
114
|
:start_date => $flight_StartDate,
|
@@ -161,7 +159,8 @@ describe "Flight API" do
|
|
161
159
|
:start_date => $flight_StartDate,
|
162
160
|
:goal_type => $flight_GoalType,
|
163
161
|
:impressions => $flight_Impressions,
|
164
|
-
:is_companion => false
|
162
|
+
:is_companion => false,
|
163
|
+
:end_date => $flight_EndDate)
|
165
164
|
expect(flight[:name]).to eq("New Flight Name")
|
166
165
|
expect(flight[:is_companion]).to be false
|
167
166
|
end
|
@@ -184,7 +183,6 @@ describe "Flight API" do
|
|
184
183
|
}]
|
185
184
|
|
186
185
|
new_flight = {
|
187
|
-
'NoEndDate' => false,
|
188
186
|
'PriorityId' => $priority_id,
|
189
187
|
'Name' => $flight_Name,
|
190
188
|
'StartDate' => $flight_StartDate,
|
@@ -232,7 +230,6 @@ describe "Flight API" do
|
|
232
230
|
it "should not create a flight for a campaign in a different network" do
|
233
231
|
expect {
|
234
232
|
@flights.create(
|
235
|
-
:no_end_date => false,
|
236
233
|
:priority_id => $priority_id,
|
237
234
|
:name => $flight_Name,
|
238
235
|
:start_date => $flight_StartDate,
|
data/test/login_api_spec.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
|
+
def random_email
|
4
|
+
"test@email-#{rand(1000000)}.com"
|
5
|
+
end
|
6
|
+
|
3
7
|
describe "Login_API" do
|
4
8
|
|
5
9
|
before do
|
@@ -7,13 +11,14 @@ describe "Login_API" do
|
|
7
11
|
end
|
8
12
|
|
9
13
|
it "should create a new login" do
|
10
|
-
email =
|
14
|
+
email = random_email()
|
11
15
|
login = @logins.create(:email => email,
|
12
16
|
:password => '1234567',
|
13
17
|
:name => "John Doe")
|
14
18
|
$login_id = login[:id]
|
15
19
|
expect(login[:email]).to eq(email)
|
16
|
-
|
20
|
+
# Password is redacted in the response.
|
21
|
+
expect(login[:password]).to eq("")
|
17
22
|
expect(login[:name]).to eq("John Doe")
|
18
23
|
end
|
19
24
|
|
@@ -28,9 +33,12 @@ describe "Login_API" do
|
|
28
33
|
end
|
29
34
|
|
30
35
|
it "should update a login" do
|
36
|
+
new_email = random_email()
|
31
37
|
login = @logins.update(:id => $login_id,
|
32
|
-
:name => "New Name"
|
38
|
+
:name => "New Name",
|
39
|
+
:email => new_email)
|
33
40
|
expect(login[:name]).to eq("New Name")
|
41
|
+
expect(login[:email]).to eq(new_email)
|
34
42
|
end
|
35
43
|
|
36
44
|
end
|
data/test/priority_api_spec.rb
CHANGED
@@ -63,7 +63,7 @@ describe "Priority API" do
|
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should not allow selection algorithm to be updated" do
|
66
|
-
expect { @priorities.update(selection_algorithm: 1) }.to raise_error
|
66
|
+
expect { @priorities.update(selection_algorithm: 1) }.to raise_error JSON::ParserError
|
67
67
|
end
|
68
68
|
|
69
69
|
it "should list all priorities" do
|
data/test/report_api_spec.rb
CHANGED
@@ -6,7 +6,7 @@ describe "Report API" do
|
|
6
6
|
@reports = Adzerk::Client.new(API_KEY).reports
|
7
7
|
|
8
8
|
$new_report = {
|
9
|
-
:start_date => "
|
9
|
+
:start_date => "01/15/2011",
|
10
10
|
:end_date => "12/31/2011",
|
11
11
|
:group_by => ['month'],
|
12
12
|
'Top30countries' => false,
|
@@ -16,8 +16,8 @@ describe "Report API" do
|
|
16
16
|
}
|
17
17
|
end
|
18
18
|
|
19
|
-
it "should create a report within
|
20
|
-
report = @reports.create_report($new_report,
|
19
|
+
it "should create a report within 60 seconds" do
|
20
|
+
report = @reports.create_report($new_report, 60000)
|
21
21
|
expect(report.has_key? :report_id).to be true
|
22
22
|
expect(report[:is_total]).to be true
|
23
23
|
# expect(report[:grouping]).to eq ["month"]
|
@@ -36,7 +36,7 @@ describe "Report API" do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should return a status of 1 if the report isn't ready yet" do
|
39
|
-
bigger_report = $new_report.update(start_date: "
|
39
|
+
bigger_report = $new_report.update(start_date: "01/01/2014", end_date: "10/01/2018")
|
40
40
|
report_id = @reports.create_queued_report(bigger_report)[:id]
|
41
41
|
# immediately poll for the result
|
42
42
|
response = @reports.retrieve_queued_report(report_id)
|
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.
|
4
|
+
version: '0.14'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kacy Fortner
|
@@ -17,7 +17,7 @@ authors:
|
|
17
17
|
autorequire:
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
|
-
date:
|
20
|
+
date: 2020-07-06 00:00:00.000000000 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: rspec
|
@@ -25,56 +25,70 @@ dependencies:
|
|
25
25
|
requirements:
|
26
26
|
- - '='
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version:
|
28
|
+
version: 3.5.0
|
29
29
|
type: :development
|
30
30
|
prerelease: false
|
31
31
|
version_requirements: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
33
|
- - '='
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version:
|
35
|
+
version: 3.5.0
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rake
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - '='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 12.3.3
|
43
|
+
type: :development
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - '='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 12.3.3
|
36
50
|
- !ruby/object:Gem::Dependency
|
37
51
|
name: json
|
38
52
|
requirement: !ruby/object:Gem::Requirement
|
39
53
|
requirements:
|
40
|
-
- -
|
54
|
+
- - "~>"
|
41
55
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
56
|
+
version: '2.0'
|
43
57
|
type: :runtime
|
44
58
|
prerelease: false
|
45
59
|
version_requirements: !ruby/object:Gem::Requirement
|
46
60
|
requirements:
|
47
|
-
- -
|
61
|
+
- - "~>"
|
48
62
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
63
|
+
version: '2.0'
|
50
64
|
- !ruby/object:Gem::Dependency
|
51
65
|
name: rest-client
|
52
66
|
requirement: !ruby/object:Gem::Requirement
|
53
67
|
requirements:
|
54
68
|
- - '='
|
55
69
|
- !ruby/object:Gem::Version
|
56
|
-
version:
|
70
|
+
version: 2.0.1
|
57
71
|
type: :runtime
|
58
72
|
prerelease: false
|
59
73
|
version_requirements: !ruby/object:Gem::Requirement
|
60
74
|
requirements:
|
61
75
|
- - '='
|
62
76
|
- !ruby/object:Gem::Version
|
63
|
-
version:
|
77
|
+
version: 2.0.1
|
64
78
|
- !ruby/object:Gem::Dependency
|
65
79
|
name: activesupport
|
66
80
|
requirement: !ruby/object:Gem::Requirement
|
67
81
|
requirements:
|
68
|
-
- -
|
82
|
+
- - "~>"
|
69
83
|
- !ruby/object:Gem::Version
|
70
|
-
version:
|
84
|
+
version: '5.1'
|
71
85
|
type: :runtime
|
72
86
|
prerelease: false
|
73
87
|
version_requirements: !ruby/object:Gem::Requirement
|
74
88
|
requirements:
|
75
|
-
- -
|
89
|
+
- - "~>"
|
76
90
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
91
|
+
version: '5.1'
|
78
92
|
description: Ruby library for the Adzerk API
|
79
93
|
email: engineering@adzerk.com
|
80
94
|
executables: []
|
@@ -122,7 +136,8 @@ files:
|
|
122
136
|
- test/util_spec.rb
|
123
137
|
- test/zone_api_spec.rb
|
124
138
|
homepage: http://adzerk.com
|
125
|
-
licenses:
|
139
|
+
licenses:
|
140
|
+
- Apache-2.0
|
126
141
|
metadata: {}
|
127
142
|
post_install_message:
|
128
143
|
rdoc_options: []
|
@@ -130,17 +145,16 @@ require_paths:
|
|
130
145
|
- lib
|
131
146
|
required_ruby_version: !ruby/object:Gem::Requirement
|
132
147
|
requirements:
|
133
|
-
- -
|
148
|
+
- - ">="
|
134
149
|
- !ruby/object:Gem::Version
|
135
150
|
version: '0'
|
136
151
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
152
|
requirements:
|
138
|
-
- -
|
153
|
+
- - ">="
|
139
154
|
- !ruby/object:Gem::Version
|
140
155
|
version: '0'
|
141
156
|
requirements: []
|
142
|
-
|
143
|
-
rubygems_version: 2.4.6
|
157
|
+
rubygems_version: 3.1.2
|
144
158
|
signing_key:
|
145
159
|
specification_version: 4
|
146
160
|
summary: Adzerk API
|