Created
December 28, 2011 19:01
-
-
Save kbuckler/1529189 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ZuoraClient | |
class ZObject | |
def initialize(type) | |
@type = type | |
end | |
def add_field(name, default_value) | |
@fields ||= {} | |
@fields[name.to_s] = default_value | |
end | |
def set_field(name, value) | |
end | |
def build | |
n = Nokogiri::XML::Builder.new do |xml| | |
xml.zObjects("xsi:type" => "ins2:#{@type}", "xmlns:ins0" => "http://api.zuora.com/", "xmlns:ins2" => "http://object.api.zuora.com/") do | |
xml.parent.namespace = xml.parent.namespace_definitions.find { |ns| ns.prefix=="ins0" } | |
@fields.each_pair do |name, value| | |
xml['ins2'].send(name.capitalize, value) | |
end | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment