Guest User

Untitled

a guest
Aug 2nd, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. require "typhoeus"
  2. require "json"
  3. require "./Constants"
  4.  
  5. include Constants
  6. include Typhoeus
  7.  
  8. class Gist
  9. def build_gist
  10. gist = { :description => "This is a test",
  11. :public => true,
  12. :files => { "file1.txt" => { :content => "Testing a sample string" } }
  13. }
  14.  
  15. json = JSON.pretty_generate(gist)
  16. puts json
  17. return json
  18. end
  19.  
  20. def send_gist(gist)
  21. url = BASE_URL + "/gists"
  22. request = Request.new(url, :username => USERNAME,
  23. :password => PASSWORD,
  24. :method => :post,
  25. :body => gist)
  26. puts request.params
  27.  
  28. hydra = Hydra.hydra
  29. hydra.queue(request)
  30. hydra.run
  31.  
  32. response = request.response
  33. puts response.body
  34. end
  35. end
  36.  
  37. gist = Gist.new
  38. gist.send_gist(gist.build_gist)
Add Comment
Please, Sign In to add comment