Guest User

Untitled

a guest
Jan 18th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2. # encoding: utf-8
  3.  
  4. require "rubygems"
  5. require "bunny"
  6. require "json"
  7.  
  8.  
  9.  
  10. def buildHash(width, height, length, orderNumber = "Mambo Test Print #9")
  11. xValues = {:X1 => 2.1}
  12. degreeZero = {:Allowed => 1}
  13. allowedRotations = {:Degree0 => degreeZero}
  14.  
  15. data = {}
  16. data[:Custom] = true
  17. data[:Length] = length.to_i
  18. data[:Width] = width.to_i
  19. data[:Height] = height.to_i
  20. data[:Quantity] = 1
  21. data[:CorrugateQuality] = 1
  22. data[:DesignId] = 2000100
  23. data[:AllowedRotations] = allowedRotations
  24. data[:MachineId] = "blahblah"
  25. data[:CustomerUniqueId] = orderNumber
  26. data[:XValues] = xValues
  27. data[:UserName] = "api"
  28.  
  29. message = {}
  30. message[:MessageType] = "CreateCustomCarton"
  31. message[:Data] = data
  32. message[:MachineGroupName] = "MG1"
  33. message[:MachineGroupId] = "blahblah"
  34. message[:UserName] = "api"
  35.  
  36. return message.to_json
  37. end
  38.  
  39. def buildConnection()
  40. bunnyConnection = Bunny.new(:host => "10.2.0.232", :user=>"username", :pass=>"password")
  41. bunnyConnection.start
  42.  
  43. channel = bunnyConnection.create_channel
  44. return channel.direct("PackNet-Direct", :durable => true)
  45. end
  46.  
  47. def sendBox(box)
  48. connection = buildConnection()
  49. puts box
  50. connection.publish(box, :routing_key => "Server", :content_type => "application/json", :persistent => true)
  51. puts "Done"
  52. end
  53.  
  54. def prompt(*args)
  55. print(*args)
  56. gets.gsub(/\n/,"")
  57. end
  58.  
  59. width = prompt "Width: "
  60. height = prompt "Height: "
  61. length = prompt "Length: "
  62. orderNumber = prompt "Order #: "
  63.  
  64. sendBox(buildHash(width, height, length, orderNumber))
Add Comment
Please, Sign In to add comment