|
| 1 | +=begin |
| 2 | +#TemplateFox API |
| 3 | +
|
| 4 | +#Generate beautiful PDFs from HTML/CSS templates with Jinja2 via API. Design once, generate thousands. |
| 5 | +
|
| 6 | +The version of the OpenAPI document: 1.10.0 |
| 7 | +
|
| 8 | +Generated by: https://openapi-generator.tech |
| 9 | +Generator version: 7.21.0 |
| 10 | +
|
| 11 | +=end |
| 12 | + |
| 13 | +require 'cgi' |
| 14 | + |
| 15 | +module TemplateFox |
| 16 | + class PDFToolsApi |
| 17 | + attr_accessor :api_client |
| 18 | + |
| 19 | + def initialize(api_client = ApiClient.default) |
| 20 | + @api_client = api_client |
| 21 | + end |
| 22 | + # Extract pages from a PDF |
| 23 | + # Return a single PDF containing only the selected pages of the input, in the order specified. Replaces the need for splitting + reassembling client-side. **Pages syntax:** 1-indexed, comma-separated. Supports ranges (`1-3`) and singles (`5`). Order is preserved: `5,1,3` outputs those 3 pages in that order. **Credits:** 1 credit per call. |
| 24 | + # @param extract_pdf_pages_request [ExtractPdfPagesRequest] |
| 25 | + # @param [Hash] opts the optional parameters |
| 26 | + # @return [PdfToolsResponse] |
| 27 | + def extract_pdf_pages(extract_pdf_pages_request, opts = {}) |
| 28 | + data, _status_code, _headers = extract_pdf_pages_with_http_info(extract_pdf_pages_request, opts) |
| 29 | + data |
| 30 | + end |
| 31 | + |
| 32 | + # Extract pages from a PDF |
| 33 | + # Return a single PDF containing only the selected pages of the input, in the order specified. Replaces the need for splitting + reassembling client-side. **Pages syntax:** 1-indexed, comma-separated. Supports ranges (`1-3`) and singles (`5`). Order is preserved: `5,1,3` outputs those 3 pages in that order. **Credits:** 1 credit per call. |
| 34 | + # @param extract_pdf_pages_request [ExtractPdfPagesRequest] |
| 35 | + # @param [Hash] opts the optional parameters |
| 36 | + # @return [Array<(PdfToolsResponse, Integer, Hash)>] PdfToolsResponse data, response status code and response headers |
| 37 | + def extract_pdf_pages_with_http_info(extract_pdf_pages_request, opts = {}) |
| 38 | + if @api_client.config.debugging |
| 39 | + @api_client.config.logger.debug 'Calling API: PDFToolsApi.extract_pdf_pages ...' |
| 40 | + end |
| 41 | + # verify the required parameter 'extract_pdf_pages_request' is set |
| 42 | + if @api_client.config.client_side_validation && extract_pdf_pages_request.nil? |
| 43 | + fail ArgumentError, "Missing the required parameter 'extract_pdf_pages_request' when calling PDFToolsApi.extract_pdf_pages" |
| 44 | + end |
| 45 | + # resource path |
| 46 | + local_var_path = '/v1/pdf-tools/extract-pages' |
| 47 | + |
| 48 | + # query parameters |
| 49 | + query_params = opts[:query_params] || {} |
| 50 | + |
| 51 | + # header parameters |
| 52 | + header_params = opts[:header_params] || {} |
| 53 | + # HTTP header 'Accept' (if needed) |
| 54 | + header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] |
| 55 | + # HTTP header 'Content-Type' |
| 56 | + content_type = @api_client.select_header_content_type(['application/json']) |
| 57 | + if !content_type.nil? |
| 58 | + header_params['Content-Type'] = content_type |
| 59 | + end |
| 60 | + |
| 61 | + # form parameters |
| 62 | + form_params = opts[:form_params] || {} |
| 63 | + |
| 64 | + # http body (model) |
| 65 | + post_body = opts[:debug_body] || @api_client.object_to_http_body(extract_pdf_pages_request) |
| 66 | + |
| 67 | + # return_type |
| 68 | + return_type = opts[:debug_return_type] || 'PdfToolsResponse' |
| 69 | + |
| 70 | + # auth_names |
| 71 | + auth_names = opts[:debug_auth_names] || ['ApiKeyAuth'] |
| 72 | + |
| 73 | + new_options = opts.merge( |
| 74 | + :operation => :"PDFToolsApi.extract_pdf_pages", |
| 75 | + :header_params => header_params, |
| 76 | + :query_params => query_params, |
| 77 | + :form_params => form_params, |
| 78 | + :body => post_body, |
| 79 | + :auth_names => auth_names, |
| 80 | + :return_type => return_type |
| 81 | + ) |
| 82 | + |
| 83 | + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) |
| 84 | + if @api_client.config.debugging |
| 85 | + @api_client.config.logger.debug "API called: PDFToolsApi#extract_pdf_pages\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" |
| 86 | + end |
| 87 | + return data, status_code, headers |
| 88 | + end |
| 89 | + |
| 90 | + # Merge PDFs |
| 91 | + # Concatenate 2 or more PDFs into a single PDF, in the order provided. Each input PDF is supplied as either an HTTPS URL or a base64 string. **Credits:** 1 credit per call. |
| 92 | + # @param merge_pdf_request [MergePdfRequest] |
| 93 | + # @param [Hash] opts the optional parameters |
| 94 | + # @return [PdfToolsResponse] |
| 95 | + def merge_pdf(merge_pdf_request, opts = {}) |
| 96 | + data, _status_code, _headers = merge_pdf_with_http_info(merge_pdf_request, opts) |
| 97 | + data |
| 98 | + end |
| 99 | + |
| 100 | + # Merge PDFs |
| 101 | + # Concatenate 2 or more PDFs into a single PDF, in the order provided. Each input PDF is supplied as either an HTTPS URL or a base64 string. **Credits:** 1 credit per call. |
| 102 | + # @param merge_pdf_request [MergePdfRequest] |
| 103 | + # @param [Hash] opts the optional parameters |
| 104 | + # @return [Array<(PdfToolsResponse, Integer, Hash)>] PdfToolsResponse data, response status code and response headers |
| 105 | + def merge_pdf_with_http_info(merge_pdf_request, opts = {}) |
| 106 | + if @api_client.config.debugging |
| 107 | + @api_client.config.logger.debug 'Calling API: PDFToolsApi.merge_pdf ...' |
| 108 | + end |
| 109 | + # verify the required parameter 'merge_pdf_request' is set |
| 110 | + if @api_client.config.client_side_validation && merge_pdf_request.nil? |
| 111 | + fail ArgumentError, "Missing the required parameter 'merge_pdf_request' when calling PDFToolsApi.merge_pdf" |
| 112 | + end |
| 113 | + # resource path |
| 114 | + local_var_path = '/v1/pdf-tools/merge' |
| 115 | + |
| 116 | + # query parameters |
| 117 | + query_params = opts[:query_params] || {} |
| 118 | + |
| 119 | + # header parameters |
| 120 | + header_params = opts[:header_params] || {} |
| 121 | + # HTTP header 'Accept' (if needed) |
| 122 | + header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] |
| 123 | + # HTTP header 'Content-Type' |
| 124 | + content_type = @api_client.select_header_content_type(['application/json']) |
| 125 | + if !content_type.nil? |
| 126 | + header_params['Content-Type'] = content_type |
| 127 | + end |
| 128 | + |
| 129 | + # form parameters |
| 130 | + form_params = opts[:form_params] || {} |
| 131 | + |
| 132 | + # http body (model) |
| 133 | + post_body = opts[:debug_body] || @api_client.object_to_http_body(merge_pdf_request) |
| 134 | + |
| 135 | + # return_type |
| 136 | + return_type = opts[:debug_return_type] || 'PdfToolsResponse' |
| 137 | + |
| 138 | + # auth_names |
| 139 | + auth_names = opts[:debug_auth_names] || ['ApiKeyAuth'] |
| 140 | + |
| 141 | + new_options = opts.merge( |
| 142 | + :operation => :"PDFToolsApi.merge_pdf", |
| 143 | + :header_params => header_params, |
| 144 | + :query_params => query_params, |
| 145 | + :form_params => form_params, |
| 146 | + :body => post_body, |
| 147 | + :auth_names => auth_names, |
| 148 | + :return_type => return_type |
| 149 | + ) |
| 150 | + |
| 151 | + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) |
| 152 | + if @api_client.config.debugging |
| 153 | + @api_client.config.logger.debug "API called: PDFToolsApi#merge_pdf\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" |
| 154 | + end |
| 155 | + return data, status_code, headers |
| 156 | + end |
| 157 | + |
| 158 | + # Rotate pages of a PDF |
| 159 | + # Rotate every page by the same angle (`rotation`), or apply a per-page rotation map (`page_rotations`). Rotations are cumulative with the page's existing rotation. Allowed angles: 0, 90, 180, 270. **Credits:** 1 credit per call. |
| 160 | + # @param rotate_pdf_request [RotatePdfRequest] |
| 161 | + # @param [Hash] opts the optional parameters |
| 162 | + # @return [PdfToolsResponse] |
| 163 | + def rotate_pdf(rotate_pdf_request, opts = {}) |
| 164 | + data, _status_code, _headers = rotate_pdf_with_http_info(rotate_pdf_request, opts) |
| 165 | + data |
| 166 | + end |
| 167 | + |
| 168 | + # Rotate pages of a PDF |
| 169 | + # Rotate every page by the same angle (`rotation`), or apply a per-page rotation map (`page_rotations`). Rotations are cumulative with the page's existing rotation. Allowed angles: 0, 90, 180, 270. **Credits:** 1 credit per call. |
| 170 | + # @param rotate_pdf_request [RotatePdfRequest] |
| 171 | + # @param [Hash] opts the optional parameters |
| 172 | + # @return [Array<(PdfToolsResponse, Integer, Hash)>] PdfToolsResponse data, response status code and response headers |
| 173 | + def rotate_pdf_with_http_info(rotate_pdf_request, opts = {}) |
| 174 | + if @api_client.config.debugging |
| 175 | + @api_client.config.logger.debug 'Calling API: PDFToolsApi.rotate_pdf ...' |
| 176 | + end |
| 177 | + # verify the required parameter 'rotate_pdf_request' is set |
| 178 | + if @api_client.config.client_side_validation && rotate_pdf_request.nil? |
| 179 | + fail ArgumentError, "Missing the required parameter 'rotate_pdf_request' when calling PDFToolsApi.rotate_pdf" |
| 180 | + end |
| 181 | + # resource path |
| 182 | + local_var_path = '/v1/pdf-tools/rotate' |
| 183 | + |
| 184 | + # query parameters |
| 185 | + query_params = opts[:query_params] || {} |
| 186 | + |
| 187 | + # header parameters |
| 188 | + header_params = opts[:header_params] || {} |
| 189 | + # HTTP header 'Accept' (if needed) |
| 190 | + header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] |
| 191 | + # HTTP header 'Content-Type' |
| 192 | + content_type = @api_client.select_header_content_type(['application/json']) |
| 193 | + if !content_type.nil? |
| 194 | + header_params['Content-Type'] = content_type |
| 195 | + end |
| 196 | + |
| 197 | + # form parameters |
| 198 | + form_params = opts[:form_params] || {} |
| 199 | + |
| 200 | + # http body (model) |
| 201 | + post_body = opts[:debug_body] || @api_client.object_to_http_body(rotate_pdf_request) |
| 202 | + |
| 203 | + # return_type |
| 204 | + return_type = opts[:debug_return_type] || 'PdfToolsResponse' |
| 205 | + |
| 206 | + # auth_names |
| 207 | + auth_names = opts[:debug_auth_names] || ['ApiKeyAuth'] |
| 208 | + |
| 209 | + new_options = opts.merge( |
| 210 | + :operation => :"PDFToolsApi.rotate_pdf", |
| 211 | + :header_params => header_params, |
| 212 | + :query_params => query_params, |
| 213 | + :form_params => form_params, |
| 214 | + :body => post_body, |
| 215 | + :auth_names => auth_names, |
| 216 | + :return_type => return_type |
| 217 | + ) |
| 218 | + |
| 219 | + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) |
| 220 | + if @api_client.config.debugging |
| 221 | + @api_client.config.logger.debug "API called: PDFToolsApi#rotate_pdf\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" |
| 222 | + end |
| 223 | + return data, status_code, headers |
| 224 | + end |
| 225 | + end |
| 226 | +end |
0 commit comments