Sha256: 677af58550d8511c4551a5abc7f829e312a1ce8c3990477db35d02b2642939a0
Contents?: true
Size: 912 Bytes
Versions: 1
Compression:
Stored size: 912 Bytes
Contents
#!/usr/bin/env ruby def invoke_api http_method,api_path,params={} require 'unp_smart' puts "invoke api:#{http_method},#{api_path},#{params}" if http_method == 'get' result = UnpSmart.get api_path,params else result = UnpSmart.post api_path,params end puts "\n" puts "-"*50 puts result puts "-"*50 end if ARGV.length >0 http_method = ARGV.shift if %w{get post}.include?(http_method) api_path = ARGV.shift else api_path = http_method http_method = 'get' end unless ARGV.length%2 == 0 puts "Args is missed!!You should give me even values" exit! end params = {} ARGV.each_slice(2) do |item| params[item[0]] = item[1] end begin invoke_api http_method,api_path,params rescue => e puts "invoke api error,got:#{e.inspect}" end else puts "Usage:\n\tunpsmart [get/post] api_path key1 value1 key2 value2 [...]" end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
unp_smart-0.1.4 | bin/unpsmart |