require 'yaml' require 'soap/header/simplehandler' module AdWords class HeaderHandler < SOAP::Header::SimpleHandler def initialize(tag, value) super(XSD::QName.new(nil, tag)) @tag = tag @value = value end #the initial handler from the sample was wrong, it generated 2 level of tags def on_simple_outbound @value end end class AdWordsCredentials attr_reader :handlers def getDefaults() prefs = YAML::load( File.open("#{ENV['HOME']}/.adwords-api.yaml", 'r')) credentials = prefs['credentials'] end def initialize(*parm) @handlers = [] if parm[0] credentials = parm[0] else credentials = getDefaults() end credentials.each {|key, value| @handlers << HeaderHandler.new(key, value)} end end end