Open Igorpollo opened 9 years ago
Even you might already found a solution I would like to point that the issues lies within your code.
The signature of the xml functions looks like:
# Translates a given +hash+ with +options+ to XML.
def self.xml(hash, options = {})
Hash.to_xml hash.dup, options
end
But what you are trying is to put two separate keys into the xml functions. Just put your data and option key in a separate hash and the function will work as expected.
@teste = Gyoku.xml( {
:enviar_instrucao => {
:instrucao_unica =>{
:razao => 'Upgrade de Conta',
:valores => {:valor => '100', :attributes! => { :valor => { :moeda => 'BRL' }}},
:id_propio => 'TesteRails',
:pagador => {
:nome => 'Igor Cesar',
:email => 'igorpollo@gmail.com',
:id_pagador =>'01',
:endereco_cobranca => {
:logradouro => 'Rua do Teste',
:numero => '45',
:complemento => 'em frente ao PC',
:bairro => 'Palhaco Ze',
:cidade => 'Rio de Janeiro',
:estado => 'RJ',
:pais => 'Brasil',
:CEP => '20765171',
:telefone_fixo => '(21) 99527-2766'
}
}
}
}
},
{ :key_converter => :none } )
Result:
<?xml version="1.0"?>
<enviar_instrucao>
<instrucao_unica>
<razao>Upgrade de Conta</razao>
<valores>
<valor moeda="BRL">100</valor>
</valores>
<id_propio>TesteRails</id_propio>
<pagador>
<nome>Igor Cesar</nome>
<email>igorpollo@gmail.com</email>
<id_pagador>01</id_pagador>
<endereco_cobranca>
<logradouro>Rua do Teste</logradouro>
<numero>45</numero>
<complemento>em frente ao PC</complemento>
<bairro>Palhaco Ze</bairro>
<cidade>Rio de Janeiro</cidade>
<estado>RJ</estado>
<pais>Brasil</pais>
<CEP>20765171</CEP>
<telefone_fixo>(21) 99527-2766</telefone_fixo>
</endereco_cobranca>
</pagador>
</instrucao_unica>
</enviar_instrucao>
Hi, congrats for the nice gem. I need instead