adzerk 0.10 → 0.15

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 7f63d6a96ce98f2088bcc15c9f69a1a6b041e4c0
4
- data.tar.gz: 49eb066401dd2dd45b419d4ce7c3bb7abeddbf16
2
+ SHA256:
3
+ metadata.gz: b08fcf724937ddb370874ccdf50506ca1f6e16be79cde06dc8777d1e1d99bfd6
4
+ data.tar.gz: 28776f7247b58b93c4590fa1689737288a738240403e0d0af18bebd381f9b97d
5
5
  SHA512:
6
- metadata.gz: 9aa5ef52b861431a0d6146a8b27e3a2aca2939c1a59c8817817d39c11f7241741c87cf687fc78ec482312f9915b988396e428ef8da714b8841e26c9106ccc22a
7
- data.tar.gz: 8ee221ad3f70d091a88ec6ceb6c23be39d10304c00e8810d69e8c4e815745e994da254a15cfe2b8ef1cbd24c61c659f0aa19d5bb435daf85edb076f0587eefd8
6
+ metadata.gz: 4763be769dac520c65beb9e7e6049089633635a75fc20f9480428d1b286cbeaa2bd543d5a16e4ae4d4a40c5674ae3e6963e2f2d5f5141ab574686829d8511630
7
+ data.tar.gz: 5e6e08ec68228782bf1acdecc0c035ac66567f0886adcbde45ba77e03a073321d375287b1e4e316aee2a6d65ba7cb20c4812d1a4597567ae0eeb8a6dbc783090
@@ -18,3 +18,6 @@ require "adzerk/site_zone_targeting"
18
18
  require "adzerk/category"
19
19
  require "adzerk/client"
20
20
  require "adzerk/priority"
21
+ require "adzerk/campaign"
22
+ require "adzerk/instant_count"
23
+ require "adzerk/creative_template"
@@ -5,5 +5,15 @@ module Adzerk
5
5
  data = { 'advertiserName' => advertiser_name }
6
6
  parse_response(client.post_request(url, data))
7
7
  end
8
+
9
+ def instant_counts(advertiser_id)
10
+ url = "instantcounts/#{endpoint}/#{advertiser_id}?page=#{page}&pageSize=#{pageSize}"
11
+ parse_response(client.get_request(url))
12
+ end
13
+
14
+ def list_creatives(advertiser_id, page: 1, pageSize: 500)
15
+ url = "advertiser/#{advertiser_id}/creatives?page=#{page}&pageSize=#{pageSize}"
16
+ parse_response(@client.get_request(url))
17
+ end
8
18
  end
9
19
  end
@@ -14,8 +14,8 @@ module Adzerk
14
14
 
15
15
  def create(opts={}, subid=nil)
16
16
  e = (subid && subendpoint) ? "#{subendpoint}/#{subid}/#{endpoint}" : endpoint
17
- data = { datakey => camelize_data(opts).to_json }
18
- response = @client.post_request(e, data)
17
+ data = camelize_data(opts)
18
+ response = @client.post_json_request(e, data)
19
19
  parse_response(response)
20
20
  end
21
21
 
@@ -24,16 +24,17 @@ module Adzerk
24
24
  parse_response(response)
25
25
  end
26
26
 
27
- def list(subid=nil)
27
+ def list(subid=nil, page: 1, pageSize: 500)
28
28
  e = (subid && subendpoint) ? "#{subendpoint}/#{subid}/#{endpoint}" : endpoint
29
+ e = "#{e}?page=#{page}&pageSize=#{pageSize}"
29
30
  response = @client.get_request(e)
30
31
  parse_response(response)
31
32
  end
32
33
 
33
34
  def update(opts={})
34
35
  id = opts[:id].to_s
35
- data = { datakey => camelize_data(opts).to_json }
36
- response = @client.put_request("#{endpoint}/#{id}", data)
36
+ data = camelize_data(opts)
37
+ response = @client.put_json_request("#{endpoint}/#{id}", data)
37
38
  parse_response(response)
38
39
  end
39
40
 
@@ -0,0 +1,8 @@
1
+ module Adzerk
2
+ class Campaign < ApiEndpoint
3
+ def instant_counts(campaign_id)
4
+ url = "instantcounts/#{endpoint}/#{campaign_id}"
5
+ parse_response(client.get_request(url))
6
+ end
7
+ end
8
+ end
@@ -20,13 +20,13 @@ module Adzerk
20
20
  @client.get_request(url)
21
21
  end
22
22
 
23
- def listAll
23
+ def listAll(page: 1, pageSize: 500)
24
24
  response = client.get_request('categories')
25
25
  parse_response(response)
26
26
  end
27
27
 
28
- def list(flight_id)
29
- url = "flight/#{flight_id}/categories"
28
+ def list(flight_id, page: 1, pageSize: 500)
29
+ url = "flight/#{flight_id}/categories?page=#{page}&pageSize=#{pageSize}"
30
30
  response = client.get_request(url)
31
31
  parse_response(response)
32
32
  end
@@ -21,7 +21,7 @@ module Adzerk
21
21
  response = parse_response(response)
22
22
  end
23
23
 
24
- def list
24
+ def list(page: 1, pageSize: 500)
25
25
  response = client.get_request('channelSite')
26
26
  parse_response(response)
27
27
  end
@@ -6,11 +6,17 @@ module Adzerk
6
6
  attr_reader :sites, :ad_types, :zones, :campaigns, :channels, :priorities,
7
7
  :advertisers, :flights, :creatives, :creative_maps,
8
8
  :publishers, :invitations, :reports, :channel_site_maps,
9
- :logins, :geotargetings, :sitezonetargetings, :categories
9
+ :logins, :geotargetings, :sitezonetargetings, :categories,
10
+ :instant_counts, :ads, :creative_templates
11
+
12
+ VERSION = Gem.loaded_specs['adzerk'].version.to_s
13
+ SDK_HEADER_NAME = 'X-Adzerk-Sdk-Version'
14
+ SDK_HEADER_VALUE = "adzerk-management-sdk-ruby:#{VERSION}"
10
15
 
11
16
  DEFAULTS = {
12
- :host => ENV["ADZERK_API_HOST"] || 'https://api.adzerk.net/v1/',
13
- :header => 'X-Adzerk-ApiKey'
17
+ :host => ENV["ADZERK_API_HOST"] || 'https://api.adzerk.net/',
18
+ :header => 'X-Adzerk-ApiKey',
19
+ :include_creative_templates => true
14
20
  }
15
21
 
16
22
  def initialize(key, opts = {})
@@ -19,62 +25,88 @@ module Adzerk
19
25
  @logins = Adzerk::ApiEndpoint.new(:client => self, :endpoint => 'login')
20
26
  @sites = Adzerk::ApiEndpoint.new(:client => self, :endpoint => 'site')
21
27
  @ad_types = Adzerk::ApiEndpoint.new(:client => self, :endpoint => 'adtypes', :subendpoint => 'channel', :datakey => 'adtype')
22
- @flights = Adzerk::ApiEndpoint.new(:client => self, :endpoint => 'flight')
28
+ @flights = Adzerk::Flight.new(:client => self, :endpoint => 'flight')
23
29
  @zones = Adzerk::ApiEndpoint.new(:client => self, :endpoint => 'zone')
24
- @campaigns = Adzerk::ApiEndpoint.new(:client => self, :endpoint => 'campaign')
30
+ @campaigns = Adzerk::Campaign.new(:client => self, :endpoint => 'campaign')
25
31
  @channels = Adzerk::ApiEndpoint.new(:client => self, :endpoint => 'channel')
26
32
  @priorities = Adzerk::Priority.new(:client => self, :endpoint => 'priority')
27
33
  @advertisers = Adzerk::Advertiser.new(:client => self, :endpoint => 'advertiser')
28
34
  @publishers = Adzerk::Publisher.new(:client => self, :endpoint => 'publisher')
29
35
  @creatives = Adzerk::Creative.new(:client => self, :endpoint => 'creative')
30
36
  @creative_maps = Adzerk::CreativeMap.new(:client => self)
37
+ @ads = @creative_maps
31
38
  @invitations = Adzerk::Invitation.new(:client => self)
32
39
  @reports = Adzerk::Reporting.new(:client => self)
33
40
  @channel_site_maps = Adzerk::ChannelSiteMap.new(:client => self)
34
41
  @geotargetings = Adzerk::GeoTargeting.new(:client => self, :endpoint => 'geotargeting')
35
42
  @sitezonetargetings = Adzerk::SiteZoneTargeting.new(:client => self, :endpoint => 'sitezone')
36
43
  @categories = Adzerk::Category.new(:client => self, :endpoint => 'category')
37
-
44
+ @instant_counts = Adzerk::InstantCount.new(:client => self)
45
+ @creative_templates = Adzerk::CreativeTemplate.new(:client => self)
38
46
  end
39
47
 
40
- def get_request(url)
41
- uri = URI.parse(@config[:host] + url)
48
+ def get_request(url, version: 'v1')
49
+ uri = URI.parse("#{@config[:host]}#{version}/#{url}")
42
50
  request = Net::HTTP::Get.new(uri.request_uri)
43
51
  request.add_field(@config[:header], @api_key)
52
+ request.add_field(SDK_HEADER_NAME, SDK_HEADER_VALUE)
44
53
  send_request(request, uri)
45
54
  end
46
55
 
47
- def post_request(url, data)
48
- uri = URI.parse(@config[:host] + url)
56
+ def post_request(url, data, version: 'v1')
57
+ uri = URI.parse("#{@config[:host]}#{version}/#{url}")
49
58
  request = Net::HTTP::Post.new(uri.request_uri)
50
59
  request.add_field(@config[:header], @api_key)
60
+ request.add_field(SDK_HEADER_NAME, SDK_HEADER_VALUE)
51
61
  request.set_form_data(data)
52
62
  send_request(request, uri)
53
63
  end
54
64
 
55
- def put_request(url, data)
56
- uri = URI.parse(@config[:host] + url)
65
+ def post_json_request(url, data, version: 'v1')
66
+ uri = URI.parse("#{@config[:host]}#{version}/#{url}")
67
+ request = Net::HTTP::Post.new(uri.request_uri, 'Content-Type' => 'application/json')
68
+ request.add_field(@config[:header], @api_key)
69
+ request.add_field(SDK_HEADER_NAME, SDK_HEADER_VALUE)
70
+ request.body = data.to_json
71
+ send_request(request, uri)
72
+ end
73
+
74
+ def put_request(url, data, version: 'v1')
75
+ uri = URI.parse("#{@config[:host]}#{version}/#{url}")
57
76
  request = Net::HTTP::Put.new(uri.request_uri)
58
77
  request.add_field(@config[:header], @api_key)
78
+ request.add_field(SDK_HEADER_NAME, SDK_HEADER_VALUE)
59
79
  request.set_form_data(data)
60
80
  send_request(request, uri)
61
81
  end
62
82
 
63
- def create_creative(data={}, image_path='')
64
- response = RestClient.post(@config[:host] + 'creative',
83
+ def put_json_request(url, data, version: 'v1')
84
+ uri = URI.parse("#{@config[:host]}#{version}/#{url}")
85
+ request = Net::HTTP::Put.new(uri.request_uri, 'Content-Type' => 'application/json')
86
+ request.add_field(@config[:header], @api_key)
87
+ request.add_field(SDK_HEADER_NAME, SDK_HEADER_VALUE)
88
+ request.body = data.to_json
89
+ send_request(request, uri)
90
+ end
91
+
92
+ def create_creative(data={}, image_path='', version: 'v1')
93
+ response = RestClient.post(@config[:host] + version + '/creative',
65
94
  {:creative => camelize_data(data).to_json},
66
- :X_Adzerk_ApiKey => @api_key,
67
- :content_type => :json,
68
- :accept => :json)
95
+ :X_Adzerk_ApiKey => @api_key,
96
+ :X_Adzerk_Sdk_Version => SDK_HEADER_VALUE,
97
+ :accept => :json)
69
98
  response = upload_creative(JSON.parse(response)["Id"], image_path) unless image_path.empty?
70
99
  response
71
100
  end
72
101
 
73
- def upload_creative(id, image_path)
102
+ def upload_creative(id, image_path, size_override: false, version: 'v1')
74
103
  image = File.new(image_path, 'rb')
75
- RestClient.post(@config[:host] + 'creative/' + id.to_s + '/upload',
104
+ url = @config[:host] + version + '/creative/' + id.to_s + '/upload'
105
+ url += '?sizeOverride=true' if size_override
106
+ RestClient.post(url,
76
107
  {:image => image},
77
108
  "X-Adzerk-ApiKey" => @api_key,
109
+ SDK_HEADER_NAME => SDK_HEADER_VALUE,
78
110
  :accept => :mime)
79
111
  end
80
112
 
@@ -82,9 +114,10 @@ module Adzerk
82
114
  http = Net::HTTP.new(uri.host, uri.port)
83
115
  http.use_ssl = uri.scheme == 'https'
84
116
  response = http.request(request)
85
- if response.kind_of? Net::HTTPClientError
117
+ if response.kind_of? Net::HTTPClientError or response.kind_of? Net::HTTPServerError
86
118
  error_response = JSON.parse(response.body)
87
- raise Adzerk::ApiError.new(error_response["message"])
119
+ msg = error_response["message"] || error_response["Error"] || response.body
120
+ raise Adzerk::ApiError.new(msg)
88
121
  end
89
122
  response
90
123
  end
@@ -8,8 +8,8 @@ module Adzerk
8
8
  uncamelize_data(JSON.parse(response))
9
9
  end
10
10
 
11
- def list(advertiserId)
12
- url = 'advertiser/' + advertiserId.to_s + "/creatives"
11
+ def list(advertiserId, page: 1, pageSize: 500)
12
+ url = "advertiser/#{advertiserId}/creatives?page=#{page}&pageSize=#{pageSize}"
13
13
  parse_response(@client.get_request(url))
14
14
  end
15
15
 
@@ -18,8 +18,8 @@ module Adzerk
18
18
  parse_response(@client.get_request(url))
19
19
  end
20
20
 
21
- def list(flight_id)
22
- url = "flight/#{flight_id}/creatives"
21
+ def list(flight_id, page: 1, pageSize: 500)
22
+ url = "flight/#{flight_id}/creatives?page=#{page}&#pageSize=#{pageSize}"
23
23
  parse_response(@client.get_request(url))
24
24
  end
25
25
 
@@ -34,5 +34,10 @@ module Adzerk
34
34
  @client.get_request(url)
35
35
  end
36
36
 
37
+ def instant_counts(creative_map_id)
38
+ url = "instantcounts/#{endpoint}/#{creative_map_id}"
39
+ parse_response(client.get_request(url))
40
+ end
41
+
37
42
  end
38
43
  end
@@ -0,0 +1,30 @@
1
+ module Adzerk
2
+ class CreativeTemplate
3
+
4
+ include Adzerk::Util
5
+
6
+ attr_reader :client
7
+
8
+ def initialize(args={})
9
+ @client = args[:client]
10
+ end
11
+
12
+ def create(data={})
13
+ parse_response(@client.post_json_request("creative-templates", camelize_data(data), version: 'v2'))
14
+ end
15
+
16
+ def update(id, data={})
17
+ url = "creative-templates/#{id}/update"
18
+ parse_response(@client.post_json_request(url, camelize_data(data), version: 'v2'))
19
+ end
20
+
21
+ def get(id)
22
+ parse_response(@client.get_request("creative-templates/#{id}", version: 'v2'))
23
+ end
24
+
25
+ def list(page: 1, pageSize: 100)
26
+ url = "creative-templates?page=#{page}&pageSize=#{pageSize}"
27
+ parse_response(@client.get_request(url, version: 'v2'))
28
+ end
29
+ end
30
+ end
@@ -8,5 +8,18 @@ module Adzerk
8
8
  url = 'region/' + region
9
9
  parse_reponse(@client.get_request(url))
10
10
  end
11
+
12
+ def instant_counts(flight_id)
13
+ url = "instantcounts/#{endpoint}/#{flight_id}"
14
+ parse_response(client.get_request(url))
15
+ end
16
+
17
+ def list_for_campaign(campaign_id, is_active = nil)
18
+ url = "campaign/#{campaign_id}/flight"
19
+ if !is_active.nil?
20
+ url = "#{url}?isActive=#{is_active}"
21
+ end
22
+ parse_response(@client.get_request(url))
23
+ end
11
24
  end
12
25
  end
@@ -0,0 +1,15 @@
1
+ module Adzerk
2
+ class InstantCount
3
+ include Adzerk::Util
4
+
5
+ def initialize(args={})
6
+ @client = args[:client]
7
+ end
8
+
9
+ def bulk(data={})
10
+ url = "instantcounts/bulk"
11
+ response = @client.post_json_request(url, data)
12
+ parse_response(response)
13
+ end
14
+ end
15
+ end
@@ -13,5 +13,19 @@ module Adzerk
13
13
  parse_response(response)
14
14
  end
15
15
 
16
+ def create(opts={}, subid=nil)
17
+ e = (subid && subendpoint) ? "#{subendpoint}/#{subid}/#{endpoint}" : endpoint
18
+ data = { datakey => camelize_data(opts).to_json }
19
+ response = @client.post_request(e, data)
20
+ parse_response(response)
21
+ end
22
+
23
+ def update(opts={})
24
+ id = opts[:id].to_s
25
+ data = { datakey => camelize_data(opts).to_json }
26
+ response = @client.put_request("#{endpoint}/#{id}", data)
27
+ parse_response(response)
28
+ end
29
+
16
30
  end
17
31
  end
@@ -1,6 +1,6 @@
1
1
  module Adzerk
2
2
  module Util
3
- extend self
3
+ extend self
4
4
 
5
5
  def camelize_data(data)
6
6
  return data unless data.respond_to?(:reduce)
@@ -1,3 +1,3 @@
1
1
  module Adzerk
2
- VERSION = "0.10"
2
+ VERSION = "0.15"
3
3
  end
@@ -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 is not part of your network")
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
@@ -106,9 +106,13 @@ describe "Category API" do
106
106
  @category.create(bad_id, $new_category)
107
107
  }.to raise_error "Flight is not a part of your network"
108
108
 
109
- expect {
110
- @category.list(bad_id)
111
- }.to raise_error "Flight is not a part of your network"
109
+ # Disabling this assertion temporarily.
110
+ # The API is no longer returning an error bur rather an empty list.
111
+ # Once the bug in API is fixed, this needs to be re-enabled.
112
+ #
113
+ # expect {
114
+ # @category.list(bad_id)
115
+ # }.to raise_error "Flight is not a part of your network"
112
116
 
113
117
  expect {
114
118
  @category.delete(bad_id,$category_id)
@@ -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 "This PassCreativeMap does not belong to your network."
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(
@@ -0,0 +1,96 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Creative Template API" do
4
+
5
+ before do
6
+ @creative_templates = Adzerk::Client.new(API_KEY).creative_templates
7
+ end
8
+
9
+ it "should create a new creative template" do
10
+ expected = {
11
+ description: 'Creative Template Description',
12
+ name: 'API Test Creative Template Name 1',
13
+ is_archived: false,
14
+ fields: [{
15
+ name: 'Title',
16
+ description: 'The Creative Template Title',
17
+ type: 'String',
18
+ variable: 'ctTitle',
19
+ required: true,
20
+ }, {
21
+ name: 'Thumbnail',
22
+ description: 'The URL of a Thumbnail Image',
23
+ type: 'String',
24
+ variable: 'ctThumbnailUrl',
25
+ required: false,
26
+ }],
27
+ contents: [{
28
+ type: 'Raw',
29
+ body: '{"title": "{{ctTitle}}", "thumbnailUrl": "{{ctThumbnailUrl}}" }'
30
+ }]
31
+ }
32
+
33
+ result = @creative_templates.create(expected)
34
+
35
+ $creative_template_id = result[:id].to_s
36
+
37
+ expect(result).to include(:id)
38
+ expect(result[:description]).to eq(expected[:description])
39
+ expect(result[:name]).to eq(expected[:name])
40
+ expect(result[:is_archived]).to eq(expected[:is_archived])
41
+ expect(result[:fields]).to match_array(expected[:fields])
42
+ end
43
+
44
+ it "should list existing creative templates" do
45
+ result = @creative_templates.list
46
+
47
+ expect(result[:page]).to eq(1)
48
+ expect(result[:page_size]).to eq(100)
49
+ expect(result[:total_items]).to be >= 1
50
+ end
51
+
52
+ it "should get an existing creative template" do
53
+ expected = {
54
+ description: 'Creative Template Description',
55
+ name: 'API Test Creative Template Name 1',
56
+ is_archived: false,
57
+ fields: [{
58
+ name: 'Title',
59
+ description: 'The Creative Template Title',
60
+ type: 'String',
61
+ variable: 'ctTitle',
62
+ required: true,
63
+ }, {
64
+ name: 'Thumbnail',
65
+ description: 'The URL of a Thumbnail Image',
66
+ type: 'String',
67
+ variable: 'ctThumbnailUrl',
68
+ required: false,
69
+ }],
70
+ contents: [{
71
+ type: 'Raw',
72
+ body: '{"title": "{{ctTitle}}", "thumbnailUrl": "{{ctThumbnailUrl}}" }'
73
+ }]
74
+ }
75
+
76
+ result = @creative_templates.get($creative_template_id)
77
+
78
+ expect(result[:description]).to eq(expected[:description])
79
+ expect(result[:name]).to eq(expected[:name])
80
+ expect(result[:is_archived]).to eq(expected[:is_archived])
81
+ expect(result[:fields]).to match_array(expected[:fields])
82
+ end
83
+
84
+ it "should update an existing creative template" do
85
+ update = {
86
+ updates: [{
87
+ path: ['IsArchived'],
88
+ value: true
89
+ }]
90
+ }
91
+
92
+ result = @creative_templates.update($creative_template_id, update)
93
+
94
+ expect(result[:is_archived]).to eq(true)
95
+ end
96
+ 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
@@ -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,25 @@
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
+ end
9
+
10
+ it "should fetch bulk instant counts" do
11
+ advertiser_id = 1065290
12
+ campaign_id = 1582611
13
+
14
+ counts = @instant_counts.bulk({
15
+ :advertisers => [advertiser_id],
16
+ :campaigns => [campaign_id]
17
+ })
18
+
19
+ expect(counts).to have_key(:advertisers)
20
+ expect(counts[:advertisers]).to have_key(advertiser_id.to_s.to_sym)
21
+
22
+ expect(counts).to have_key(:campaigns)
23
+ expect(counts[:campaigns]).to have_key(campaign_id.to_s.to_sym)
24
+ end
25
+ end
@@ -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 = "test@email_#{rand(1000000)}.com"
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
- expect(login[:password]).to eq("1234567")
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
@@ -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
@@ -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)
@@ -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
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.10'
4
+ version: '0.15'
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-02-23 00:00:00.000000000 Z
20
+ date: 2021-01-22 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: 2.11.0
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: 2.11.0
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: 1.7.7
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: 1.7.7
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: 1.6.9
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: 1.6.9
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: 3.2.8
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: 3.2.8
91
+ version: '5.1'
78
92
  description: Ruby library for the Adzerk API
79
93
  email: engineering@adzerk.com
80
94
  executables: []
@@ -84,14 +98,17 @@ files:
84
98
  - lib/adzerk.rb
85
99
  - lib/adzerk/advertiser.rb
86
100
  - lib/adzerk/api_endpoint.rb
101
+ - lib/adzerk/campaign.rb
87
102
  - lib/adzerk/category.rb
88
103
  - lib/adzerk/channel_site_map.rb
89
104
  - lib/adzerk/client.rb
90
105
  - lib/adzerk/creative.rb
91
106
  - lib/adzerk/creative_map.rb
107
+ - lib/adzerk/creative_template.rb
92
108
  - lib/adzerk/errors.rb
93
109
  - lib/adzerk/flight.rb
94
110
  - lib/adzerk/geo_targeting.rb
111
+ - lib/adzerk/instant_count.rb
95
112
  - lib/adzerk/invitation.rb
96
113
  - lib/adzerk/priority.rb
97
114
  - lib/adzerk/publisher.rb
@@ -107,8 +124,10 @@ files:
107
124
  - test/channel_site_map_api_spec.rb
108
125
  - test/creative_api_spec.rb
109
126
  - test/creative_map_api_spec.rb
127
+ - test/creative_template_spec.rb
110
128
  - test/flight_api_spec.rb
111
129
  - test/geo_targeting_api_spec.rb
130
+ - test/instant_count_api_spec.rb
112
131
  - test/invitation_api_spec.rb
113
132
  - test/login_api_spec.rb
114
133
  - test/priority_api_spec.rb
@@ -122,7 +141,8 @@ files:
122
141
  - test/util_spec.rb
123
142
  - test/zone_api_spec.rb
124
143
  homepage: http://adzerk.com
125
- licenses: []
144
+ licenses:
145
+ - Apache-2.0
126
146
  metadata: {}
127
147
  post_install_message:
128
148
  rdoc_options: []
@@ -139,8 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
159
  - !ruby/object:Gem::Version
140
160
  version: '0'
141
161
  requirements: []
142
- rubyforge_project:
143
- rubygems_version: 2.5.1
162
+ rubygems_version: 3.1.2
144
163
  signing_key:
145
164
  specification_version: 4
146
165
  summary: Adzerk API