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

Add GetEnvelopeDocumentFields custom method #22

Merged
merged 1 commit into from
May 17, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@
"/accounts/{accountId}/envelopes/{envelopeId}/documents/{documentId}/fields": {
"get": {
"summary": "Get envelope document custom fields",
"description": "Get envelope document custom fields.",
"description": "Get custom document fields of envelope document.",
"operationId": "GetEnvelopeDocumentFields",
"parameters": [
{
Expand Down
23 changes: 23 additions & 0 deletions certified-connectors/DocuSignDemo/script.csx
Original file line number Diff line number Diff line change
Expand Up @@ -1797,6 +1797,29 @@ public class Script : ScriptBase
body["workflowIds"] = workflowsArray;
response.Content = new StringContent(body.ToString(), Encoding.UTF8, "application/json");
}

if ("GetEnvelopeDocumentFields".Equals(this.Context.OperationId, StringComparison.OrdinalIgnoreCase))
{
var body = ParseContentAsJObject(await response.Content.ReadAsStringAsync().ConfigureAwait(false), false);
var query = HttpUtility.ParseQueryString(this.Context.Request.RequestUri.Query);
var newBody = new JObject();
JArray envelopeDocumentFields = new JArray();

foreach(JProperty documentFields in body.Properties())
{
foreach(var field in documentFields.Value)
{
envelopeDocumentFields.Add(new JObject()
{
["name"] = field["name"],
["value"] = field["value"]
});
}
}

newBody["envelopeDocumentFields"] = envelopeDocumentFields;
response.Content = new StringContent(newBody.ToString(), Encoding.UTF8, "application/json");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this the same encoding we use elsewhere in the script file?

Copy link
Owner Author

Choose a reason for hiding this comment

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

yes it is same encoding for all methods in the script file.

}

if ("GetEnvelopeDocumentTabs".Equals(this.Context.OperationId, StringComparison.OrdinalIgnoreCase))
{
Expand Down