Skip to content

Commit

Permalink
ON-36307 # Add GeneratePdfFromSubmissionData function to `PdfClient…
Browse files Browse the repository at this point in the history
…` class
  • Loading branch information
kizaonline committed Nov 15, 2023
1 parent 874aa03 commit a33facf
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"ms-dotnettools.csdevkit",
"ms-dotnettools.csharp",
"ms-dotnettools.vscodeintellicode-csharp",
"MS-CST-E.vscode-devskim"
]
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Added

- `GeneratePdfFromSubmissionData` function to `PdfClient` class

## 5.1.1 (2023-11-01)

### Added
Expand Down
7 changes: 7 additions & 0 deletions OneBlink.SDK/PdfClient.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma warning disable IDE1006 // T is already uses throughout the codebase
using System.Threading.Tasks;
using System.IO;
using OneBlink.SDK.Model;
Expand Down Expand Up @@ -39,5 +40,11 @@ public async Task<Stream> GeneratePdf(GeneratePdfOptionsRequest options)
string url = "/pdf-document";
return await this.oneBlinkPdfClient.PostRequest(url, options);
}

public async Task<Stream> GeneratePdfFromSubmissionData<T>(GeneratePDFFromSubmissionDataRequest<T> options)
{
string url = "/generate-pdf";
return await this.oneBlinkPdfClient.PostRequest(url, options);
}
}
}
30 changes: 30 additions & 0 deletions OneBlink.SDK/models/GeneratePDFFromSubmissionDataRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma warning disable IDE1006 // Naming is dictated by OneBlink API
using System;
using System.Collections.Generic;

namespace OneBlink.SDK.Model
{
public class GeneratePDFFromSubmissionDataRequest<T>
{
public FormSubmission<T> submissionData
{
get; set;
}
public long formsAppId
{
get; set;
}
public List<string> excludedElementIds
{
get; set;
}
public bool? usePagesAsBreaks
{
get; set;
}
public List<string> excludedCSSClasses
{
get; set;
}
}
}
32 changes: 32 additions & 0 deletions docs/pdf-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## Instance Functions

- [`GetSubmissionPdf()`](#getSubmissionpdf)
- [`GeneratePdf()`](#generatepdf)
- [`GeneratePdfFromSubmissionData()`](#generatepdffromsubmissiondata)

## Constructor

Expand Down Expand Up @@ -81,3 +83,33 @@ Stream response = await pdfClient.GeneratePdf(pdfOptionsRequest);
### Result

A `Stream` object

## `GeneratePdfFromSubmissionData()`

### Example

```c#
MySubmissionDataType submissionData = new MySubmissionDataType();
// populuate submissionData here
long formsAppId = 1;
GeneratePDFFromSubmissionDataRequest<MySubmissionDataType> options = new GeneratePDFFromSubmissionDataRequest<MySubmissionDataType>();
options.submissionData = submissionData;
options.formsAppId = formsAppId;
PdfClient pdfClient = new PdfClient(ACCESS_KEY, SECRET_KEY);
Stream response = await pdfClient.GeneratePdfFromSubmissionData<MySubmissionDataType>(options);
```

### Parameters

| Parameter | Required | Type | Description |
| --------- | -------- | -------------------------------------- | ---------------------------------------------------------------------------------------- |
| `options` | Yes | `GeneratePDFFromSubmissionDataRequest` | Includes various PDF configuration options and the submission data to be used in the PDF |

### Throws

- `OneBlinkAPIException`
- `Exception`

### Result

A `Stream` object

0 comments on commit a33facf

Please sign in to comment.