Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- # encoding: utf-8
- require "rubygems"
- require "bunny"
- require "json"
- def buildHash(width, height, length, orderNumber = "Mambo Test Print #9")
- xValues = {:X1 => 2.1}
- degreeZero = {:Allowed => 1}
- allowedRotations = {:Degree0 => degreeZero}
- data = {}
- data[:Custom] = true
- data[:Length] = length.to_i
- data[:Width] = width.to_i
- data[:Height] = height.to_i
- data[:Quantity] = 1
- data[:CorrugateQuality] = 1
- data[:DesignId] = 2000100
- data[:AllowedRotations] = allowedRotations
- data[:MachineId] = "blahblah"
- data[:CustomerUniqueId] = orderNumber
- data[:XValues] = xValues
- data[:UserName] = "api"
- message = {}
- message[:MessageType] = "CreateCustomCarton"
- message[:Data] = data
- message[:MachineGroupName] = "MG1"
- message[:MachineGroupId] = "blahblah"
- message[:UserName] = "api"
- return message.to_json
- end
- def buildConnection()
- bunnyConnection = Bunny.new(:host => "10.2.0.232", :user=>"username", :pass=>"password")
- bunnyConnection.start
- channel = bunnyConnection.create_channel
- return channel.direct("PackNet-Direct", :durable => true)
- end
- def sendBox(box)
- connection = buildConnection()
- puts box
- connection.publish(box, :routing_key => "Server", :content_type => "application/json", :persistent => true)
- puts "Done"
- end
- def prompt(*args)
- print(*args)
- gets.gsub(/\n/,"")
- end
- width = prompt "Width: "
- height = prompt "Height: "
- length = prompt "Length: "
- orderNumber = prompt "Order #: "
- sendBox(buildHash(width, height, length, orderNumber))
Add Comment
Please, Sign In to add comment