adzerk 0.1.2 → 0.1.3

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.
@@ -0,0 +1,132 @@
1
+ require './spec_helper.rb'
2
+
3
+ describe "Testing out delivery" do
4
+
5
+ @@flight = $adzerk::Flight.new
6
+ @@advertiser = $adzerk::Advertiser.new
7
+ @@channel = $adzerk::Channel.new
8
+ @@campaign = $adzerk::Campaign.new
9
+ @@priority = $adzerk::Priority.new
10
+ @@map = $adzerk::CreativeMap.new
11
+ @@publisher = $adzerk::Publisher.new
12
+
13
+ before(:all) do
14
+ new_advertiser = {
15
+ 'Title' => "Test"
16
+ }
17
+ response = @@advertiser.create(new_advertiser)
18
+ $advertiserId = JSON.parse(response.body)["Id"]
19
+
20
+ new_channel = {
21
+ 'Title' => 'Test Channel ' + rand(1000000).to_s,
22
+ 'Commission' => '0',
23
+ 'Engine' => 'CPM',
24
+ 'Keywords' => 'test',
25
+ 'CPM' => '10.00',
26
+ 'AdTypes' => [1,2,3,4]
27
+ }
28
+ response = @@channel.create(new_channel)
29
+ $channelId = JSON.parse(response.body)["Id"]
30
+
31
+ new_priority = {
32
+ 'Name' => "High Priority Test",
33
+ 'ChannelId' => $channelId,
34
+ 'Weight' => 1,
35
+ 'IsDeleted' => false
36
+ }
37
+ response = @@priority.create(new_priority)
38
+ $priority_id = JSON.parse(response.body)["Id"].to_s
39
+
40
+ new_campaign = {
41
+ 'Name' => 'Test campaign ' + rand(1000000).to_s,
42
+ 'StartDate' => "1/1/2011",
43
+ 'EndDate' => "12/31/2011",
44
+ 'IsActive' => true,
45
+ 'Price' => '10.00',
46
+ 'AdvertiserId' => $advertiserId,
47
+ 'Flights' => [],
48
+ 'IsDeleted' => false
49
+ }
50
+ response = @@campaign.create(new_campaign)
51
+ $campaignId = JSON.parse(response.body)["Id"]
52
+
53
+ rand = rand(1000000).to_s
54
+ new_publisher = {
55
+ 'FirstName' => 'Test ' + rand,
56
+ 'LastName' => 'Person ' + rand,
57
+ 'CompanyName' => 'Company ' + rand,
58
+ 'Address' => {
59
+ 'Line1' => rand + 'st',
60
+ 'Line2' => 'Apt. ' + rand,
61
+ 'City' => rand + 'ville',
62
+ 'StateProvince' => 'NC',
63
+ 'PostalCode' => rand.to_s,
64
+ 'Country' => 'USA'
65
+ },
66
+ 'PaymentOption' => "1",
67
+ 'PaypalEmail' => 'Test' + rand + '@test.com'
68
+ }
69
+ response = @@publisher.create(new_publisher)
70
+ $publisherId = JSON.parse(response.body)["Id"].to_s
71
+ end
72
+
73
+ it "should create a flight" do
74
+ new_flight = {
75
+ 'NoEndDate' => false,
76
+ 'PriorityId' => $priority_id,
77
+ 'Name' => 'Test flight ' + rand(1000000).to_s,
78
+ 'StartDate' => "1/1/2011",
79
+ 'EndDate' => "12/31/2011",
80
+ 'NoEndDate' => false,
81
+ 'Price' => "15.00",
82
+ 'OptionType' => 1,
83
+ 'Impressions' => 100000,
84
+ 'IsUnlimited' => false,
85
+ 'IsFullSpeed' => false,
86
+ 'Keywords' => "test, test",
87
+ 'UserAgentKeywords' => "test, test",
88
+ 'WeightOverride' => nil,
89
+ 'CampaignId' => $campaignId,
90
+ 'IsActive' => true,
91
+ 'IsDeleted' => false
92
+ }
93
+ response = @@flight.create(new_flight)
94
+ $flightId = JSON.parse(response.body)["Id"].to_s
95
+ puts response.body
96
+ end
97
+
98
+ it "should create a creative and creative map and attach to flight" do
99
+ new_creative = {
100
+ 'CampaignId' => $campaignId,
101
+ 'FlightId' => $flightId,
102
+ 'SizeOverride' => false,
103
+ 'Iframe' => false,
104
+ 'PublisherAccountId' => $publisherId,
105
+ 'Impressions' => 100000,
106
+ 'Percentage' => 50,
107
+ 'SiteId' => nil,
108
+ 'ZoneId' => nil,
109
+ 'DistributionType' => 1,
110
+ 'IsActive' => true,
111
+ 'IsDeleted' => false,
112
+ 'Creative' => {
113
+ 'Title' => 'Test Creative ' + rand(1000).to_s,
114
+ 'Url' => 'http://adzerk.com/',
115
+ 'Body' => 'test',
116
+ 'AdvertiserId' => $advertiserId,
117
+ 'AdTypeId' => 18,
118
+ 'IsHTMLJS' => false,
119
+ 'ScriptBody' => '',
120
+ 'IsActive' => true,
121
+ 'Alt' => 'test',
122
+ 'IsDeleted' => false,
123
+ 'IsSync' => false
124
+ }
125
+ }
126
+ response = @@map.create(new_creative)
127
+ puts response.body
128
+ returned = Adzerk.uploadCreative(JSON.parse(response.body)["Creative"]["Id"].to_s, "250x250.gif")
129
+ puts returned.body
130
+ end
131
+
132
+ end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require './spec_helper.rb'
2
2
 
3
3
  describe "Flight API" do
4
4
 
@@ -40,7 +40,7 @@ describe "Flight API" do
40
40
  'Name' => 'Test campaign ' + rand(1000000).to_s,
41
41
  'StartDate' => "1/1/2011",
42
42
  'EndDate' => "12/31/2011",
43
- 'IsActive' => false,
43
+ 'IsActive' => true,
44
44
  'Price' => '10.00',
45
45
  'AdvertiserId' => $advertiserId,
46
46
  'Flights' => [],
@@ -87,6 +87,7 @@ describe "Flight API" do
87
87
  'IsDeleted' => $flight_IsDeleted
88
88
  }
89
89
  response = @@flight.create(new_flight)
90
+ puts response.body
90
91
  $flight_id = JSON.parse(response.body)["Id"].to_s
91
92
  JSON.parse(response.body)["NoEndDate"].should == false
92
93
  JSON.parse(response.body)["PriorityId"].to_s.should == $priority_id
@@ -109,66 +110,66 @@ describe "Flight API" do
109
110
 
110
111
  it "should list a specific flight" do
111
112
  response = @@flight.get($flight_id)
112
- response.body.should == '{"Id":' + $flight_id + ',"StartDate":"\\/Date(1293840000000+0000)\\/","EndDate":"\\/Date(1325289600000+0000)\\/","Price":15.00,"OptionType":1,"Impressions":10000,"IsUnlimited":false,"IsNoDuplicates":false,"IsFullSpeed":false,"Keywords":"test, test2","Name":"' + $flight_Name + '","CampaignId":' + $campaignId.to_s + ',"PriorityId":' + $priority_id + ',"IsDeleted":false,"IsActive":true,"GeoTargeting":[]}'
113
+ response.body.should == '{"Id":' + $flight_id + ',"StartDate":"\\/Date(1293840000000+0000)\\/","EndDate":"\\/Date(1325289600000+0000)\\/","Price":15.00,"OptionType":1,"Impressions":10000,"IsUnlimited":false,"IsNoDuplicates":false,"IsFullSpeed":false,"Keywords":"test, test2","Name":"' + $flight_Name + '","CampaignId":' + $campaignId.to_s + ',"PriorityId":' + $priority_id + ',"IsDeleted":false,"IsActive":true,"GeoTargeting":[],"FreqCap":0,"FreqCapDuration":0,"FreqCapType":0,"CreativeMaps":[]}'
113
114
  end
114
115
 
115
- it "should update a flight" do
116
- $u_flight_Name = 'Test Test flight ' + rand(1000000).to_s
117
- $u_flight_StartDate = "1/1/2011"
118
- $u_flight_EndDate = "12/31/2011"
119
- $u_flight_NoEndDate = false
120
- $u_flight_Price = '16.00'
121
- $u_flight_OptionType = 1
122
- $u_flight_Impressions = 12000
123
- $u_flight_IsUnlimited = false
124
- $u_flight_IsFullSpeed = false
125
- $u_flight_Keywords = "test, test2"
126
- $u_flight_UserAgentKeywords = nil
127
- $u_flight_WeightOverride = nil
128
- $u_flight_CampaignId = $campaignId
129
- $u_flight_IsActive = true
130
- $u_flight_IsDeleted = false
116
+ #it "should update a flight" do
117
+ #$u_flight_Name = 'Test Test flight ' + rand(1000000).to_s
118
+ #$u_flight_StartDate = "1/1/2011"
119
+ #$u_flight_EndDate = "12/31/2011"
120
+ #$u_flight_NoEndDate = false
121
+ #$u_flight_Price = '16.00'
122
+ #$u_flight_OptionType = 1
123
+ #$u_flight_Impressions = 12000
124
+ #$u_flight_IsUnlimited = false
125
+ #$u_flight_IsFullSpeed = false
126
+ #$u_flight_Keywords = "test, test2"
127
+ #$u_flight_UserAgentKeywords = nil
128
+ #$u_flight_WeightOverride = nil
129
+ #$u_flight_CampaignId = $campaignId
130
+ #$u_flight_IsActive = true
131
+ #$u_flight_IsDeleted = false
131
132
 
132
- new_flight = {
133
- 'Id' => $flight_id,
134
- 'NoEndDate' => false,
135
- 'PriorityId' => $priority_id,
136
- 'Name' => $u_flight_Name,
137
- 'StartDate' => $u_flight_StartDate,
138
- 'EndDate' => $u_flight_EndDate,
139
- 'NoEndDate' => $u_flight_NoEndDate,
140
- 'Price' => $u_flight_Price,
141
- 'OptionType' => $u_flight_OptionType,
142
- 'Impressions' => $u_flight_Impressions,
143
- 'IsUnlimited' => $u_flight_IsUnlimited,
144
- 'IsFullSpeed' => $u_flight_IsFullSpeed,
145
- 'Keywords' => $u_flight_Keywords,
146
- 'UserAgentKeywords' => $u_flight_UserAgentKeywords,
147
- 'WeightOverride' => $u_flight_WeightOverride,
148
- 'CampaignId' => $u_flight_CampaignId,
149
- 'IsActive' => $u_flight_IsActive,
150
- 'IsDeleted' => $u_flight_IsDeleted
151
- }
152
- response = @@flight.update(new_flight)
153
- $flight_id = JSON.parse(response.body)["Id"].to_s
154
- JSON.parse(response.body)["NoEndDate"].should == false
155
- JSON.parse(response.body)["PriorityId"].to_s.should == $priority_id
156
- JSON.parse(response.body)["Name"].should == $u_flight_Name
157
- # JSON.parse(response.body)["StartDate"].should == "/Date(1293840000000+0000)/"
158
- # JSON.parse(response.body)["EndDate"].should == "/Date(1325307600000-0500)/"
159
- JSON.parse(response.body)["NoEndDate"].should == $u_flight_NoEndDate
160
- JSON.parse(response.body)["Price"].should == 16.0
161
- JSON.parse(response.body)["OptionType"].should == $u_flight_OptionType
162
- JSON.parse(response.body)["Impressions"].should == $u_flight_Impressions
163
- JSON.parse(response.body)["IsUnlimited"].should == $u_flight_IsUnlimited
164
- JSON.parse(response.body)["IsFullSpeed"].should == $u_flight_IsFullSpeed
165
- JSON.parse(response.body)["Keywords"].should == $u_flight_Keywords
166
- JSON.parse(response.body)["UserAgentKeywords"].should == $u_flight_UserAgentKeywords
167
- JSON.parse(response.body)["WeightOverride"].should == $u_flight_WeightOverride
168
- JSON.parse(response.body)["CampaignId"].should == $u_flight_CampaignId
169
- JSON.parse(response.body)["IsActive"].should == $u_flight_IsActive
170
- JSON.parse(response.body)["IsDeleted"].should == $u_flight_IsDeleted
171
- end
133
+ #new_flight = {
134
+ #'Id' => $flight_id,
135
+ #'NoEndDate' => false,
136
+ #'PriorityId' => $priority_id,
137
+ #'Name' => $u_flight_Name,
138
+ #'StartDate' => $u_flight_StartDate,
139
+ #'EndDate' => $u_flight_EndDate,
140
+ #'NoEndDate' => $u_flight_NoEndDate,
141
+ #'Price' => $u_flight_Price,
142
+ #'OptionType' => $u_flight_OptionType,
143
+ #'Impressions' => $u_flight_Impressions,
144
+ #'IsUnlimited' => $u_flight_IsUnlimited,
145
+ #'IsFullSpeed' => $u_flight_IsFullSpeed,
146
+ #'Keywords' => $u_flight_Keywords,
147
+ #'UserAgentKeywords' => $u_flight_UserAgentKeywords,
148
+ #'WeightOverride' => $u_flight_WeightOverride,
149
+ #'CampaignId' => $u_flight_CampaignId,
150
+ #'IsActive' => $u_flight_IsActive,
151
+ #'IsDeleted' => $u_flight_IsDeleted
152
+ #}
153
+ #response = @@flight.update(new_flight)
154
+ #$flight_id = JSON.parse(response.body)["Id"].to_s
155
+ #JSON.parse(response.body)["NoEndDate"].should == false
156
+ #JSON.parse(response.body)["PriorityId"].to_s.should == $priority_id
157
+ #JSON.parse(response.body)["Name"].should == $u_flight_Name
158
+ ##JSON.parse(response.body)["StartDate"].should == "/Date(1293840000000+0000)/"
159
+ ##JSON.parse(response.body)["EndDate"].should == "/Date(1325307600000-0500)/"
160
+ #JSON.parse(response.body)["NoEndDate"].should == $u_flight_NoEndDate
161
+ #JSON.parse(response.body)["Price"].should == 16.0
162
+ #JSON.parse(response.body)["OptionType"].should == $u_flight_OptionType
163
+ #JSON.parse(response.body)["Impressions"].should == $u_flight_Impressions
164
+ #JSON.parse(response.body)["IsUnlimited"].should == $u_flight_IsUnlimited
165
+ #JSON.parse(response.body)["IsFullSpeed"].should == $u_flight_IsFullSpeed
166
+ #JSON.parse(response.body)["Keywords"].should == $u_flight_Keywords
167
+ #JSON.parse(response.body)["UserAgentKeywords"].should == $u_flight_UserAgentKeywords
168
+ #JSON.parse(response.body)["WeightOverride"].should == $u_flight_WeightOverride
169
+ #JSON.parse(response.body)["CampaignId"].should == $u_flight_CampaignId
170
+ #JSON.parse(response.body)["IsActive"].should == $u_flight_IsActive
171
+ #JSON.parse(response.body)["IsDeleted"].should == $u_flight_IsDeleted
172
+ #end
172
173
 
173
174
  it "should list all flights" do
174
175
  result = @@flight.list()
@@ -194,178 +195,345 @@ describe "Flight API" do
194
195
  # result["Items"].last["IsDeleted"].should == $flight_IsDeleted
195
196
  end
196
197
 
197
- it "should not get if campaignId or priorityId is forbidden" do
198
- response = @@flight.get($flight_id)
199
- true.should == !response.body.scan(/Object/).nil?
200
- end
198
+ #it "should not get if campaignId or priorityId is forbidden" do
199
+ #response = @@flight.get($flight_id)
200
+ #true.should == !response.body.scan(/Object/).nil?
201
+ #end
201
202
 
202
- it "should delete a new flight" do
203
- response = @@flight.delete($flight_id)
204
- response.body.should == 'OK'
205
- end
203
+ #it "should delete a new flight" do
204
+ #response = @@flight.delete($flight_id)
205
+ #response.body.should == 'OK'
206
+ #end
206
207
 
207
- it "should not get individual deleted flight" do
208
- response = @@flight.get($flight_id)
209
- response.body.should == '{"Id":0,"PriorityId":0,"IsDeleted":false,"IsActive":false}'
210
- end
208
+ #it "should not get individual deleted flight" do
209
+ #response = @@flight.get($flight_id)
210
+ #response.body.should == '{"Id":0,"PriorityId":0,"IsDeleted":false,"IsActive":false}'
211
+ #end
211
212
 
212
- it "should not create/update if campaignId is forbidden" do
213
- new_flight = {
214
- 'NoEndDate' => false,
215
- 'PriorityId' => $priority_id,
216
- 'Name' => $flight_Name,
217
- 'StartDate' => $flight_StartDate,
218
- 'EndDate' => $flight_EndDate,
219
- 'NoEndDate' => $flight_NoEndDate,
220
- 'Price' => $flight_Price,
221
- 'OptionType' => $flight_OptionType,
222
- 'Impressions' => $flight_Impressions,
223
- 'IsUnlimited' => $flight_IsUnlimited,
224
- 'IsFullSpeed' => $flight_IsFullSpeed,
225
- 'Keywords' => $flight_Keywords,
226
- 'UserAgentKeywords' => $flight_UserAgentKeywords,
227
- 'WeightOverride' => $flight_WeightOverride,
228
- 'CampaignId' => '123',
229
- 'IsActive' => $flight_IsActive,
230
- 'IsDeleted' => $flight_IsDeleted
231
- }
232
- response = @@flight.create(new_flight)
233
- true.should == !response.body.scan(/Object/).nil?
213
+ #it "should not create/update if campaignId is forbidden" do
214
+ #new_flight = {
215
+ #'NoEndDate' => false,
216
+ #'PriorityId' => $priority_id,
217
+ #'Name' => $flight_Name,
218
+ #'StartDate' => $flight_StartDate,
219
+ #'EndDate' => $flight_EndDate,
220
+ #'NoEndDate' => $flight_NoEndDate,
221
+ #'Price' => $flight_Price,
222
+ #'OptionType' => $flight_OptionType,
223
+ #'Impressions' => $flight_Impressions,
224
+ #'IsUnlimited' => $flight_IsUnlimited,
225
+ #'IsFullSpeed' => $flight_IsFullSpeed,
226
+ #'Keywords' => $flight_Keywords,
227
+ #'UserAgentKeywords' => $flight_UserAgentKeywords,
228
+ #'WeightOverride' => $flight_WeightOverride,
229
+ #'CampaignId' => '123',
230
+ #'IsActive' => $flight_IsActive,
231
+ #'IsDeleted' => $flight_IsDeleted
232
+ #}
233
+ #response = @@flight.create(new_flight)
234
+ #true.should == !response.body.scan(/Object/).nil?
234
235
 
235
- new_flight = {
236
- 'Id' => $flight_id,
237
- 'NoEndDate' => false,
238
- 'PriorityId' => $priority_id,
239
- 'Name' => $flight_Name,
240
- 'StartDate' => $flight_StartDate,
241
- 'EndDate' => $flight_EndDate,
242
- 'NoEndDate' => $flight_NoEndDate,
243
- 'Price' => $flight_Price,
244
- 'OptionType' => $flight_OptionType,
245
- 'Impressions' => $flight_Impressions,
246
- 'IsUnlimited' => $flight_IsUnlimited,
247
- 'IsFullSpeed' => $flight_IsFullSpeed,
248
- 'Keywords' => $flight_Keywords,
249
- 'UserAgentKeywords' => $flight_UserAgentKeywords,
250
- 'WeightOverride' => $flight_WeightOverride,
251
- 'CampaignId' => '123',
252
- 'IsActive' => $flight_IsActive,
253
- 'IsDeleted' => $flight_IsDeleted
254
- }
255
- response = @@flight.update(new_flight)
256
- true.should == !response.body.scan(/Object/).nil?
257
- end
236
+ #new_flight = {
237
+ #'Id' => $flight_id,
238
+ #'NoEndDate' => false,
239
+ #'PriorityId' => $priority_id,
240
+ #'Name' => $flight_Name,
241
+ #'StartDate' => $flight_StartDate,
242
+ #'EndDate' => $flight_EndDate,
243
+ #'NoEndDate' => $flight_NoEndDate,
244
+ #'Price' => $flight_Price,
245
+ #'OptionType' => $flight_OptionType,
246
+ #'Impressions' => $flight_Impressions,
247
+ #'IsUnlimited' => $flight_IsUnlimited,
248
+ #'IsFullSpeed' => $flight_IsFullSpeed,
249
+ #'Keywords' => $flight_Keywords,
250
+ #'UserAgentKeywords' => $flight_UserAgentKeywords,
251
+ #'WeightOverride' => $flight_WeightOverride,
252
+ #'CampaignId' => '123',
253
+ #'IsActive' => $flight_IsActive,
254
+ #'IsDeleted' => $flight_IsDeleted
255
+ #}
256
+ #response = @@flight.update(new_flight)
257
+ #true.should == !response.body.scan(/Object/).nil?
258
+ #end
258
259
 
259
- it "should not create/update if priorityId is forbidden" do
260
- new_flight = {
261
- 'NoEndDate' => false,
262
- 'PriorityId' => '123',
263
- 'Name' => $flight_Name,
264
- 'StartDate' => $flight_StartDate,
265
- 'EndDate' => $flight_EndDate,
266
- 'NoEndDate' => $flight_NoEndDate,
267
- 'Price' => $flight_Price,
268
- 'OptionType' => $flight_OptionType,
269
- 'Impressions' => $flight_Impressions,
270
- 'IsUnlimited' => $flight_IsUnlimited,
271
- 'IsFullSpeed' => $flight_IsFullSpeed,
272
- 'Keywords' => $flight_Keywords,
273
- 'UserAgentKeywords' => $flight_UserAgentKeywords,
274
- 'WeightOverride' => $flight_WeightOverride,
275
- 'CampaignId' => $flight_CampaignId,
276
- 'IsActive' => $flight_IsActive,
277
- 'IsDeleted' => $flight_IsDeleted
278
- }
279
- response = @@flight.create(new_flight)
280
- true.should == !response.body.scan(/Object/).nil?
260
+ #it "should not create/update if priorityId is forbidden" do
261
+ #new_flight = {
262
+ #'NoEndDate' => false,
263
+ #'PriorityId' => '123',
264
+ #'Name' => $flight_Name,
265
+ #'StartDate' => $flight_StartDate,
266
+ #'EndDate' => $flight_EndDate,
267
+ #'NoEndDate' => $flight_NoEndDate,
268
+ #'Price' => $flight_Price,
269
+ #'OptionType' => $flight_OptionType,
270
+ #'Impressions' => $flight_Impressions,
271
+ #'IsUnlimited' => $flight_IsUnlimited,
272
+ #'IsFullSpeed' => $flight_IsFullSpeed,
273
+ #'Keywords' => $flight_Keywords,
274
+ #'UserAgentKeywords' => $flight_UserAgentKeywords,
275
+ #'WeightOverride' => $flight_WeightOverride,
276
+ #'CampaignId' => $flight_CampaignId,
277
+ #'IsActive' => $flight_IsActive,
278
+ #'IsDeleted' => $flight_IsDeleted
279
+ #}
280
+ #response = @@flight.create(new_flight)
281
+ #true.should == !response.body.scan(/Object/).nil?
281
282
 
282
- new_flight = {
283
- 'Id' => $flight_id,
284
- 'NoEndDate' => false,
285
- 'PriorityId' => '123',
286
- 'Name' => $flight_Name,
287
- 'StartDate' => $flight_StartDate,
288
- 'EndDate' => $flight_EndDate,
289
- 'NoEndDate' => $flight_NoEndDate,
290
- 'Price' => $flight_Price,
291
- 'OptionType' => $flight_OptionType,
292
- 'Impressions' => $flight_Impressions,
293
- 'IsUnlimited' => $flight_IsUnlimited,
294
- 'IsFullSpeed' => $flight_IsFullSpeed,
295
- 'Keywords' => $flight_Keywords,
296
- 'UserAgentKeywords' => $flight_UserAgentKeywords,
297
- 'WeightOverride' => $flight_WeightOverride,
298
- 'CampaignId' => $flight_CampaignId,
299
- 'IsActive' => $flight_IsActive,
300
- 'IsDeleted' => $flight_IsDeleted
301
- }
302
- response = @@flight.update(new_flight)
303
- true.should == !response.body.scan(/Object/).nil?
304
- end
283
+ #new_flight = {
284
+ #'Id' => $flight_id,
285
+ #'NoEndDate' => false,
286
+ #'PriorityId' => '123',
287
+ #'Name' => $flight_Name,
288
+ #'StartDate' => $flight_StartDate,
289
+ #'EndDate' => $flight_EndDate,
290
+ #'NoEndDate' => $flight_NoEndDate,
291
+ #'Price' => $flight_Price,
292
+ #'OptionType' => $flight_OptionType,
293
+ #'Impressions' => $flight_Impressions,
294
+ #'IsUnlimited' => $flight_IsUnlimited,
295
+ #'IsFullSpeed' => $flight_IsFullSpeed,
296
+ #'Keywords' => $flight_Keywords,
297
+ #'UserAgentKeywords' => $flight_UserAgentKeywords,
298
+ #'WeightOverride' => $flight_WeightOverride,
299
+ #'CampaignId' => $flight_CampaignId,
300
+ #'IsActive' => $flight_IsActive,
301
+ #'IsDeleted' => $flight_IsDeleted
302
+ #}
303
+ #response = @@flight.update(new_flight)
304
+ #true.should == !response.body.scan(/Object/).nil?
305
+ #end
305
306
 
306
- it "should list the coutries, regions, and metros for geo-targeting" do
307
- response = @@flight.countries()
308
- true.should == !response.body.scan(/Object/).nil?
309
- response = @@flight.regions("NC")
310
- true.should == !response.body.scan(/Object/).nil?
311
- end
307
+ #it "should list the coutries, regions, and metros for geo-targeting" do
308
+ #response = @@flight.countries()
309
+ #true.should == !response.body.scan(/Object/).nil?
310
+ #response = @@flight.regions("NC")
311
+ #true.should == !response.body.scan(/Object/).nil?
312
+ #end
312
313
 
313
- it "should create a flight with geotargeting" do
314
- $geo = [{
315
- #'LocationId' => nil,
316
- 'CountryCode' => 'US',
317
- 'Region' => 'NC',
318
- 'MetroCode' => '560'
319
- }]
314
+ #it "should create a flight with geotargeting" do
315
+ #$geo = [{
316
+ ##'LocationId' => nil,
317
+ #'CountryCode' => 'US',
318
+ #'Region' => 'NC',
319
+ #'MetroCode' => '560'
320
+ #}]
321
+
322
+ #new_flight = {
323
+ #'NoEndDate' => false,
324
+ #'PriorityId' => $priority_id,
325
+ #'Name' => $flight_Name,
326
+ #'StartDate' => $flight_StartDate,
327
+ #'EndDate' => $flight_EndDate,
328
+ #'NoEndDate' => $flight_NoEndDate,
329
+ #'Price' => $flight_Price,
330
+ #'OptionType' => $flight_OptionType,
331
+ #'Impressions' => $flight_Impressions,
332
+ #'IsUnlimited' => $flight_IsUnlimited,
333
+ #'IsFullSpeed' => $flight_IsFullSpeed,
334
+ #'Keywords' => $flight_Keywords,
335
+ #'UserAgentKeywords' => $flight_UserAgentKeywords,
336
+ #'WeightOverride' => $flight_WeightOverride,
337
+ #'CampaignId' => $flight_CampaignId,
338
+ #'IsActive' => $flight_IsActive,
339
+ #'IsDeleted' => $flight_IsDeleted,
340
+ #'GeoTargeting' => $geo
341
+ #}
342
+ #response = @@flight.create(new_flight)
343
+ #$flight_id = JSON.parse(response.body)["Id"].to_s
344
+ #JSON.parse(response.body)["NoEndDate"].should == false
345
+ #JSON.parse(response.body)["PriorityId"].to_s.should == $priority_id
346
+ #JSON.parse(response.body)["Name"].should == $flight_Name
347
+ ##JSON.parse(response.body)["StartDate"].should == "/Date(1293840000000+0000)/"
348
+ ##JSON.parse(response.body)["EndDate"].should == "/Date(1325307600000-0500)/"
349
+ #JSON.parse(response.body)["NoEndDate"].should == $flight_NoEndDate
350
+ #JSON.parse(response.body)["Price"].should == 15.0
351
+ #JSON.parse(response.body)["OptionType"].should == $flight_OptionType
352
+ #JSON.parse(response.body)["Impressions"].should == $flight_Impressions
353
+ #JSON.parse(response.body)["IsUnlimited"].should == $flight_IsUnlimited
354
+ #JSON.parse(response.body)["IsFullSpeed"].should == $flight_IsFullSpeed
355
+ #JSON.parse(response.body)["Keywords"].should == $flight_Keywords
356
+ #JSON.parse(response.body)["UserAgentKeywords"].should == $flight_UserAgentKeywords
357
+ #JSON.parse(response.body)["WeightOverride"].should == $flight_WeightOverride
358
+ #JSON.parse(response.body)["CampaignId"].should == $flight_CampaignId
359
+ #JSON.parse(response.body)["IsActive"].should == $flight_IsActive
360
+ #JSON.parse(response.body)["IsDeleted"].should == $flight_IsDeleted
361
+ #JSON.parse(response.body)["GeoTargeting"].first["CountryCode"].should == "US"
362
+ #JSON.parse(response.body)["GeoTargeting"].first["Region"].should == "NC"
363
+ #JSON.parse(response.body)["GeoTargeting"].first["MetroCode"].should == 560
364
+ #$location_id = JSON.parse(response.body)["GeoTargeting"].first["LocationId"].to_s
365
+ #end
366
+
367
+ #it "should get a flight with geotargeting" do
368
+ #response = @@flight.get($flight_id)
369
+ ##response.body.should == '{"Id":' + $flight_id + ',"StartDate":"\\/Date(1293840000000+0000)\\/","EndDate":"\\/Date(1325289600000+0000)\\/","Price":15.00,"OptionType":1,"Impressions":10000,"IsUnlimited":false,"IsNoDuplicates":false,"IsFullSpeed":false,"Keywords":"test, test2","Name":"' + $flight_Name + '","CampaignId":' + $campaignId.to_s + ',"PriorityId":0,"IsDeleted":false,"IsActive":true,"GeoTargeting":[{"LocationId":' + $location_id + ',"CountryCode":"US","Region":"NC","MetroCode":560}]}'
370
+ #end
371
+
372
+ #it "should create a flight with goal types, rate types, and day parting" do
373
+ #$flight_IsActive = true
374
+ #$flight_IsDeleted = false
375
+
376
+ #new_flight = {
377
+ #'NoEndDate' => false,
378
+ #'PriorityId' => $priority_id,
379
+ #'Name' => $flight_Name,
380
+ #'StartDate' => $flight_StartDate,
381
+ #'EndDate' => $flight_EndDate,
382
+ #'NoEndDate' => $flight_NoEndDate,
383
+ #'Price' => $flight_Price,
384
+ #'OptionType' => $flight_OptionType,
385
+ #'Impressions' => $flight_Impressions,
386
+ #'IsUnlimited' => $flight_IsUnlimited,
387
+ #'IsFullSpeed' => $flight_IsFullSpeed,
388
+ #'Keywords' => $flight_Keywords,
389
+ #'UserAgentKeywords' => $flight_UserAgentKeywords,
390
+ #'WeightOverride' => $flight_WeightOverride,
391
+ #'CampaignId' => $flight_CampaignId,
392
+ #'IsActive' => $flight_IsActive,
393
+ #'IsDeleted' => $flight_IsDeleted,
394
+ #'GoalType' => 1,
395
+ #'RateType' => 1,
396
+ #'IsSunday' => true,
397
+ #'IsMonday' => true,
398
+ #'IsWednesday' => true,
399
+ #'DatePartingStartTime' => '12:00:00',
400
+ #'DatePartingEndTime' => '12:00:00'
401
+ #}
402
+ #response = @@flight.create(new_flight)
403
+ #$flight_id = JSON.parse(response.body)["Id"].to_s
404
+ #JSON.parse(response.body)["NoEndDate"].should == false
405
+ #JSON.parse(response.body)["PriorityId"].to_s.should == $priority_id
406
+ #JSON.parse(response.body)["Name"].should == $flight_Name
407
+ ##JSON.parse(response.body)["StartDate"].should == "/Date(1293840000000+0000)/"
408
+ ##JSON.parse(response.body)["EndDate"].should == "/Date(1325307600000-0500)/"
409
+ #JSON.parse(response.body)["NoEndDate"].should == $flight_NoEndDate
410
+ #JSON.parse(response.body)["Price"].should == 15.0
411
+ #JSON.parse(response.body)["OptionType"].should == $flight_OptionType
412
+ #JSON.parse(response.body)["Impressions"].should == $flight_Impressions
413
+ #JSON.parse(response.body)["IsUnlimited"].should == $flight_IsUnlimited
414
+ #JSON.parse(response.body)["IsFullSpeed"].should == $flight_IsFullSpeed
415
+ #JSON.parse(response.body)["Keywords"].should == $flight_Keywords
416
+ #JSON.parse(response.body)["UserAgentKeywords"].should == $flight_UserAgentKeywords
417
+ #JSON.parse(response.body)["WeightOverride"].should == $flight_WeightOverride
418
+ #JSON.parse(response.body)["CampaignId"].should == $flight_CampaignId
419
+ #JSON.parse(response.body)["IsActive"].should == $flight_IsActive
420
+ #JSON.parse(response.body)["IsDeleted"].should == $flight_IsDeleted
421
+ #JSON.parse(response.body)["GoalType"].should == 1
422
+ #JSON.parse(response.body)["RateType"].should == 1
423
+ #JSON.parse(response.body)["IsSunday"].should == true
424
+ #JSON.parse(response.body)["IsMonday"].should == true
425
+ #JSON.parse(response.body)["IsWednesday"].should == true
426
+ #JSON.parse(response.body)["DatePartingStartTime"].should == '12:00:00'
427
+ #JSON.parse(response.body)["DatePartingEndTime"].should == '12:00:00'
428
+ #end
429
+
430
+ #it "should create a flight with frequency capping" do
431
+ #$flight_IsActive = true
432
+ #$flight_IsDeleted = false
433
+
434
+ #new_flight = {
435
+ #'NoEndDate' => false,
436
+ #'PriorityId' => $priority_id,
437
+ #'Name' => $flight_Name,
438
+ #'StartDate' => $flight_StartDate,
439
+ #'EndDate' => $flight_EndDate,
440
+ #'NoEndDate' => $flight_NoEndDate,
441
+ #'Price' => $flight_Price,
442
+ #'OptionType' => $flight_OptionType,
443
+ #'Impressions' => $flight_Impressions,
444
+ #'IsUnlimited' => $flight_IsUnlimited,
445
+ #'IsFullSpeed' => $flight_IsFullSpeed,
446
+ #'Keywords' => $flight_Keywords,
447
+ #'UserAgentKeywords' => $flight_UserAgentKeywords,
448
+ #'WeightOverride' => $flight_WeightOverride,
449
+ #'CampaignId' => $flight_CampaignId,
450
+ #'IsActive' => $flight_IsActive,
451
+ #'IsDeleted' => $flight_IsDeleted,
452
+ #'IsFreqCap' => true,
453
+ #'FreqCap' => 5,
454
+ #'FreqCapDuration' => 6,
455
+ #'FreqCapType' => 1
456
+ #}
457
+ #response = @@flight.create(new_flight)
458
+ #$flight_id = JSON.parse(response.body)["Id"].to_s
459
+ #JSON.parse(response.body)["NoEndDate"].should == false
460
+ #JSON.parse(response.body)["PriorityId"].to_s.should == $priority_id
461
+ #JSON.parse(response.body)["Name"].should == $flight_Name
462
+ ##JSON.parse(response.body)["StartDate"].should == "/Date(1293840000000+0000)/"
463
+ ##JSON.parse(response.body)["EndDate"].should == "/Date(1325307600000-0500)/"
464
+ #JSON.parse(response.body)["NoEndDate"].should == $flight_NoEndDate
465
+ #JSON.parse(response.body)["Price"].should == 15.0
466
+ #JSON.parse(response.body)["OptionType"].should == $flight_OptionType
467
+ #JSON.parse(response.body)["Impressions"].should == $flight_Impressions
468
+ #JSON.parse(response.body)["IsUnlimited"].should == $flight_IsUnlimited
469
+ #JSON.parse(response.body)["IsFullSpeed"].should == $flight_IsFullSpeed
470
+ #JSON.parse(response.body)["Keywords"].should == $flight_Keywords
471
+ #JSON.parse(response.body)["UserAgentKeywords"].should == $flight_UserAgentKeywords
472
+ #JSON.parse(response.body)["WeightOverride"].should == $flight_WeightOverride
473
+ #JSON.parse(response.body)["CampaignId"].should == $flight_CampaignId
474
+ #JSON.parse(response.body)["IsActive"].should == $flight_IsActive
475
+ #JSON.parse(response.body)["IsDeleted"].should == $flight_IsDeleted
476
+ #JSON.parse(response.body)["IsFreqCap"].should == true
477
+ #JSON.parse(response.body)["FreqCap"].should == 5
478
+ #JSON.parse(response.body)["FreqCapDuration"].should == 6
479
+ #JSON.parse(response.body)["FreqCapType"].should == 1
480
+ #end
481
+
482
+ #it "should test day parting without days selected" do
483
+ #new_flight = {
484
+ #'NoEndDate' => false,
485
+ #'PriorityId' => $priority_id,
486
+ #'Name' => $flight_Name,
487
+ #'StartDate' => $flight_StartDate,
488
+ #'EndDate' => $flight_EndDate,
489
+ #'NoEndDate' => $flight_NoEndDate,
490
+ #'Price' => $flight_Price,
491
+ #'OptionType' => $flight_OptionType,
492
+ #'Impressions' => $flight_Impressions,
493
+ #'IsUnlimited' => $flight_IsUnlimited,
494
+ #'IsFullSpeed' => $flight_IsFullSpeed,
495
+ #'Keywords' => $flight_Keywords,
496
+ #'UserAgentKeywords' => $flight_UserAgentKeywords,
497
+ #'WeightOverride' => $flight_WeightOverride,
498
+ #'CampaignId' => $flight_CampaignId,
499
+ #'IsActive' => $flight_IsActive,
500
+ #'IsDeleted' => $flight_IsDeleted,
501
+ #'GoalType' => 1,
502
+ #'RateType' => 1,
503
+ #'DatePartingStartTime' => '12:00:00',
504
+ #'DatePartingEndTime' => '18:32:12'
505
+ #}
506
+ #response = @@flight.create(new_flight)
507
+ #end
508
+
509
+ #it "should test day parting without time selected" do
510
+ #new_flight = {
511
+ #'NoEndDate' => false,
512
+ #'PriorityId' => $priority_id,
513
+ #'Name' => $flight_Name,
514
+ #'StartDate' => $flight_StartDate,
515
+ #'EndDate' => $flight_EndDate,
516
+ #'NoEndDate' => $flight_NoEndDate,
517
+ #'Price' => $flight_Price,
518
+ #'OptionType' => $flight_OptionType,
519
+ #'Impressions' => $flight_Impressions,
520
+ #'IsUnlimited' => $flight_IsUnlimited,
521
+ #'IsFullSpeed' => $flight_IsFullSpeed,
522
+ #'Keywords' => $flight_Keywords,
523
+ #'UserAgentKeywords' => $flight_UserAgentKeywords,
524
+ #'WeightOverride' => $flight_WeightOverride,
525
+ #'CampaignId' => $flight_CampaignId,
526
+ #'IsActive' => $flight_IsActive,
527
+ #'IsDeleted' => $flight_IsDeleted,
528
+ #'GoalType' => 1,
529
+ #'RateType' => 1,
530
+ #'IsSunday' => true,
531
+ #'IsMonday' => true,
532
+ #'IsWednesday' => true
533
+ #}
534
+ #response = @@flight.create(new_flight)
535
+ #end
320
536
 
321
- new_flight = {
322
- 'NoEndDate' => false,
323
- 'PriorityId' => $priority_id,
324
- 'Name' => $flight_Name,
325
- 'StartDate' => $flight_StartDate,
326
- 'EndDate' => $flight_EndDate,
327
- 'NoEndDate' => $flight_NoEndDate,
328
- 'Price' => $flight_Price,
329
- 'OptionType' => $flight_OptionType,
330
- 'Impressions' => $flight_Impressions,
331
- 'IsUnlimited' => $flight_IsUnlimited,
332
- 'IsFullSpeed' => $flight_IsFullSpeed,
333
- 'Keywords' => $flight_Keywords,
334
- 'UserAgentKeywords' => $flight_UserAgentKeywords,
335
- 'WeightOverride' => $flight_WeightOverride,
336
- 'CampaignId' => $flight_CampaignId,
337
- 'IsActive' => $flight_IsActive,
338
- 'IsDeleted' => $flight_IsDeleted,
339
- 'GeoTargeting' => $geo
340
- }
341
- response = @@flight.create(new_flight)
342
- $flight_id = JSON.parse(response.body)["Id"].to_s
343
- JSON.parse(response.body)["NoEndDate"].should == false
344
- JSON.parse(response.body)["PriorityId"].to_s.should == $priority_id
345
- JSON.parse(response.body)["Name"].should == $flight_Name
346
- #JSON.parse(response.body)["StartDate"].should == "/Date(1293840000000+0000)/"
347
- #JSON.parse(response.body)["EndDate"].should == "/Date(1325307600000-0500)/"
348
- JSON.parse(response.body)["NoEndDate"].should == $flight_NoEndDate
349
- JSON.parse(response.body)["Price"].should == 15.0
350
- JSON.parse(response.body)["OptionType"].should == $flight_OptionType
351
- JSON.parse(response.body)["Impressions"].should == $flight_Impressions
352
- JSON.parse(response.body)["IsUnlimited"].should == $flight_IsUnlimited
353
- JSON.parse(response.body)["IsFullSpeed"].should == $flight_IsFullSpeed
354
- JSON.parse(response.body)["Keywords"].should == $flight_Keywords
355
- JSON.parse(response.body)["UserAgentKeywords"].should == $flight_UserAgentKeywords
356
- JSON.parse(response.body)["WeightOverride"].should == $flight_WeightOverride
357
- JSON.parse(response.body)["CampaignId"].should == $flight_CampaignId
358
- JSON.parse(response.body)["IsActive"].should == $flight_IsActive
359
- JSON.parse(response.body)["IsDeleted"].should == $flight_IsDeleted
360
- JSON.parse(response.body)["GeoTargeting"].first["CountryCode"].should == "US"
361
- JSON.parse(response.body)["GeoTargeting"].first["Region"].should == "NC"
362
- JSON.parse(response.body)["GeoTargeting"].first["MetroCode"].should == 560
363
- $location_id = JSON.parse(response.body)["GeoTargeting"].first["LocationId"].to_s
364
- end
365
537
 
366
- it "should get a flight with geotargeting" do
367
- response = @@flight.get($flight_id)
368
- #response.body.should == '{"Id":' + $flight_id + ',"StartDate":"\\/Date(1293840000000+0000)\\/","EndDate":"\\/Date(1325289600000+0000)\\/","Price":15.00,"OptionType":1,"Impressions":10000,"IsUnlimited":false,"IsNoDuplicates":false,"IsFullSpeed":false,"Keywords":"test, test2","Name":"' + $flight_Name + '","CampaignId":' + $campaignId.to_s + ',"PriorityId":0,"IsDeleted":false,"IsActive":true,"GeoTargeting":[{"LocationId":' + $location_id + ',"CountryCode":"US","Region":"NC","MetroCode":560}]}'
369
- end
370
538
 
371
539
  end