oas 0.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/.gitignore +6 -6
  2. data/.travis.yml +9 -3
  3. data/Gemfile +4 -4
  4. data/LICENSE +20 -20
  5. data/README.md +47 -0
  6. data/Rakefile +11 -8
  7. data/lib/oas.rb +19 -31
  8. data/lib/oas/client.rb +39 -17
  9. data/lib/oas/configuration.rb +45 -45
  10. data/lib/oas/response.rb +31 -0
  11. data/lib/oas/version.rb +3 -3
  12. data/oas.gemspec +30 -29
  13. data/test/fixtures/successful_response.xml +15 -0
  14. data/test/helper.rb +6 -0
  15. data/test/test_client.rb +49 -0
  16. data/test/test_oas.rb +15 -0
  17. data/test/test_response.rb +22 -0
  18. metadata +85 -61
  19. data/.rspec +0 -2
  20. data/README.markdown +0 -103
  21. data/lib/oas/api.rb +0 -56
  22. data/lib/oas/client/campaigns.rb +0 -25
  23. data/lib/oas/client/databases.rb +0 -96
  24. data/lib/oas/client/notifications.rb +0 -15
  25. data/lib/oas/client/reports.rb +0 -71
  26. data/lib/oas/client/utils.rb +0 -16
  27. data/lib/oas/core_ext/hash.rb +0 -57
  28. data/lib/oas/core_ext/object.rb +0 -6
  29. data/lib/oas/error.rb +0 -17
  30. data/spec/fixtures/read_advertiser.xml +0 -49
  31. data/spec/fixtures/read_agency.xml +0 -49
  32. data/spec/fixtures/read_campaign.xml +0 -121
  33. data/spec/fixtures/read_campaign_group.xml +0 -31
  34. data/spec/fixtures/read_creative.xml +0 -52
  35. data/spec/fixtures/read_keyname.xml +0 -29
  36. data/spec/fixtures/read_keyword.xml +0 -27
  37. data/spec/fixtures/read_notification.xml +0 -31
  38. data/spec/fixtures/read_page.xml +0 -33
  39. data/spec/fixtures/read_section.xml +0 -30
  40. data/spec/fixtures/read_site.xml +0 -32
  41. data/spec/fixtures/read_site_group.xml +0 -33
  42. data/spec/fixtures/wsdl.xml +0 -37
  43. data/spec/oas/client/campaigns_spec.rb +0 -30
  44. data/spec/oas/client/databases_spec.rb +0 -111
  45. data/spec/oas/client/notifications_spec.rb +0 -16
  46. data/spec/oas_spec.rb +0 -14
  47. data/spec/spec_helper.rb +0 -29
@@ -0,0 +1,15 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
3
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
4
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
5
+ <soapenv:Body>
6
+ <ns1:OasXmlRequestResponse xmlns:ns1="http://api.oas.tfsm.com/">
7
+ <result>
8
+ <![CDATA[
9
+ <?xml version="1.0"?>
10
+ <AdXML><Response></Response></AdXML>
11
+ ]]>
12
+ </result>
13
+ </ns1:OasXmlRequestResponse>
14
+ </soapenv:Body>
15
+ </soapenv:Envelope>
data/test/helper.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+
4
+ require 'minitest/autorun'
5
+ require 'minitest/pride'
6
+ require 'oas'
@@ -0,0 +1,49 @@
1
+ require 'helper'
2
+ require 'webmock'
3
+
4
+ class TestClient < MiniTest::Unit::TestCase
5
+ include WebMock::API
6
+
7
+ def setup
8
+ OAS.reset!
9
+ @client = OAS::Client.new
10
+ end
11
+
12
+ def teardown
13
+ WebMock.reset!
14
+ end
15
+
16
+ def fixture(file)
17
+ File.new(File.join(File.expand_path("../fixtures", __FILE__), file))
18
+ end
19
+
20
+ def test_call_with_string_xml
21
+ res = Class.new do
22
+ def body; { :oas_xml_request_response => { :result => "<AdXML></AdXML>" } } end
23
+ end.new
24
+ @client.driver = MiniTest::Mock.new
25
+ @client.driver.expect :call, res, [:oas_xml_request, message: Hash["String_1", @client.account.to_s, "String_2", @client.username.to_s, "String_3", @client.password.to_s, "String_4", "<AdXML></AdXML>"]]
26
+ @client.request("<AdXML></AdXML>")
27
+ @client.driver.verify
28
+ end
29
+
30
+ def test_call_with_object_respond_to_xml
31
+ doc = Class.new do
32
+ def to_xml; "<AdXML></AdXML>" end
33
+ end.new
34
+ res = Class.new do
35
+ def body; { :oas_xml_request_response => { :result => "<AdXML></AdXML>" } } end
36
+ end.new
37
+ @client.driver = MiniTest::Mock.new
38
+ @client.driver.expect :call, res, [:oas_xml_request, message: Hash["String_1", @client.account.to_s, "String_2", @client.username.to_s, "String_3", @client.password.to_s, "String_4", doc.to_xml]]
39
+ @client.request(doc)
40
+ @client.driver.verify
41
+ end
42
+
43
+ def test_correctly_parse_soap_response
44
+ stub_request(:post, @client.endpoint.to_s)
45
+ .to_return(:status => 200, :body => fixture("successful_response.xml"))
46
+ res = @client.request("<AdXML></AdXML>")
47
+ assert_kind_of OAS::Response, res
48
+ end
49
+ end
data/test/test_oas.rb ADDED
@@ -0,0 +1,15 @@
1
+ require 'helper'
2
+
3
+ class TestOas < MiniTest::Unit::TestCase
4
+
5
+ describe "#configure" do
6
+ OAS::Configuration::VALID_OPTIONS_KEYS.each do |key|
7
+ it "should set the #{key}" do
8
+ OAS.configure do |config|
9
+ config.send("#{key}=", key)
10
+ assert_equal key, OAS.send(key)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,22 @@
1
+ require 'helper'
2
+
3
+ class TestResponse < MiniTest::Unit::TestCase
4
+ def setup
5
+ doc = <<EOF
6
+ <AdXML>
7
+ <Response>
8
+ </Response>
9
+ </AdXML>
10
+ EOF
11
+ @response = OAS::Response.new(doc)
12
+ end
13
+
14
+ def test_convert_to_hash
15
+ assert @response.to_hash.has_key?(:AdXML)
16
+ assert @response.to_hash[:AdXML].has_key?(:Response)
17
+ end
18
+
19
+ def test_convert_to_string_without_spaces_and_line_breaks
20
+ assert_equal "<AdXML><Response></Response></AdXML>", @response.to_s
21
+ end
22
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,75 +9,121 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-13 00:00:00.000000000 Z
12
+ date: 2013-01-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httpclient
16
- requirement: &70677300 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 2.2.0.2
21
+ version: '2.3'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70677300
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '2.3'
25
30
  - !ruby/object:Gem::Dependency
26
- name: nokogiri
27
- requirement: &70675520 !ruby/object:Gem::Requirement
31
+ name: savon
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ~>
31
36
  - !ruby/object:Gem::Version
32
- version: 1.4.4
37
+ version: '2.0'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *70675520
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '2.0'
36
46
  - !ruby/object:Gem::Dependency
37
- name: savon
38
- requirement: &70674200 !ruby/object:Gem::Requirement
47
+ name: nori
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ~>
42
52
  - !ruby/object:Gem::Version
43
- version: 0.9.2
53
+ version: '2.0'
44
54
  type: :runtime
45
55
  prerelease: false
46
- version_requirements: *70674200
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
47
62
  - !ruby/object:Gem::Dependency
48
- name: rake
49
- requirement: &70672880 !ruby/object:Gem::Requirement
63
+ name: minitest
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ~>
53
68
  - !ruby/object:Gem::Version
54
- version: 0.9.2.2
69
+ version: '4.3'
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *70672880
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '4.3'
58
78
  - !ruby/object:Gem::Dependency
59
- name: rspec
60
- requirement: &70671320 !ruby/object:Gem::Requirement
79
+ name: webmock
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ~>
64
84
  - !ruby/object:Gem::Version
65
- version: 2.5.0
85
+ version: '1.9'
66
86
  type: :development
67
87
  prerelease: false
68
- version_requirements: *70671320
69
- - !ruby/object:Gem::Dependency
70
- name: webmock
71
- requirement: &70670080 !ruby/object:Gem::Requirement
88
+ version_requirements: !ruby/object:Gem::Requirement
72
89
  none: false
73
90
  requirements:
74
91
  - - ~>
75
92
  - !ruby/object:Gem::Version
76
- version: 1.6.2
93
+ version: '1.9'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rake
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
77
102
  type: :development
78
103
  prerelease: false
79
- version_requirements: *70670080
80
- description: Ruby wrapper for the OAS 7.4 API
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: simplecov
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ description: Ruby client for the OpenAdstream API
81
127
  email:
82
128
  - damian.caruso@gmail.com
83
129
  executables: []
@@ -85,45 +131,23 @@ extensions: []
85
131
  extra_rdoc_files: []
86
132
  files:
87
133
  - .gitignore
88
- - .rspec
89
134
  - .travis.yml
90
135
  - Gemfile
91
136
  - LICENSE
92
- - README.markdown
137
+ - README.md
93
138
  - Rakefile
94
139
  - lib/oas.rb
95
- - lib/oas/api.rb
96
140
  - lib/oas/client.rb
97
- - lib/oas/client/campaigns.rb
98
- - lib/oas/client/databases.rb
99
- - lib/oas/client/notifications.rb
100
- - lib/oas/client/reports.rb
101
- - lib/oas/client/utils.rb
102
141
  - lib/oas/configuration.rb
103
- - lib/oas/core_ext/hash.rb
104
- - lib/oas/core_ext/object.rb
105
- - lib/oas/error.rb
142
+ - lib/oas/response.rb
106
143
  - lib/oas/version.rb
107
144
  - oas.gemspec
108
- - spec/fixtures/read_advertiser.xml
109
- - spec/fixtures/read_agency.xml
110
- - spec/fixtures/read_campaign.xml
111
- - spec/fixtures/read_campaign_group.xml
112
- - spec/fixtures/read_creative.xml
113
- - spec/fixtures/read_keyname.xml
114
- - spec/fixtures/read_keyword.xml
115
- - spec/fixtures/read_notification.xml
116
- - spec/fixtures/read_page.xml
117
- - spec/fixtures/read_section.xml
118
- - spec/fixtures/read_site.xml
119
- - spec/fixtures/read_site_group.xml
120
- - spec/fixtures/wsdl.xml
121
- - spec/oas/client/campaigns_spec.rb
122
- - spec/oas/client/databases_spec.rb
123
- - spec/oas/client/notifications_spec.rb
124
- - spec/oas_spec.rb
125
- - spec/spec_helper.rb
126
- homepage: http://github.com/realmedia/ruby-oas
145
+ - test/fixtures/successful_response.xml
146
+ - test/helper.rb
147
+ - test/test_client.rb
148
+ - test/test_oas.rb
149
+ - test/test_response.rb
150
+ homepage: http://github.com/realmedia/oas-ruby-client
127
151
  licenses: []
128
152
  post_install_message:
129
153
  rdoc_options: []
@@ -137,7 +161,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
137
161
  version: '0'
138
162
  segments:
139
163
  - 0
140
- hash: -204055725
164
+ hash: 67502451
141
165
  required_rubygems_version: !ruby/object:Gem::Requirement
142
166
  none: false
143
167
  requirements:
@@ -146,11 +170,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
170
  version: '0'
147
171
  segments:
148
172
  - 0
149
- hash: -204055725
173
+ hash: 67502451
150
174
  requirements: []
151
175
  rubyforge_project: oas
152
- rubygems_version: 1.8.10
176
+ rubygems_version: 1.8.24
153
177
  signing_key:
154
178
  specification_version: 3
155
- summary: Ruby wrapper for the OAS 7.4 API
179
+ summary: Ruby client for the OpenAdstream API
156
180
  test_files: []
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --color
2
- --format documentation
data/README.markdown DELETED
@@ -1,103 +0,0 @@
1
- OAS API Ruby Gem
2
- ====================
3
- A Ruby wrapper for OAS 7.4 API
4
-
5
- Installation
6
- ------------
7
- gem install oas
8
-
9
- Usage Examples
10
- --------------
11
- require "rubygems"
12
- require "oas"
13
-
14
- # All methods require authentication.
15
- Oas.configure do |config|
16
- config.endpoint = WSDL_URI
17
- config.account = YOUR_OAS_ACCOUNT
18
- config.username = YOUR_USERNAME
19
- config.password = YOUR_PASSWORD
20
- end
21
-
22
- # Read an advertiser
23
- puts Oas.advertiser("advertiser_id")
24
-
25
- # Read an agency
26
- puts Oas.agency("agency_id")
27
-
28
- # Read a campaign
29
- puts Oas.campaign("campaign_id")
30
-
31
- # Read a campaign group
32
- puts Oas.campaign_group("campaign_group_id")
33
-
34
- # Read a creative
35
- puts Oas.creative("campaign_id", "creative_id")
36
-
37
- # Read a keyname
38
- puts Oas.keyname("keyname")
39
-
40
- # Read a keyword
41
- puts Oas.keyword("keyword_id")
42
-
43
- # Read a notification
44
- puts Oas.notification("campaign_id", "event_name")
45
-
46
- # Read a page
47
- puts Oas.page("page_url")
48
-
49
- # Read a section
50
- puts Oas.section("section_id")
51
-
52
- # Read a site
53
- puts Oas.site("site_id")
54
-
55
- # Read a site group
56
- puts Oas.site_group("site_group_id")
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
-
92
- TODO
93
- ------------
94
-
95
- * Create and update support on Campaign and Database sections.
96
- * Listings
97
- * Reach and Frequency Reports
98
- * Inventory
99
-
100
- Copyright
101
- ---------
102
- Copyright (c) 2011 Realmedia LatinAmerica.
103
- See [LICENSE](https://github.com/realmedia/ruby-oas/blob/master/LICENSE) for details.