Skip to content

Commit

Permalink
feat: added support for nested enum in request body in node (#534)
Browse files Browse the repository at this point in the history
<!--
We appreciate the effort for this pull request but before that please
make sure you read the contribution guidelines, then fill out the blanks
below.

Please format the PR title appropriately based on the type of change:
  <type>[!]: <description>
Where <type> is one of: docs, chore, feat, fix, test, misc.
Add a '!' after the type for breaking changes (e.g. feat!: new breaking
feature).

**All third-party contributors acknowledge that any contributions they
provide will be made under the same open-source license that the
open-source project is provided under.**

Please enter each Issue number you are resolving in your PR after one of
the following words [Fixes, Closes, Resolves]. This will auto-link these
issues and close them when this PR is merged!
e.g.
Fixes #1
Closes #2
-->

# Fixes #

Fixed the handling of nested enum objects in request body of node

### Checklist
- [x] I acknowledge that all my contributions will be made under the
project's license
- [x] Run `make test-docker`
- [x] Verify affected language:
- [ ] Generate [twilio-go](https://github.com/twilio/twilio-go) from our
[OpenAPI specification](https://github.com/twilio/twilio-oai) using the
[build_twilio_go.py](./examples/build_twilio_go.py) using `python
examples/build_twilio_go.py path/to/twilio-oai/spec/yaml
path/to/twilio-go` and inspect the diff
    - [ ] Run `make test` in `twilio-go`
    - [ ] Create a pull request in `twilio-go`
    - [ ] Provide a link below to the pull request
- [x] I have made a material change to the repo (functionality, testing,
spelling, grammar)
- [x] I have read the [Contribution
Guidelines](https://github.com/twilio/twilio-oai-generator/blob/main/CONTRIBUTING.md)
and my PR follows them
- [x] 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 create a GitHub Issue in this repository.

---------

Co-authored-by: sbansla <[email protected]>
Co-authored-by: Athira Sabu <[email protected]>
  • Loading branch information
3 people authored Nov 2, 2023
1 parent c9f611f commit e924083
Show file tree
Hide file tree
Showing 60 changed files with 1,466 additions and 1,223 deletions.
375 changes: 182 additions & 193 deletions examples/go/go-client/helper/rest/api/v2010/accounts.go

Large diffs are not rendered by default.

242 changes: 116 additions & 126 deletions examples/go/go-client/helper/rest/api/v2010/accounts_calls.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,164 +18,154 @@ import (
"encoding/json"
"fmt"
"net/url"

"github.com/twilio/twilio-go/client"
"strings"
)


// Optional parameters for the method 'CreateCall'
type CreateCallParams struct {
//
PathAccountSid *string `json:"PathAccountSid,omitempty"`
//
RequiredStringProperty *string `json:"RequiredStringProperty,omitempty"`
//
TestArrayOfStrings *[]string `json:"TestArrayOfStrings,omitempty"`
//
TestArrayOfUri *[]string `json:"TestArrayOfUri,omitempty"`
// The HTTP method that we should use to request the `TestArrayOfUri`.
TestMethod *string `json:"TestMethod,omitempty"`
//
PathAccountSid *string `json:"PathAccountSid,omitempty"`
//
RequiredStringProperty *string `json:"RequiredStringProperty,omitempty"`
//
TestArrayOfStrings *[]string `json:"TestArrayOfStrings,omitempty"`
//
TestArrayOfUri *[]string `json:"TestArrayOfUri,omitempty"`
// The HTTP method that we should use to request the `TestArrayOfUri`.
TestMethod *string `json:"TestMethod,omitempty"`
}

func (params *CreateCallParams) SetPathAccountSid(PathAccountSid string) (*CreateCallParams){
params.PathAccountSid = &PathAccountSid
return params
func (params *CreateCallParams) SetPathAccountSid(PathAccountSid string) *CreateCallParams {
params.PathAccountSid = &PathAccountSid
return params
}
func (params *CreateCallParams) SetRequiredStringProperty(RequiredStringProperty string) (*CreateCallParams){
params.RequiredStringProperty = &RequiredStringProperty
return params
func (params *CreateCallParams) SetRequiredStringProperty(RequiredStringProperty string) *CreateCallParams {
params.RequiredStringProperty = &RequiredStringProperty
return params
}
func (params *CreateCallParams) SetTestArrayOfStrings(TestArrayOfStrings []string) (*CreateCallParams){
params.TestArrayOfStrings = &TestArrayOfStrings
return params
func (params *CreateCallParams) SetTestArrayOfStrings(TestArrayOfStrings []string) *CreateCallParams {
params.TestArrayOfStrings = &TestArrayOfStrings
return params
}
func (params *CreateCallParams) SetTestArrayOfUri(TestArrayOfUri []string) (*CreateCallParams){
params.TestArrayOfUri = &TestArrayOfUri
return params
func (params *CreateCallParams) SetTestArrayOfUri(TestArrayOfUri []string) *CreateCallParams {
params.TestArrayOfUri = &TestArrayOfUri
return params
}
func (params *CreateCallParams) SetTestMethod(TestMethod string) (*CreateCallParams){
params.TestMethod = &TestMethod
return params
func (params *CreateCallParams) SetTestMethod(TestMethod string) *CreateCallParams {
params.TestMethod = &TestMethod
return params
}

func (c *ApiService) CreateCall(params *CreateCallParams) (*TestResponseObject, error) {
path := "/2010-04-01/Accounts/{AccountSid}/Calls.json"
if params != nil && params.PathAccountSid != nil {
path = strings.Replace(path, "{"+"AccountSid"+"}", *params.PathAccountSid, -1)
} else {
path = strings.Replace(path, "{"+"AccountSid"+"}", c.requestHandler.Client.AccountSid(), -1)
}

data := url.Values{}
headers := make(map[string]interface{})

if params != nil && params.RequiredStringProperty != nil {
data.Set("RequiredStringProperty", *params.RequiredStringProperty)
}
if params != nil && params.TestArrayOfStrings != nil {
for _, item := range *params.TestArrayOfStrings {
data.Add("TestArrayOfStrings", item)
}
}
if params != nil && params.TestArrayOfUri != nil {
for _, item := range *params.TestArrayOfUri {
data.Add("TestArrayOfUri", item)
}
}
if params != nil && params.TestMethod != nil {
data.Set("TestMethod", *params.TestMethod)
}



resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
if err != nil {
return nil, err
}

defer resp.Body.Close()

ps := &TestResponseObject{}
if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
return nil, err
}

return ps, err
path := "/2010-04-01/Accounts/{AccountSid}/Calls.json"
if params != nil && params.PathAccountSid != nil {
path = strings.Replace(path, "{"+"AccountSid"+"}", *params.PathAccountSid, -1)
} else {
path = strings.Replace(path, "{"+"AccountSid"+"}", c.requestHandler.Client.AccountSid(), -1)
}

data := url.Values{}
headers := make(map[string]interface{})

if params != nil && params.RequiredStringProperty != nil {
data.Set("RequiredStringProperty", *params.RequiredStringProperty)
}
if params != nil && params.TestArrayOfStrings != nil {
for _, item := range *params.TestArrayOfStrings {
data.Add("TestArrayOfStrings", item)
}
}
if params != nil && params.TestArrayOfUri != nil {
for _, item := range *params.TestArrayOfUri {
data.Add("TestArrayOfUri", item)
}
}
if params != nil && params.TestMethod != nil {
data.Set("TestMethod", *params.TestMethod)
}

resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
if err != nil {
return nil, err
}

defer resp.Body.Close()

ps := &TestResponseObject{}
if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
return nil, err
}

return ps, err
}

// Optional parameters for the method 'DeleteCall'
type DeleteCallParams struct {
//
PathAccountSid *string `json:"PathAccountSid,omitempty"`
}

func (params *DeleteCallParams) SetPathAccountSid(PathAccountSid string) (*DeleteCallParams){
params.PathAccountSid = &PathAccountSid
return params
//
PathAccountSid *string `json:"PathAccountSid,omitempty"`
}

func (c *ApiService) DeleteCall(TestInteger int, params *DeleteCallParams) (error) {
path := "/2010-04-01/Accounts/{AccountSid}/Calls/{TestInteger}.json"
if params != nil && params.PathAccountSid != nil {
path = strings.Replace(path, "{"+"AccountSid"+"}", *params.PathAccountSid, -1)
} else {
path = strings.Replace(path, "{"+"AccountSid"+"}", c.requestHandler.Client.AccountSid(), -1)
func (params *DeleteCallParams) SetPathAccountSid(PathAccountSid string) *DeleteCallParams {
params.PathAccountSid = &PathAccountSid
return params
}
path = strings.Replace(path, "{"+"TestInteger"+"}", fmt.Sprint(TestInteger), -1)

data := url.Values{}
headers := make(map[string]interface{})

func (c *ApiService) DeleteCall(TestInteger int, params *DeleteCallParams) error {
path := "/2010-04-01/Accounts/{AccountSid}/Calls/{TestInteger}.json"
if params != nil && params.PathAccountSid != nil {
path = strings.Replace(path, "{"+"AccountSid"+"}", *params.PathAccountSid, -1)
} else {
path = strings.Replace(path, "{"+"AccountSid"+"}", c.requestHandler.Client.AccountSid(), -1)
}
path = strings.Replace(path, "{"+"TestInteger"+"}", fmt.Sprint(TestInteger), -1)

data := url.Values{}
headers := make(map[string]interface{})

resp, err := c.requestHandler.Delete(c.baseURL+path, data, headers)
if err != nil {
return err
}

resp, err := c.requestHandler.Delete(c.baseURL+path, data, headers)
if err != nil {
return err
}
defer resp.Body.Close()

defer resp.Body.Close()

return nil
return nil
}

// Optional parameters for the method 'FetchCall'
type FetchCallParams struct {
//
PathAccountSid *string `json:"PathAccountSid,omitempty"`
//
PathAccountSid *string `json:"PathAccountSid,omitempty"`
}

func (params *FetchCallParams) SetPathAccountSid(PathAccountSid string) (*FetchCallParams){
params.PathAccountSid = &PathAccountSid
return params
func (params *FetchCallParams) SetPathAccountSid(PathAccountSid string) *FetchCallParams {
params.PathAccountSid = &PathAccountSid
return params
}

func (c *ApiService) FetchCall(TestInteger int, params *FetchCallParams) (*TestResponseObject, error) {
path := "/2010-04-01/Accounts/{AccountSid}/Calls/{TestInteger}.json"
if params != nil && params.PathAccountSid != nil {
path = strings.Replace(path, "{"+"AccountSid"+"}", *params.PathAccountSid, -1)
} else {
path = strings.Replace(path, "{"+"AccountSid"+"}", c.requestHandler.Client.AccountSid(), -1)
}
path = strings.Replace(path, "{"+"TestInteger"+"}", fmt.Sprint(TestInteger), -1)

data := url.Values{}
headers := make(map[string]interface{})




resp, err := c.requestHandler.Get(c.baseURL+path, data, headers)
if err != nil {
return nil, err
}

defer resp.Body.Close()

ps := &TestResponseObject{}
if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
return nil, err
}

return ps, err
path := "/2010-04-01/Accounts/{AccountSid}/Calls/{TestInteger}.json"
if params != nil && params.PathAccountSid != nil {
path = strings.Replace(path, "{"+"AccountSid"+"}", *params.PathAccountSid, -1)
} else {
path = strings.Replace(path, "{"+"AccountSid"+"}", c.requestHandler.Client.AccountSid(), -1)
}
path = strings.Replace(path, "{"+"TestInteger"+"}", fmt.Sprint(TestInteger), -1)

data := url.Values{}
headers := make(map[string]interface{})

resp, err := c.requestHandler.Get(c.baseURL+path, data, headers)
if err != nil {
return nil, err
}

defer resp.Body.Close()

ps := &TestResponseObject{}
if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
return nil, err
}

return ps, err
}
Loading

0 comments on commit e924083

Please sign in to comment.