Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Array handling in payload values more compact to reflect subsequent equal tags #21

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

meismann
Copy link

Old behaviour:

# Adds: "<a>1</a><a><b>1</b><b>2</b></a>" to the ebay request body
args = [{ :a => 1 }, { :a => [{:b => 1 }, { :b => 2 }] }]
Ebayr::Request.new(:Blah, :input => args)

New behaviour:

If a value in this Hash is an Array, then each of the Array's elements is wrapped in the same tag (which is the value's key), like here (1 and 2 are both wrapped in the tag b):

# Adds: "<a>1</a><a><b>1</b><b>2</b></a>" to the ebay request body
args = {a: [ 1, { b: [1, 2] } ]}
Ebayr::Request.new(:Blah, :input => args)

If you have to, you can switch the legacy syntax on with this setting:

Ebayr.use_old_hash_to_xml_conversion = true

Also:
These methods cannot be used from outside of Ebayr::Request any more:
.xml, .serialize_input, .camelize, #input_xml

In order to create "<a>1</a><a><b>1</b><b>2</b></a>", you used
to to call .xml([{ :a => 1 }, { :a => [{:b => 1 }, { :b => 2 }] }]).

Now you will only need to call .xml(a: [1, { b: [1, 2] } ])
@meismann
Copy link
Author

@bjjb Took up your suggestion to make it backward compatible. Here is the result.

@SpeerJ
Copy link
Contributor

SpeerJ commented Sep 29, 2015

Please remember to use the "=>" over ":" for hashes, since this project targets ruby 1.8.7 as well.
the tests return this error "
/home/travis/build/bjjb/ebayr/test/ebayr/request_test.rb:24: syntax error, unexpected ':', expecting ')'

  xml_of(a: [ 1, { b: [1, 2] } ])."

it can be fixed with "xml_of(:a=> [ 1, { :b=> [1, 2] } ])"

@meismann
Copy link
Author

Ok, will change it in a minute.

…melize and #input_xml

This will break code that relies on Ebayr::Request methods
made private. You should not rely on these methods anyway,
since they are, though not private, class internals.
@meismann
Copy link
Author

Any progress here?

@meismann
Copy link
Author

meismann commented Mar 9, 2018

Any chance that theses changes will make it into master? If not, let us close it.

@bjjb
Copy link
Owner

bjjb commented Mar 17, 2018

Hi @meismann The changes currently conflict with other changes in master. Is it still an issue for you? If not, then I guess we can just close it. If so, then I can make some suggestions for prepping the MR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants