Closed tomsouthall-zz closed 9 years ago
Oh actually /promos
too. Need both.
@tomsouthall do you need the whole entity or will just the id suffice?
@smnirven the whole entity - it's the way backbone's sync works.
@tomsouthall can you check this out now?
@smnirven Thanks very much. Both end-points confirmed working.
@smnirven Reopening. Working for POST. Needs to work for PUT too.
@t2 FYI the response status code on updates will change from 204 to 200. You don't want to know how long I was trying to figure out why the body was always nil, even though I was adding the updated promo in the handler. Turns out if you specify a status 204 (No Content), ring ignores what you set in the body and makes it nil.
@tomsouthall okay, give this another shot. Let me know if anything's not copacetic
@smnirven The structure of the offer in the response differs between POST and PUT. For instance in POST, presentation is an object whereas in PUT presentation fields are flattened out. I'm expecting the object.
(and nice use of copacetic)
@tomsouthall okay, one more time
@smnirven Looking good now! Cheers.
@smnirven I spoke too soon. This one doesn't actually affect anything yet, but it's still wrong so should be fixed.
I tried doing a PUT to /offers. I was adding a condition to the offer, and the condition seemed to be saved successfully. However the condition was not included in the response.
now what
god this bug won't die
Yeah sorry.
@smnirven I'm baaaack!!
If I PUT a condition to /offers, the condition is returned in the response. Correct.
If I POST a condition to /offers, the condition is NOT returned in the response. Bad!
cURL:
curl 'http://localhost:8282/api/v1/offers' -H 'Pragma: no-cache' -H 'Origin: http://localhost:8282' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q=0.8,fr;q=0.6' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_102) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36' -H 'Content-Type: application/json' -H 'Accept: application/json, text/javascript, /_; q=0.01' -H 'Cache-Control: no-cache' -H 'X-Requested-With: XMLHttpRequest' -H 'Cookie: promotably-session=9f29f071-b91d-4f94-aa70-bee816e4ed2a; promotably=b2714a1c-5e08-4f6e-9afb-5ad9ab35930a; promotably-user=%7B%22user-id%22%3A%22b71e2361-2750-4cd0-bcd4-eb2db158244c%22%7D; __apiauth=cD73YIz3BTFFi%2BHohbQyeS3CBIYoblv1qTX%2FPzfYLi0CptDVHzK5Zottw%2BTfJ9wKB3gMR2r0WUlnPoL1F1yPTA%3D%3D; _gat=1; _ga=GA1.1.79999154.1426216891' -H 'Connection: keep-alive' -H 'Referer: http://localhost:8282/offers/create' --data-binary $'{"conditions":[{"type":"product-views","period-in-days":"60","product-views":"5"}],"reward":{"type":"promo","promo-id":"3a7a7852-4446-4317-80ca-f571093e4a78"},"presentation":{"type":"lightbox","page":"any","display-text":"Test","html":"<div class=\"promotably-theme\">\n <a class=\"promotably-close\">\xd7\n <p class=\"promotably-offer-text\">Test
\n\n Use code: <span class=\"promotably-promo-code\">\n
\n <p class=\"promotably-expiry\" style=\"display: none;\">\n Expires in: <span class=\"promotably-countdown\">\n \nHeh -- okay. I fix
I see conditions :+1: Thanks.
But the bug that will never die lives on. The site-id
in both the POST and PUT responses is an int and not a uuid. I think that might be the last thing.
Hm promo responses do not return a site-id
at all. That probably doesn't matter for now as I don't use it anyway.
BUT... like offers the POST returns zero conditions (PUT is okay).
Currently, if say I successfully create an offer via a POST to
/api/v1/offers
, I receive a 201 Created response. The response text however is empty.I am in a situation where I need to know the
offer-id
of a newly created offer without having to do a subsequent GET to retrieve it.In my mind, all 201 responses should return the newly created entity.
If this is tricky for any reason, I particularly need
/offers
right now.