#!/usr/bin/env rubyrequire'rubygems'require'ezcrypto'require'json'require'cgi'require'time'moduleBookingBugclassTokenGeneratorattr_accessor:dataattr_accessor:optionsBOOKINGBUG_COMPANY_ID="{Your Company ID parent or child or Affiliate ID}"BOOKINGBUG_SECURE_KEY="{Your Secure Key}"definitialize(options={})options.merge!({:expires=>(Time.now+3600).iso8601})key=EzCrypto::Key.with_passwordBOOKINGBUG_COMPANY_ID,BOOKINGBUG_SECURE_KEY@data=key.encrypt64(options.to_json).gsub(/\n/,'')@data=CGI.escape(@data)enddefto_s@dataenddefdecryptkey=EzCrypto::Key.with_passwordBOOKINGBUG_COMPANY_ID,BOOKINGBUG_SECURE_KEYkey.decrypt64(CGI.unescape(@data))endendendtoken=BookingBug::TokenGenerator.new({'first_name'=>'John','email'=>'smith@example.com','last_name'=>'Smith','mobile'=>'0123456789','reference'=>'external-reference'})putstoken.to_s