Module: Vindicia::SoapClient
- Includes:
- XMLBuilder
- Included in:
- Account, Activity, Address, AutoBill, BillingPlan, Chargeback, Entitlement, PaymentMethod, PaymentProvider, Product, Refund, Transaction
- Defined in:
- lib/vindicia.rb
Instance Method Summary
collapse
Methods included from XMLBuilder
#build_array_xml, #build_tag_xml, #build_xml
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
|
# File 'lib/vindicia.rb', line 179
def method_missing(method, *args)
method = underscore(method.to_s).to_sym out_vars = nil
response = soap.request(:wsdl, method) do |soap, wsdl, http|
http.auth.ssl.verify_mode = :none if Vindicia.environment == 'prodtest'
out_vars = wsdl.arg_list["#{method.to_s.lower_camelcase}_out"]
soap.namespaces["xmlns:vin"] = Vindicia::NAMESPACE
soap.body = begin
xml = Builder::XmlMarkup.new
key = "#{method.to_s.lower_camelcase}_in"
wsdl.arg_list[key].zip([Vindicia.auth] + args).each do |arg, data|
build_xml(xml, arg['name'], arg['type'], data)
end
xml.target!
end
end
values = response.to_hash[:"#{method}_response"]
objs = out_vars.map do |var|
value = values[underscore(var["name"]).to_sym]
Vindicia.coerce(var["name"], var["type"], value)
end
ret = objs.shift
return [ret] + objs unless objs.first.is_a? SoapObject
case objs.size
when 0
ret.request_status = ret
ret
when 1
objs.first.request_status = ret
objs.first
else
objs.first.request_status = ret
objs
end
end
|
Instance Method Details
#find(id) ⇒ Object
175
176
177
|
# File 'lib/vindicia.rb', line 175
def find(id)
self.send(:"fetch_by_merchant_#{name.downcase}_id", id)
end
|
#name ⇒ Object
227
228
229
|
# File 'lib/vindicia.rb', line 227
def name
self.to_s.split('::').last
end
|
#soap ⇒ Object
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
|
# File 'lib/vindicia.rb', line 231
def soap
@soap ||= begin
Savon::Client.new do |wsdl|
wsdl.document = Vindicia.wsdl(name)
wsdl.endpoint = Vindicia.endpoint
def wsdl.parser
@parser ||= begin
parser = Savon::WSDL::ParserWithArgList.new
REXML::Document.parse_stream self.document, parser
parser
end
end
end
end
end
|