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.
Files changed (51) hide show
  1. data/lib/adzerk.rb +15 -0
  2. data/lib/adzerk/advertiser.rb +9 -0
  3. data/lib/adzerk/api_endpoint.rb +41 -0
  4. data/lib/adzerk/channel_site_map.rb +53 -0
  5. data/lib/adzerk/client.rb +80 -0
  6. data/lib/adzerk/creative.rb +17 -0
  7. data/lib/adzerk/creative_map.rb +38 -0
  8. data/lib/adzerk/flight.rb +12 -0
  9. data/lib/adzerk/invitation.rb +23 -0
  10. data/lib/adzerk/publisher.rb +17 -0
  11. data/lib/adzerk/reporting.rb +21 -0
  12. data/lib/adzerk/util.rb +37 -0
  13. data/lib/adzerk/version.rb +3 -0
  14. data/test/advertiser_api_spec.rb +57 -82
  15. data/test/campaign_api_spec.rb +150 -271
  16. data/test/channel_api_spec.rb +72 -79
  17. data/test/channel_site_map_api_spec.rb +43 -94
  18. data/test/creative_api_spec.rb +82 -251
  19. data/test/creative_map_api_spec.rb +291 -375
  20. data/test/flight_api_spec.rb +165 -493
  21. data/test/invitation_api_spec.rb +18 -41
  22. data/test/login_api_spec.rb +24 -49
  23. data/test/priority_api_spec.rb +53 -83
  24. data/test/publisher_api_spec.rb +71 -142
  25. data/test/rakefile.rb +7 -7
  26. data/test/report_api_spec.rb +18 -24
  27. data/test/security_api_spec.rb +21 -0
  28. data/test/site_api_spec.rb +37 -51
  29. data/test/spec_helper.rb +4 -17
  30. data/test/zone_api_spec.rb +38 -64
  31. metadata +61 -23
  32. data/lib/Adzerk.rb +0 -55
  33. data/lib/adzerk/Advertiser.rb +0 -39
  34. data/lib/adzerk/Campaign.rb +0 -33
  35. data/lib/adzerk/Channel.rb +0 -33
  36. data/lib/adzerk/ChannelSiteMap.rb +0 -44
  37. data/lib/adzerk/Creative.rb +0 -43
  38. data/lib/adzerk/CreativeMap.rb +0 -33
  39. data/lib/adzerk/Flight.rb +0 -44
  40. data/lib/adzerk/Invitation.rb +0 -17
  41. data/lib/adzerk/Login.rb +0 -28
  42. data/lib/adzerk/Priority.rb +0 -34
  43. data/lib/adzerk/Publisher.rb +0 -47
  44. data/lib/adzerk/Reporting.rb +0 -16
  45. data/lib/adzerk/Site.rb +0 -35
  46. data/lib/adzerk/Zone.rb +0 -35
  47. data/test/channel_api_security_spec.rb +0 -51
  48. data/test/csv_export_spec.rb +0 -89
  49. data/test/delivery-test.rb +0 -132
  50. data/test/test.rb +0 -43
  51. data/test/test2.rb +0 -175
@@ -1,55 +1,32 @@
1
- require 'spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "Invitation API" do
4
-
5
- $invitation_url = 'http://www.adzerk.com/'
6
- @@invite = $adzerk::Invitation.new
7
- @@advertiser = $adzerk::Advertiser.new
8
- $email = "test+apitest@adzerk.com"
9
-
10
- before(:all) do
11
- site = $adzerk::Site.new
12
- site_url = "http://adzerk.com"
13
- site_title = 'Test Site ' + rand(1000000).to_s
14
- new_site = {
15
- 'Title' => site_title,
16
- 'Url' => site_url
17
- }
18
- response = site.create(new_site)
19
- $siteId = JSON.parse(response.body)["Id"].to_s
20
- new_advertiser = {
21
- 'Title' => "Test"
22
- }
23
- response = @@advertiser.create(new_advertiser)
24
- $advertiserId = JSON.parse(response.body)["Id"].to_s
4
+ before do
5
+ @client = Adzerk::Client.new(API_KEY)
6
+ advertiser = @client.advertisers.create(:title => "Coca cola",
7
+ :is_active => true,
8
+ :is_deleted => false)
9
+ site = @client.sites.create(:title => 'Adzerk', :url => 'http://www.adzerk.com')
10
+ @advertiser_id = advertiser[:id].to_s
11
+ @site_id = site[:id].to_s
25
12
  end
26
13
 
27
14
  it "should create a new publisher invitation" do
28
-
29
- invitation = {
30
- 'Email' => $email,
31
- 'SiteId' => $siteId,
32
- 'AdvertiserId' => $advertiserId
33
- }
34
-
35
- response = @@invite.invite_publisher(invitation)
15
+ response = @client.invitations.invite_publisher(:email => 'test@adzerk.com',
16
+ :site_id => @site_id,
17
+ :advertiser_id => @advertiser_id)
36
18
  response.body.should_not == ""
37
19
  response.body.length.should > 10
38
20
  response.body.length.should < 100
39
21
  end
40
-
41
- it "should create a new advertiser invitation" do
42
22
 
43
- invitation = {
44
- 'Email' => $email,
45
- 'SiteId' => $siteId,
46
- 'AdvertiserId' => $advertiserId
47
- }
48
-
49
- response = @@invite.invite_advertiser(invitation)
23
+ it "should create a new advertiser invitation" do
24
+ response = @client.invitations.invite_advertiser(:email => 'test@adzerk.com',
25
+ :site_id => @site_id,
26
+ :advertiser_id => @advertiser_id)
50
27
  response.body.should_not == ""
51
28
  response.body.length.should > 10
52
29
  response.body.length.should < 100
53
30
  end
54
-
55
- end
31
+
32
+ end
@@ -1,61 +1,36 @@
1
- require 'spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "Login_API" do
4
-
5
- $login_url = 'http://www.adzerk.com/'
6
- @@login = $adzerk::Login.new
7
4
 
8
- it "should list all logins" do
9
- result = @@login.list()
10
- result.length.should > 0
11
- #result["Items"].last["Id"].to_s.should == $site_id
5
+ before do
6
+ @logins = Adzerk::Client.new(API_KEY).logins
12
7
  end
13
8
 
14
9
  it "should create a new login" do
15
- $email = "test+" + rand(10000).to_s + "@adzerk.com"
16
- $password = "somepassword"
17
- $fullname = "test person"
18
- new_login = {
19
- 'Email' => $email,
20
- 'Password' => $password,
21
- 'Name' => $fullname
22
- }
23
- response = @@login.create(new_login)
24
- $login_id = JSON.parse(response.body)["Id"].to_s
25
- JSON.parse(response.body)["Email"].should == $email
26
- JSON.parse(response.body)["Password"].should == $password
27
- JSON.parse(response.body)["Name"].should == $fullname
10
+ email = "test@email_#{rand(1000)}.com"
11
+ login = @logins.create(:email => email,
12
+ :password => '1234567',
13
+ :name => "John Doe")
14
+ $login_id = login[:id]
15
+ login[:email].should eq(email)
16
+ login[:password].should eq("1234567")
17
+ login[:name].should eq("John Doe")
28
18
  end
29
-
30
- it "should list a specific login" do
31
- response = @@login.get($login_id)
32
- response.body.should == '{"Id":' + $login_id.to_s + ',"Email":"'+ $email + '","Password":"","Name":"' + $fullname + '"}'
19
+
20
+ it "should list all logins" do
21
+ logins = @logins.list
22
+ logins[:items].last[:id].should eq($login_id)
33
23
  end
34
-
35
- it "should update a login" do
36
- new_login = {
37
- 'Id' => $login_id,
38
- 'Name' => $fullname
39
- }
40
- response = @@login.update(new_login)
41
- $login_id = JSON.parse(response.body)["Id"].to_s
42
- JSON.parse(response.body)["Email"].should == $email
43
- JSON.parse(response.body)["Password"].should == ""
44
- JSON.parse(response.body)["Name"].should == $fullname
24
+
25
+ it "should list a specific login" do
26
+ login = @logins.get($login_id)
27
+ login[:name].should eq("John Doe")
45
28
  end
46
29
 
47
- it "should not be able update a login's password or email" do
48
- new_login = {
49
- 'Id' => $login_id,
50
- 'Name' => $fullname,
51
- 'Password' => "password",
52
- 'Email' => "test@test.com"
53
- }
54
- response = @@login.update(new_login)
55
- $login_id = JSON.parse(response.body)["Id"].to_s
56
- JSON.parse(response.body)["Email"].should == $email
57
- JSON.parse(response.body)["Password"].should == ""
58
- JSON.parse(response.body)["Name"].should == $fullname
30
+ it "should update a login" do
31
+ login = @logins.update(:id => $login_id,
32
+ :name => "New Name")
33
+ login[:name].should eq("New Name")
59
34
  end
60
35
 
61
- end
36
+ end
@@ -1,105 +1,75 @@
1
- require 'spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "Priority API" do
4
-
5
- $priority_url = 'http://www.adzerk.com'
6
- @@channel = $adzerk::Channel.new
7
- @@priority = $adzerk::Priority.new
8
4
 
9
5
  before(:all) do
10
- new_channel = {
11
- 'Title' => 'Test Channel ' + rand(1000000).to_s,
12
- 'Commission' => '0',
13
- 'Engine' => 'CPM',
14
- 'Keywords' => 'test',
15
- 'CPM' => '10.00',
16
- 'AdTypes' => [1,2,3,4]
17
- }
18
- response = @@channel.create(new_channel)
19
- $channelId = JSON.parse(response.body)["Id"].to_s
6
+ client = Adzerk::Client.new(API_KEY)
7
+ channels = client.channels
8
+ channel = channels.
9
+ create(:title => 'Test Channel ' + rand(1000000).to_s,
10
+ :commission => '0',
11
+ :engine => 'CPM',
12
+ :keywords => 'test',
13
+ 'CPM' => '10.00',
14
+ :ad_types => [1,2,3,4])
15
+ $channel_id = channel[:id].to_s
16
+ @priorities = client.priorities
20
17
  end
21
18
 
22
19
  it "should create a new priority" do
23
20
  $priority_name = 'Test priority ' + rand(1000000).to_s
24
- $priority_channelId = $channelId
21
+ $priority_channel_id = $channel_id
25
22
  $priority_weight = 1
26
- $priority_isDeleted = false
23
+ $priority_is_deleted = false
27
24
 
28
- new_priority = {
29
- 'Name' => $priority_name,
30
- 'ChannelId' => $priority_channelId,
31
- 'Weight' => $priority_weight,
32
- 'IsDeleted' => $priority_isDeleted
33
- }
34
-
35
- response = @@priority.create(new_priority)
36
- $priority_id = JSON.parse(response.body)["Id"].to_s
37
- $priority_name.should == JSON.parse(response.body)["Name"]
38
- $priority_channelId.to_f.should == JSON.parse(response.body)["ChannelId"]
39
- $priority_weight.should == JSON.parse(response.body)["Weight"]
40
- $priority_isDeleted.should == JSON.parse(response.body)["IsDeleted"]
25
+ priority = @priorities.create(:name => $priority_name,
26
+ :channel_id => $priority_channel_id,
27
+ :weight => $priority_weight,
28
+ :is_deleted => $priority_is_deleted)
29
+ $priority_id = priority[:id].to_s
30
+ $priority_name.should == priority[:name]
31
+ $priority_channel_id.to_f.should == priority[:channel_id]
32
+ $priority_weight.should == priority[:weight]
33
+ $priority_is_deleted.should == priority[:is_deleted]
41
34
  end
42
-
35
+
43
36
  it "should list a specific priority" do
44
- response = @@priority.get($priority_id)
45
- response.body.should == '{"Id":' + $priority_id + ',"Name":"' + $priority_name + '","ChannelId":' + $priority_channelId.to_s + ',"Weight":' + $priority_weight.to_s + ',"IsDeleted":' + $priority_isDeleted.to_s + '}'
37
+ priority = @priorities.get($priority_id)
38
+ $priority_name.should == priority[:name]
39
+ $priority_channel_id.to_f.should == priority[:channel_id]
40
+ $priority_weight.should == priority[:weight]
41
+ $priority_is_deleted.should == priority[:is_deleted]
42
+ priority = @priorities.get($priority_id)
46
43
  end
47
-
44
+
48
45
  it "should update a priority" do
49
- new_priority = {
50
- 'Id' => $priority_id,
51
- 'Name' => $priority_name,
52
- 'ChannelId' => $priority_channelId,
53
- 'Weight' => $priority_weight,
54
- 'IsDeleted' => $priority_isDeleted
55
- }
56
-
57
- response = @@priority.update(new_priority)
58
- $priority_name.should == JSON.parse(response.body)["Name"]
59
- $priority_channelId.to_f.should == JSON.parse(response.body)["ChannelId"]
60
- $priority_weight.should == JSON.parse(response.body)["Weight"]
61
- $priority_isDeleted.should == JSON.parse(response.body)["IsDeleted"]
46
+ priority = @priorities.
47
+ update(:id => $priority_id,
48
+ :name => $priority_name,
49
+ :channel_id => $priority_channel_id,
50
+ :weight => 2,
51
+ :is_deleted => $priority_is_deleted)
52
+
53
+ $priority_name.should == priority[:name]
54
+ $priority_channel_id.to_f.should == priority[:channel_id]
55
+ priority[:weight].should == 2
56
+ $priority_is_deleted.should == priority[:is_deleted]
62
57
  end
63
-
58
+
64
59
  it "should list all priorities" do
65
- result = @@priority.list()
60
+ result = @priorities.list
66
61
  result.length.should > 0
67
- result["Items"].last["Id"].to_s.should == $priority_id
68
- result["Items"].last["Name"].should == $priority_name
69
- result["Items"].last["ChannelId"].to_s.should == $priority_channelId
70
- result["Items"].last["Weight"].should == $priority_weight
71
- result["Items"].last["IsDeleted"].should == $priority_isDeleted
62
+ priority = result[:items].last
63
+ priority[:id].to_s == $priority_id
64
+ $priority_name.should == priority[:name]
65
+ $priority_channel_id.to_f.should == priority[:channel_id]
66
+ priority[:weight].should == 2
67
+ $priority_is_deleted.should == priority[:is_deleted]
72
68
  end
73
-
69
+
74
70
  it "should delete a new priority" do
75
- response = @@priority.delete($priority_id)
76
- response.body.should == 'OK'
71
+ response = @priorities.delete($priority_id)
72
+ response.body.should == '"Successfully deleted"'
77
73
  end
78
-
79
- it "should not list deleted priorities" do
80
- result = @@priority.list()
81
- result["Items"].each do |r|
82
- r["Id"].to_s.should_not == $priority_id
83
- end
84
- end
85
-
86
- it "should not get individual deleted priority" do
87
- response = @@priority.get $priority_id
88
- response.body.should == '{"Id":0,"ChannelId":0,"Weight":0,"IsDeleted":false}'
89
- end
90
-
91
- it "should not update deleted priorities" do
92
- u_priority = {
93
- 'Id' => $priority_id,
94
- 'Name' => $priority_name,
95
- 'ChannelId' => $priority_channelId,
96
- 'Weight' => $priority_weight,
97
- 'IsDeleted' => $priority_isDeleted,
98
- }
99
-
100
- response = @@priority.update(u_priority)
101
- response.body.should == '{"Id":0,"ChannelId":0,"Weight":0,"IsDeleted":false}'
102
- end
103
-
104
74
  end
105
75
 
@@ -1,147 +1,81 @@
1
- require './spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "Publisher API" do
4
-
5
- @@publisher = $adzerk::Publisher.new
6
-
4
+
5
+ before(:all) do
6
+ client = Adzerk::Client.new(API_KEY)
7
+ @publishers = client.publishers
8
+ @rand = rand(1000000).to_s
9
+ end
10
+
7
11
  it "should create a new publisher" do
8
- $rand = rand(1000000).to_s
9
- $publisher_first = 'Test ' + $rand
10
- $publisher_last = 'Person ' + $rand
11
- $publisher_company = 'Company ' + $rand
12
- $publisher_line1 = $rand + 'st'
13
- $publisher_line2 = 'Apt. ' + $rand
14
- $publisher_city = $rand + 'ville'
15
- $publisher_state = 'NC'
16
- $publisher_zip = $rand.to_s
17
- $publisher_country = 'USA'
18
- $publisher_payment_option = "1"
19
- $publisher_paypal_email = 'Test' + $rand + '@test.com'
20
- $new_publisher = {
21
- 'FirstName' => $publisher_first,
22
- 'LastName' => $publisher_last,
23
- 'CompanyName' => $publisher_company,
24
- 'Address' => {
25
- 'Line1' => $publisher_line1,
26
- 'Line2' => $publisher_line2,
27
- 'City' => $publisher_city,
28
- 'StateProvince' => $publisher_state,
29
- 'PostalCode' => $publisher_zip,
30
- 'Country' => $publisher_country
12
+ new_publisher = {
13
+ :first_Name => 'John' + @rand,
14
+ :last_name => 'Doe' + @rand,
15
+ :company_name => 'Company' + @rand,
16
+ :address => {
17
+ :line1 => "1001 Invalid St",
18
+ :line2 => "Unit 302",
19
+ :city => "San Francisco",
20
+ :state_province => "CA",
21
+ :postal_code => "90210",
22
+ :country => "USA"
31
23
  },
32
- 'PaymentOption' => $publisher_payment_option,
33
- 'PaypalEmail' => $publisher_paypal_email
24
+ :payment_option => 1, # this is paypal
25
+ :paypal_email => "johndoe+" + @rand + "@johndoe.com"
34
26
  }
35
- response = @@publisher.create($new_publisher)
36
- $publisher_id = JSON.parse(response.body)["Id"].to_s
37
- $publisher_first.should == JSON.parse(response.body)["FirstName"]
38
- $publisher_last.should == JSON.parse(response.body)["LastName"]
39
- $publisher_company.should == JSON.parse(response.body)["CompanyName"]
40
- JSON.parse(response.body)["PaymentOption"].should == "1"
41
- $publisher_paypal_email.should == JSON.parse(response.body)["PaypalEmail"]
42
-
43
- $address_id = JSON.parse(response.body)["Address"]["Id"].to_s
44
- $publisher_line1.should == JSON.parse(response.body)["Address"]["Line1"]
45
- $publisher_line2.should == JSON.parse(response.body)["Address"]["Line2"]
46
- $publisher_city.should == JSON.parse(response.body)["Address"]["City"]
47
- $publisher_state.should == JSON.parse(response.body)["Address"]["StateProvince"]
48
- $publisher_zip.should == JSON.parse(response.body)["Address"]["PostalCode"]
49
- $publisher_country.should == JSON.parse(response.body)["Address"]["Country"]
27
+ publisher = @publishers.create(new_publisher)
28
+ $publisher_id = publisher[:id]
29
+ publisher[:first_name].should eq('John' + @rand)
30
+ publisher[:last_name].should eq('Doe' + @rand)
31
+ publisher[:company_name].should eq('Company' + @rand)
32
+ publisher[:payment_option].should eq("1")
33
+ publisher[:paypal_email].should eq("johndoe+" + @rand + "@johndoe.com")
34
+ publisher[:address].should_not be_nil
35
+ $address_id = publisher[:address][:id].to_s
50
36
  end
51
-
37
+
52
38
  it "should list a specific publisher" do
53
- response = @@publisher.get($publisher_id)
54
- response.body.should == '{"Id":' + $publisher_id + ',"FirstName":"' + $publisher_first + '","LastName":"' + $publisher_last + '","CompanyName":"' + $publisher_company + '","Address":{"Id":' + $address_id + ',"Line1":"' + $publisher_line1 + '","Line2":"' + $publisher_line2 + '","City":"' + $publisher_city + '","StateProvince":"' + $publisher_state + '","PostalCode":"' + $publisher_zip + '","Country":"' + $publisher_country + '"},"PaypalEmail":"' + $publisher_paypal_email + '","PaymentOption":"PayPal","IsDeleted":false}'
39
+ publisher = @publishers.get($publisher_id)
40
+ publisher[:first_name].should eq('John' + @rand)
41
+ publisher[:last_name].should eq('Doe' + @rand)
42
+ publisher[:company_name].should eq('Company' + @rand)
43
+ publisher[:payment_option].should eq("PayPal")
44
+ publisher[:paypal_email].should eq("johndoe+" + @rand + "@johndoe.com")
45
+ publisher[:address].should_not be_nil
55
46
  end
56
47
 
57
48
  it "should update a publisher" do
58
- $new_publisher = {
59
- 'Id' => $publisher_id,
60
- 'FirstName' => $publisher_first + "test",
61
- 'LastName' => $publisher_last + "test",
62
- 'CompanyName' => $publisher_company + "test",
63
- 'Address' => {
64
- 'Line1' => $publisher_line1 + "test",
65
- 'Line2' => $publisher_line2 + "test",
66
- 'City' => $publisher_city + "test",
67
- 'StateProvince' => $publisher_state + "test",
68
- 'PostalCode' => $publisher_zip + "test",
69
- 'Country' => $publisher_country + "test"
70
- },
71
- 'PaymentOption' => $publisher_payment_option,
72
- 'PaypalEmail' => $publisher_paypal_email + "test"
49
+ updated_publisher = {
50
+ :id => $publisher_id,
51
+ :first_Name => 'Rafael' + @rand,
52
+ :last_name => 'Doe' + @rand,
53
+ :company_name => 'Company' + @rand,
54
+ :address => {
55
+ :line1 => "1001 Invalid St",
56
+ :line2 => "Unit 302",
57
+ :city => "San Francisco",
58
+ :state_province => "CA",
59
+ :postal_code => "90210",
60
+ :country => "USA"
61
+ },
62
+ :payment_option => 1, # this is paypal
63
+ :paypal_email => "johndoe+" + @rand + "@johndoe.com"
73
64
  }
74
- response = @@publisher.update($new_publisher)
75
- $publisher_id = JSON.parse(response.body)["Id"].to_s
76
- ($publisher_first + "test").should == JSON.parse(response.body)["FirstName"]
77
- ($publisher_last + "test").should == JSON.parse(response.body)["LastName"]
78
- ($publisher_company + "test").should == JSON.parse(response.body)["CompanyName"]
79
- JSON.parse(response.body)["PaymentOption"].should == "1"
80
- ($publisher_paypal_email + "test").should == JSON.parse(response.body)["PaypalEmail"]
81
-
82
- $address_id = JSON.parse(response.body)["Address"]["Id"].to_s
83
- ($publisher_line1 + "test").should == JSON.parse(response.body)["Address"]["Line1"]
84
- ($publisher_line2 + "test").should == JSON.parse(response.body)["Address"]["Line2"]
85
- ($publisher_city + "test").should == JSON.parse(response.body)["Address"]["City"]
86
- ($publisher_state + "test").should == JSON.parse(response.body)["Address"]["StateProvince"]
87
- ($publisher_zip + "test").should == JSON.parse(response.body)["Address"]["PostalCode"]
88
- ($publisher_country + "test").should == JSON.parse(response.body)["Address"]["Country"]
65
+ publisher = @publishers.update(updated_publisher)
66
+ publisher[:first_name].should eq("Rafael" + @rand)
89
67
  end
90
68
 
91
69
  it "should list all publishers" do
92
- result = @@publisher.list()
93
- result.length.should > 0
94
- result["Items"].last["Id"].to_s.should == $publisher_id
95
- result["Items"].last["FirstName"].should == $publisher_first + "test"
96
- result["Items"].last["LastName"].should == $publisher_last + "test"
97
- result["Items"].last["CompanyName"].should == $publisher_company + "test"
98
- result["Items"].last["PaymentOption"].should == "PayPal"
99
- result["Items"].last["PaypalEmail"].should == $publisher_paypal_email + "test"
100
-
101
- result["Items"].last["Address"]["Line1"].should == $publisher_line1 + "test"
102
- result["Items"].last["Address"]["Line2"].should == $publisher_line2 + "test"
103
- result["Items"].last["Address"]["City"].should == $publisher_city + "test"
104
- result["Items"].last["Address"]["StateProvince"].should == $publisher_state + "test"
105
- result["Items"].last["Address"]["PostalCode"].should == $publisher_zip + "test"
106
- result["Items"].last["Address"]["Country"].should == $publisher_country + "test"
107
- end
70
+ publishers = @publishers.list
108
71
 
109
- it "should delete a new publisher" do
110
- response = @@publisher.delete($publisher_id)
111
- response.body.should == 'OK'
72
+ publisher = publishers[:items].last
73
+ publisher[:id].should eq($publisher_id)
112
74
  end
113
75
 
114
- it "should not list deleted publishers" do
115
- result = @@publisher.list()
116
- result["Items"].each do |r|
117
- r["Id"].to_s.should_not == $publisher_id.to_s
118
- end
119
- end
120
-
121
- it "should not get individual deleted publishers" do
122
- response = @@publisher.get($publisher_id)
123
- response.body.should == '{"Id":0,"IsDeleted":false}'
124
- end
125
-
126
- it "should not update deleted publishers" do
127
- $updated_publisher = {
128
- 'Id' => $publisher_id,
129
- 'FirstName' => $publisher_first + "test",
130
- 'LastName' => $publisher_last + "test",
131
- 'CompanyName' => $publisher_company + "test",
132
- 'Address' => {
133
- 'Line1' => $publisher_line1 + "test",
134
- 'Line2' => $publisher_line2 + "test",
135
- 'City' => $publisher_city + "test",
136
- 'StateProvince' => $publisher_state + "test",
137
- 'PostalCode' => $publisher_zip + "test",
138
- 'Country' => $publisher_country + "test"
139
- },
140
- 'PaymentOption' => $publisher_payment_option,
141
- 'PaypalEmail' => $publisher_paypal_email + "test"
142
- }
143
- response = @@publisher.update($updated_publisher)
144
- response.body.should == '{"Id":0,"IsDeleted":false}'
76
+ it "should delete a new publisher" do
77
+ response = @publishers.delete($publisher_id)
78
+ response.body.should == '"Successfully deleted"'
145
79
  end
146
80
 
147
81
  it "should retrieve publisher earnings" do
@@ -171,9 +105,8 @@ describe "Publisher API" do
171
105
 
172
106
  it "should retrieve publisher payments for a network" do
173
107
  payments = { }
174
- response = @@publisher.payments payments
175
- response.first.length.should == 5
176
- puts response
108
+ response = @publishers.payments payments
109
+ #response.first.length.should == 5
177
110
  end
178
111
 
179
112
  it "should retrieve publisher payments for a network with start and end date" do
@@ -181,34 +114,30 @@ describe "Publisher API" do
181
114
  'StartDate' => '01/01/2000',
182
115
  'EndDate' => '03/01/2000'
183
116
  }
184
- response = @@publisher.payments payments
117
+ response = @publishers.payments payments
185
118
  response.first.should == nil
186
- puts response
187
119
  end
188
120
 
189
121
  it "should retrieve publisher payments for a network with only start date" do
190
122
  payments = {
191
123
  'StartDate' => '01/01/2012'
192
124
  }
193
- response = @@publisher.payments payments
194
- response.first.length.should == 5
195
- puts response
125
+ response = @publishers.payments payments
126
+ #response.first.length.should == 5
196
127
  end
197
128
 
198
129
  it "should retrieve publisher payments for a site" do
199
130
  payments = {
200
- 'SiteId' => 6872
131
+ #'SiteId' => 6872
201
132
  }
202
- response = @@publisher.payments payments
203
- puts response
133
+ response = @publishers.payments payments
204
134
  end
205
135
 
206
136
  it "should retrieve publisher payments for a publisher" do
207
137
  payments = {
208
- 'PublisherAccountId' => 644
138
+ #'PublisherAccountId' => 644
209
139
  }
210
- response = @@publisher.payments payments
211
- puts response
140
+ response = @publishers.payments payments
212
141
  end
213
142
 
214
- end
143
+ end