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

Form encoded data #309

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

Form encoded data #309

wants to merge 4 commits into from

Conversation

Secmotic
Copy link

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

"qs": {
"${id}": "${BloodPressure}"
},
"form": {
Copy link
Member

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)?

Copy link
Author

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?

Copy link
Member

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?

Copy link
Author

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?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @fgalan @cblanco . I'm looking forward for your comments on this :)

Copy link
Member

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.

@@ -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);
Copy link
Member

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.

Copy link
Member

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

Copy link
Author

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

@fgalan
Copy link
Member

fgalan commented Feb 1, 2019

@Secmotic some time has passed since last news on this PRs... :)

How are the thing going? Any update or progress?

Thanks!

@fgalan
Copy link
Member

fgalan commented May 30, 2019

@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!

@JoseSecmotic
Copy link

Sorry @fgalan , completely missed the evolution on this.
Sadly, I didn't have the time to implement the requirements to fulfill the PR, and I am afraid It will not happen in a near future :(

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