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

feat: add the ability to post a JSON payload to the Twilio API's #83

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

Conversation

RJPearson94
Copy link

Updating the configuration of a Flex instance requires a POST request to be made with a JSON payload. This change lays the foundations to support this. This is highlighted in twilio/twilio-oai-generator#49

The PostJson accepts an interface for the request body (data) instead of just a map as this prevents the computational overhead of having to marshal the struct to a slice of bytes then create a string from the bytes. The JSON string would then be unmarshalled to a map and then marshalled again to a slice of bytes

This change makes the Content-Type header mandatory for POST requests

Checklist

  • I acknowledge that all my contributions will be made under the project's license
  • I have made a material change to the repo (functionality, testing, spelling, grammar)
  • I have read the Contribution Guidelines and my PR follows them
  • I have titled the PR appropriately
  • I have updated my branch with the main branch
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation about the functionality in the appropriate .md file
  • I have added inline documentation to the code I modified

If you have questions, please file a support ticket, or create a GitHub Issue in this repository.

RJPearson94 added a commit to RJPearson94/twilio-oai-generator that referenced this pull request Jun 10, 2021
…JSON media type for the request body

The Go Generator has been updated to add a vendor extension to set `x-is-json` to true when the consume media type is `application/json` and `x-is-form` when the consumes media type is `application/x-www-form-urlencoded`

The `x-is-json` vendor extension is used to generate the code to handle calling the new PostJson function or the corresponding HTTP method function on the request handler. This is designed to only work with Post requests at the moment but could be extended in the future if needed.

This PR aids in resolving twilio#49 however once this PR is merged twilio/twilio-oai#36 will need to be finished to fully resolve the issue

This change relies on twilio/twilio-go#83 and the tests cannot be updated until this PR is merged and released

This change also fixes an issue with JSON struct tags for the Params structs being `html-escaped`. I have disabled the escaping by using `{{{}}}` as this was highlighted during linting the Go SDK repo
@thinkingserious thinkingserious added status: code review request requesting a community code review or review from Twilio type: community enhancement feature request not on Twilio's roadmap labels Jun 11, 2021
@RJPearson94 RJPearson94 changed the base branch from main to travis July 9, 2021 00:07
@RJPearson94 RJPearson94 changed the base branch from travis to main July 9, 2021 00:07
RJPearson94 added a commit to RJPearson94/twilio-oai-generator that referenced this pull request Jul 9, 2021
…JSON media type for the request body

The Go Generator has been updated to add a vendor extension to set `x-is-json` to true when the consume media type is `application/json` and `x-is-form` when the consumes media type is `application/x-www-form-urlencoded`

The `x-is-json` vendor extension is used to generate the code to handle calling the new PostJson function or the corresponding HTTP method function on the request handler. This is designed to only work with Post requests at the moment but could be extended in the future if needed.

This PR aids in resolving twilio#49 however once this PR is merged twilio/twilio-oai#36 will need to be finished to fully resolve the issue

This change relies on twilio/twilio-go#83 and the tests cannot be updated until this PR is merged and released

This change also fixes an issue with JSON struct tags for the Params structs being `html-escaped`. I have disabled the escaping by using `{{{}}}` as this was highlighted during linting the Go SDK repo
Updating the configuration of a Flex instance requires a POST request to be made with a JSON payload. This change lays the foundations to support this.
The PostJson accepts an interface for the request body (data) instead of just a map as this prevents the computational overhead of having to marshal the struct to a slice of bytes then create a string from the bytes. The JSON string would then be unmarshalled to a map and then marshalled again to a slice of bytes
@RJPearson94 RJPearson94 force-pushed the add-support-for-json-post-requests branch from 069ac91 to 3d97366 Compare July 9, 2021 01:24
RJPearson94 added a commit to RJPearson94/twilio-oai-generator that referenced this pull request Jul 9, 2021
…JSON media type for the request body

The Go Generator has been updated to add a vendor extension to set `x-is-json` to true when the consume media type is `application/json` and `x-is-form` when the consumes media type is `application/x-www-form-urlencoded`

The `x-is-json` vendor extension is used to generate the code to handle calling the new PostJson function or the corresponding HTTP method function on the request handler. This is designed to only work with Post requests at the moment but could be extended in the future if needed.

This PR aids in resolving twilio#49 however once this PR is merged twilio/twilio-oai#36 will need to be finished to fully resolve the issue

This change relies on twilio/twilio-go#83 and the tests cannot be updated until this PR is merged and released

This change also fixes an issue with JSON struct tags for the Params structs being `html-escaped`. I have disabled the escaping by using `{{{}}}` as this was highlighted during linting the Go SDK repo
RJPearson94 and others added 3 commits July 20, 2021 23:49
the http methods are converted to upper case to because the http method constants i.e. MethodGet, MethodPost values are uppercase
@mattcole19 mattcole19 added status: waiting for feature feature will be implemented in the future and removed status: code review request requesting a community code review or review from Twilio labels Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting for feature feature will be implemented in the future type: community enhancement feature request not on Twilio's roadmap
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants