roflmoas 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in propaganda.gemspec
4
+ gemspec
5
+
6
+ group :development, :test do
7
+ gem 'rspec'
8
+ gem 'webmock'
9
+ gem 'vcr'
10
+ end
@@ -0,0 +1,33 @@
1
+ # Lets ROFL!
2
+ RoflOAS is a library to help you to interact with OAS and their strange soap API.
3
+
4
+ ## Installation
5
+ gem install roflmoas
6
+
7
+ ## Configuration
8
+ Add global configurations directly to the RoflmOAS module:
9
+
10
+ RoflmOAS.configure do |config|
11
+ config.endpoint = "The wsdl endpoint"
12
+ config.account = "Your OAS account"
13
+ config.username = "LOL"
14
+ config.password = "WUT"
15
+ end
16
+
17
+ You can override any settings when you instantiate a new client
18
+
19
+ client = RoflmOAS::Client.new :username => "Other", :password => "Secret"
20
+
21
+ ## Usage
22
+ client = RoflmOAS::Client.new
23
+ campaign = client.read_campaign("campaign_id")
24
+
25
+ You can also make requests that are not yet natively implemented
26
+
27
+ client.request "Campaign" do |xml|
28
+ xml.Campaign(:action => "list") do
29
+ xml.SearchCriteria do
30
+ xml.Status "L"
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,21 @@
1
+ require 'active_support/core_ext/module/attribute_accessors'
2
+ require 'active_support/core_ext/hash/reverse_merge'
3
+ require 'savon'
4
+ require 'roflmoas/errors'
5
+
6
+ module RoflmOAS
7
+ autoload :Client, "roflmoas/client"
8
+ autoload :Campaign, "roflmoas/campaign"
9
+
10
+ mattr_accessor :endpoint
11
+ @@endpoint = "https://training7.247realmedia.com//oasapi/OaxApi?wsdl"
12
+
13
+ mattr_accessor :account
14
+ @@account = "OasDefault"
15
+
16
+ mattr_accessor :username, :password
17
+
18
+ def configure
19
+ yield self
20
+ end
21
+ end
@@ -0,0 +1,11 @@
1
+ module RoflmOAS
2
+ module Campaign
3
+ def read_campaign(id)
4
+ request "Campaign" do |xml|
5
+ xml.Campaign(:action => "read") do
6
+ xml.Overview { xml.Id id }
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,58 @@
1
+ module RoflmOAS
2
+ class Client
3
+ attr_accessor :endpoint, :account, :username, :password
4
+
5
+ include Campaign
6
+
7
+ def initialize(options = {})
8
+ options.reverse_merge! :endpoint => RoflmOAS.endpoint,
9
+ :account => RoflmOAS.account,
10
+ :username => RoflmOAS.username,
11
+ :password => RoflmOAS.password
12
+
13
+ options.each_pair do |key, value|
14
+ send "#{key}=", value
15
+ end
16
+ end
17
+
18
+ def request(method)
19
+ body = Nokogiri::XML::Builder.new(:encoding => "UTF-8") do |xml|
20
+ xml.AdXML do
21
+ xml.Request(:type => method) do
22
+ yield xml
23
+ end
24
+ end
25
+ end
26
+
27
+ response = Savon::Client.new(endpoint).request :n1, :oas_xml_request, :"xmlns:n1" => "http://api.oas.tfsm.com/" do
28
+ soap.body = {
29
+ "String_1" => account,
30
+ "String_2" => username,
31
+ "String_3" => password,
32
+ "String_4" => body.to_xml
33
+ }
34
+ end
35
+
36
+ parse(response)
37
+ end
38
+
39
+ protected
40
+
41
+ def parse(response)
42
+ response = Nokogiri::XML.parse(response.to_hash[:oas_xml_request_response][:result])
43
+ raise_errors(response)
44
+ response.css("AdXML > Response > *").first
45
+ end
46
+
47
+ def raise_errors(response)
48
+ return if (error = response.css("Exception")).empty?
49
+
50
+ case error.attribute("errorCode").value.to_i
51
+ when 545
52
+ raise RoflmOAS::NotFoundError.new
53
+ else
54
+ raise RoflmOAS::OASError
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,4 @@
1
+ module RoflmOAS
2
+ class OASError < StandardError; end
3
+ class NotFoundError < OASError; end
4
+ end
@@ -0,0 +1,3 @@
1
+ module RoflmOAS
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "roflmoas/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "roflmoas"
7
+ s.version = RoflmOAS::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Rodrigo Navarro"]
10
+ s.email = ["navarro@manapot.com.br"]
11
+ s.homepage = ""
12
+ s.summary = %q{Funny API to access OAS hellish soap interface}
13
+ s.description = %q{Help you to communicate with the corporate advertisers world!}
14
+
15
+ s.rubyforge_project = "roflmoas"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_dependency "savon", "~> 0.9.2"
23
+ s.add_dependency "nokogiri", "~> 1.4.4"
24
+ s.add_dependency "activesupport", "~> 3.0.0"
25
+ end
@@ -0,0 +1,240 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :get
5
+ uri: https://training7.247realmedia.com:443//oasapi/OaxApi?wsdl
6
+ body:
7
+ headers:
8
+ response: !ruby/struct:VCR::Response
9
+ status: !ruby/struct:VCR::ResponseStatus
10
+ code: 200
11
+ message: OK
12
+ headers:
13
+ etag:
14
+ - "\"44e617-674-48c8d0448cd40\""
15
+ p3p:
16
+ - CP="NON NID PSAa PSDa OUR IND UNI COM NAV STA",policyref="/w3c/p3p.xml"
17
+ last-modified:
18
+ - Thu, 29 Jul 2010 20:59:57 GMT
19
+ content-type:
20
+ - text/xml
21
+ server:
22
+ - Apache/2.2.3 (Red Hat)
23
+ date:
24
+ - Wed, 25 May 2011 15:28:22 GMT
25
+ content-length:
26
+ - "1652"
27
+ accept-ranges:
28
+ - bytes
29
+ body: |
30
+ <?xml version="1.0" encoding="UTF-8"?>
31
+ <definitions name="OaxApiService" targetNamespace="http://api.oas.tfsm.com/" xmlns:tns="http://api.oas.tfsm.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://schemas.xmlsoap.org/wsdl/">
32
+ <types>
33
+ </types>
34
+ <message name="OaxApi_OasXmlRequestResponse">
35
+ <part name="result" type="xsd:string">
36
+ </part>
37
+ </message>
38
+ <message name="OaxApi_OasXmlRequest">
39
+ <part name="String_1" type="xsd:string">
40
+
41
+ </part>
42
+ <part name="String_2" type="xsd:string">
43
+ </part>
44
+ <part name="String_3" type="xsd:string">
45
+ </part>
46
+ <part name="String_4" type="xsd:string">
47
+ </part>
48
+ </message>
49
+ <portType name="OaxApi">
50
+
51
+ <operation name="OasXmlRequest" parameterOrder="String_1 String_2 String_3 String_4">
52
+ <input message="tns:OaxApi_OasXmlRequest">
53
+ </input>
54
+ <output message="tns:OaxApi_OasXmlRequestResponse">
55
+ </output>
56
+ </operation>
57
+ </portType>
58
+ <binding name="OaxApiBinding" type="tns:OaxApi">
59
+ <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
60
+
61
+ <operation name="OasXmlRequest">
62
+ <soap:operation soapAction=""/>
63
+ <input>
64
+ <soap:body use="literal" namespace="http://api.oas.tfsm.com/"/>
65
+ </input>
66
+ <output>
67
+ <soap:body use="literal" namespace="http://api.oas.tfsm.com/"/>
68
+ </output>
69
+ </operation>
70
+
71
+ </binding>
72
+ <service name="OaxApiService">
73
+ <port name="OaxApiPort" binding="tns:OaxApiBinding">
74
+ <soap:address location="https://training7.247realmedia.com:443/oasapi/OaxApi"/>
75
+ </port>
76
+ </service>
77
+ </definitions>
78
+
79
+ http_version: "1.1"
80
+ - !ruby/struct:VCR::HTTPInteraction
81
+ request: !ruby/struct:VCR::Request
82
+ method: :post
83
+ uri: https://training7.247realmedia.com:443/oasapi/OaxApi
84
+ body: |-
85
+ <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:n1="http://api.oas.tfsm.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><n1:OasXmlRequest xmlns:n1="http://api.oas.tfsm.com/"><String_1>Abril</String_1><String_2>dev_abril</String_2><String_3>d3v@p1SgpD</String_3><String_4>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
86
+ &lt;AdXML&gt;
87
+ &lt;Request type=&quot;Campaign&quot;&gt;
88
+ &lt;Campaign action=&quot;read&quot;&gt;
89
+ &lt;Overview&gt;
90
+ &lt;Id&gt;abx_oferta3&lt;/Id&gt;
91
+ &lt;/Overview&gt;
92
+ &lt;/Campaign&gt;
93
+ &lt;/Request&gt;
94
+ &lt;/AdXML&gt;
95
+ </String_4></n1:OasXmlRequest></env:Body></env:Envelope>
96
+ headers:
97
+ content-type:
98
+ - text/xml;charset=UTF-8
99
+ soapaction:
100
+ - "\"OasXmlRequest\""
101
+ response: !ruby/struct:VCR::Response
102
+ status: !ruby/struct:VCR::ResponseStatus
103
+ code: 200
104
+ message: OK
105
+ headers:
106
+ x-powered-by:
107
+ - Servlet 2.5; JBoss-5.0/JBossWeb-2.1
108
+ p3p:
109
+ - CP="NON NID PSAa PSDa OUR IND UNI COM NAV STA",policyref="/w3c/p3p.xml"
110
+ content-type:
111
+ - text/xml;charset=UTF-8
112
+ via:
113
+ - 1.1 training7.247realmedia.com
114
+ server:
115
+ - Apache-Coyote/1.1
116
+ date:
117
+ - Wed, 25 May 2011 15:28:24 GMT
118
+ transfer-encoding:
119
+ - chunked
120
+ body: |-
121
+ <?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns1:OasXmlRequestResponse xmlns:ns1="http://api.oas.tfsm.com/"><result>&lt;?xml version='1.0'?>
122
+ &lt;AdXML>
123
+
124
+ &lt;Response>
125
+ &lt;Campaign>
126
+ &lt;Overview>
127
+ &lt;Id>abx_oferta3&lt;/Id>
128
+ &lt;AdvertiserId>abx_anunciante&lt;/AdvertiserId>
129
+ &lt;Name>abx_oferta2&lt;/Name>
130
+ &lt;AgencyId>vitrine&lt;/AgencyId>
131
+ &lt;Description/>
132
+ &lt;ProductId>vitrine&lt;/ProductId>
133
+ &lt;Status>L&lt;/Status>
134
+ &lt;CampaignGroups>
135
+ &lt;CampaignGroupId>abx_anunciante&lt;/CampaignGroupId>
136
+ &lt;/CampaignGroups>
137
+ &lt;CompetitiveCategories/>
138
+ &lt;ExternalUsers/>
139
+ &lt;InternalQuickReport>to-date&lt;/InternalQuickReport>
140
+ &lt;ExternalQuickReport>short&lt;/ExternalQuickReport>
141
+ &lt;WhoCreated>vitrine_api&lt;/WhoCreated>
142
+ &lt;WhenCreated>2011-04-11 16:15:32&lt;/WhenCreated>
143
+ &lt;WhoModified>vitrine_api&lt;/WhoModified>
144
+ &lt;WhenModified>2011-04-11 16:23:43&lt;/WhenModified>
145
+ &lt;/Overview>
146
+ &lt;Schedule>
147
+ &lt;Impressions>0&lt;/Impressions>
148
+ &lt;Clicks>0&lt;/Clicks>
149
+ &lt;Uniques>0&lt;/Uniques>
150
+ &lt;Weight>0&lt;/Weight>
151
+ &lt;PriorityLevel>5&lt;/PriorityLevel>
152
+ &lt;Completion>S&lt;/Completion>
153
+ &lt;StartDate>2011-04-11&lt;/StartDate>
154
+ &lt;StartTime>00:00&lt;/StartTime>
155
+ &lt;EndDate>&lt;/EndDate>
156
+ &lt;EndTime>&lt;/EndTime>
157
+ &lt;Reach>O&lt;/Reach>
158
+ &lt;DailyImp>0&lt;/DailyImp>
159
+ &lt;DailyGoals/>
160
+ &lt;DailyClicks>0&lt;/DailyClicks>
161
+ &lt;DailyUniq>0&lt;/DailyUniq>
162
+ &lt;SmoothOrAsap>S&lt;/SmoothOrAsap>
163
+ &lt;ImpOverrun>0&lt;/ImpOverrun>
164
+ &lt;CompanionPositions/>
165
+ &lt;StrictCompanions>N&lt;/StrictCompanions>
166
+ &lt;PrimaryFrequency>
167
+ &lt;ImpPerVisitor>0&lt;/ImpPerVisitor>
168
+ &lt;ClickPerVisitor>0&lt;/ClickPerVisitor>
169
+ &lt;FreqScope>0&lt;/FreqScope>
170
+ &lt;/PrimaryFrequency>
171
+ &lt;SecondaryFrequency>
172
+ &lt;ImpPerVisitor>0&lt;/ImpPerVisitor>
173
+ &lt;FreqScope>0&lt;/FreqScope>
174
+ &lt;/SecondaryFrequency>
175
+ &lt;HourOfDay/>
176
+ &lt;DayOfWeek/>
177
+ &lt;UserTimeZone>N&lt;/UserTimeZone>
178
+ &lt;Sections/>
179
+ &lt;CampaignPauses/>
180
+ &lt;/Schedule>
181
+ &lt;Pages/>
182
+ &lt;Target>
183
+ &lt;ExcludeTargets>N&lt;/ExcludeTargets>
184
+ &lt;TopLevelDomain/>
185
+ &lt;Domain>&lt;/Domain>
186
+ &lt;Bandwidth/>
187
+ &lt;Continent/>
188
+ &lt;Country/>
189
+ &lt;State/>
190
+ &lt;AreaCode/>
191
+ &lt;Msa/>
192
+ &lt;Dma/>
193
+ &lt;City/>
194
+ &lt;Zones/>
195
+ &lt;Zip/>
196
+ &lt;ClaritasSegments/>
197
+ &lt;Omniture/>
198
+ &lt;Os/>
199
+ &lt;Browser/>
200
+ &lt;BrowserV/>
201
+ &lt;SearchType>A&lt;/SearchType>
202
+ &lt;SearchTerm>&lt;/SearchTerm>
203
+ &lt;Cookie/>
204
+ &lt;AgeFrom>&lt;/AgeFrom>
205
+ &lt;AgeTo>&lt;/AgeTo>
206
+ &lt;Gender>
207
+ &lt;Code>E&lt;/Code>
208
+ &lt;/Gender>
209
+ &lt;IncomeFrom>&lt;/IncomeFrom>
210
+ &lt;IncomeTo>&lt;/IncomeTo>
211
+ &lt;SubscriberCode>&lt;/SubscriberCode>
212
+ &lt;PreferenceFlags>&lt;/PreferenceFlags>
213
+ &lt;Cluster/>
214
+ &lt;/Target>
215
+ &lt;Exclude>
216
+ &lt;Sites/>
217
+ &lt;Pages/>
218
+ &lt;/Exclude>
219
+ &lt;Billing>
220
+ &lt;ContractedRevenue>&lt;/ContractedRevenue>
221
+ &lt;BillOffContracted>N&lt;/BillOffContracted>
222
+ &lt;Cpm>0.0000&lt;/Cpm>
223
+ &lt;Cpc>0.0000&lt;/Cpc>
224
+ &lt;Cpa>&lt;/Cpa>
225
+ &lt;FlatRate>&lt;/FlatRate>
226
+ &lt;Tax>&lt;/Tax>
227
+ &lt;AgencyCommission>0.00&lt;/AgencyCommission>
228
+ &lt;PaymentMethod>C&lt;/PaymentMethod>
229
+ &lt;PurchaseOrder/>
230
+ &lt;SalesRepresentative/>
231
+ &lt;CommissionPercent>0.0000&lt;/CommissionPercent>
232
+ &lt;Notes/>
233
+ &lt;IsYieldManaged>N&lt;/IsYieldManaged>
234
+ &lt;BillTo>G&lt;/BillTo>
235
+ &lt;Currency/>
236
+ &lt;/Billing>
237
+ &lt;/Campaign>
238
+ &lt;/Response>
239
+ &lt;/AdXML></result></ns1:OasXmlRequestResponse></soapenv:Body></soapenv:Envelope>
240
+ http_version: "1.1"
@@ -0,0 +1,291 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :get
5
+ uri: https://training7.247realmedia.com:443//oasapi/OaxApi?wsdl
6
+ body:
7
+ headers:
8
+ response: !ruby/struct:VCR::Response
9
+ status: !ruby/struct:VCR::ResponseStatus
10
+ code: 200
11
+ message: OK
12
+ headers:
13
+ etag:
14
+ - "\"44e617-674-48c8d0448cd40\""
15
+ last-modified:
16
+ - Thu, 29 Jul 2010 20:59:57 GMT
17
+ p3p:
18
+ - CP="NON NID PSAa PSDa OUR IND UNI COM NAV STA",policyref="/w3c/p3p.xml"
19
+ content-type:
20
+ - text/xml
21
+ date:
22
+ - Wed, 25 May 2011 15:16:42 GMT
23
+ server:
24
+ - Apache/2.2.3 (Red Hat)
25
+ content-length:
26
+ - "1652"
27
+ accept-ranges:
28
+ - bytes
29
+ body: |
30
+ <?xml version="1.0" encoding="UTF-8"?>
31
+ <definitions name="OaxApiService" targetNamespace="http://api.oas.tfsm.com/" xmlns:tns="http://api.oas.tfsm.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://schemas.xmlsoap.org/wsdl/">
32
+ <types>
33
+ </types>
34
+ <message name="OaxApi_OasXmlRequestResponse">
35
+ <part name="result" type="xsd:string">
36
+ </part>
37
+ </message>
38
+ <message name="OaxApi_OasXmlRequest">
39
+ <part name="String_1" type="xsd:string">
40
+
41
+ </part>
42
+ <part name="String_2" type="xsd:string">
43
+ </part>
44
+ <part name="String_3" type="xsd:string">
45
+ </part>
46
+ <part name="String_4" type="xsd:string">
47
+ </part>
48
+ </message>
49
+ <portType name="OaxApi">
50
+
51
+ <operation name="OasXmlRequest" parameterOrder="String_1 String_2 String_3 String_4">
52
+ <input message="tns:OaxApi_OasXmlRequest">
53
+ </input>
54
+ <output message="tns:OaxApi_OasXmlRequestResponse">
55
+ </output>
56
+ </operation>
57
+ </portType>
58
+ <binding name="OaxApiBinding" type="tns:OaxApi">
59
+ <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
60
+
61
+ <operation name="OasXmlRequest">
62
+ <soap:operation soapAction=""/>
63
+ <input>
64
+ <soap:body use="literal" namespace="http://api.oas.tfsm.com/"/>
65
+ </input>
66
+ <output>
67
+ <soap:body use="literal" namespace="http://api.oas.tfsm.com/"/>
68
+ </output>
69
+ </operation>
70
+
71
+ </binding>
72
+ <service name="OaxApiService">
73
+ <port name="OaxApiPort" binding="tns:OaxApiBinding">
74
+ <soap:address location="https://training7.247realmedia.com:443/oasapi/OaxApi"/>
75
+ </port>
76
+ </service>
77
+ </definitions>
78
+
79
+ http_version: "1.1"
80
+ - !ruby/struct:VCR::HTTPInteraction
81
+ request: !ruby/struct:VCR::Request
82
+ method: :post
83
+ uri: https://training7.247realmedia.com:443/oasapi/OaxApi
84
+ body: |-
85
+ <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:n1="http://api.oas.tfsm.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><n1:OasXmlRequest xmlns:n1="http://api.oas.tfsm.com/"><String_1>Abril</String_1><String_2>dev_abril</String_2><String_3>d3v@p1SgpD</String_3><String_4>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
86
+ &lt;AdXML&gt;
87
+ &lt;Request type=&quot;Campaign&quot;&gt;
88
+ &lt;Campaign action=&quot;read&quot;&gt;
89
+ &lt;Overview&gt;
90
+ &lt;Id&gt;abx_oferta3&lt;/Id&gt;
91
+ &lt;/Overview&gt;
92
+ &lt;/Campaign&gt;
93
+ &lt;/Request&gt;
94
+ &lt;/AdXML&gt;
95
+ </String_4></n1:OasXmlRequest></env:Body></env:Envelope>
96
+ headers:
97
+ soapaction:
98
+ - "\"OasXmlRequest\""
99
+ content-type:
100
+ - text/xml;charset=UTF-8
101
+ response: !ruby/struct:VCR::Response
102
+ status: !ruby/struct:VCR::ResponseStatus
103
+ code: 200
104
+ message: OK
105
+ headers:
106
+ x-powered-by:
107
+ - Servlet 2.5; JBoss-5.0/JBossWeb-2.1
108
+ p3p:
109
+ - CP="NON NID PSAa PSDa OUR IND UNI COM NAV STA",policyref="/w3c/p3p.xml"
110
+ via:
111
+ - 1.1 training7.247realmedia.com
112
+ content-type:
113
+ - text/xml;charset=UTF-8
114
+ date:
115
+ - Wed, 25 May 2011 15:16:43 GMT
116
+ server:
117
+ - Apache-Coyote/1.1
118
+ transfer-encoding:
119
+ - chunked
120
+ body: |-
121
+ <?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns1:OasXmlRequestResponse xmlns:ns1="http://api.oas.tfsm.com/"><result>&lt;?xml version='1.0'?>
122
+ &lt;AdXML>
123
+
124
+ &lt;Response>
125
+ &lt;Campaign>
126
+ &lt;Overview>
127
+ &lt;Id>abx_oferta3&lt;/Id>
128
+ &lt;AdvertiserId>abx_anunciante&lt;/AdvertiserId>
129
+ &lt;Name>abx_oferta2&lt;/Name>
130
+ &lt;AgencyId>vitrine&lt;/AgencyId>
131
+ &lt;Description/>
132
+ &lt;ProductId>vitrine&lt;/ProductId>
133
+ &lt;Status>L&lt;/Status>
134
+ &lt;CampaignGroups>
135
+ &lt;CampaignGroupId>abx_anunciante&lt;/CampaignGroupId>
136
+ &lt;/CampaignGroups>
137
+ &lt;CompetitiveCategories/>
138
+ &lt;ExternalUsers/>
139
+ &lt;InternalQuickReport>to-date&lt;/InternalQuickReport>
140
+ &lt;ExternalQuickReport>short&lt;/ExternalQuickReport>
141
+ &lt;WhoCreated>vitrine_api&lt;/WhoCreated>
142
+ &lt;WhenCreated>2011-04-11 16:15:32&lt;/WhenCreated>
143
+ &lt;WhoModified>vitrine_api&lt;/WhoModified>
144
+ &lt;WhenModified>2011-04-11 16:23:43&lt;/WhenModified>
145
+ &lt;/Overview>
146
+ &lt;Schedule>
147
+ &lt;Impressions>0&lt;/Impressions>
148
+ &lt;Clicks>0&lt;/Clicks>
149
+ &lt;Uniques>0&lt;/Uniques>
150
+ &lt;Weight>0&lt;/Weight>
151
+ &lt;PriorityLevel>5&lt;/PriorityLevel>
152
+ &lt;Completion>S&lt;/Completion>
153
+ &lt;StartDate>2011-04-11&lt;/StartDate>
154
+ &lt;StartTime>00:00&lt;/StartTime>
155
+ &lt;EndDate>&lt;/EndDate>
156
+ &lt;EndTime>&lt;/EndTime>
157
+ &lt;Reach>O&lt;/Reach>
158
+ &lt;DailyImp>0&lt;/DailyImp>
159
+ &lt;DailyGoals/>
160
+ &lt;DailyClicks>0&lt;/DailyClicks>
161
+ &lt;DailyUniq>0&lt;/DailyUniq>
162
+ &lt;SmoothOrAsap>S&lt;/SmoothOrAsap>
163
+ &lt;ImpOverrun>0&lt;/ImpOverrun>
164
+ &lt;CompanionPositions/>
165
+ &lt;StrictCompanions>N&lt;/StrictCompanions>
166
+ &lt;PrimaryFrequency>
167
+ &lt;ImpPerVisitor>0&lt;/ImpPerVisitor>
168
+ &lt;ClickPerVisitor>0&lt;/ClickPerVisitor>
169
+ &lt;FreqScope>0&lt;/FreqScope>
170
+ &lt;/PrimaryFrequency>
171
+ &lt;SecondaryFrequency>
172
+ &lt;ImpPerVisitor>0&lt;/ImpPerVisitor>
173
+ &lt;FreqScope>0&lt;/FreqScope>
174
+ &lt;/SecondaryFrequency>
175
+ &lt;HourOfDay/>
176
+ &lt;DayOfWeek/>
177
+ &lt;UserTimeZone>N&lt;/UserTimeZone>
178
+ &lt;Sections/>
179
+ &lt;CampaignPauses/>
180
+ &lt;/Schedule>
181
+ &lt;Pages/>
182
+ &lt;Target>
183
+ &lt;ExcludeTargets>N&lt;/ExcludeTargets>
184
+ &lt;TopLevelDomain/>
185
+ &lt;Domain>&lt;/Domain>
186
+ &lt;Bandwidth/>
187
+ &lt;Continent/>
188
+ &lt;Country/>
189
+ &lt;State/>
190
+ &lt;AreaCode/>
191
+ &lt;Msa/>
192
+ &lt;Dma/>
193
+ &lt;City/>
194
+ &lt;Zones/>
195
+ &lt;Zip/>
196
+ &lt;ClaritasSegments/>
197
+ &lt;Omniture/>
198
+ &lt;Os/>
199
+ &lt;Browser/>
200
+ &lt;BrowserV/>
201
+ &lt;SearchType>A&lt;/SearchType>
202
+ &lt;SearchTerm>&lt;/SearchTerm>
203
+ &lt;Cookie/>
204
+ &lt;AgeFrom>&lt;/AgeFrom>
205
+ &lt;AgeTo>&lt;/AgeTo>
206
+ &lt;Gender>
207
+ &lt;Code>E&lt;/Code>
208
+ &lt;/Gender>
209
+ &lt;IncomeFrom>&lt;/IncomeFrom>
210
+ &lt;IncomeTo>&lt;/IncomeTo>
211
+ &lt;SubscriberCode>&lt;/SubscriberCode>
212
+ &lt;PreferenceFlags>&lt;/PreferenceFlags>
213
+ &lt;Cluster/>
214
+ &lt;/Target>
215
+ &lt;Exclude>
216
+ &lt;Sites/>
217
+ &lt;Pages/>
218
+ &lt;/Exclude>
219
+ &lt;Billing>
220
+ &lt;ContractedRevenue>&lt;/ContractedRevenue>
221
+ &lt;BillOffContracted>N&lt;/BillOffContracted>
222
+ &lt;Cpm>0.0000&lt;/Cpm>
223
+ &lt;Cpc>0.0000&lt;/Cpc>
224
+ &lt;Cpa>&lt;/Cpa>
225
+ &lt;FlatRate>&lt;/FlatRate>
226
+ &lt;Tax>&lt;/Tax>
227
+ &lt;AgencyCommission>0.00&lt;/AgencyCommission>
228
+ &lt;PaymentMethod>C&lt;/PaymentMethod>
229
+ &lt;PurchaseOrder/>
230
+ &lt;SalesRepresentative/>
231
+ &lt;CommissionPercent>0.0000&lt;/CommissionPercent>
232
+ &lt;Notes/>
233
+ &lt;IsYieldManaged>N&lt;/IsYieldManaged>
234
+ &lt;BillTo>G&lt;/BillTo>
235
+ &lt;Currency/>
236
+ &lt;/Billing>
237
+ &lt;/Campaign>
238
+ &lt;/Response>
239
+ &lt;/AdXML></result></ns1:OasXmlRequestResponse></soapenv:Body></soapenv:Envelope>
240
+ http_version: "1.1"
241
+ - !ruby/struct:VCR::HTTPInteraction
242
+ request: !ruby/struct:VCR::Request
243
+ method: :post
244
+ uri: https://training7.247realmedia.com:443/oasapi/OaxApi
245
+ body: |-
246
+ <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:n1="http://api.oas.tfsm.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><n1:OasXmlRequest xmlns:n1="http://api.oas.tfsm.com/"><String_1>Abril</String_1><String_2>dev_abril</String_2><String_3>d3v@p1SgpD</String_3><String_4>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
247
+ &lt;AdXML&gt;
248
+ &lt;Request type=&quot;Campaign&quot;&gt;
249
+ &lt;Campaign action=&quot;read&quot;&gt;
250
+ &lt;Overview&gt;
251
+ &lt;Id&gt;invalid_id_lol&lt;/Id&gt;
252
+ &lt;/Overview&gt;
253
+ &lt;/Campaign&gt;
254
+ &lt;/Request&gt;
255
+ &lt;/AdXML&gt;
256
+ </String_4></n1:OasXmlRequest></env:Body></env:Envelope>
257
+ headers:
258
+ content-type:
259
+ - text/xml;charset=UTF-8
260
+ soapaction:
261
+ - "\"OasXmlRequest\""
262
+ response: !ruby/struct:VCR::Response
263
+ status: !ruby/struct:VCR::ResponseStatus
264
+ code: 200
265
+ message: OK
266
+ headers:
267
+ x-powered-by:
268
+ - Servlet 2.5; JBoss-5.0/JBossWeb-2.1
269
+ p3p:
270
+ - CP="NON NID PSAa PSDa OUR IND UNI COM NAV STA",policyref="/w3c/p3p.xml"
271
+ content-type:
272
+ - text/xml;charset=UTF-8
273
+ via:
274
+ - 1.1 training7.247realmedia.com
275
+ server:
276
+ - Apache-Coyote/1.1
277
+ date:
278
+ - Wed, 25 May 2011 15:22:39 GMT
279
+ transfer-encoding:
280
+ - chunked
281
+ body: |-
282
+ <?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns1:OasXmlRequestResponse xmlns:ns1="http://api.oas.tfsm.com/"><result>&lt;?xml version='1.0'?>
283
+ &lt;AdXML>
284
+
285
+ &lt;Response>
286
+ &lt;Campaign>
287
+ &lt;Exception errorCode='545'>Invalid CampaignId.&lt;/Exception>
288
+ &lt;/Campaign>
289
+ &lt;/Response>
290
+ &lt;/AdXML></result></ns1:OasXmlRequestResponse></soapenv:Body></soapenv:Envelope>
291
+ http_version: "1.1"
@@ -0,0 +1,70 @@
1
+ require 'spec_helper'
2
+
3
+ describe RoflmOAS::Client do
4
+ context "configuration" do
5
+ [:endpoint, :account, :username, :password].each do |setting|
6
+ context "on initialization" do
7
+ subject { RoflmOAS::Client.new setting => "WUT" }
8
+ its(setting) { should == "WUT" }
9
+ end
10
+
11
+ context "after initialization" do
12
+ subject { RoflmOAS::Client.new }
13
+ before { subject.send("#{setting}=", "WUT") }
14
+ its(setting) { should == "WUT" }
15
+ end
16
+ end
17
+ end
18
+
19
+ describe "#request" do
20
+ use_vcr_cassette :record => :new_episodes, :match_requests_on => [:uri, :method, :body]
21
+
22
+ let(:client) { RoflmOAS::Client.new }
23
+
24
+ context "successfully" do
25
+ subject do
26
+ client.request "Campaign" do |xml|
27
+ xml.Campaign(:action => "read") do
28
+ xml.Overview { xml.Id "abx_oferta3" }
29
+ end
30
+ end
31
+ end
32
+
33
+ it "finds the right campaign" do
34
+ subject.css("Id").first.content.should == "abx_oferta3"
35
+ end
36
+ end
37
+
38
+ context "unsuccessfully" do
39
+ it "raises a OASError" do
40
+ expect {
41
+ client.request "Campaign" do |xml|
42
+ xml.Campaign(:action => "read") do
43
+ xml.Overview { xml.Id "invalid_id_lol" }
44
+ end
45
+ end
46
+ }.to raise_error(RoflmOAS::OASError)
47
+ end
48
+ end
49
+ end
50
+
51
+ describe "#read_campaign" do
52
+ use_vcr_cassette :record => :new_episodes, :match_requests_on => [:uri, :method, :body]
53
+
54
+ let(:client) { RoflmOAS::Client.new }
55
+
56
+ context "with a valid id" do
57
+ subject { client.read_campaign("abx_oferta3") }
58
+
59
+ it "finds the right campaign" do
60
+ subject.css("Id").first.content.should == "abx_oferta3"
61
+ end
62
+ end
63
+
64
+ context "with an invalid id" do
65
+ it "raises a NotFoundError" do
66
+ expect { client.read_campaign("LOLWUT").to raise_error(RoflmOAS::NotFoundError) }
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,11 @@
1
+ require "spec_helper"
2
+
3
+ describe RoflmOAS do
4
+ describe ".configure" do
5
+ [:endpoint, :account, :username, :password].each do |setting|
6
+ it "allows configuration for #{setting}" do
7
+ expect { RoflmOAS.send("#{setting}=", "LOL") }.to change { RoflmOAS.send(setting) }.to("LOL")
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ require 'roflmoas'
2
+ require 'vcr'
3
+
4
+ VCR.config do |config|
5
+ config.cassette_library_dir = File.join("spec/fixtures/vcr_cassettes")
6
+ config.stub_with :webmock
7
+ end
8
+
9
+ RSpec.configure do |config|
10
+ config.extend VCR::RSpec::Macros
11
+ end
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: roflmoas
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Rodrigo Navarro
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-05-25 00:00:00 -03:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: savon
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 63
30
+ segments:
31
+ - 0
32
+ - 9
33
+ - 2
34
+ version: 0.9.2
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: nokogiri
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ hash: 15
46
+ segments:
47
+ - 1
48
+ - 4
49
+ - 4
50
+ version: 1.4.4
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: activesupport
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ hash: 7
62
+ segments:
63
+ - 3
64
+ - 0
65
+ - 0
66
+ version: 3.0.0
67
+ type: :runtime
68
+ version_requirements: *id003
69
+ description: Help you to communicate with the corporate advertisers world!
70
+ email:
71
+ - navarro@manapot.com.br
72
+ executables: []
73
+
74
+ extensions: []
75
+
76
+ extra_rdoc_files: []
77
+
78
+ files:
79
+ - .gitignore
80
+ - Gemfile
81
+ - README.md
82
+ - Rakefile
83
+ - lib/roflmoas.rb
84
+ - lib/roflmoas/campaign.rb
85
+ - lib/roflmoas/client.rb
86
+ - lib/roflmoas/errors.rb
87
+ - lib/roflmoas/version.rb
88
+ - roflmoas.gemspec
89
+ - spec/fixtures/vcr_cassettes/RoflmOAS_Client/_read_campaign.yml
90
+ - spec/fixtures/vcr_cassettes/RoflmOAS_Client/_request.yml
91
+ - spec/roflmoas/client_spec.rb
92
+ - spec/roflmoas/configuration_spec.rb
93
+ - spec/spec_helper.rb
94
+ has_rdoc: true
95
+ homepage: ""
96
+ licenses: []
97
+
98
+ post_install_message:
99
+ rdoc_options: []
100
+
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ hash: 3
109
+ segments:
110
+ - 0
111
+ version: "0"
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ hash: 3
118
+ segments:
119
+ - 0
120
+ version: "0"
121
+ requirements: []
122
+
123
+ rubyforge_project: roflmoas
124
+ rubygems_version: 1.5.0
125
+ signing_key:
126
+ specification_version: 3
127
+ summary: Funny API to access OAS hellish soap interface
128
+ test_files:
129
+ - spec/fixtures/vcr_cassettes/RoflmOAS_Client/_read_campaign.yml
130
+ - spec/fixtures/vcr_cassettes/RoflmOAS_Client/_request.yml
131
+ - spec/roflmoas/client_spec.rb
132
+ - spec/roflmoas/configuration_spec.rb
133
+ - spec/spec_helper.rb