-
Notifications
You must be signed in to change notification settings - Fork 29
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
Form encoded data #309
base: master
Are you sure you want to change the base?
Form encoded data #309
Conversation
"qs": { | ||
"${id}": "${BloodPressure}" | ||
}, | ||
"form": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking to the examples, it seems that "form" and "json" are mutually exclusive. Is my interpretation correct? What would happen if the action includes both "form" and "json" (I don't see anything in the code modifications checking that posibility)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it would make sense that they are mutually exclusive. Either you send the data as application/json or as application/x-www-form-urlencoded.
Should we restrict that in order to be accepted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so. Any other opinion? @cblanco what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My first approach would be to throw an exception if both fields are filled, but I think that it wouldn't follow the guidelines of this coding.
What do you think about this approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lest's consider the end-to-end perspective in the CEP API. I mean, what should happen in the case the user tries to use both "json" and "form" when creating or updating a rule is that he/she gets a 400 Bad Request response with an error telling about she/he cannot do that.
In addition:
- An unit test covering this situation should be added to ensure it is working.
- Documentation should explain that both parameters are mutually exclusive.
lib/models/postAction.js
Outdated
@@ -41,6 +41,8 @@ function buildPostOptions(action, event) { | |||
} | |||
else if (action.template) { | |||
options.text = myutils.expandVar(action.template, event); | |||
}else if (action.parameters.form){ | |||
options.form = myutils.expandObject(action.parameters.form,event); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line seems to be under-indented. Same in L68.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: whitespace between ,
and event
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in the next commit
@Secmotic some time has passed since last news on this PRs... :) How are the thing going? Any update or progress? Thanks! |
@Secmotic any update in this PR, please? Don't hesitate of asking if something is not clear about what is pending in this PR to be finished and merged. Thanks! |
Sorry @fgalan , completely missed the evolution on this. |
Since we had to integrate CEP with an API that only receives form data (Twilio) , we have created this functionality.
Documentation has been modified aswell to complete it with this option