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: Csharp request body #525

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/resources/twilio-csharp/ResourceUsings.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using Twilio.Base;
using Twilio.Clients;
using Twilio.Constant;
using Twilio.Converters;
using Twilio.Exceptions;
using Twilio.Http;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
}
{{/vendorExtensions.x-required-param-exists}}

{{^vendorExtensions.x-is-json}}
{{>options/GetParams}}
{{/vendorExtensions.x-is-json}}
{{#vendorExtensions.x-is-json}}
{{>options/GetBody}}
{{/vendorExtensions.x-is-json}}
{{>options/HeaderParams}}
}
18 changes: 18 additions & 0 deletions src/main/resources/twilio-csharp/options/GetBody.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

/// <summary> Generate the request body </summary>
public string GetBody()
{
string body = "";

{{#vendorExtensions.x-getparams}}
{{^isArray}}
{{^vendorExtensions.x-parameter-map}}
if ({{paramName}} != null)
{
body = {{apiName}}{{resourceConstant}}.ToJson({{paramName}});
}
{{/vendorExtensions.x-parameter-map}}
{{/isArray}}
{{/vendorExtensions.x-getparams}}
return body;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

/// <summary> Generate the necessary parameters </summary>
public {{#vendorExtensions.x-is-read-operation}} override{{/vendorExtensions.x-is-read-operation}} List<KeyValuePair<string, string>> GetParams()
public List<KeyValuePair<string, string>> GetParams()
{
var p = new List<KeyValuePair<string, string>>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
HttpMethod.Post,
Rest.Domain.{{domainPackage}},
path,
postParams: options.GetParams(),
{{^bodyParam}}postParams: options.GetParams(),{{/bodyParam}}
{{#bodyParam}}
contentType: EnumConstants.ContentTypeEnum.JSON,
body: options.GetBody(),
{{/bodyParam}}
headerParams: {{^vendorExtensions.hasOptionalHeaderParams}}null{{/vendorExtensions.hasOptionalHeaderParams}}{{#vendorExtensions.hasOptionalHeaderParams}}options.GetHeaderParams(){{/vendorExtensions.hasOptionalHeaderParams}}
);
}
Expand Down
Loading