Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added save and load feature for requests and responses

  • Loading branch information...
commit e69887876db4b8d4a247d5fcf63a125354e199ae 1 parent 7d32e69
mpclocal authored
View
2  Rakefile
@@ -7,7 +7,7 @@ task :default => 'test:all'
namespace :maintenance do
current_dir = File.dirname(__FILE__)
- client_dir = "#{current_dir}/generated_clients"
+ client_dir = "#{current_dir}/public/generated_clients"
desc "clean out the generated clients directory"
task :clean do
View
53 app.rb
@@ -19,15 +19,14 @@
@driver_file = nil
@client = nil
if @params[:action] == 'Upload'
- File.open("saved_forms/requests/#{@params['datafile'][:filename]}", "w+").syswrite(@params["datafile"][:tempfile].readlines)
- @params[:wsdl] = Dir.pwd.to_s + "/saved_forms/requests/#{@params['datafile'][:filename]}"
+ File.open("public/saved_forms/requests/#{@params['datafile'][:filename]}", "w+").syswrite(@params["datafile"][:tempfile].readlines)
+ @params[:wsdl] = Dir.pwd.to_s + "/public/saved_forms/requests/#{@params['datafile'][:filename]}"
end
@wsdl = @params[:wsdl]
@ast = nil
@curr = Dir.pwd
@namespace ="MySoap::Interface" + rand(Time.now.to_i).to_s
- @folder_name = "generated_clients/" + (File.basename(@params[:wsdl].gsub('.wsdl',''))) + "_" + Time.now.to_i.to_s + "_" + rand(Time.now.to_i).to_s
- puts @folder_name, @namespace, @params[:wsdl]
+ @folder_name = "public/generated_clients/" + (File.basename(@params[:wsdl].gsub('.wsdl',''))) + "_" + Time.now.to_i.to_s + "_" + rand(Time.now.to_i).to_s
@driver_file = GeneratorHelpers::generate_ruby_classes(@folder_name, @namespace, @params[:wsdl])
@client = @curr + "/" + @folder_name
@@ -46,6 +45,8 @@
@input = tool.build_default_input_instance_for_method(@params[:method])
@endpoint = tool.default_endpoint
+ @saved_requests = Dir.entries(Dir.pwd + "/public/saved_forms/requests/").grep(/\.xml$/)
+ @saved_responses = Dir.entries(Dir.pwd + "/public/saved_forms/responses/").grep(/\.xml$/)
haml :client
end
@@ -57,42 +58,36 @@
@endpoint = @params[:endpoint]
@params = SinatraAppHelpers::update @params
@input = @params['input']
-
+ @saved_requests = Dir.entries(Dir.pwd + "/public/saved_forms/requests/").grep(/\.xml$/)
+ @saved_responses = Dir.entries(Dir.pwd + "/public/saved_forms/responses/").grep(/\.xml$/)
+
if @params[:action] == 'Submit'
@input = SinatraAppHelpers::send_request(@input,@service_method, @client, @namespace, @wsdl, @endpoint)
- # tool = Soap4r2Ruby.new(@params[:client],@params[:namespace])
- # port_type = tool.port_type
- # driver_file = tool.driver_file
- # @result = SaveLoadConvertHelpers::obj2xml(@client, driver_file, @namespace, port_type, response)
- # puts @result
- # require 'ruby-debug'; debugger
- #@result = File.open("test/fixtures/sample_xmls/working_vdev_sample_request.xml").readlines.to_s
- # content_type 'text/xml', :charset => 'utf-8'
- haml :result
+ return haml :result
elsif @params[:action] == 'SaveRequest'
- # SaveLoadConvertHelpers::save_request_as_yaml(@params,"saved_forms/"+@params["file_name"]+".yml")
- SaveLoadConvertHelpers::save_request_xml(@input, "saved_forms/requests/"+@params["file_name"], @client, @namespace, @wsdl)
- haml :client
+ SaveLoadConvertHelpers::save_request_xml(@input, "public/saved_forms/requests/"+@params["file_name"], @client, @namespace, @wsdl)
+ elsif @params[:action] == 'DeleteRequest'
+ SaveLoadConvertHelpers::del_request_xml(@params["file_name"])
elsif @params[:action] == 'SaveResponse'
- # SaveLoadConvertHelpers::save_request_as_yaml(@params,"saved_forms/"+@params["file_name"]+".yml")
- SaveLoadConvertHelpers::save_request_xml(@input, "saved_forms/responses/"+@params["file_name"], @client, @namespace, @wsdl)
- haml :client
+ SaveLoadConvertHelpers::save_request_xml(@input, "public/saved_forms/responses/"+@params["file_name"], @client, @namespace, @wsdl)
+ return haml :result
+ elsif @params[:action] == 'DeleteResponse'
+ SaveLoadConvertHelpers::del_response_xml(@params["file_name"])
+ return haml :result
elsif @params[:action] == 'LoadRequest'
- #@params = SaveLoadConvertHelpers::load_request_from_yaml("saved_forms/"+@params["file_name"]+".yml")
- @params['input'] = SaveLoadConvertHelpers::load_request_xml("saved_forms/requests/"+@params["file_name"], @client, @namespace, @wsdl)
+ @params['input'] = SaveLoadConvertHelpers::load_request_xml("public/saved_forms/requests/"+@params["file_name"], @client, @namespace, @wsdl)
@input = @params['input']
- haml :client
elsif @params[:action] == 'Upload'
- File.open("saved_forms/requests/#{@params['datafile'][:filename]}", "w+").syswrite(@params["datafile"][:tempfile].readlines)
- @params['input'] = SaveLoadConvertHelpers::load_request_xml("saved_forms/requests/#{@params['datafile'][:filename]}", @client, @namespace, @wsdl)
+ File.open("public/saved_forms/requests/#{@params['datafile'][:filename]}", "w+").syswrite(@params["datafile"][:tempfile].readlines)
+ @params['input'] = SaveLoadConvertHelpers::load_request_xml("public/saved_forms/requests/#{@params['datafile'][:filename]}", @client, @namespace, @wsdl)
@input = @params['input']
- haml :client
elsif @params[:action] == 'Add'
@input = SinatraAppHelpers::create_element(@input, @params[:element])
- haml :client
elsif @params[:action] == 'Del'
@input = SinatraAppHelpers::remove_element(@input, @params[:element])
- haml :client
- end
+ end
+ @saved_requests = Dir.entries(Dir.pwd + "/public/saved_forms/requests/").grep(/\.xml$/)
+ @saved_responses = Dir.entries(Dir.pwd + "/public/saved_forms/responses/").grep(/\.xml$/)
+ haml :client
end
View
13 lib/save_load_convert_helpers.rb
@@ -23,6 +23,19 @@ def self.save_request_xml(obj, file, client_folder, namespace, wsdl)
File.open(file, "w+").syswrite(SaveLoadConvertHelpers::obj2xml(driver, obj))
end
+ def self.del_request_xml(file)
+ #ensure we aren't being hacked with different file names or folder names.
+ file.gsub!('\\','')
+ file.gsub!('/','')
+ File.delete("public/saved_forms/requests/" + file)
+ end
+
+ def self.del_response_xml(file)
+ #ensure we aren't being hacked with different file names or folder names.
+ file.gsub!('\\','')
+ file.gsub!('/','')
+ File.delete("public/saved_forms/responses/" + file)
+ end
def self.obj2xml(driver, obj)
name = driver.literal_mapping_registry.elename_schema_definition_from_class(obj.class).elename.name
View
0  generated_clients/temp_generated_stubs_go_here → ...ic/generated_clients/temp_generated_stubs_go_here
File renamed without changes
View
1  public/saved_forms/requests/requests_go_here
@@ -0,0 +1 @@
+requests go here
View
1  public/saved_forms/responses/responses_go_here
@@ -0,0 +1 @@
+ responses go here
View
0  saved_forms/saved_form_fields_go_here → public/saved_forms/saved_form_fields_go_here
File renamed without changes
View
45 saved_forms/requests/minimal.xml
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<env:Envelope 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>
- <DiscountServiceRequest>
- <StoreID>1</StoreID>
- <RequestType>LIVE</RequestType>
- <orderRequest>
- <OrderID>1</OrderID>
- <QualifyType>QUALIFY_WITH_TENDER</QualifyType>
- <OrderDate>09/09/2009 09:00</OrderDate>
- <Channel>POS</Channel>
- <Brand>Gap</Brand>
- <Market>USA</Market>
- <OrderLineItems>
- <SequenceNumber>0</SequenceNumber>
- <Product>
- <Brand>Gap</Brand>
- <MerchandiseType>7</MerchandiseType>
- <StyleColor>1234567</StyleColor>
- </Product>
- <Price>
- <NetPrice>50.00</NetPrice>
- <PriceType>MARKDOWN</PriceType>
- <IsPromotional>false</IsPromotional>
- </Price>
- <Quantity>1</Quantity>
- <Awards>
- <AwardMethod>FIXED_PRICE</AwardMethod>
- </Awards>
- <IsLineItemExcluded>false</IsLineItemExcluded>
- </OrderLineItems>
- <Promotions>
- <SequenceNumber>0</SequenceNumber>
- <PromotionCode>MYCODE123</PromotionCode>
- <ReceiptMessages></ReceiptMessages>
- <PromoUsages></PromoUsages>
- <QualifyingTenders xsi:nil="true"></QualifyingTenders>
- </Promotions>
- <Tenders></Tenders>
- </orderRequest>
- </DiscountServiceRequest>
- </env:Body>
-</env:Envelope>
View
75 saved_forms/requests/samtest.xml
@@ -1,75 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<env:Envelope 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>
- <DiscountServiceRequest>
- <RequestDateTime>09/09/2009 09:00</RequestDateTime>
- <StoreID>1</StoreID>
- <RequestType>LIVE</RequestType>
- <orderRequest>
- <OrderID>1</OrderID>
- <QualifyType>QUALIFY_WITH_TENDER</QualifyType>
- <OrderDate>09/09/2009 09:00</OrderDate>
- <Channel>POS</Channel>
- <Brand>Gap</Brand>
- <Market>USA</Market>
- <OrderLineItems>
- <SequenceNumber>0</SequenceNumber>
- <Product>
- <Brand>Gap</Brand>
- <MerchandiseType>7</MerchandiseType>
- <StyleColor>1234567</StyleColor>
- </Product>
- <Price>
- <CurrentPrice></CurrentPrice>
- <NetPrice>50.00</NetPrice>
- <PriceType>MARKDOWN</PriceType>
- <IsPromotional>false</IsPromotional>
- <DiscountPrice></DiscountPrice>
- </Price>
- <Quantity>1</Quantity>
- <Awards>
- <AwardID></AwardID>
- <PromotionCode></PromotionCode>
- <DiscountedAmount></DiscountedAmount>
- <AwardMethod>FIXED_PRICE</AwardMethod>
- <AwardAmount></AwardAmount>
- </Awards>
- <IsLineItemExcluded>false</IsLineItemExcluded>
- <NumberOfManualDiscountsApplied></NumberOfManualDiscountsApplied>
- </OrderLineItems>
- <Promotions>
- <SequenceNumber>0</SequenceNumber>
- <PromotionCode>MYCODE123</PromotionCode>
- <ProgramType></ProgramType>
- <MemberId></MemberId>
- <PromotionID>1234</PromotionID>
- <DiscountReasonCode>adsfa</DiscountReasonCode>
- <AppliedStatus>CODE_APPLIED</AppliedStatus>
- <ReceiptMessages>
- <message></message>
- <locale></locale>
- </ReceiptMessages>
- <PromoUsages>
- <StoreId></StoreId>
- <TransactionId></TransactionId>
- <UsageDateTime></UsageDateTime>
- <Brand></Brand>
- <Channel></Channel>
- </PromoUsages>
- <QualifyingTenders></QualifyingTenders>
- <PromotionType>TRANSACTION</PromotionType>
- <HasExclusions>false</HasExclusions>
- </Promotions>
- <Tenders>
- <TenderType></TenderType>
- <CreditCardHash></CreditCardHash>
- <CreditCardType></CreditCardType>
- </Tenders>
- <MaxDiscountsAllowed>1</MaxDiscountsAllowed>
- <SellingOrganization></SellingOrganization>
- </orderRequest>
- </DiscountServiceRequest>
- </env:Body>
-</env:Envelope>
View
75 saved_forms/requests/test.xml
@@ -1,75 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<env:Envelope 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>
- <DiscountServiceRequest>
- <RequestDateTime>09/09/2009 09:00</RequestDateTime>
- <StoreID>1</StoreID>
- <RequestType>LIVE</RequestType>
- <orderRequest>
- <OrderID>1</OrderID>
- <QualifyType>QUALIFY_WITH_TENDER</QualifyType>
- <OrderDate>09/09/2009 09:00</OrderDate>
- <Channel>POS</Channel>
- <Brand>Gap</Brand>
- <Market>USA</Market>
- <OrderLineItems>
- <SequenceNumber>0</SequenceNumber>
- <Product>
- <Brand>Gap</Brand>
- <MerchandiseType>7</MerchandiseType>
- <StyleColor>1234567</StyleColor>
- </Product>
- <Price>
- <CurrentPrice></CurrentPrice>
- <NetPrice>50.00</NetPrice>
- <PriceType>MARKDOWN</PriceType>
- <IsPromotional>false</IsPromotional>
- <DiscountPrice></DiscountPrice>
- </Price>
- <Quantity>1</Quantity>
- <Awards>
- <AwardID></AwardID>
- <PromotionCode></PromotionCode>
- <DiscountedAmount></DiscountedAmount>
- <AwardMethod>FIXED_PRICE</AwardMethod>
- <AwardAmount></AwardAmount>
- </Awards>
- <IsLineItemExcluded>false</IsLineItemExcluded>
- <NumberOfManualDiscountsApplied></NumberOfManualDiscountsApplied>
- </OrderLineItems>
- <Promotions>
- <SequenceNumber>0</SequenceNumber>
- <PromotionCode>MYCODE123</PromotionCode>
- <ProgramType></ProgramType>
- <MemberId></MemberId>
- <PromotionID>1234</PromotionID>
- <DiscountReasonCode>adsfa</DiscountReasonCode>
- <AppliedStatus>CODE_APPLIED</AppliedStatus>
- <ReceiptMessages>
- <message></message>
- <locale></locale>
- </ReceiptMessages>
- <PromoUsages>
- <StoreId></StoreId>
- <TransactionId></TransactionId>
- <UsageDateTime></UsageDateTime>
- <Brand></Brand>
- <Channel></Channel>
- </PromoUsages>
- <QualifyingTenders></QualifyingTenders>
- <PromotionType>TRANSACTION</PromotionType>
- <HasExclusions>false</HasExclusions>
- </Promotions>
- <Tenders>
- <TenderType></TenderType>
- <CreditCardHash></CreditCardHash>
- <CreditCardType></CreditCardType>
- </Tenders>
- <MaxDiscountsAllowed>1</MaxDiscountsAllowed>
- <SellingOrganization></SellingOrganization>
- </orderRequest>
- </DiscountServiceRequest>
- </env:Body>
- </env:Envelope>
View
21 views/client.haml
@@ -33,12 +33,23 @@
%label
filename:
%input{:type => :text, :id => "file_name", :name => "file_name", :value => ''}
- %input{:type => 'submit', :name => 'SaveRequest',:value => 'SaveRequest', :onclick => "document.getElementById(\"action\").value = \"SaveRequest\";"}
- %input{:type => 'submit', :name => 'LoadRequest',:value => 'LoadRequest', :onclick => "document.getElementById(\"action\").value = \"LoadRequest\";"}
+ %input{:type => 'submit', :name => 'SaveRequestAs',:value => 'SaveRequestAs', :onclick => "document.getElementById(\"action\").value = \"SaveRequest\";"}
%div
%label
- fileupload:
+ file upload:
%input{ :name => "datafile", :size => "40", :type => "file" }
%input{:type => 'submit', :name => 'Upload',:value => 'Upload', :onclick => "document.getElementById(\"action\").value = \"Upload\";"}
-
-
+ %div
+ %h4
+ previously saved requests:
+ %table
+ - for file in @saved_requests
+ %tr
+ %td
+ %a{:title => "saved_forms/requests/#{file}", :href => "saved_forms/requests/#{file}"} download
+ %td
+ %input{:type => 'submit', :name => 'LoadRequest',:value => 'LoadRequest', :onclick => "document.getElementById(\"action\").value = \"LoadRequest\";document.getElementById(\"file_name\").value = \"#{file}\""}
+ %td
+ %input{:type => 'submit', :name => 'DeleteRequest',:value => 'DeleteRequest', :onclick => "document.getElementById(\"action\").value = \"DeleteRequest\";document.getElementById(\"file_name\").value = \"#{file}\""}
+ %td
+ = file
View
14 views/result.haml
@@ -31,4 +31,18 @@
filename:
%input{:type => :text, :id => "file_name", :name => "file_name", :value => ''}
%input{:type => 'submit', :name => 'SaveResponse',:value => 'SaveResponse', :onclick => "document.getElementById(\"action\").value = \"SaveResponse\";"}
+ %div
+ %h4
+ previously saved responses:
+ %table
+ - for file in @saved_responses
+ %tr
+ %td
+ %a{:title => "saved_forms/responses/#{file}", :href => "saved_forms/responses/#{file}"} download
+ %td
+ %input{:type => 'submit', :name => 'LoadResponse',:value => 'LoadResponse', :onclick => "document.getElementById(\"action\").value = \"LoadResponse\";document.getElementById(\"file_name\").value = \"#{file}\""}
+ %td
+ %input{:type => 'submit', :name => 'DeleteResponse',:value => 'DeleteResponse', :onclick => "document.getElementById(\"action\").value = \"DeleteResponse\";document.getElementById(\"file_name\").value = \"#{file}\""}
+ %td
+ = file
Please sign in to comment.
Something went wrong with that request. Please try again.