adzerk 0.13 → 0.18

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.
Files changed (54) hide show
  1. checksums.yaml +5 -5
  2. data/lib/adzerk.rb +7 -0
  3. data/lib/adzerk/advertiser.rb +11 -0
  4. data/lib/adzerk/api_endpoint.rb +6 -5
  5. data/lib/adzerk/campaign.rb +15 -0
  6. data/lib/adzerk/category.rb +3 -3
  7. data/lib/adzerk/channel.rb +9 -0
  8. data/lib/adzerk/channel_site_map.rb +1 -1
  9. data/lib/adzerk/client.rb +100 -27
  10. data/lib/adzerk/creative.rb +2 -2
  11. data/lib/adzerk/creative_map.rb +7 -2
  12. data/lib/adzerk/creative_template.rb +30 -0
  13. data/lib/adzerk/day_parting.rb +23 -0
  14. data/lib/adzerk/distance_targeting.rb +33 -0
  15. data/lib/adzerk/errors.rb +0 -0
  16. data/lib/adzerk/flight.rb +25 -3
  17. data/lib/adzerk/geo_targeting.rb +0 -0
  18. data/lib/adzerk/instant_count.rb +21 -0
  19. data/lib/adzerk/invitation.rb +0 -0
  20. data/lib/adzerk/priority.rb +0 -0
  21. data/lib/adzerk/publisher.rb +14 -0
  22. data/lib/adzerk/reporting.rb +0 -0
  23. data/lib/adzerk/scheduled_reporting.rb +24 -0
  24. data/lib/adzerk/site_zone_targeting.rb +0 -0
  25. data/lib/adzerk/util.rb +7 -2
  26. data/lib/adzerk/version.rb +1 -1
  27. data/test/adtype_api_spec.rb +0 -0
  28. data/test/advertiser_api_spec.rb +8 -0
  29. data/test/campaign_api_spec.rb +16 -4
  30. data/test/category_api_spec.rb +7 -3
  31. data/test/channel_api_spec.rb +6 -1
  32. data/test/channel_site_map_api_spec.rb +0 -0
  33. data/test/creative_api_spec.rb +0 -0
  34. data/test/creative_map_api_spec.rb +10 -33
  35. data/test/creative_template_spec.rb +100 -0
  36. data/test/day_parting_api_spec.rb +102 -0
  37. data/test/distance_targeting_api_spec.rb +138 -0
  38. data/test/flight_api_spec.rb +28 -1
  39. data/test/geo_targeting_api_spec.rb +1 -1
  40. data/test/instant_count_api_spec.rb +55 -0
  41. data/test/invitation_api_spec.rb +0 -0
  42. data/test/login_api_spec.rb +0 -1
  43. data/test/priority_api_spec.rb +0 -0
  44. data/test/publisher_api_spec.rb +0 -0
  45. data/test/rakefile.rb +0 -0
  46. data/test/report_api_spec.rb +2 -2
  47. data/test/scheduled_reporting_api_spec.rb +60 -0
  48. data/test/security_api_spec.rb +0 -0
  49. data/test/site_api_spec.rb +0 -0
  50. data/test/site_zone_targeting_api_spec.rb +1 -1
  51. data/test/spec_helper.rb +0 -0
  52. data/test/util_spec.rb +0 -0
  53. data/test/zone_api_spec.rb +0 -0
  54. metadata +17 -6
@@ -0,0 +1,138 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "DistanceTargeting API" do
4
+ before(:all) do
5
+ client = Adzerk::Client.new(API_KEY)
6
+ @distance_targeting = client.distance_targetings
7
+ @flights = client.flights
8
+ @advertisers = client.advertisers
9
+ @channels = client.channels
10
+ @campaigns = client.campaigns
11
+ @priorities = client.priorities
12
+
13
+ advertiser = @advertisers.create(:title => "test")
14
+ $advertiserId = advertiser[:id].to_s
15
+
16
+ channel = @channels.create(:title => 'Test Channel ' + rand(1000000).to_s,
17
+ :commission => '0.0',
18
+ :engine => 'CPM',
19
+ :keywords => 'test',
20
+ 'CPM' => '10.00',
21
+ :ad_types => [1,2,3,4])
22
+ $channel_id = channel[:id].to_s
23
+
24
+ priority = @priorities.create(:name => "High Priority Test",
25
+ :channel_id => $channel_id,
26
+ :weight => 1,
27
+ :is_deleted => false)
28
+ $priority_id = priority[:id].to_s
29
+
30
+ campaign = @campaigns.
31
+ create(:name => 'Test campaign ' + rand(1000000).to_s,
32
+ :start_date => "1/1/2011",
33
+ :end_date => "12/31/2011",
34
+ :is_active => false,
35
+ :price => '10.00',
36
+ :advertiser_id => $advertiserId,
37
+ :flights => [],
38
+ :is_deleted => false)
39
+ $campaign_id = campaign[:id]
40
+
41
+ new_flight = {
42
+ :priority_id => $priority_id,
43
+ :name => 'Test flight ' + rand(1000000).to_s,
44
+ :start_date => "1/1/2011",
45
+ :end_date => "12/31/2011",
46
+ :no_end_date => false,
47
+ :price => '15.00',
48
+ :option_type => 1,
49
+ :impressions => 10000,
50
+ :is_unlimited => false,
51
+ :is_full_speed => false,
52
+ :keywords => "test, test2",
53
+ :user_agent_keywords => nil,
54
+ :weight_override => nil,
55
+ :campaign_id => $campaign_id,
56
+ :is_active => true,
57
+ :is_deleted => false,
58
+ :goal_type => 1
59
+ }
60
+ flight = @flights.create(new_flight)
61
+ $flight_id = flight[:id].to_s
62
+ end
63
+
64
+ after(:all) do
65
+ @flights.delete($flight_id)
66
+ @campaigns.delete($campaign_id)
67
+ @advertisers.delete($advertiserId)
68
+ @priorities.delete($priority_id)
69
+ @channels.delete($channel_id)
70
+ end
71
+
72
+ it "should create a Distance Targeting Geometry object with a street address" do
73
+ distance = 42
74
+ address = "1600 Pennsylvania Avenue NW, Washington DC 20500"
75
+ data = {
76
+ :distance => distance,
77
+ :street_address => address
78
+ }
79
+
80
+ response = @distance_targeting.create($flight_id, data)
81
+ expect(response[:flight_id].to_s).to eq($flight_id)
82
+ expect(response[:distance]).to eq(distance)
83
+ expect(response[:street_address]).to eq(address)
84
+ $geometry_id = response[:id]
85
+ end
86
+
87
+ it "should upload a batch of Distance Targeting Geometries" do
88
+ data = {
89
+ :replace_existing => false,
90
+ :geometries => [
91
+ {
92
+ :latitude => -89.05,
93
+ :longitude => 57.1,
94
+ :distance => 5
95
+ },
96
+ {
97
+ :latitude => 14,
98
+ :longitude => 57.1,
99
+ :distance => 5
100
+ }
101
+ ]
102
+ }
103
+
104
+ response = @distance_targeting.batch_upload($flight_id, data)
105
+ expect(response[:inserted_geometries]).to_not eq(nil)
106
+ end
107
+
108
+ it "should update a Distance Targeting Geometry" do
109
+ new_distance = 43
110
+ new_address = "701 N 1st Ave, Minneapolis MN 55403"
111
+ data = {
112
+ :distance => new_distance,
113
+ :street_address => new_address
114
+ }
115
+
116
+ response = @distance_targeting.update($flight_id, $geometry_id, data)
117
+ expect(response[:flight_id].to_s).to eq($flight_id)
118
+ expect(response[:id]).to eq($geometry_id)
119
+ expect(response[:distance]).to eq(new_distance)
120
+ expect(response[:street_address]).to eq(new_address)
121
+ end
122
+
123
+ it "should get a specific Distance Targeting Geometry" do
124
+ response = @distance_targeting.get($flight_id, $geometry_id)
125
+ expect(response[:flight_id].to_s).to eq($flight_id)
126
+ expect(response[:id]).to eq($geometry_id)
127
+ end
128
+
129
+ it "should list Distance Targeting Geometry objects associated with a flight" do
130
+ response = @distance_targeting.list($flight_id)
131
+ expect(response.length).to be > 0
132
+ end
133
+
134
+ it "should delete a specific Distance Targeting Geometry" do
135
+ response = @distance_targeting.delete($flight_id, $geometry_id)
136
+ expect(response.code).to eq('204')
137
+ end
138
+ end
@@ -159,7 +159,8 @@ describe "Flight API" do
159
159
  :start_date => $flight_StartDate,
160
160
  :goal_type => $flight_GoalType,
161
161
  :impressions => $flight_Impressions,
162
- :is_companion => false)
162
+ :is_companion => false,
163
+ :end_date => $flight_EndDate)
163
164
  expect(flight[:name]).to eq("New Flight Name")
164
165
  expect(flight[:is_companion]).to be false
165
166
  end
@@ -169,6 +170,15 @@ describe "Flight API" do
169
170
  expect(flights.length).to be > 0
170
171
  end
171
172
 
173
+ it "should get flight instant counts" do
174
+ data = {
175
+ start: "2021-04-04",
176
+ end: "2021-04-20"
177
+ }
178
+ count = @flights.instant_counts($flight_id, data)
179
+ expect(count.length).to be > 0
180
+ end
181
+
172
182
  it "should delete a new flight" do
173
183
  response = @flights.delete($flight_id)
174
184
  expect(response.body).to eq('"Successfully deleted"')
@@ -249,4 +259,21 @@ describe "Flight API" do
249
259
  )
250
260
  }.to raise_error "This campaign is not part of your network"
251
261
  end
262
+
263
+ it "should list countries" do
264
+ response = @flights.countries()
265
+ expect(response.length).to be > 0
266
+ end
267
+
268
+ it "should list metro codes for region" do
269
+ region_code = "MN"
270
+ response = @flights.regions(region_code)
271
+ expect(response.length).to be > 0
272
+ end
273
+
274
+ it "should list regions for a country" do
275
+ country_code = "US"
276
+ response = @flights.list_regions_for_country(country_code)
277
+ expect(response.length).to be > 0
278
+ end
252
279
  end
@@ -112,7 +112,7 @@ describe "GeoTargeting API" do
112
112
  it "should error when deleting a geotargeting that does not exist" do
113
113
  expect {
114
114
  @geotargetings.delete($flight_id, 1)
115
- }.to raise_error "Couldn't find network for model: PassLocation, id: 1"
115
+ }.to raise_error "This PassLocation does not exist in your network."
116
116
  end
117
117
 
118
118
  it "should check if a flight is not a part of your network" do
@@ -0,0 +1,55 @@
1
+ require 'pp'
2
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
+
4
+ describe "Instant Count API" do
5
+ before(:all) do
6
+ client = Adzerk::Client.new(API_KEY)
7
+ @instant_counts = client.instant_counts
8
+ @advertisers = client.advertisers
9
+ @campaigns = client.campaigns
10
+
11
+ advertiser = @advertisers.create(:title => "test")
12
+ @advertiser_id = advertiser[:id]
13
+
14
+ campaign = @campaigns.
15
+ create(:name => 'Test campaign ' + rand(1000000).to_s,
16
+ :start_date => "1/1/2011",
17
+ :end_date => "12/31/2011",
18
+ :is_active => false,
19
+ :price => '10.00',
20
+ :advertiser_id => @advertiser_id,
21
+ :flights => [],
22
+ :is_deleted => false)
23
+ @campaign_id = campaign[:id]
24
+ end
25
+
26
+ after(:all) do
27
+ @campaigns.delete(@campaign_id)
28
+ @advertisers.delete(@advertiser_id)
29
+ end
30
+
31
+ it "should fetch bulk instant counts" do
32
+ advertiser_id = @advertiser_id
33
+ campaign_id = @campaign_id
34
+
35
+ counts = @instant_counts.bulk({
36
+ :advertisers => [advertiser_id],
37
+ :campaigns => [campaign_id]
38
+ })
39
+
40
+ expect(counts).to have_key(:advertisers)
41
+ expect(counts[:advertisers]).to have_key(advertiser_id.to_s.to_sym)
42
+
43
+ expect(counts).to have_key(:campaigns)
44
+ expect(counts[:campaigns]).to have_key(campaign_id.to_s.to_sym)
45
+ end
46
+
47
+ it "should get network instant counts" do
48
+ data = {
49
+ start: "2021-04-04",
50
+ end: "2021-04-20"
51
+ }
52
+ count = @instant_counts.network_counts(data)
53
+ expect(count.length).to be > 0
54
+ end
55
+ end
File without changes
@@ -38,7 +38,6 @@ describe "Login_API" do
38
38
  :name => "New Name",
39
39
  :email => new_email)
40
40
  expect(login[:name]).to eq("New Name")
41
- expect(login[:email]).to eq(new_email)
42
41
  end
43
42
 
44
43
  end
File without changes
File without changes
data/test/rakefile.rb CHANGED
File without changes
@@ -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 => "1/15/2011",
9
+ :start_date => "01/15/2011",
10
10
  :end_date => "12/31/2011",
11
11
  :group_by => ['month'],
12
12
  'Top30countries' => false,
@@ -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: "1/1/2014", end_date: "10/1/2018")
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)
@@ -0,0 +1,60 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Reporting API" do
4
+ before(:all) do
5
+ client = Adzerk::Client.new(API_KEY)
6
+ @scheduled_reports = client.scheduled_reports
7
+ end
8
+
9
+ it "should create a scheduled report" do
10
+ $name = 'Test Report' + rand(1000000).to_s
11
+ $login_id = 25218
12
+ $kickoff_date = '2020-02-02T00:00:00'
13
+ $scheduling_window = 1
14
+ $recurrence_type = 2
15
+ data = {
16
+ :name => $name,
17
+ :login_id => $login_id,
18
+ :kickoff_date => $kickoff_date,
19
+ :scheduling_window => $scheduling_window,
20
+ :recurrence_type => $recurrence_type,
21
+ :criteria => {
22
+ :start_date_iso => '2020-01-01T00:00:00',
23
+ :end_date_iso => '2020-11-23T23:59:59',
24
+ :group_by => ['month'],
25
+ :parameters => [{
26
+ :country_code => 'US'
27
+ }],
28
+ },
29
+ :emails => ['cbensel@kevel.co'],
30
+ :show_events => true,
31
+ :show_click_bucketing => true,
32
+ :show_revenue => true,
33
+ :show_conversions => true,
34
+ }
35
+
36
+ response = @scheduled_reports.create(data)
37
+ expect($name).to eq(response[:name])
38
+ expect($login_id).to eq(response[:login_id])
39
+ expect($kickoff_date).to eq(response[:kickoff_date])
40
+ expect($scheduling_window).to eq(response[:scheduling_window])
41
+ expect($recurrence_type).to eq(response[:recurrence_type])
42
+ $report_id = response[:id]
43
+ end
44
+
45
+ it "should get a single report" do
46
+ response = @scheduled_reports.get($report_id)
47
+ expect($report_id).to eq(response[:id])
48
+ expect($name).to eq(response[:name])
49
+ end
50
+
51
+ it "should list all reports for account" do
52
+ response = @scheduled_reports.list()
53
+ expect(response.length).to be > 0
54
+ end
55
+
56
+ it "should delete a report" do
57
+ response = @scheduled_reports.delete($report_id)
58
+ expect(response).to eq('Successfully deleted')
59
+ end
60
+ end
File without changes
File without changes
@@ -127,7 +127,7 @@ describe "SiteZoneTargeting API" do
127
127
  it "should error when deleting a sitezone targeting that does not exist" do
128
128
  expect {
129
129
  @sitezonetargeting.delete($flight_id,1)
130
- }.to raise_error "Couldn't find network for model: PassSiteMap, id: 1"
130
+ }.to raise_error "This PassSiteMap does not exist in your network."
131
131
  end
132
132
 
133
133
  it "should check if a flight is not a part of your network" do
data/test/spec_helper.rb CHANGED
File without changes
data/test/util_spec.rb CHANGED
File without changes
File without changes
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.13'
4
+ version: '0.18'
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: 2017-10-19 00:00:00.000000000 Z
20
+ date: 2021-05-05 00:00:00.000000000 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: rspec
@@ -39,14 +39,14 @@ dependencies:
39
39
  requirements:
40
40
  - - '='
41
41
  - !ruby/object:Gem::Version
42
- version: 12.0.0
42
+ version: 12.3.3
43
43
  type: :development
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - '='
48
48
  - !ruby/object:Gem::Version
49
- version: 12.0.0
49
+ version: 12.3.3
50
50
  - !ruby/object:Gem::Dependency
51
51
  name: json
52
52
  requirement: !ruby/object:Gem::Requirement
@@ -98,18 +98,25 @@ files:
98
98
  - lib/adzerk.rb
99
99
  - lib/adzerk/advertiser.rb
100
100
  - lib/adzerk/api_endpoint.rb
101
+ - lib/adzerk/campaign.rb
101
102
  - lib/adzerk/category.rb
103
+ - lib/adzerk/channel.rb
102
104
  - lib/adzerk/channel_site_map.rb
103
105
  - lib/adzerk/client.rb
104
106
  - lib/adzerk/creative.rb
105
107
  - lib/adzerk/creative_map.rb
108
+ - lib/adzerk/creative_template.rb
109
+ - lib/adzerk/day_parting.rb
110
+ - lib/adzerk/distance_targeting.rb
106
111
  - lib/adzerk/errors.rb
107
112
  - lib/adzerk/flight.rb
108
113
  - lib/adzerk/geo_targeting.rb
114
+ - lib/adzerk/instant_count.rb
109
115
  - lib/adzerk/invitation.rb
110
116
  - lib/adzerk/priority.rb
111
117
  - lib/adzerk/publisher.rb
112
118
  - lib/adzerk/reporting.rb
119
+ - lib/adzerk/scheduled_reporting.rb
113
120
  - lib/adzerk/site_zone_targeting.rb
114
121
  - lib/adzerk/util.rb
115
122
  - lib/adzerk/version.rb
@@ -121,14 +128,19 @@ files:
121
128
  - test/channel_site_map_api_spec.rb
122
129
  - test/creative_api_spec.rb
123
130
  - test/creative_map_api_spec.rb
131
+ - test/creative_template_spec.rb
132
+ - test/day_parting_api_spec.rb
133
+ - test/distance_targeting_api_spec.rb
124
134
  - test/flight_api_spec.rb
125
135
  - test/geo_targeting_api_spec.rb
136
+ - test/instant_count_api_spec.rb
126
137
  - test/invitation_api_spec.rb
127
138
  - test/login_api_spec.rb
128
139
  - test/priority_api_spec.rb
129
140
  - test/publisher_api_spec.rb
130
141
  - test/rakefile.rb
131
142
  - test/report_api_spec.rb
143
+ - test/scheduled_reporting_api_spec.rb
132
144
  - test/security_api_spec.rb
133
145
  - test/site_api_spec.rb
134
146
  - test/site_zone_targeting_api_spec.rb
@@ -154,8 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
166
  - !ruby/object:Gem::Version
155
167
  version: '0'
156
168
  requirements: []
157
- rubyforge_project:
158
- rubygems_version: 2.5.1
169
+ rubygems_version: 3.0.3.1
159
170
  signing_key:
160
171
  specification_version: 4
161
172
  summary: Adzerk API