roflmoas 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +10 -0
- data/README.md +33 -0
- data/Rakefile +2 -0
- data/lib/roflmoas.rb +21 -0
- data/lib/roflmoas/campaign.rb +11 -0
- data/lib/roflmoas/client.rb +58 -0
- data/lib/roflmoas/errors.rb +4 -0
- data/lib/roflmoas/version.rb +3 -0
- data/roflmoas.gemspec +25 -0
- data/spec/fixtures/vcr_cassettes/RoflmOAS_Client/_read_campaign.yml +240 -0
- data/spec/fixtures/vcr_cassettes/RoflmOAS_Client/_request.yml +291 -0
- data/spec/roflmoas/client_spec.rb +70 -0
- data/spec/roflmoas/configuration_spec.rb +11 -0
- data/spec/spec_helper.rb +11 -0
- metadata +133 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -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
|
data/Rakefile
ADDED
data/lib/roflmoas.rb
ADDED
@@ -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,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
|
data/roflmoas.gemspec
ADDED
@@ -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><?xml version="1.0" encoding="UTF-8"?>
|
86
|
+
<AdXML>
|
87
|
+
<Request type="Campaign">
|
88
|
+
<Campaign action="read">
|
89
|
+
<Overview>
|
90
|
+
<Id>abx_oferta3</Id>
|
91
|
+
</Overview>
|
92
|
+
</Campaign>
|
93
|
+
</Request>
|
94
|
+
</AdXML>
|
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><?xml version='1.0'?>
|
122
|
+
<AdXML>
|
123
|
+
|
124
|
+
<Response>
|
125
|
+
<Campaign>
|
126
|
+
<Overview>
|
127
|
+
<Id>abx_oferta3</Id>
|
128
|
+
<AdvertiserId>abx_anunciante</AdvertiserId>
|
129
|
+
<Name>abx_oferta2</Name>
|
130
|
+
<AgencyId>vitrine</AgencyId>
|
131
|
+
<Description/>
|
132
|
+
<ProductId>vitrine</ProductId>
|
133
|
+
<Status>L</Status>
|
134
|
+
<CampaignGroups>
|
135
|
+
<CampaignGroupId>abx_anunciante</CampaignGroupId>
|
136
|
+
</CampaignGroups>
|
137
|
+
<CompetitiveCategories/>
|
138
|
+
<ExternalUsers/>
|
139
|
+
<InternalQuickReport>to-date</InternalQuickReport>
|
140
|
+
<ExternalQuickReport>short</ExternalQuickReport>
|
141
|
+
<WhoCreated>vitrine_api</WhoCreated>
|
142
|
+
<WhenCreated>2011-04-11 16:15:32</WhenCreated>
|
143
|
+
<WhoModified>vitrine_api</WhoModified>
|
144
|
+
<WhenModified>2011-04-11 16:23:43</WhenModified>
|
145
|
+
</Overview>
|
146
|
+
<Schedule>
|
147
|
+
<Impressions>0</Impressions>
|
148
|
+
<Clicks>0</Clicks>
|
149
|
+
<Uniques>0</Uniques>
|
150
|
+
<Weight>0</Weight>
|
151
|
+
<PriorityLevel>5</PriorityLevel>
|
152
|
+
<Completion>S</Completion>
|
153
|
+
<StartDate>2011-04-11</StartDate>
|
154
|
+
<StartTime>00:00</StartTime>
|
155
|
+
<EndDate></EndDate>
|
156
|
+
<EndTime></EndTime>
|
157
|
+
<Reach>O</Reach>
|
158
|
+
<DailyImp>0</DailyImp>
|
159
|
+
<DailyGoals/>
|
160
|
+
<DailyClicks>0</DailyClicks>
|
161
|
+
<DailyUniq>0</DailyUniq>
|
162
|
+
<SmoothOrAsap>S</SmoothOrAsap>
|
163
|
+
<ImpOverrun>0</ImpOverrun>
|
164
|
+
<CompanionPositions/>
|
165
|
+
<StrictCompanions>N</StrictCompanions>
|
166
|
+
<PrimaryFrequency>
|
167
|
+
<ImpPerVisitor>0</ImpPerVisitor>
|
168
|
+
<ClickPerVisitor>0</ClickPerVisitor>
|
169
|
+
<FreqScope>0</FreqScope>
|
170
|
+
</PrimaryFrequency>
|
171
|
+
<SecondaryFrequency>
|
172
|
+
<ImpPerVisitor>0</ImpPerVisitor>
|
173
|
+
<FreqScope>0</FreqScope>
|
174
|
+
</SecondaryFrequency>
|
175
|
+
<HourOfDay/>
|
176
|
+
<DayOfWeek/>
|
177
|
+
<UserTimeZone>N</UserTimeZone>
|
178
|
+
<Sections/>
|
179
|
+
<CampaignPauses/>
|
180
|
+
</Schedule>
|
181
|
+
<Pages/>
|
182
|
+
<Target>
|
183
|
+
<ExcludeTargets>N</ExcludeTargets>
|
184
|
+
<TopLevelDomain/>
|
185
|
+
<Domain></Domain>
|
186
|
+
<Bandwidth/>
|
187
|
+
<Continent/>
|
188
|
+
<Country/>
|
189
|
+
<State/>
|
190
|
+
<AreaCode/>
|
191
|
+
<Msa/>
|
192
|
+
<Dma/>
|
193
|
+
<City/>
|
194
|
+
<Zones/>
|
195
|
+
<Zip/>
|
196
|
+
<ClaritasSegments/>
|
197
|
+
<Omniture/>
|
198
|
+
<Os/>
|
199
|
+
<Browser/>
|
200
|
+
<BrowserV/>
|
201
|
+
<SearchType>A</SearchType>
|
202
|
+
<SearchTerm></SearchTerm>
|
203
|
+
<Cookie/>
|
204
|
+
<AgeFrom></AgeFrom>
|
205
|
+
<AgeTo></AgeTo>
|
206
|
+
<Gender>
|
207
|
+
<Code>E</Code>
|
208
|
+
</Gender>
|
209
|
+
<IncomeFrom></IncomeFrom>
|
210
|
+
<IncomeTo></IncomeTo>
|
211
|
+
<SubscriberCode></SubscriberCode>
|
212
|
+
<PreferenceFlags></PreferenceFlags>
|
213
|
+
<Cluster/>
|
214
|
+
</Target>
|
215
|
+
<Exclude>
|
216
|
+
<Sites/>
|
217
|
+
<Pages/>
|
218
|
+
</Exclude>
|
219
|
+
<Billing>
|
220
|
+
<ContractedRevenue></ContractedRevenue>
|
221
|
+
<BillOffContracted>N</BillOffContracted>
|
222
|
+
<Cpm>0.0000</Cpm>
|
223
|
+
<Cpc>0.0000</Cpc>
|
224
|
+
<Cpa></Cpa>
|
225
|
+
<FlatRate></FlatRate>
|
226
|
+
<Tax></Tax>
|
227
|
+
<AgencyCommission>0.00</AgencyCommission>
|
228
|
+
<PaymentMethod>C</PaymentMethod>
|
229
|
+
<PurchaseOrder/>
|
230
|
+
<SalesRepresentative/>
|
231
|
+
<CommissionPercent>0.0000</CommissionPercent>
|
232
|
+
<Notes/>
|
233
|
+
<IsYieldManaged>N</IsYieldManaged>
|
234
|
+
<BillTo>G</BillTo>
|
235
|
+
<Currency/>
|
236
|
+
</Billing>
|
237
|
+
</Campaign>
|
238
|
+
</Response>
|
239
|
+
</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><?xml version="1.0" encoding="UTF-8"?>
|
86
|
+
<AdXML>
|
87
|
+
<Request type="Campaign">
|
88
|
+
<Campaign action="read">
|
89
|
+
<Overview>
|
90
|
+
<Id>abx_oferta3</Id>
|
91
|
+
</Overview>
|
92
|
+
</Campaign>
|
93
|
+
</Request>
|
94
|
+
</AdXML>
|
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><?xml version='1.0'?>
|
122
|
+
<AdXML>
|
123
|
+
|
124
|
+
<Response>
|
125
|
+
<Campaign>
|
126
|
+
<Overview>
|
127
|
+
<Id>abx_oferta3</Id>
|
128
|
+
<AdvertiserId>abx_anunciante</AdvertiserId>
|
129
|
+
<Name>abx_oferta2</Name>
|
130
|
+
<AgencyId>vitrine</AgencyId>
|
131
|
+
<Description/>
|
132
|
+
<ProductId>vitrine</ProductId>
|
133
|
+
<Status>L</Status>
|
134
|
+
<CampaignGroups>
|
135
|
+
<CampaignGroupId>abx_anunciante</CampaignGroupId>
|
136
|
+
</CampaignGroups>
|
137
|
+
<CompetitiveCategories/>
|
138
|
+
<ExternalUsers/>
|
139
|
+
<InternalQuickReport>to-date</InternalQuickReport>
|
140
|
+
<ExternalQuickReport>short</ExternalQuickReport>
|
141
|
+
<WhoCreated>vitrine_api</WhoCreated>
|
142
|
+
<WhenCreated>2011-04-11 16:15:32</WhenCreated>
|
143
|
+
<WhoModified>vitrine_api</WhoModified>
|
144
|
+
<WhenModified>2011-04-11 16:23:43</WhenModified>
|
145
|
+
</Overview>
|
146
|
+
<Schedule>
|
147
|
+
<Impressions>0</Impressions>
|
148
|
+
<Clicks>0</Clicks>
|
149
|
+
<Uniques>0</Uniques>
|
150
|
+
<Weight>0</Weight>
|
151
|
+
<PriorityLevel>5</PriorityLevel>
|
152
|
+
<Completion>S</Completion>
|
153
|
+
<StartDate>2011-04-11</StartDate>
|
154
|
+
<StartTime>00:00</StartTime>
|
155
|
+
<EndDate></EndDate>
|
156
|
+
<EndTime></EndTime>
|
157
|
+
<Reach>O</Reach>
|
158
|
+
<DailyImp>0</DailyImp>
|
159
|
+
<DailyGoals/>
|
160
|
+
<DailyClicks>0</DailyClicks>
|
161
|
+
<DailyUniq>0</DailyUniq>
|
162
|
+
<SmoothOrAsap>S</SmoothOrAsap>
|
163
|
+
<ImpOverrun>0</ImpOverrun>
|
164
|
+
<CompanionPositions/>
|
165
|
+
<StrictCompanions>N</StrictCompanions>
|
166
|
+
<PrimaryFrequency>
|
167
|
+
<ImpPerVisitor>0</ImpPerVisitor>
|
168
|
+
<ClickPerVisitor>0</ClickPerVisitor>
|
169
|
+
<FreqScope>0</FreqScope>
|
170
|
+
</PrimaryFrequency>
|
171
|
+
<SecondaryFrequency>
|
172
|
+
<ImpPerVisitor>0</ImpPerVisitor>
|
173
|
+
<FreqScope>0</FreqScope>
|
174
|
+
</SecondaryFrequency>
|
175
|
+
<HourOfDay/>
|
176
|
+
<DayOfWeek/>
|
177
|
+
<UserTimeZone>N</UserTimeZone>
|
178
|
+
<Sections/>
|
179
|
+
<CampaignPauses/>
|
180
|
+
</Schedule>
|
181
|
+
<Pages/>
|
182
|
+
<Target>
|
183
|
+
<ExcludeTargets>N</ExcludeTargets>
|
184
|
+
<TopLevelDomain/>
|
185
|
+
<Domain></Domain>
|
186
|
+
<Bandwidth/>
|
187
|
+
<Continent/>
|
188
|
+
<Country/>
|
189
|
+
<State/>
|
190
|
+
<AreaCode/>
|
191
|
+
<Msa/>
|
192
|
+
<Dma/>
|
193
|
+
<City/>
|
194
|
+
<Zones/>
|
195
|
+
<Zip/>
|
196
|
+
<ClaritasSegments/>
|
197
|
+
<Omniture/>
|
198
|
+
<Os/>
|
199
|
+
<Browser/>
|
200
|
+
<BrowserV/>
|
201
|
+
<SearchType>A</SearchType>
|
202
|
+
<SearchTerm></SearchTerm>
|
203
|
+
<Cookie/>
|
204
|
+
<AgeFrom></AgeFrom>
|
205
|
+
<AgeTo></AgeTo>
|
206
|
+
<Gender>
|
207
|
+
<Code>E</Code>
|
208
|
+
</Gender>
|
209
|
+
<IncomeFrom></IncomeFrom>
|
210
|
+
<IncomeTo></IncomeTo>
|
211
|
+
<SubscriberCode></SubscriberCode>
|
212
|
+
<PreferenceFlags></PreferenceFlags>
|
213
|
+
<Cluster/>
|
214
|
+
</Target>
|
215
|
+
<Exclude>
|
216
|
+
<Sites/>
|
217
|
+
<Pages/>
|
218
|
+
</Exclude>
|
219
|
+
<Billing>
|
220
|
+
<ContractedRevenue></ContractedRevenue>
|
221
|
+
<BillOffContracted>N</BillOffContracted>
|
222
|
+
<Cpm>0.0000</Cpm>
|
223
|
+
<Cpc>0.0000</Cpc>
|
224
|
+
<Cpa></Cpa>
|
225
|
+
<FlatRate></FlatRate>
|
226
|
+
<Tax></Tax>
|
227
|
+
<AgencyCommission>0.00</AgencyCommission>
|
228
|
+
<PaymentMethod>C</PaymentMethod>
|
229
|
+
<PurchaseOrder/>
|
230
|
+
<SalesRepresentative/>
|
231
|
+
<CommissionPercent>0.0000</CommissionPercent>
|
232
|
+
<Notes/>
|
233
|
+
<IsYieldManaged>N</IsYieldManaged>
|
234
|
+
<BillTo>G</BillTo>
|
235
|
+
<Currency/>
|
236
|
+
</Billing>
|
237
|
+
</Campaign>
|
238
|
+
</Response>
|
239
|
+
</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><?xml version="1.0" encoding="UTF-8"?>
|
247
|
+
<AdXML>
|
248
|
+
<Request type="Campaign">
|
249
|
+
<Campaign action="read">
|
250
|
+
<Overview>
|
251
|
+
<Id>invalid_id_lol</Id>
|
252
|
+
</Overview>
|
253
|
+
</Campaign>
|
254
|
+
</Request>
|
255
|
+
</AdXML>
|
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><?xml version='1.0'?>
|
283
|
+
<AdXML>
|
284
|
+
|
285
|
+
<Response>
|
286
|
+
<Campaign>
|
287
|
+
<Exception errorCode='545'>Invalid CampaignId.</Exception>
|
288
|
+
</Campaign>
|
289
|
+
</Response>
|
290
|
+
</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
|
data/spec/spec_helper.rb
ADDED
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
|