Ruby Wrapper: set_item_quantity fails

tom hicks's Avatar

tom hicks

26 Sep, 2014 07:51 PM

I'm trying to change an existing item quantity using set_item_quantity with the following data ...

{:code=>"GCR_ADMIN", :item_code=>"MEMBERS", :quantity=>"2"}

but it always returns an error as follows...

[{:text=>"A value is required", :id=>"18411299", :code=>"412", :auxCode=>"quantity:isEmpty", :fieldName=>"quantity", :errorType=>"isEmpty"}]

Any idea what I'm doing wrong?

Thanks!

Tom

  1. Support Staff 1 Posted by Marc Guyer on 29 Sep, 2014 01:14 PM

    Marc Guyer's Avatar

    Hi Tom -- On the surface, it appears that your params are correct but somehow CG isn't getting the quantity. I've confirmed via our logs that there are no POST params for this API call. So, something's wrong. I can't help further without knowing your code. You'll just have to dig in. Can you log your raw API request locally?

  2. 2 Posted by tom hicks on 29 Sep, 2014 01:33 PM

    tom hicks's Avatar

    Some additional info...

    I also have tried using numeric for quantity as is :quantity=>2 which also does not work.

    Also, add_item_quantity does succeed but it ignores the quantity and always adds one to the existing item quantity.

  3. 3 Posted by tom hicks on 29 Sep, 2014 01:37 PM

    tom hicks's Avatar

    More info ...

    I am using the cheddargetter_client_ruby from expectedbehavior.

    I have looked at their code and it doesn't seem to be doing anything to mess up the quantity parameter.

    Disclaimer: I am a ruby nuby to be sure so maybe I'm missing something obvious. For example I have no idea what you mean by "Can you log your raw API request locally?" Is this something you do via the web browser?

  4. Support Staff 4 Posted by Marc Guyer on 29 Sep, 2014 01:45 PM

    Marc Guyer's Avatar

    Sounds like the wrapper method isn't receiving the params as required. Here's the wrapper method:

    https://github.com/expectedbehavior/cheddargetter_client_ruby/blob/...

    It takes two hashes, the id_hash and the data. Can you post your code for the wrapper method call here?

  5. 5 Posted by tom hicks on 29 Sep, 2014 02:09 PM

    tom hicks's Avatar

    Here is my code ...

              data = { :code => plan_code, :item_code => 'MEMBERS', :quantity => @plan_count.to_s }
              logger.info "data = #{data}"
              response = @cg.add_item_quantity(data)

    In this case the plan code and the customer code are the same so that is why I am passing that as the "code"

    I'm not sure what I would need to put in the id_hash. As I said this works but it ignores the quantity.

  6. 6 Posted by tom hicks on 29 Sep, 2014 02:22 PM

    tom hicks's Avatar

    Ok, problem solved. It was the issue with id_hash vs data. Now that I have separated the two I'm getting the expected results. Thanks for pointing a real noob in the right direction.

  7. 7 Posted by tom hicks on 29 Sep, 2014 02:41 PM

    tom hicks's Avatar

    I know this isn't your domain but it would have helped if the example code in the cheddargetter_client_ruby had included an example of something that required both the id_hash and the data parameter. That's where I got messed up. Of course I did look at their code but by that time I had already gotten it in to my head that everything goes in to the data parameter.

    The other thing that caused me some pain was figuring out the response format from the get_customers call. I am sure I did this in the hardest most convoluted way as there was no example of how you should do it. So in your spare time ... anyway ...

    Thanks again for being a great help!

    Tom

  8. Jess Pendley closed this discussion on 29 Sep, 2014 04:45 PM.

Discussions are closed to public comments.
If you need help with Cheddar please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

28 Mar, 2024 10:45 PM
24 Jan, 2024 08:33 AM
11 Jan, 2024 07:13 AM
30 Nov, 2023 02:07 AM
22 Nov, 2023 08:41 AM