lib/soapy_cake/request.rb in soapy_cake-1.0.1 vs lib/soapy_cake/request.rb in soapy_cake-1.1.0

- old
+ new

@@ -9,11 +9,11 @@ @method = method.to_s @opts = opts end def path - "/#{(role != 'admin') ? role : ''}/api/#{version}/#{service}.asmx" + "#{api_path}/#{service}.asmx" end def xml Nokogiri::XML::Builder.new do |xml| xml['env'].Envelope(xml_namespaces) do @@ -27,20 +27,24 @@ end.to_xml end private + def api_path + "#{(role != 'admin') ? "/#{role.pluralize}" : ''}/api/#{version}" + end + def xml_params(xml) xml.api_key api_key opts.each do |k, v| xml.send(k.to_sym, format_param(v)) end end def xml_namespaces { 'xmlns:env' => 'http://www.w3.org/2003/05/soap-envelope', - 'xmlns:cake' => "http://cakemarketing.com/api/#{version}/" + 'xmlns:cake' => "http://cakemarketing.com#{api_path}/" } end def format_param(value) case value