demo.rb 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. require_relative 'phalapi_client'
  2. class MyFilter < PhalApi::ClientFilter
  3. end
  4. def show_res(response)
  5. puts "response: #{response.ret}, #{response.data}, #{response.msg}"
  6. end
  7. a_client = PhalApi::Client.create.withHost('http://demo.phalapi.net')
  8. a_response = a_client.withService('Default.Index').withParams('username', 'dogstar').withTimeout(3000).request()
  9. puts a_response.ret, a_response.data, a_response.msg
  10. puts "--------------------"
  11. a_client = PhalApi::Client.create
  12. #a_client = PhalApi::Client.new
  13. a_response = a_client.withHost('http://demo.phalapi.net').withService('Default.Index').withParams('username', 'dogstar').withParams('v', '1.3.0').request()
  14. puts "--------------------"
  15. #puts a_client
  16. show_res a_response
  17. puts "--------------------"
  18. begin
  19. a_response = a_client.reset.withParams('one').request
  20. rescue Exception => e
  21. puts e.message
  22. end
  23. puts "--------------------"
  24. a_response = a_client.reset.withFilter(MyFilter.new).withService('Default.Index').withParams('username', 'dogstar').request
  25. show_res a_response
  26. puts "--------------------"
  27. a_response = a_client.reset.withService('XXXX.noThisMethod').request
  28. puts a_response.ret, a_response.data, a_response.msg
  29. show_res a_response
  30. puts 'we done!'
  31. puts 'we done!'
  32. puts 'we done!'