mobify / commercecloud-ocapi-client

Salesforce Commerce Cloud Open Commerce API (OCAPI) for Node and browsers 🛒
MIT License
70 stars 31 forks source link

Add `overrideHttpPut` Option #13

Closed bendvc closed 6 years ago

bendvc commented 6 years ago

Description

This change added a new option to the api. overrideHttpPut which is defaulted tofalse that will ensure all commands that using http PUT as specified in their swagger doc will masquerade as http POST. Their http method will then be overridden with an additional header x-dw-http-method-override: 'PUT' to ensure things work server side.

This was done on the API side for security reasons, so it is out of our hands. More information about this can be found here --> https://documentation.demandware.com/DOC1/index.jsp?topic=%2Fcom.demandware.dochelp%2FOCAPI%2F18.8%2Fusage%2FHttpMethods.html

Type of change

Changes

How to test this PR?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

Checklist:

olibrook commented 6 years ago

Looks really great! Only thing is, I kinda hate the name allowHttpPut, because we're always going to have methods called putCart or whatever, and they are always going to be "allowed". Could we rename the flag to overrideHttpPut? Users can then probably imagine that would correspond to a commonly-used "x-method-override" header, too.

kevinxh commented 6 years ago

Looking pretty good.

One thing we might want to do is add some documentation around this flag, maybe here: https://github.com/mobify/commercecloud-ocapi-client#-configuration

(I agree with Oli, word 'override' sounds more intuitive in this case)

bendvc commented 6 years ago

I've addressed both of your comments. This involved inverting the logic a little as the name change is the inverse. Please take a look