adzerk 0.1.4 → 0.2
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.
- data/lib/adzerk.rb +15 -0
- data/lib/adzerk/advertiser.rb +9 -0
- data/lib/adzerk/api_endpoint.rb +41 -0
- data/lib/adzerk/channel_site_map.rb +53 -0
- data/lib/adzerk/client.rb +80 -0
- data/lib/adzerk/creative.rb +17 -0
- data/lib/adzerk/creative_map.rb +38 -0
- data/lib/adzerk/flight.rb +12 -0
- data/lib/adzerk/invitation.rb +23 -0
- data/lib/adzerk/publisher.rb +17 -0
- data/lib/adzerk/reporting.rb +21 -0
- data/lib/adzerk/util.rb +37 -0
- data/lib/adzerk/version.rb +3 -0
- data/test/advertiser_api_spec.rb +57 -82
- data/test/campaign_api_spec.rb +150 -271
- data/test/channel_api_spec.rb +72 -79
- data/test/channel_site_map_api_spec.rb +43 -94
- data/test/creative_api_spec.rb +82 -251
- data/test/creative_map_api_spec.rb +291 -375
- data/test/flight_api_spec.rb +165 -493
- data/test/invitation_api_spec.rb +18 -41
- data/test/login_api_spec.rb +24 -49
- data/test/priority_api_spec.rb +53 -83
- data/test/publisher_api_spec.rb +71 -142
- data/test/rakefile.rb +7 -7
- data/test/report_api_spec.rb +18 -24
- data/test/security_api_spec.rb +21 -0
- data/test/site_api_spec.rb +37 -51
- data/test/spec_helper.rb +4 -17
- data/test/zone_api_spec.rb +38 -64
- metadata +61 -23
- data/lib/Adzerk.rb +0 -55
- data/lib/adzerk/Advertiser.rb +0 -39
- data/lib/adzerk/Campaign.rb +0 -33
- data/lib/adzerk/Channel.rb +0 -33
- data/lib/adzerk/ChannelSiteMap.rb +0 -44
- data/lib/adzerk/Creative.rb +0 -43
- data/lib/adzerk/CreativeMap.rb +0 -33
- data/lib/adzerk/Flight.rb +0 -44
- data/lib/adzerk/Invitation.rb +0 -17
- data/lib/adzerk/Login.rb +0 -28
- data/lib/adzerk/Priority.rb +0 -34
- data/lib/adzerk/Publisher.rb +0 -47
- data/lib/adzerk/Reporting.rb +0 -16
- data/lib/adzerk/Site.rb +0 -35
- data/lib/adzerk/Zone.rb +0 -35
- data/test/channel_api_security_spec.rb +0 -51
- data/test/csv_export_spec.rb +0 -89
- data/test/delivery-test.rb +0 -132
- data/test/test.rb +0 -43
- data/test/test2.rb +0 -175
data/test/channel_api_spec.rb
CHANGED
@@ -1,42 +1,44 @@
|
|
1
|
-
require '
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
3
|
describe "Channel API" do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
|
5
|
+
before do
|
6
|
+
@channel_url = 'http://www.adzerk.com'
|
7
|
+
@channels = Adzerk::Client.new(API_KEY).channels
|
8
|
+
end
|
9
|
+
|
8
10
|
it "should create a new channel" do
|
9
11
|
$channel_title = 'Test Channel ' + rand(1000000).to_s
|
10
12
|
$channel_commission = '0.00'
|
11
13
|
$channel_engine = 'CPM'
|
12
14
|
$channel_keywords = 'test, another test'
|
13
|
-
$
|
14
|
-
$
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
$
|
27
|
-
$
|
28
|
-
$channel_commission.to_f.should == JSON.parse(response.body)["Commission"]
|
29
|
-
$channel_engine.should == JSON.parse(response.body)["Engine"]
|
30
|
-
$channel_keywords.should == JSON.parse(response.body)["Keywords"]
|
31
|
-
$channel_CPM.to_f.should == JSON.parse(response.body)["CPM"]
|
32
|
-
$channel_AdTypes.should == JSON.parse(response.body)["AdTypes"]
|
15
|
+
$channel_cpm = '10.00'
|
16
|
+
$channel_ad_types = [1,2,3,4,5]
|
17
|
+
channel = @channels.create(:title => $channel_title,
|
18
|
+
:commission => $channel_commission,
|
19
|
+
:engine => $channel_engine,
|
20
|
+
:keywords => $channel_keywords,
|
21
|
+
:ad_types => $channel_ad_types,
|
22
|
+
'CPM' => $channel_cpm)
|
23
|
+
$channel_id = channel[:id].to_s
|
24
|
+
$channel_title.should == channel[:title]
|
25
|
+
$channel_commission.to_f.should == channel[:commission]
|
26
|
+
$channel_engine.should == channel[:engine]
|
27
|
+
$channel_keywords.should == channel[:keywords]
|
28
|
+
$channel_cpm.to_f.should == channel[:cpm]
|
29
|
+
$channel_ad_types.should == channel[:ad_types]
|
33
30
|
end
|
34
|
-
|
31
|
+
|
35
32
|
it "should list a specific channel" do
|
36
|
-
|
37
|
-
|
33
|
+
channel = @channels.get($channel_id)
|
34
|
+
$channel_title.should == channel[:title]
|
35
|
+
$channel_commission.to_f.should == channel[:commission]
|
36
|
+
$channel_engine.should == channel[:engine]
|
37
|
+
$channel_keywords.should == channel[:keywords]
|
38
|
+
$channel_cpm.to_f.should == channel[:cpm]
|
39
|
+
$channel_ad_types.should == channel[:ad_types]
|
38
40
|
end
|
39
|
-
|
41
|
+
|
40
42
|
it "should update a channel" do
|
41
43
|
$u_channel_title = 'Test Channel ' + rand(1000000).to_s + 'test'
|
42
44
|
$u_channel_commission = '1.0'
|
@@ -44,68 +46,59 @@ describe "Channel API" do
|
|
44
46
|
$u_channel_keywords = 'another test'
|
45
47
|
$u_channel_CPM = '0'
|
46
48
|
$u_channel_AdTypes = [4,5,6,7,8]
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
$
|
60
|
-
$
|
61
|
-
|
62
|
-
$
|
63
|
-
$u_channel_keywords.should == JSON.parse(response.body)["Keywords"]
|
64
|
-
$u_channel_CPM.to_f.should == JSON.parse(response.body)["CPM"]
|
65
|
-
$u_channel_AdTypes.should == JSON.parse(response.body)["AdTypes"]
|
49
|
+
|
50
|
+
channel = @channels.
|
51
|
+
update(:id => $channel_id,
|
52
|
+
:title => $u_channel_title,
|
53
|
+
:commission => $u_channel_commission,
|
54
|
+
:engine => $u_channel_engine,
|
55
|
+
:keywords => $u_channel_keywords,
|
56
|
+
:ad_types => $u_channel_AdTypes,
|
57
|
+
'CPM' => $u_channel_CPM)
|
58
|
+
|
59
|
+
$u_channel_title.should == channel[:title]
|
60
|
+
$u_channel_commission.should == channel[:commission].to_s
|
61
|
+
$u_channel_engine.should == channel[:engine]
|
62
|
+
$u_channel_keywords.should == channel[:keywords]
|
63
|
+
$u_channel_CPM.to_f.should == channel[:cpm]
|
64
|
+
$u_channel_AdTypes.should == channel[:ad_types]
|
66
65
|
end
|
67
|
-
|
66
|
+
|
68
67
|
it "should list all channels" do
|
69
|
-
result =
|
68
|
+
result = @channels.list
|
70
69
|
result.length.should > 0
|
71
|
-
result[
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
70
|
+
last_channel = result[:items].last
|
71
|
+
last_channel[:id].to_s.should == $channel_id
|
72
|
+
last_channel[:title].should == $u_channel_title
|
73
|
+
last_channel[:commission].should == $u_channel_commission.to_f
|
74
|
+
last_channel[:engine].should == $u_channel_engine
|
75
|
+
last_channel[:keywords].should == $u_channel_keywords
|
76
|
+
last_channel[:cpm].should == $u_channel_CPM.to_f
|
77
|
+
last_channel[:ad_types].should == $u_channel_AdTypes
|
78
78
|
end
|
79
|
-
|
79
|
+
|
80
80
|
it "should delete a new channel" do
|
81
|
-
response =
|
82
|
-
response.body.should == '
|
83
|
-
end
|
84
|
-
|
85
|
-
it "should not list deleted channels" do
|
86
|
-
result = @@channel.list()
|
87
|
-
result["Items"].each do |r|
|
88
|
-
r["Id"].to_s.should_not == $channel_id
|
89
|
-
end
|
81
|
+
response = @channels.delete($channel_id)
|
82
|
+
response.body.should == '"Successfully deleted"'
|
90
83
|
end
|
91
|
-
|
84
|
+
|
92
85
|
it "should not get individual deleted channel" do
|
93
|
-
response =
|
94
|
-
response.
|
86
|
+
response = @channels.get($channel_id)
|
87
|
+
response[:message].should == 'This channel has been deleted'
|
95
88
|
end
|
96
|
-
|
89
|
+
|
97
90
|
it "should not update deleted channels" do
|
98
91
|
updated_channel = {
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
92
|
+
:id => $channel_id,
|
93
|
+
:title => $u_channel_title + "test",
|
94
|
+
:commission => $u_channel_commission,
|
95
|
+
:engine => $u_channel_engine,
|
96
|
+
:keywords => $u_channel_keywords,
|
104
97
|
'CPM' => $u_channel_CPM,
|
105
|
-
|
98
|
+
:ad_types => $u_channel_AdTypes
|
106
99
|
}
|
107
|
-
response =
|
108
|
-
response.
|
100
|
+
response = @channels.update(updated_channel)
|
101
|
+
response[:message].should == "This channel has been deleted"
|
109
102
|
end
|
110
103
|
|
111
104
|
end
|
@@ -1,125 +1,74 @@
|
|
1
|
-
require 'spec_helper'
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
3
|
describe "Channel Site Map API" do
|
4
|
-
|
5
|
-
$site_url = 'http://www.adzerk.com'
|
6
|
-
@@csm = $adzerk::ChannelSiteMap.new
|
7
|
-
@@channel = $adzerk::Channel.new
|
8
|
-
@@site = $adzerk::Site.new
|
9
4
|
|
10
5
|
before(:all) do
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
6
|
+
client = Adzerk::Client.new(API_KEY)
|
7
|
+
@csm = client.channel_site_maps
|
8
|
+
@sites = client.sites
|
9
|
+
@channels = client.channels
|
10
|
+
channel = @channels.create(:title => 'Test Channel ' + rand(1000000).to_s,
|
11
|
+
:commission => '0.0',
|
12
|
+
:engine => 'CPM',
|
13
|
+
:keywords => 'test',
|
14
|
+
'CPM' => '10.00',
|
15
|
+
:ad_types => [1,2,3,4])
|
16
|
+
@channel_id = channel[:id]
|
22
17
|
new_site = {
|
23
|
-
|
24
|
-
|
18
|
+
:title => 'Test Site ' + rand(1000000).to_s,
|
19
|
+
:url => 'http://www.adzerk.com'
|
25
20
|
}
|
26
|
-
|
27
|
-
|
21
|
+
site = @sites.create(new_site)
|
22
|
+
@site_id = site[:id]
|
28
23
|
end
|
29
|
-
|
24
|
+
|
30
25
|
it "should create a new map" do
|
31
26
|
new_map = {
|
32
|
-
|
33
|
-
|
34
|
-
|
27
|
+
:site_id => @site_id,
|
28
|
+
:channel_id => @channel_id,
|
29
|
+
:priority => 10
|
35
30
|
}
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
31
|
+
channel_site_map = @csm.create(new_map)
|
32
|
+
channel_site_map[:site_id].should eq(@site_id)
|
33
|
+
channel_site_map[:channel_id].should eq(@channel_id)
|
34
|
+
channel_site_map[:priority].should eq(10)
|
40
35
|
end
|
41
36
|
|
42
37
|
it "should retrieve a list of sites in a channel" do
|
43
|
-
|
44
|
-
|
38
|
+
sites = @csm.sites_in_channel(@channel_id)
|
39
|
+
sites[:site_ids].should include(@site_id)
|
45
40
|
end
|
46
41
|
|
47
42
|
it "should retrieve a list of channels in a site" do
|
48
|
-
|
49
|
-
|
43
|
+
channels = @csm.channels_in_site(@site_id)
|
44
|
+
channels[:channel_ids].should include(@channel_id)
|
50
45
|
end
|
51
|
-
|
46
|
+
|
52
47
|
it "should list a specific map" do
|
53
|
-
|
54
|
-
|
48
|
+
channel_site_map = @csm.get(@channel_id, @site_id)
|
49
|
+
channel_site_map[:site_id].should eq(@site_id)
|
50
|
+
channel_site_map[:channel_id].should eq(@channel_id)
|
51
|
+
channel_site_map[:priority].should eq(10)
|
55
52
|
end
|
56
53
|
|
57
54
|
it "should update a map" do
|
58
55
|
u_map = {
|
59
|
-
|
60
|
-
|
61
|
-
|
56
|
+
:site_id => @site_id,
|
57
|
+
:channel_id => @channel_id,
|
58
|
+
:priority => 200
|
62
59
|
}
|
63
|
-
|
64
|
-
|
65
|
-
JSON.parse(response.body)["ChannelId"].should == $channelId
|
66
|
-
JSON.parse(response.body)["Priority"].should == 200
|
60
|
+
channel_map = @csm.update(u_map)
|
61
|
+
channel_map[:priority].should eq(200)
|
67
62
|
end
|
68
63
|
|
69
64
|
it "should list all maps for network" do
|
70
|
-
|
71
|
-
|
72
|
-
result["Items"].last["SiteId"].should == $siteId
|
73
|
-
result["Items"].last["ChannelId"].should == $channelId
|
74
|
-
result["Items"].last["Priority"].should == 200
|
65
|
+
channel_maps = @csm.list
|
66
|
+
channel_maps[:items].last[:site_id].should eq(@site_id)
|
75
67
|
end
|
76
68
|
|
77
69
|
it "should delete a new maps" do
|
78
|
-
response =
|
79
|
-
response.body.should == '
|
80
|
-
end
|
81
|
-
|
82
|
-
it "should not list deleted maps" do
|
83
|
-
result = @@csm.list()
|
84
|
-
#result["Items"].each do |r|
|
85
|
-
# r["SiteId"].should_not == $siteId and
|
86
|
-
# r["ChannelId"].should_not == $channelId
|
87
|
-
#end
|
88
|
-
end
|
89
|
-
|
90
|
-
it "should not get individual deleted maps" do
|
91
|
-
response = @@csm.get($channelId, $siteId)
|
92
|
-
response.body.should == '{"SiteId":0,"ChannelId":0,"Priority":0}'
|
93
|
-
end
|
94
|
-
|
95
|
-
it "should not update deleted maps" do
|
96
|
-
u_map = {
|
97
|
-
'SiteId' => $siteId,
|
98
|
-
'ChannelId' => $channelId,
|
99
|
-
'Priority' => 300
|
100
|
-
}
|
101
|
-
response = @@csm.update(u_map)
|
102
|
-
response.body.should == '{"SiteId":0,"ChannelId":0,"Priority":0}'
|
103
|
-
end
|
104
|
-
|
105
|
-
it "should not create if the site is in a different network" do
|
106
|
-
new_map = {
|
107
|
-
'SiteId' => 1,
|
108
|
-
'ChannelId' => $channelId,
|
109
|
-
'Priority' => 10
|
110
|
-
}
|
111
|
-
response = @@csm.create(new_map)
|
112
|
-
true.should == response.body.scan(/This site is not part of your network/).length > 1
|
113
|
-
end
|
114
|
-
|
115
|
-
it "should not create if the channel is in a different netowork" do
|
116
|
-
new_map = {
|
117
|
-
'SiteId' => $siteId,
|
118
|
-
'ChannelId' => 1,
|
119
|
-
'Priority' => 10
|
120
|
-
}
|
121
|
-
response = @@csm.create(new_map)
|
122
|
-
true.should == response.body.scan(/This channel is not part of your network/).length > 1
|
70
|
+
response = @csm.delete(@channel_id, @site_id)
|
71
|
+
response.body.should == '"Successfully deleted."'
|
123
72
|
end
|
124
73
|
|
125
|
-
end
|
74
|
+
end
|
data/test/creative_api_spec.rb
CHANGED
@@ -1,280 +1,111 @@
|
|
1
|
-
require '
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
3
|
describe "Creative API" do
|
4
|
-
|
5
|
-
$creative_url = 'http://www.adzerk.com'
|
6
|
-
@@creative = $adzerk::Creative.new
|
7
|
-
@@advertiser = $adzerk::Advertiser.new
|
8
|
-
|
4
|
+
|
9
5
|
before(:all) do
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
response = @@advertiser.create(new_advertiser)
|
14
|
-
$advertiserId = JSON.parse(response.body)["Id"]
|
6
|
+
client = Adzerk::Client.new(API_KEY)
|
7
|
+
@creatives = client.creatives
|
8
|
+
@advertiser_id = client.advertisers.create(:title => "Test")[:id]
|
15
9
|
end
|
16
|
-
|
10
|
+
|
17
11
|
it "should create a creative using old api spec" do
|
18
|
-
$Title = 'Test creative ' + rand(1000000).to_s
|
19
|
-
$ImageName = ""
|
20
|
-
$Url = "http://adzerk.com"
|
21
|
-
$Body = "Test text"
|
22
|
-
$AdvertiserId = $advertiserId
|
23
|
-
$AdTypeId = 18
|
24
|
-
$IsActive = true
|
25
|
-
$Alt = "test alt"
|
26
|
-
$IsDeleted = false
|
27
|
-
$IsSync = false
|
28
|
-
$IsHTMLJS = true
|
29
|
-
$ScriptBody = "<html>"
|
30
12
|
new_creative = {
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
13
|
+
:title => 'Test Creative Old API',
|
14
|
+
:image_name => "",
|
15
|
+
:url => "http://adzerk.com",
|
16
|
+
:body => "Test Body",
|
17
|
+
:advertiser_id => @advertiser_id,
|
18
|
+
:ad_type_id => 18,
|
19
|
+
:is_active => true,
|
20
|
+
:alt => 'test alt',
|
21
|
+
:is_deleted => false,
|
22
|
+
:is_sync => false
|
41
23
|
}
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
24
|
+
creative_path = File.expand_path(File.dirname(__FILE__) + '/' + '250x250.gif')
|
25
|
+
creative = @creatives.create(new_creative, creative_path)
|
26
|
+
$creative_id = creative[:id].to_s
|
27
|
+
creative[:title].should eq('Test Creative Old API')
|
28
|
+
creative[:url].should eq("http://adzerk.com")
|
29
|
+
creative[:body].should eq("Test Body")
|
30
|
+
creative[:advertiser_id].should eq(@advertiser_id)
|
31
|
+
creative[:ad_type_id].should eq(18)
|
32
|
+
creative[:is_active].should eq(true)
|
33
|
+
creative[:alt].should eq('test alt')
|
34
|
+
creative[:is_deleted].should eq(false)
|
35
|
+
creative[:is_sync].should eq(false)
|
53
36
|
end
|
54
37
|
|
55
38
|
it "should create a creative using new api fields" do
|
56
39
|
new_creative = {
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
'
|
68
|
-
|
40
|
+
:title => "Creative with the new API",
|
41
|
+
:image_name => "",
|
42
|
+
:url => "http://adzerk.com",
|
43
|
+
:body => "Test Body",
|
44
|
+
:advertiser_id => @advertiser_id,
|
45
|
+
:ad_type_id => 18,
|
46
|
+
:is_active => true,
|
47
|
+
:alt => "alt text",
|
48
|
+
:is_deleted => false,
|
49
|
+
:is_sync => true,
|
50
|
+
'isHTMLJS' => true,
|
51
|
+
:script_body => "<html></html>"
|
69
52
|
}
|
70
|
-
|
71
|
-
$creative_id =
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
JSON.parse(response.body)["IsHTMLJS"].should == $IsHTMLJS
|
82
|
-
JSON.parse(response.body)["ScriptBody"].should == $ScriptBody
|
53
|
+
creative = @creatives.create(new_creative)
|
54
|
+
$creative_id = creative[:id].to_s
|
55
|
+
creative[:title].should eq('Creative with the new API')
|
56
|
+
creative[:url].should eq("http://adzerk.com")
|
57
|
+
creative[:body].should eq("Test Body")
|
58
|
+
creative[:advertiser_id].should eq(@advertiser_id)
|
59
|
+
creative[:ad_type_id].should eq(18)
|
60
|
+
creative[:is_active].should eq(true)
|
61
|
+
creative[:alt].should eq('alt text')
|
62
|
+
creative[:is_deleted].should eq(false)
|
63
|
+
creative[:is_sync].should eq(false)
|
83
64
|
end
|
84
65
|
|
85
66
|
it "should get a specific creative" do
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
JSON.parse(response.body)["IsSync"].should == $IsSync
|
67
|
+
creative = @creatives.get($creative_id)
|
68
|
+
creative[:title].should eq('Creative with the new API')
|
69
|
+
creative[:url].should eq("http://adzerk.com")
|
70
|
+
creative[:body].should eq("Test Body")
|
71
|
+
creative[:advertiser_id].should eq(@advertiser_id)
|
72
|
+
creative[:ad_type_id].should eq(18)
|
73
|
+
creative[:is_active].should eq(true)
|
74
|
+
creative[:alt].should eq('alt text')
|
75
|
+
creative[:is_deleted].should eq(false)
|
76
|
+
creative[:is_sync].should eq(false)
|
97
77
|
end
|
98
78
|
|
99
79
|
it "should update a specific creative" do
|
100
80
|
update_creative = {
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
'IsSync' => $IsSync
|
112
|
-
}
|
113
|
-
response = @@creative.update(update_creative)
|
114
|
-
JSON.parse(response.body)["Id"].should == $creative_id.to_i
|
115
|
-
JSON.parse(response.body)["Title"].should == $Title
|
116
|
-
JSON.parse(response.body)["Url"].should == $Url
|
117
|
-
JSON.parse(response.body)["Body"].should == $Body
|
118
|
-
JSON.parse(response.body)["AdvertiserId"].should == $AdvertiserId
|
119
|
-
JSON.parse(response.body)["AdTypeId"].should == $AdTypeId
|
120
|
-
JSON.parse(response.body)["IsActive"].should == $IsActive
|
121
|
-
JSON.parse(response.body)["Alt"].should == $Alt
|
122
|
-
JSON.parse(response.body)["IsDeleted"].should == $IsDeleted
|
123
|
-
JSON.parse(response.body)["IsSync"].should == $IsSync
|
124
|
-
end
|
125
|
-
|
126
|
-
it "should update a specific creative with html ad" do
|
127
|
-
update_creative = {
|
128
|
-
'Id' => $creative_id.to_i,
|
129
|
-
'Title' => $Title,
|
130
|
-
'ImageName' => $ImageName,
|
131
|
-
'Url' => $Url,
|
132
|
-
'Body' => $Body,
|
133
|
-
'AdvertiserId' => $AdvertiserId,
|
134
|
-
'AdTypeId' => $AdTypeId,
|
135
|
-
'IsActive' => $IsActive,
|
136
|
-
'Alt' => $Alt,
|
137
|
-
'IsDeleted' => $IsDeleted,
|
138
|
-
'IsSync' => $IsSync,
|
139
|
-
'IsHTMLJS' => true,
|
140
|
-
'ScriptBody' => "<html></html>"
|
81
|
+
:id => $creative_id.to_i,
|
82
|
+
:title => "Updated Title",
|
83
|
+
:url => 'http://www.google.com',
|
84
|
+
:body => 'new body',
|
85
|
+
:advertiser_id => @advertiser_id,
|
86
|
+
:ad_type_id => 18,
|
87
|
+
:is_active => true,
|
88
|
+
:alt => 'new alt text',
|
89
|
+
:is_deleted => false,
|
90
|
+
:is_sync => false
|
141
91
|
}
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
JSON.parse(response.body)["Body"].should == $Body
|
147
|
-
JSON.parse(response.body)["AdvertiserId"].should == $AdvertiserId
|
148
|
-
JSON.parse(response.body)["AdTypeId"].should == $AdTypeId
|
149
|
-
JSON.parse(response.body)["IsActive"].should == $IsActive
|
150
|
-
JSON.parse(response.body)["Alt"].should == $Alt
|
151
|
-
JSON.parse(response.body)["IsDeleted"].should == $IsDeleted
|
152
|
-
JSON.parse(response.body)["IsSync"].should == $IsSync
|
153
|
-
JSON.parse(response.body)["IsHTMLJS"].should == true
|
154
|
-
JSON.parse(response.body)["ScriptBody"].should == "<html></html>"
|
92
|
+
creative = @creatives.update(update_creative)
|
93
|
+
creative[:title].should eq('Updated Title')
|
94
|
+
creative[:url].should eq('http://www.google.com')
|
95
|
+
creative[:body].should eq('new body')
|
155
96
|
end
|
156
97
|
|
157
98
|
|
158
99
|
it "should list all creatives for an advertiser" do
|
159
|
-
response =
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
JSON.parse(entry)["Url"].should == $Url
|
164
|
-
JSON.parse(entry)["Body"].should == $Body
|
165
|
-
JSON.parse(entry)["AdvertiserId"].should == $AdvertiserId
|
166
|
-
JSON.parse(entry)["AdTypeId"].should == $AdTypeId
|
167
|
-
JSON.parse(entry)["IsActive"].should == $IsActive
|
168
|
-
JSON.parse(entry)["Alt"].should == $Alt
|
169
|
-
JSON.parse(entry)["IsDeleted"].should == $IsDeleted
|
170
|
-
JSON.parse(entry)["IsSync"].should == $IsSync
|
100
|
+
response = @creatives.list(@advertiser_id)
|
101
|
+
creative = response[:items].last
|
102
|
+
creative[:url].should eq('http://www.google.com')
|
103
|
+
creative[:body].should eq('new body')
|
171
104
|
end
|
172
105
|
|
173
|
-
#it "should update a creative with no adtype and preserve the adtype" do
|
174
|
-
#updated_creative = {
|
175
|
-
#'Id' => $creative_id,
|
176
|
-
#'Title' => 'test',
|
177
|
-
#'Body' => 'test',
|
178
|
-
#'AdvertiserId' => $advertiserId,
|
179
|
-
##'AdTypeId' => 18,
|
180
|
-
#'IsActive' => true,
|
181
|
-
#'Alt' => "",
|
182
|
-
#'IsDeleted' => false,
|
183
|
-
#'IsSync' => false
|
184
|
-
#}
|
185
|
-
#response = @@creative.update(updated_creative)
|
186
|
-
#JSON.parse(response.body)["Title"].should == 'test'
|
187
|
-
#JSON.parse(response.body)["Body"].should == 'test'
|
188
|
-
#JSON.parse(response.body)["AdvertiserId"].should == $advertiserId
|
189
|
-
#JSON.parse(response.body)["AdTypeId"].should == $AdTypeId
|
190
|
-
#end
|
191
|
-
|
192
106
|
it "should delete the creatives after creating it" do
|
193
|
-
response =
|
194
|
-
response.body.should == "
|
195
|
-
end
|
196
|
-
|
197
|
-
it "should not use a AdvertiserId it doesn't have access to when creating" do
|
198
|
-
new_creative = {
|
199
|
-
'Title' => $Title,
|
200
|
-
'ImageName' => $ImageName,
|
201
|
-
'Url' => $Url,
|
202
|
-
'Body' => $Body,
|
203
|
-
'AdvertiserId' => 1,
|
204
|
-
'AdTypeId' => $AdTypeId,
|
205
|
-
'IsActive' => $IsActive,
|
206
|
-
'Alt' => $Alt,
|
207
|
-
'IsDeleted' => $IsDeleted,
|
208
|
-
'IsSync' => $IsSync
|
209
|
-
}
|
210
|
-
begin
|
211
|
-
response = @@creative.create(new_creative)
|
212
|
-
rescue Exception => e
|
213
|
-
response = e
|
214
|
-
end
|
215
|
-
|
216
|
-
response.to_s.scan("302 Found").should_not == nil
|
217
|
-
end
|
218
|
-
|
219
|
-
it "should not use a AdvertiserId it doesn't have access to when updating" do
|
220
|
-
new_creative = {
|
221
|
-
'Id' => $creative_id.to_i,
|
222
|
-
'Title' => $Title,
|
223
|
-
'ImageName' => $ImageName,
|
224
|
-
'Url' => $Url,
|
225
|
-
'Body' => $Body,
|
226
|
-
'AdvertiserId' => 1,
|
227
|
-
'AdTypeId' => $AdTypeId,
|
228
|
-
'IsActive' => $IsActive,
|
229
|
-
'Alt' => $Alt,
|
230
|
-
'IsDeleted' => $IsDeleted,
|
231
|
-
'IsSync' => $IsSync
|
232
|
-
}
|
233
|
-
response = @@creative.update(new_creative)
|
234
|
-
true.should == !response.body.scan(/Object/).nil?
|
235
|
-
end
|
236
|
-
|
237
|
-
it "should not retrieve a creative it doesn't have access to" do
|
238
|
-
response = @@creative.get("123")
|
239
|
-
true.should == !response.body.scan(/Object/).nil?
|
240
|
-
end
|
241
|
-
|
242
|
-
it "should not delete a creative it doesn't have access to" do
|
243
|
-
response = @@creative.delete("123")
|
244
|
-
true.should == !response.body.scan(/Object/).nil?
|
245
|
-
end
|
246
|
-
|
247
|
-
it "should create a creative with no url or image name passed in" do
|
248
|
-
$Url = "http://adzerk.com"
|
249
|
-
$Body = "Test text"
|
250
|
-
$AdvertiserId = $advertiserId
|
251
|
-
$AdTypeId = 18
|
252
|
-
$IsActive = true
|
253
|
-
$Alt = "test alt"
|
254
|
-
$IsDeleted = false
|
255
|
-
$IsSync = false
|
256
|
-
|
257
|
-
new_creative = {
|
258
|
-
'Title' => $Title,
|
259
|
-
'Body' => $Body,
|
260
|
-
'AdvertiserId' => $AdvertiserId,
|
261
|
-
'AdTypeId' => $AdTypeId,
|
262
|
-
'IsActive' => $IsActive,
|
263
|
-
'Alt' => $Alt,
|
264
|
-
'IsDeleted' => $IsDeleted,
|
265
|
-
'IsSync' => $IsSync
|
266
|
-
}
|
267
|
-
response = @@creative.create(new_creative, '250x250.gif')
|
268
|
-
$creative_id = JSON.parse(response)["Id"].to_s
|
269
|
-
JSON.parse(response.body)["Title"].should == $Title
|
270
|
-
JSON.parse(response.body)["Body"].should == $Body
|
271
|
-
JSON.parse(response.body)["AdvertiserId"].should == $AdvertiserId
|
272
|
-
JSON.parse(response.body)["AdTypeId"].should == $AdTypeId
|
273
|
-
JSON.parse(response.body)["IsActive"].should == $IsActive
|
274
|
-
JSON.parse(response.body)["Alt"].should == $Alt
|
275
|
-
JSON.parse(response.body)["IsDeleted"].should == $IsDeleted
|
276
|
-
JSON.parse(response.body)["IsSync"].should == $IsSync
|
277
|
-
|
107
|
+
response = @creatives.delete($creative_id)
|
108
|
+
response.body.should == '"Successfully deleted"'
|
278
109
|
end
|
279
110
|
|
280
|
-
end
|
111
|
+
end
|