lib/portatext/command/base.rb in portatext-1.1.1 vs lib/portatext/command/base.rb in portatext-1.1.2
- old
+ new
@@ -38,10 +38,15 @@
def content_type(_method)
return 'text/csv' unless @args[:file].nil?
'application/json'
end
+ def accept_content_type(_method)
+ return 'text/csv' unless @args[:accept_file].nil?
+ 'application/json'
+ end
+
def body(_method)
return "file:#{@args[:file]}" unless @args[:file].nil?
return '' if @args.size.eql? 0
@args.to_json
end
@@ -51,10 +56,17 @@
end
private
def run(method)
- @client.run endpoint(method), method, content_type(method), body(method)
+ a_type = accept_content_type method
+ command_endpoint = endpoint(method)
+ file = @args[:accept_file]
+ @args.delete :accept_file
+ @client.run(
+ command_endpoint, method, content_type(method),
+ a_type, body(method), file
+ )
end
end
end
end