diff --git a/src/main/java/com/twilio/oai/TwilioGoGenerator.java b/src/main/java/com/twilio/oai/TwilioGoGenerator.java index cb5a2f23c..26301baa9 100644 --- a/src/main/java/com/twilio/oai/TwilioGoGenerator.java +++ b/src/main/java/com/twilio/oai/TwilioGoGenerator.java @@ -187,6 +187,9 @@ public void postProcessParameter(final CodegenParameter parameter) { if(parameter.isBodyParam){ parameter.vendorExtensions.put("x-is-body-param",true); } + if(parameter.isQueryParam){ + parameter.vendorExtensions.put("x-is-query-param",true); + } if (parameter.isFreeFormObject || parameter.isAnyType) { parameter.vendorExtensions.put("x-marshal", true); } diff --git a/src/main/resources/twilio-go/api.mustache b/src/main/resources/twilio-go/api.mustache index ea5d8ae8e..6ba00255f 100644 --- a/src/main/resources/twilio-go/api.mustache +++ b/src/main/resources/twilio-go/api.mustache @@ -48,15 +48,17 @@ func (c *ApiService) {{{nickname}}}({{#allParams}}{{#required}}{{paramName}} {{{ {{/headerParams}} {{/hasHeaderParams}} {{#vendorExtensions.x-is-create-operation}} -{{#vendorExtensions.x-is-json-type}} - resp, err := c.requestHandler.{{httpMethod}}(c.baseURL+path, data, headers, body...) -{{/vendorExtensions.x-is-json-type}} -{{^vendorExtensions.x-is-json-type}} - resp, err := c.requestHandler.{{httpMethod}}(c.baseURL+path, data, headers) -{{/vendorExtensions.x-is-json-type}} + {{#vendorExtensions.x-is-json-type}} + resp, err := c.requestHandler.{{httpMethod}}(c.baseURL+path, data, headers, queryParams, body...) + {{/vendorExtensions.x-is-json-type}} + {{^vendorExtensions.x-is-json-type}} + resp, err := c.requestHandler.{{httpMethod}}(c.baseURL+path, data, headers, queryParams) + {{/vendorExtensions.x-is-json-type}} {{/vendorExtensions.x-is-create-operation}} {{^vendorExtensions.x-is-create-operation}} - resp, err := c.requestHandler.{{httpMethod}}(c.baseURL+path, data, headers) + {{^vendorExtensions.x-is-json-type}} + resp, err := c.requestHandler.{{httpMethod}}(c.baseURL+path, data, headers, queryParams) + {{/vendorExtensions.x-is-json-type}} {{/vendorExtensions.x-is-create-operation}} {{#returnType}} if err != nil { @@ -96,7 +98,7 @@ func (c *ApiService) Page{{{vendorExtensions.x-domain-name}}}({{#allParams}}{{#r data.Set("Page", pageNumber) } - resp, err := c.requestHandler.Get(c.baseURL+path, data, headers) + resp, err := c.requestHandler.Get(c.baseURL+path, data, headers, queryParams) if err != nil { return nil, err } @@ -184,7 +186,7 @@ func (c *ApiService) getNext{{{returnContainer}}}(nextPageUrl string) (interface if nextPageUrl == "" { return nil, nil } - resp, err := c.requestHandler.Get(nextPageUrl, nil, nil) + resp, err := c.requestHandler.Get(nextPageUrl, nil, nil, nil) if err != nil { return nil, err } diff --git a/src/main/resources/twilio-go/partial_serialization.mustache b/src/main/resources/twilio-go/partial_serialization.mustache index 25b9f207e..265acf3a0 100644 --- a/src/main/resources/twilio-go/partial_serialization.mustache +++ b/src/main/resources/twilio-go/partial_serialization.mustache @@ -12,6 +12,7 @@ if params != nil && params.PathAccountSid != nil { {{/pathParams}} data := url.Values{} + queryParams := url.Values{} {{^vendorExtensions.x-is-json-type}} headers := make(map[string]interface{}) @@ -47,10 +48,20 @@ if params != nil && params.PathAccountSid != nil { return nil, err } - data.Add("{{{baseName}}}", string(v)) +{{^vendorExtensions.x-is-query-param}} + data.Add("{{{baseName}}}", string(v)) +{{/vendorExtensions.x-is-query-param}} +{{#vendorExtensions.x-is-query-param}} + queryParams.Add("{{{baseName}}}", string(v)) +{{/vendorExtensions.x-is-query-param}} {{/items.vendorExtensions.x-marshal}} {{^items.vendorExtensions.x-marshal}} - data.Add("{{{baseName}}}", item) +{{^vendorExtensions.x-is-query-param}} + data.Add("{{{baseName}}}", item) +{{/vendorExtensions.x-is-query-param}} +{{#vendorExtensions.x-is-query-param}} + queryParams.Add("{{{baseName}}}", item) +{{/vendorExtensions.x-is-query-param}} {{/items.vendorExtensions.x-marshal}} } {{/isArray}} @@ -62,10 +73,20 @@ if params != nil && params.PathAccountSid != nil { return nil, err } - data.Set("{{{baseName}}}", string(v)) +{{^vendorExtensions.x-is-query-param}} + data.Set("{{{baseName}}}", string(v)) +{{/vendorExtensions.x-is-query-param}} +{{#vendorExtensions.x-is-query-param}} + queryParams.Set("{{{baseName}}}", string(v)) +{{/vendorExtensions.x-is-query-param}} {{/vendorExtensions.x-marshal}} {{^vendorExtensions.x-marshal}} +{{^vendorExtensions.x-is-query-param}} data.Set("{{{baseName}}}", {{^isString}}fmt.Sprint({{/isString}}{{#isDateTime}}({{/isDateTime}}*params.{{paramName}}{{^isString}}{{#isDateTime}}).Format(time.RFC3339){{/isDateTime}}){{/isString}}) +{{/vendorExtensions.x-is-query-param}} +{{#vendorExtensions.x-is-query-param}} + queryParams.Set("{{{baseName}}}", {{^isString}}fmt.Sprint({{/isString}}{{#isDateTime}}({{/isDateTime}}*params.{{paramName}}{{^isString}}{{#isDateTime}}).Format(time.RFC3339){{/isDateTime}}){{/isString}}) +{{/vendorExtensions.x-is-query-param}} {{/vendorExtensions.x-marshal}} {{/isArray}} } @@ -92,10 +113,20 @@ if params != nil && params.PathAccountSid != nil { return nil, err } +{{^vendorExtensions.x-is-query-param}} data.Add("{{{baseName}}}", string(v)) +{{/vendorExtensions.x-is-query-param}} +{{#vendorExtensions.x-is-query-param}} + queryParams.Add("{{{baseName}}}", string(v)) +{{/vendorExtensions.x-is-query-param}} {{/items.vendorExtensions.x-marshal}} {{^items.vendorExtensions.x-marshal}} +{{^vendorExtensions.x-is-query-param}} data.Add("{{{baseName}}}", item) +{{/vendorExtensions.x-is-query-param}} +{{#vendorExtensions.x-is-query-param}} + queryParams.Add("{{{baseName}}}", item) +{{/vendorExtensions.x-is-query-param}} {{/items.vendorExtensions.x-marshal}} } {{/isArray}} @@ -107,10 +138,20 @@ if params != nil && params.PathAccountSid != nil { return nil, err } +{{^vendorExtensions.x-is-query-param}} data.Set("{{{baseName}}}", string(v)) +{{/vendorExtensions.x-is-query-param}} +{{#vendorExtensions.x-is-query-param}} + queryParams.Set("{{{baseName}}}", string(v)) +{{/vendorExtensions.x-is-query-param}} {{/vendorExtensions.x-marshal}} {{^vendorExtensions.x-marshal}} +{{^vendorExtensions.x-is-query-param}} data.Set("{{{baseName}}}", {{^isString}}fmt.Sprint({{/isString}}{{#isDateTime}}({{/isDateTime}}*params.{{paramName}}{{^isString}}{{#isDateTime}}).Format(time.RFC3339){{/isDateTime}}){{/isString}}) +{{/vendorExtensions.x-is-query-param}} +{{#vendorExtensions.x-is-query-param}} + queryParams.Set("{{{baseName}}}", {{^isString}}fmt.Sprint({{/isString}}{{#isDateTime}}({{/isDateTime}}*params.{{paramName}}{{^isString}}{{#isDateTime}}).Format(time.RFC3339){{/isDateTime}}){{/isString}}) +{{/vendorExtensions.x-is-query-param}} {{/vendorExtensions.x-marshal}} {{/isArray}} }