oas 0.1.0 → 0.1.1

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/README.markdown CHANGED
@@ -55,12 +55,46 @@ Usage Examples
55
55
  # Read a site group
56
56
  puts Oas.site_group("site_group_id")
57
57
 
58
+ # Reports
59
+ # StartDate defaults to first time in history
60
+ # EndDate defaults to Date.today
61
+
62
+ # Get advertiser reports
63
+ puts Oas.advertiser_report("advertiser_id", "Delivery.Advertiser.Base.T602.01,Delivery.Advertiser.Base.T652.01", "2011/01/01", "2011/01/31")
64
+
65
+ # Get campaign reports
66
+ puts Oas.campaign_report("campaign_id", "Delivery.Campaign.Base.T154.01")
67
+
68
+ # Get section reports
69
+ puts Oas.section_report("section_id", "Delivery.Section.Cookie.T358.01")
70
+
71
+ # Get site reports
72
+ puts Oas.site_report("site_id", "Delivery.Site.Base.T258.01")
73
+
74
+ # Get Site Performance Reports
75
+ puts Oas.site_performance_report("site_id, other_site_id", "2011/01/01", "2011/01/31")
76
+
77
+ # Get Page Priority Reports
78
+ puts Oas.page_priority_report("www.247realmedia.com/home")
79
+
80
+ # Get Campaigns Status Report
81
+ puts Oas.campaign_status_report
82
+
83
+ #Execute not implemented request
84
+ puts Oas.client.request('Site') do |xml|
85
+ xml.Database(:action => 'list') {
86
+ xml.SearchCriteria {
87
+ xml.Id "%"
88
+ }
89
+ }
90
+ end.inspect
91
+
58
92
  TODO
59
93
  ------------
60
94
 
61
95
  * Create and update support on Campaign and Database sections.
62
96
  * Listings
63
- * Reports
97
+ * Reach and Frequency Reports
64
98
  * Inventory
65
99
 
66
100
  Copyright
data/lib/oas/api.rb CHANGED
@@ -30,13 +30,13 @@ module Oas
30
30
  }
31
31
  end
32
32
  response = Hash.from_xml(response.to_hash[:oas_xml_request_response][:result])[:AdXML][:Response]
33
- verify_errors(request_type, response)
33
+ verify_errors(response)
34
34
  response
35
35
  end
36
36
 
37
37
  private
38
- def verify_errors(request_type, response)
39
- return if (e = response[:Exception]).nil? && (e = response[request_type.to_sym][:Exception]).nil?
38
+ def verify_errors(response)
39
+ return if ((e = response[:Exception]).nil? && (!response[response.keys.first].is_a?(Hash) || (e = response[response.keys.first][:Exception]).nil?))
40
40
  error_code = e[:errorCode]
41
41
  error_msg = e[:content]
42
42
  case error_code
@@ -1,7 +1,7 @@
1
1
  module Oas
2
2
  class Client
3
3
  # Defines methods related to oas campaigns
4
- module Campaign
4
+ module Campaigns
5
5
  def campaign(id)
6
6
  request("Campaign") do |xml|
7
7
  xml.Campaign(:action => "read") {
@@ -10,7 +10,16 @@ module Oas
10
10
  }
11
11
  }
12
12
  end
13
- end
13
+ end
14
+
15
+ def creative(campaign_id, id)
16
+ request("Creative") do |xml|
17
+ xml.Creative(:action => "read") {
18
+ xml.CampaignId campaign_id
19
+ xml.Id id
20
+ }
21
+ end
22
+ end
14
23
  end
15
24
  end
16
25
  end
@@ -1,7 +1,7 @@
1
1
  module Oas
2
2
  class Client
3
- # Defines methods related to oas database section
4
- module Database
3
+ # Defines methods related to oas databases section
4
+ module Databases
5
5
  def advertiser(id)
6
6
  request("Advertiser") do |xml|
7
7
  xml.Database(:action => "read") {
@@ -1,7 +1,7 @@
1
1
  module Oas
2
2
  class Client
3
3
  # Defines methods related to oas campaigns
4
- module Notification
4
+ module Notifications
5
5
  def notification(campaign_id, event_name)
6
6
  request("Notification") do |xml|
7
7
  xml.Notification(:action => "read") {
@@ -0,0 +1,71 @@
1
+ module Oas
2
+ class Client
3
+ # Defines methods related to oas reports section
4
+ module Reports
5
+ class MissingTablesError < Client::Error; end
6
+
7
+ def advertiser_report(advertiser_id, report_ids, start_date = nil, end_date = Date.today)
8
+ report_request("Advertiser", advertiser_id, report_ids, start_date, end_date)
9
+ end
10
+
11
+ def campaign_report(campaign_id, report_ids, start_date, end_date = Date.today)
12
+ report_request("Campaign", campaign_id, report_ids, start_date, end_date)
13
+ end
14
+
15
+ def section_report(section_id, report_ids, start_date = nil, end_date = Date.today)
16
+ report_request("Section", site_id, report_ids, start_date, end_date)
17
+ end
18
+
19
+ def site_report(site_id, report_ids, start_date = nil, end_date = Date.today)
20
+ report_request("Site", site_id, report_ids, start_date = Date.today, end_date)
21
+ end
22
+
23
+ def site_performance_report(site_ids = "", start_date = nil, end_date = Date.today)
24
+ request("SitePerformanceReport") do |xml|
25
+ xml.SitePerformanceReport {
26
+ xml.Ids {
27
+ site_ids.split(",").each do |s|
28
+ xml.Id s
29
+ end
30
+ }
31
+ xml.StartDate start_date
32
+ xml.EndDate end_date
33
+ xml.Table "Performance.Site.Base.T100.03"
34
+ }
35
+ end
36
+ end
37
+
38
+ def page_priority_report(page_url)
39
+ request("PagePriorityReport") do |xml|
40
+ xml.PagePriorityReport {
41
+ xml.Id page_url
42
+ xml.Table "Delivery.Page.Base.T100.05"
43
+ }
44
+ end
45
+ end
46
+
47
+ def campaign_status_report
48
+ request("StatusReport") do |xml|
49
+ xml.StatusReport(:type => "Campaign") {
50
+ xml.Table "ImpressionCampaignStatusDetail"
51
+ }
52
+ end
53
+ end
54
+
55
+ private
56
+ def report_request(type, id, report_ids, start_date, end_date)
57
+ raise NoReportTablesError.new if report_ids.blank?
58
+ request("Report") do |xml|
59
+ xml.Report(:type => type) {
60
+ xml.Id id
61
+ xml.StartDate start_date
62
+ xml.EndDate end_date
63
+ report_ids.split(",").each do |r|
64
+ xml.Table r
65
+ end
66
+ }
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
data/lib/oas/client.rb CHANGED
@@ -1,15 +1,17 @@
1
1
  module Oas
2
2
  class Client < Api
3
+ class Error < StandardError; end
4
+
3
5
  require 'oas/client/utils'
4
- require 'oas/client/campaign'
5
- require 'oas/client/creative'
6
- require 'oas/client/database'
7
- require 'oas/client/notification'
6
+ require 'oas/client/campaigns'
7
+ require 'oas/client/databases'
8
+ require 'oas/client/notifications'
9
+ require 'oas/client/reports'
8
10
 
9
11
  include Oas::Client::Utils
10
- include Oas::Client::Campaign
11
- include Oas::Client::Creative
12
- include Oas::Client::Database
13
- include Oas::Client::Notification
12
+ include Oas::Client::Campaigns
13
+ include Oas::Client::Databases
14
+ include Oas::Client::Notifications
15
+ include Oas::Client::Reports
14
16
  end
15
17
  end
data/lib/oas/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Oas
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -1,6 +1,19 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Oas::Client do
4
+ describe "campaign" do
5
+ before(:each) do
6
+ stub_api_call fixture("read_campaign.xml")
7
+ end
8
+
9
+ it "should return a campaign hash for a given id" do
10
+ response = Oas.campaign("campaign_id")
11
+ response.should_not be_nil
12
+ response[:Campaign].should be_a(Hash)
13
+ response[:Campaign][:Overview][:Id].should eq("campaign_id")
14
+ end
15
+ end
16
+
4
17
  describe "creative" do
5
18
  before(:each) do
6
19
  stub_api_call fixture("read_creative.xml")
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: oas
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Damian Caruso
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-12 00:00:00 -03:00
13
+ date: 2011-05-19 00:00:00 -03:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -87,10 +87,10 @@ files:
87
87
  - lib/oas.rb
88
88
  - lib/oas/api.rb
89
89
  - lib/oas/client.rb
90
- - lib/oas/client/campaign.rb
91
- - lib/oas/client/creative.rb
92
- - lib/oas/client/database.rb
93
- - lib/oas/client/notification.rb
90
+ - lib/oas/client/campaigns.rb
91
+ - lib/oas/client/databases.rb
92
+ - lib/oas/client/notifications.rb
93
+ - lib/oas/client/reports.rb
94
94
  - lib/oas/client/utils.rb
95
95
  - lib/oas/configuration.rb
96
96
  - lib/oas/core_ext/hash.rb
@@ -111,10 +111,9 @@ files:
111
111
  - spec/fixtures/read_site.xml
112
112
  - spec/fixtures/read_site_group.xml
113
113
  - spec/fixtures/wsdl.xml
114
- - spec/oas/client/campaign_spec.rb
115
- - spec/oas/client/creative_spec.rb
116
- - spec/oas/client/database_spec.rb
117
- - spec/oas/client/notification_spec.rb
114
+ - spec/oas/client/campaigns_spec.rb
115
+ - spec/oas/client/databases_spec.rb
116
+ - spec/oas/client/notifications_spec.rb
118
117
  - spec/oas_spec.rb
119
118
  - spec/spec_helper.rb
120
119
  has_rdoc: true
@@ -1,15 +0,0 @@
1
- module Oas
2
- class Client
3
- # Defines methods related to oas campaign creatives
4
- module Creative
5
- def creative(campaign_id, id)
6
- request("Creative") do |xml|
7
- xml.Creative(:action => "read") {
8
- xml.CampaignId campaign_id
9
- xml.Id id
10
- }
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,16 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Oas::Client do
4
- describe "campaign" do
5
- before(:each) do
6
- stub_api_call fixture("read_campaign.xml")
7
- end
8
-
9
- it "should return a campaign hash for a given id" do
10
- response = Oas.campaign("campaign_id")
11
- response.should_not be_nil
12
- response[:Campaign].should be_a(Hash)
13
- response[:Campaign][:Overview][:Id].should eq("campaign_id")
14
- end
15
- end
16
- end