pdf4me 1.0.1 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (291) hide show
  1. checksums.yaml +4 -4
  2. data/{LICENSE → LICENSE.txt} +6 -6
  3. data/README.md +124 -395
  4. data/lib/pdf4me.rb +40 -110
  5. data/lib/pdf4me/actions/complex_action.rb +64 -0
  6. data/lib/pdf4me/actions/convert_file_to_pdf.rb +30 -0
  7. data/lib/pdf4me/actions/convert_to_pdf.rb +14 -0
  8. data/lib/pdf4me/actions/create_pdf_a.rb +29 -0
  9. data/lib/pdf4me/actions/create_thumbnail.rb +55 -0
  10. data/lib/pdf4me/actions/extract_pages.rb +49 -0
  11. data/lib/pdf4me/actions/merge_two_pdfs.rb +34 -0
  12. data/lib/pdf4me/actions/optimize.rb +10 -0
  13. data/lib/pdf4me/actions/optimize_by_profile.rb +42 -0
  14. data/lib/pdf4me/actions/split_by_page_nr.rb +55 -0
  15. data/lib/pdf4me/actions/text_stamp.rb +63 -0
  16. data/lib/pdf4me/actions/wrapper_action.rb +65 -0
  17. data/lib/pdf4me/client.rb +87 -0
  18. data/lib/pdf4me/configuration.rb +9 -88
  19. data/lib/pdf4me/exceptions.rb +26 -0
  20. data/lib/pdf4me/models/base.rb +26 -0
  21. data/lib/pdf4me/models/convert_to_pdf_action.rb +26 -246
  22. data/lib/pdf4me/models/convert_to_pdf_res.rb +5 -185
  23. data/lib/pdf4me/models/doc_log.rb +12 -257
  24. data/lib/pdf4me/models/doc_metadata.rb +13 -282
  25. data/lib/pdf4me/models/document.rb +14 -282
  26. data/lib/pdf4me/models/notification.rb +8 -191
  27. data/lib/pdf4me/models/optimize_action.rb +72 -508
  28. data/lib/pdf4me/models/optimize_res.rb +5 -195
  29. data/lib/pdf4me/models/page.rb +12 -254
  30. data/lib/pdf4me/utils/assigner.rb +10 -0
  31. data/lib/pdf4me/utils/serializer.rb +43 -0
  32. data/lib/pdf4me/version.rb +1 -13
  33. data/spec/actions/create_pdf_a_spec.rb +21 -0
  34. data/spec/actions/wrapper_action_spec.rb +24 -0
  35. data/spec/files/4.pdf +0 -0
  36. data/spec/spec_helper.rb +17 -100
  37. metadata +70 -421
  38. data/Gemfile +0 -7
  39. data/Rakefile +0 -8
  40. data/docs/ActionFlow.md +0 -8
  41. data/docs/ApiUsageRes.md +0 -11
  42. data/docs/ArchiveConfig.md +0 -11
  43. data/docs/ArchiveJobReq.md +0 -12
  44. data/docs/ArchiveJobRes.md +0 -9
  45. data/docs/Color.md +0 -10
  46. data/docs/ConvertApi.md +0 -102
  47. data/docs/ConvertToPdf.md +0 -10
  48. data/docs/ConvertToPdfAction.md +0 -10
  49. data/docs/ConvertToPdfRes.md +0 -8
  50. data/docs/CreateImages.md +0 -10
  51. data/docs/CreateImagesRes.md +0 -8
  52. data/docs/CreatePdfA.md +0 -10
  53. data/docs/CreatePdfARes.md +0 -8
  54. data/docs/CustomCMSConfig.md +0 -23
  55. data/docs/DocAction.md +0 -8
  56. data/docs/DocLog.md +0 -12
  57. data/docs/DocMetadata.md +0 -16
  58. data/docs/Document.md +0 -16
  59. data/docs/DocumentApi.md +0 -203
  60. data/docs/DropDocumentReq.md +0 -20
  61. data/docs/DropDocumentRes.md +0 -15
  62. data/docs/ExecutionTrigger.md +0 -10
  63. data/docs/Extract.md +0 -10
  64. data/docs/ExtractAction.md +0 -9
  65. data/docs/ExtractApi.md +0 -102
  66. data/docs/ExtractRes.md +0 -8
  67. data/docs/GetDocumentListRes.md +0 -13
  68. data/docs/GetDocumentReq.md +0 -14
  69. data/docs/GetDocumentRes.md +0 -14
  70. data/docs/IFormFile.md +0 -13
  71. data/docs/Image.md +0 -15
  72. data/docs/ImageAction.md +0 -30
  73. data/docs/ImageApi.md +0 -107
  74. data/docs/Job.md +0 -10
  75. data/docs/JobApi.md +0 -197
  76. data/docs/JobConfig.md +0 -18
  77. data/docs/JobConfigRes.md +0 -8
  78. data/docs/KeyValuePairStringObject.md +0 -9
  79. data/docs/KeyValuePairStringString.md +0 -9
  80. data/docs/ManagementApi.md +0 -92
  81. data/docs/Merge.md +0 -10
  82. data/docs/MergeAction.md +0 -8
  83. data/docs/MergeApi.md +0 -102
  84. data/docs/MergeRes.md +0 -8
  85. data/docs/Notification.md +0 -9
  86. data/docs/OcrAction.md +0 -12
  87. data/docs/OcrApi.md +0 -57
  88. data/docs/Optimize.md +0 -10
  89. data/docs/OptimizeAction.md +0 -35
  90. data/docs/OptimizeApi.md +0 -103
  91. data/docs/OptimizeRes.md +0 -9
  92. data/docs/Page.md +0 -14
  93. data/docs/PageSelection.md +0 -10
  94. data/docs/Pdf4meAction.md +0 -12
  95. data/docs/Pdf4meDocument.md +0 -32
  96. data/docs/Pdf4meException.md +0 -8
  97. data/docs/PdfAAction.md +0 -14
  98. data/docs/PdfAApi.md +0 -102
  99. data/docs/PdfFont.md +0 -9
  100. data/docs/Pricing.md +0 -13
  101. data/docs/ProduceDocuments.md +0 -14
  102. data/docs/ProduceDocumentsRes.md +0 -8
  103. data/docs/ProduceOutput.md +0 -8
  104. data/docs/RGBSet.md +0 -10
  105. data/docs/RecognizeDocument.md +0 -10
  106. data/docs/RecognizeDocumentRes.md +0 -9
  107. data/docs/Rectangle.md +0 -11
  108. data/docs/Rotate.md +0 -10
  109. data/docs/RunJobRes.md +0 -10
  110. data/docs/SignatureConfig.md +0 -7
  111. data/docs/Split.md +0 -10
  112. data/docs/SplitAction.md +0 -11
  113. data/docs/SplitApi.md +0 -103
  114. data/docs/SplitRes.md +0 -8
  115. data/docs/Stamp.md +0 -10
  116. data/docs/StampAction.md +0 -22
  117. data/docs/StampApi.md +0 -110
  118. data/docs/StampRes.md +0 -8
  119. data/docs/StorageFolder.md +0 -10
  120. data/docs/Text.md +0 -17
  121. data/docs/Transform.md +0 -13
  122. data/docs/Translate.md +0 -9
  123. data/docs/UserFingerprint.md +0 -9
  124. data/docs/VersionRes.md +0 -8
  125. data/docs/java.md +0 -425
  126. data/lib/pdf4me/api/convert_api.rb +0 -130
  127. data/lib/pdf4me/api/document_api.rb +0 -218
  128. data/lib/pdf4me/api/extract_api.rb +0 -131
  129. data/lib/pdf4me/api/image_api.rb +0 -139
  130. data/lib/pdf4me/api/job_api.rb +0 -223
  131. data/lib/pdf4me/api/management_api.rb +0 -117
  132. data/lib/pdf4me/api/merge_api.rb +0 -131
  133. data/lib/pdf4me/api/ocr_api.rb +0 -74
  134. data/lib/pdf4me/api/optimize_api.rb +0 -139
  135. data/lib/pdf4me/api/pdf_a_api.rb +0 -134
  136. data/lib/pdf4me/api/split_api.rb +0 -135
  137. data/lib/pdf4me/api/stamp_api.rb +0 -159
  138. data/lib/pdf4me/api_client.rb +0 -380
  139. data/lib/pdf4me/api_error.rb +0 -38
  140. data/lib/pdf4me/models/action_flow.rb +0 -190
  141. data/lib/pdf4me/models/api_usage_res.rb +0 -219
  142. data/lib/pdf4me/models/archive_config.rb +0 -226
  143. data/lib/pdf4me/models/archive_job_req.rb +0 -249
  144. data/lib/pdf4me/models/archive_job_res.rb +0 -207
  145. data/lib/pdf4me/models/color.rb +0 -206
  146. data/lib/pdf4me/models/convert_to_pdf.rb +0 -209
  147. data/lib/pdf4me/models/create_images.rb +0 -209
  148. data/lib/pdf4me/models/create_images_res.rb +0 -189
  149. data/lib/pdf4me/models/create_pdf_a.rb +0 -209
  150. data/lib/pdf4me/models/create_pdf_a_res.rb +0 -189
  151. data/lib/pdf4me/models/custom_cms_config.rb +0 -323
  152. data/lib/pdf4me/models/doc_action.rb +0 -190
  153. data/lib/pdf4me/models/drop_document_req.rb +0 -348
  154. data/lib/pdf4me/models/drop_document_res.rb +0 -260
  155. data/lib/pdf4me/models/execution_trigger.rb +0 -206
  156. data/lib/pdf4me/models/extract.rb +0 -207
  157. data/lib/pdf4me/models/extract_action.rb +0 -201
  158. data/lib/pdf4me/models/extract_res.rb +0 -188
  159. data/lib/pdf4me/models/get_document_list_res.rb +0 -237
  160. data/lib/pdf4me/models/get_document_req.rb +0 -243
  161. data/lib/pdf4me/models/get_document_res.rb +0 -246
  162. data/lib/pdf4me/models/i_form_file.rb +0 -235
  163. data/lib/pdf4me/models/image.rb +0 -300
  164. data/lib/pdf4me/models/image_action.rb +0 -513
  165. data/lib/pdf4me/models/job.rb +0 -213
  166. data/lib/pdf4me/models/job_config.rb +0 -298
  167. data/lib/pdf4me/models/job_config_res.rb +0 -193
  168. data/lib/pdf4me/models/key_value_pair_string_object.rb +0 -197
  169. data/lib/pdf4me/models/key_value_pair_string_string.rb +0 -197
  170. data/lib/pdf4me/models/merge.rb +0 -209
  171. data/lib/pdf4me/models/merge_action.rb +0 -190
  172. data/lib/pdf4me/models/merge_res.rb +0 -188
  173. data/lib/pdf4me/models/ocr_action.rb +0 -259
  174. data/lib/pdf4me/models/optimize.rb +0 -209
  175. data/lib/pdf4me/models/page_selection.rb +0 -246
  176. data/lib/pdf4me/models/pdf4me_action.rb +0 -259
  177. data/lib/pdf4me/models/pdf4me_document.rb +0 -511
  178. data/lib/pdf4me/models/pdf4me_exception.rb +0 -189
  179. data/lib/pdf4me/models/pdf_a_action.rb +0 -297
  180. data/lib/pdf4me/models/pdf_font.rb +0 -213
  181. data/lib/pdf4me/models/pricing.rb +0 -278
  182. data/lib/pdf4me/models/produce_documents.rb +0 -251
  183. data/lib/pdf4me/models/produce_documents_res.rb +0 -191
  184. data/lib/pdf4me/models/produce_output.rb +0 -221
  185. data/lib/pdf4me/models/recognize_document.rb +0 -209
  186. data/lib/pdf4me/models/recognize_document_res.rb +0 -198
  187. data/lib/pdf4me/models/rectangle.rb +0 -215
  188. data/lib/pdf4me/models/rgb_set.rb +0 -206
  189. data/lib/pdf4me/models/rotate.rb +0 -221
  190. data/lib/pdf4me/models/run_job_res.rb +0 -215
  191. data/lib/pdf4me/models/signature_config.rb +0 -179
  192. data/lib/pdf4me/models/split.rb +0 -207
  193. data/lib/pdf4me/models/split_action.rb +0 -219
  194. data/lib/pdf4me/models/split_res.rb +0 -190
  195. data/lib/pdf4me/models/stamp.rb +0 -209
  196. data/lib/pdf4me/models/stamp_action.rb +0 -387
  197. data/lib/pdf4me/models/stamp_res.rb +0 -189
  198. data/lib/pdf4me/models/storage_folder.rb +0 -239
  199. data/lib/pdf4me/models/text.rb +0 -320
  200. data/lib/pdf4me/models/transform.rb +0 -263
  201. data/lib/pdf4me/models/translate.rb +0 -207
  202. data/lib/pdf4me/models/user_fingerprint.rb +0 -197
  203. data/lib/pdf4me/models/version_res.rb +0 -188
  204. data/pdf4me.gemspec +0 -47
  205. data/spec/api/convert_api_spec.rb +0 -60
  206. data/spec/api/document_api_spec.rb +0 -83
  207. data/spec/api/extract_api_spec.rb +0 -60
  208. data/spec/api/image_api_spec.rb +0 -62
  209. data/spec/api/job_api_spec.rb +0 -82
  210. data/spec/api/management_api_spec.rb +0 -57
  211. data/spec/api/merge_api_spec.rb +0 -60
  212. data/spec/api/ocr_api_spec.rb +0 -47
  213. data/spec/api/optimize_api_spec.rb +0 -60
  214. data/spec/api/pdf_a_api_spec.rb +0 -60
  215. data/spec/api/split_api_spec.rb +0 -60
  216. data/spec/api/stamp_api_spec.rb +0 -63
  217. data/spec/api_client_spec.rb +0 -226
  218. data/spec/configuration_spec.rb +0 -42
  219. data/spec/models/action_flow_spec.rb +0 -42
  220. data/spec/models/api_usage_res_spec.rb +0 -60
  221. data/spec/models/archive_config_spec.rb +0 -60
  222. data/spec/models/archive_job_req_spec.rb +0 -66
  223. data/spec/models/archive_job_res_spec.rb +0 -48
  224. data/spec/models/color_spec.rb +0 -54
  225. data/spec/models/convert_to_pdf_action_spec.rb +0 -62
  226. data/spec/models/convert_to_pdf_res_spec.rb +0 -42
  227. data/spec/models/convert_to_pdf_spec.rb +0 -54
  228. data/spec/models/create_images_res_spec.rb +0 -42
  229. data/spec/models/create_images_spec.rb +0 -54
  230. data/spec/models/create_pdf_a_res_spec.rb +0 -42
  231. data/spec/models/create_pdf_a_spec.rb +0 -54
  232. data/spec/models/custom_cms_config_spec.rb +0 -132
  233. data/spec/models/doc_action_spec.rb +0 -42
  234. data/spec/models/doc_log_spec.rb +0 -70
  235. data/spec/models/doc_metadata_spec.rb +0 -90
  236. data/spec/models/document_spec.rb +0 -90
  237. data/spec/models/drop_document_req_spec.rb +0 -118
  238. data/spec/models/drop_document_res_spec.rb +0 -84
  239. data/spec/models/execution_trigger_spec.rb +0 -54
  240. data/spec/models/extract_action_spec.rb +0 -48
  241. data/spec/models/extract_res_spec.rb +0 -42
  242. data/spec/models/extract_spec.rb +0 -54
  243. data/spec/models/get_document_list_res_spec.rb +0 -72
  244. data/spec/models/get_document_req_spec.rb +0 -78
  245. data/spec/models/get_document_res_spec.rb +0 -78
  246. data/spec/models/i_form_file_spec.rb +0 -72
  247. data/spec/models/image_action_spec.rb +0 -206
  248. data/spec/models/image_spec.rb +0 -88
  249. data/spec/models/job_config_res_spec.rb +0 -42
  250. data/spec/models/job_config_spec.rb +0 -102
  251. data/spec/models/job_spec.rb +0 -54
  252. data/spec/models/key_value_pair_string_object_spec.rb +0 -48
  253. data/spec/models/key_value_pair_string_string_spec.rb +0 -48
  254. data/spec/models/merge_action_spec.rb +0 -42
  255. data/spec/models/merge_res_spec.rb +0 -42
  256. data/spec/models/merge_spec.rb +0 -54
  257. data/spec/models/notification_spec.rb +0 -48
  258. data/spec/models/ocr_action_spec.rb +0 -70
  259. data/spec/models/optimize_action_spec.rb +0 -228
  260. data/spec/models/optimize_res_spec.rb +0 -48
  261. data/spec/models/optimize_spec.rb +0 -54
  262. data/spec/models/page_selection_spec.rb +0 -58
  263. data/spec/models/page_spec.rb +0 -78
  264. data/spec/models/pdf4me_action_spec.rb +0 -70
  265. data/spec/models/pdf4me_document_spec.rb +0 -202
  266. data/spec/models/pdf4me_exception_spec.rb +0 -42
  267. data/spec/models/pdf_a_action_spec.rb +0 -86
  268. data/spec/models/pdf_font_spec.rb +0 -48
  269. data/spec/models/pricing_spec.rb +0 -80
  270. data/spec/models/produce_documents_res_spec.rb +0 -42
  271. data/spec/models/produce_documents_spec.rb +0 -78
  272. data/spec/models/produce_output_spec.rb +0 -46
  273. data/spec/models/recognize_document_res_spec.rb +0 -48
  274. data/spec/models/recognize_document_spec.rb +0 -54
  275. data/spec/models/rectangle_spec.rb +0 -60
  276. data/spec/models/rgb_set_spec.rb +0 -54
  277. data/spec/models/rotate_spec.rb +0 -54
  278. data/spec/models/run_job_res_spec.rb +0 -54
  279. data/spec/models/signature_config_spec.rb +0 -36
  280. data/spec/models/split_action_spec.rb +0 -60
  281. data/spec/models/split_res_spec.rb +0 -42
  282. data/spec/models/split_spec.rb +0 -54
  283. data/spec/models/stamp_action_spec.rb +0 -142
  284. data/spec/models/stamp_res_spec.rb +0 -42
  285. data/spec/models/stamp_spec.rb +0 -54
  286. data/spec/models/storage_folder_spec.rb +0 -58
  287. data/spec/models/text_spec.rb +0 -104
  288. data/spec/models/transform_spec.rb +0 -72
  289. data/spec/models/translate_spec.rb +0 -48
  290. data/spec/models/user_fingerprint_spec.rb +0 -48
  291. data/spec/models/version_res_spec.rb +0 -42
@@ -1,135 +0,0 @@
1
- =begin
2
- #DmsApi
3
-
4
- #No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
5
-
6
- OpenAPI spec version: v1
7
-
8
- Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.3.0
10
-
11
- =end
12
-
13
- require "uri"
14
-
15
- module Pdf4me
16
- class SplitApi
17
- attr_accessor :api_client
18
-
19
- def initialize(api_client = ApiClient.default)
20
- @api_client = api_client
21
- end
22
-
23
- #
24
- #
25
- # @param [Hash] opts the optional parameters
26
- # @option opts [Split] :req
27
- # @return [SplitRes]
28
- def split(opts = {})
29
- data, _status_code, _headers = split_with_http_info(opts)
30
- return data
31
- end
32
-
33
- #
34
- #
35
- # @param [Hash] opts the optional parameters
36
- # @option opts [Split] :req
37
- # @return [Array<(SplitRes, Fixnum, Hash)>] SplitRes data, response status code and response headers
38
- def split_with_http_info(opts = {})
39
- if @api_client.config.debugging
40
- @api_client.config.logger.debug "Calling API: SplitApi.split ..."
41
- end
42
- # resource path
43
- local_var_path = "/Split/Split"
44
-
45
- # query parameters
46
- query_params = {}
47
-
48
- # header parameters
49
- header_params = {}
50
- # HTTP header 'Accept' (if needed)
51
- header_params['Accept'] = @api_client.select_header_accept(['text/plain', 'application/json', 'text/json', 'application/bson'])
52
- # HTTP header 'Content-Type'
53
- header_params['Content-Type'] = @api_client.select_header_content_type(['application/json-patch+json', 'application/json', 'text/json', 'application/*+json', 'application/bson'])
54
-
55
- # form parameters
56
- form_params = {}
57
-
58
- # http body (model)
59
- post_body = @api_client.object_to_http_body(opts[:'req'])
60
- auth_names = []
61
- data, status_code, headers = @api_client.call_api(:POST, local_var_path,
62
- :header_params => header_params,
63
- :query_params => query_params,
64
- :form_params => form_params,
65
- :body => post_body,
66
- :auth_names => auth_names,
67
- :return_type => 'SplitRes')
68
- if @api_client.config.debugging
69
- @api_client.config.logger.debug "API called: SplitApi#split\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
70
- end
71
- return data, status_code, headers
72
- end
73
-
74
- #
75
- #
76
- # @param page_nr
77
- # @param [Hash] opts the optional parameters
78
- # @option opts [String] :file
79
- # @return [SplitRes]
80
- def split_by_page_nr(page_nr, opts = {})
81
- data, _status_code, _headers = split_by_page_nr_with_http_info(page_nr, opts)
82
- return data
83
- end
84
-
85
- #
86
- #
87
- # @param page_nr
88
- # @param [Hash] opts the optional parameters
89
- # @option opts [String] :file
90
- # @return [Array<(SplitRes, Fixnum, Hash)>] SplitRes data, response status code and response headers
91
- def split_by_page_nr_with_http_info(page_nr, opts = {})
92
- if @api_client.config.debugging
93
- @api_client.config.logger.debug "Calling API: SplitApi.split_by_page_nr ..."
94
- end
95
- # verify the required parameter 'page_nr' is set
96
- if @api_client.config.client_side_validation && page_nr.nil?
97
- fail ArgumentError, "Missing the required parameter 'page_nr' when calling SplitApi.split_by_page_nr"
98
- end
99
- # resource path
100
- local_var_path = "/Split/SplitByPageNr"
101
-
102
- # query parameters
103
- query_params = {}
104
- # query_params[:'pageNr'] = page_nr
105
- # query_params[:'file'] = opts[:'file'] if !opts[:'file'].nil?
106
-
107
- # header parameters
108
- header_params = {}
109
- # HTTP header 'Accept' (if needed)
110
- header_params['Accept'] = @api_client.select_header_accept(['text/plain', 'application/json', 'text/json', 'application/bson'])
111
- header_params['Content-Type'] ='multipart/form-data'
112
-
113
- # form parameters
114
- form_params = {
115
- pageNr: page_nr,
116
- file: opts[:file]
117
- }
118
-
119
- # http body (model)
120
- post_body = nil
121
- auth_names = []
122
- data, status_code, headers = @api_client.call_api(:POST, local_var_path,
123
- :header_params => header_params,
124
- :query_params => query_params,
125
- :form_params => form_params,
126
- :body => post_body,
127
- :auth_names => auth_names,
128
- :return_type => 'SplitRes')
129
- if @api_client.config.debugging
130
- @api_client.config.logger.debug "API called: SplitApi#split_by_page_nr\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
131
- end
132
- return data, status_code, headers
133
- end
134
- end
135
- end
@@ -1,159 +0,0 @@
1
- =begin
2
- #DmsApi
3
-
4
- #No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
5
-
6
- OpenAPI spec version: v1
7
-
8
- Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.3.0
10
-
11
- =end
12
-
13
- require "uri"
14
-
15
- module Pdf4me
16
- class StampApi
17
- attr_accessor :api_client
18
-
19
- def initialize(api_client = ApiClient.default)
20
- @api_client = api_client
21
- end
22
-
23
- #
24
- #
25
- # @param [Hash] opts the optional parameters
26
- # @option opts [Stamp] :req
27
- # @return [StampRes]
28
- def stamp(opts = {})
29
- data, _status_code, _headers = stamp_with_http_info(opts)
30
- return data
31
- end
32
-
33
- #
34
- #
35
- # @param [Hash] opts the optional parameters
36
- # @option opts [Stamp] :req
37
- # @return [Array<(StampRes, Fixnum, Hash)>] StampRes data, response status code and response headers
38
- def stamp_with_http_info(opts = {})
39
- if @api_client.config.debugging
40
- @api_client.config.logger.debug "Calling API: StampApi.stamp ..."
41
- end
42
- # resource path
43
- local_var_path = "/Stamp/Stamp"
44
-
45
- # query parameters
46
- query_params = {}
47
-
48
- # header parameters
49
- header_params = {}
50
- # HTTP header 'Accept' (if needed)
51
- header_params['Accept'] = @api_client.select_header_accept(['text/plain', 'application/json', 'text/json', 'application/bson'])
52
- # HTTP header 'Content-Type'
53
- header_params['Content-Type'] = @api_client.select_header_content_type(['application/json-patch+json', 'application/json', 'text/json', 'application/*+json', 'application/bson'])
54
-
55
- # form parameters
56
- form_params = {}
57
-
58
- # http body (model)
59
- post_body = @api_client.object_to_http_body(opts[:'req'])
60
- auth_names = []
61
- data, status_code, headers = @api_client.call_api(:POST, local_var_path,
62
- :header_params => header_params,
63
- :query_params => query_params,
64
- :form_params => form_params,
65
- :body => post_body,
66
- :auth_names => auth_names,
67
- :return_type => 'StampRes')
68
- if @api_client.config.debugging
69
- @api_client.config.logger.debug "API called: StampApi#stamp\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
70
- end
71
- return data, status_code, headers
72
- end
73
-
74
- #
75
- #
76
- # @param align_x
77
- # @param align_y
78
- # @param [Hash] opts the optional parameters
79
- # @option opts [String] :text
80
- # @option opts [String] :pages
81
- # @option opts [String] :file
82
- # @return [File]
83
- def text_stamp(align_x, align_y, opts = {})
84
- data, _status_code, _headers = text_stamp_with_http_info(align_x, align_y, opts)
85
- return data
86
- end
87
-
88
- #
89
- #
90
- # @param align_x
91
- # @param align_y
92
- # @param [Hash] opts the optional parameters
93
- # @option opts [String] :text
94
- # @option opts [String] :pages
95
- # @option opts [String] :file
96
- # @return [Array<(File, Fixnum, Hash)>] File data, response status code and response headers
97
- def text_stamp_with_http_info(align_x, align_y, opts = {})
98
- if @api_client.config.debugging
99
- @api_client.config.logger.debug "Calling API: StampApi.text_stamp ..."
100
- end
101
- # verify the required parameter 'align_x' is set
102
- if @api_client.config.client_side_validation && align_x.nil?
103
- fail ArgumentError, "Missing the required parameter 'align_x' when calling StampApi.text_stamp"
104
- end
105
- # verify enum value
106
- if @api_client.config.client_side_validation && !['left', 'center', 'right'].include?(align_x)
107
- fail ArgumentError, "invalid value for 'align_x', must be one of left, center, right"
108
- end
109
- # verify the required parameter 'align_y' is set
110
- if @api_client.config.client_side_validation && align_y.nil?
111
- fail ArgumentError, "Missing the required parameter 'align_y' when calling StampApi.text_stamp"
112
- end
113
- # verify enum value
114
- if @api_client.config.client_side_validation && !['top', 'middle', 'bottom'].include?(align_y)
115
- fail ArgumentError, "invalid value for 'align_y', must be one of top, middle, bottom"
116
- end
117
- # resource path
118
- local_var_path = "/Stamp/TextStamp"
119
-
120
- # query parameters
121
- query_params = {}
122
- # query_params[:'alignX'] = align_x
123
- # query_params[:'alignY'] = align_y
124
- # query_params[:'text'] = opts[:'text'] if !opts[:'text'].nil?
125
- # query_params[:'pages'] = opts[:'pages'] if !opts[:'pages'].nil?
126
- # query_params[:'file'] = opts[:'file'] if !opts[:'file'].nil?
127
-
128
- # header parameters
129
- header_params = {}
130
- # HTTP header 'Accept' (if needed)
131
- header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream'])
132
- header_params['Content-Type'] ='multipart/form-data'
133
-
134
- # form parameters
135
- form_params = {
136
- alignX: align_x,
137
- alignY: align_y,
138
- text: opts[:text],
139
- pages: opts[:pages],
140
- file: opts[:file]
141
- }
142
-
143
- # http body (model)
144
- post_body = nil
145
- auth_names = []
146
- data, status_code, headers = @api_client.call_api(:POST, local_var_path,
147
- :header_params => header_params,
148
- :query_params => query_params,
149
- :form_params => form_params,
150
- :body => post_body,
151
- :auth_names => auth_names,
152
- :return_type => 'File')
153
- if @api_client.config.debugging
154
- @api_client.config.logger.debug "API called: StampApi#text_stamp\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
155
- end
156
- return data, status_code, headers
157
- end
158
- end
159
- end
@@ -1,380 +0,0 @@
1
- =begin
2
- #DmsApi
3
-
4
- #No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
5
-
6
- OpenAPI spec version: v1
7
-
8
- Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.3.0
10
-
11
- =end
12
-
13
- require 'date'
14
- require 'json'
15
- require 'logger'
16
- require 'tempfile'
17
- require 'typhoeus'
18
- require 'uri'
19
-
20
- module Pdf4me
21
- class ApiClient
22
- # The Configuration object holding settings to be used in the API client.
23
- attr_accessor :config
24
-
25
- # Defines the headers to be used in HTTP requests of all API calls by default.
26
- #
27
- # @return [Hash]
28
- attr_accessor :default_headers
29
-
30
- # Initializes the ApiClient
31
- # @option config [Configuration] Configuration for initializing the object, default to Configuration.default
32
- def initialize(config = Configuration.default)
33
- @config = config
34
- @user_agent = "Swagger-Codegen/#{VERSION}/ruby"
35
- @default_headers = {
36
- 'Content-Type' => "application/json",
37
- 'User-Agent' => @user_agent,
38
- 'Authorization' => "Bearer #{config.access_token}"
39
- }
40
- end
41
-
42
- def self.default
43
- @@default ||= ApiClient.new
44
- end
45
-
46
- # Call an API with given options.
47
- #
48
- # @return [Array<(Object, Fixnum, Hash)>] an array of 3 elements:
49
- # the data deserialized from response body (could be nil), response status code and response headers.
50
- def call_api(http_method, path, opts = {})
51
- request = build_request(http_method, path, opts)
52
- response = request.run
53
-
54
- if @config.debugging
55
- @config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
56
- end
57
-
58
- unless response.success?
59
- if response.timed_out?
60
- fail ApiError.new('Connection timed out')
61
- elsif response.code == 0
62
- # Errors from libcurl will be made visible here
63
- fail ApiError.new(:code => 0,
64
- :message => response.return_message)
65
- else
66
- fail ApiError.new(:code => response.code,
67
- :response_headers => response.headers,
68
- :response_body => response.body),
69
- response.status_message
70
- end
71
- end
72
-
73
- if opts[:return_type]
74
- data = deserialize(response, opts[:return_type])
75
- else
76
- data = nil
77
- end
78
- return data, response.code, response.headers
79
- end
80
-
81
- # Builds the HTTP request
82
- #
83
- # @param [String] http_method HTTP method/verb (e.g. POST)
84
- # @param [String] path URL path (e.g. /account/new)
85
- # @option opts [Hash] :header_params Header parameters
86
- # @option opts [Hash] :query_params Query parameters
87
- # @option opts [Hash] :form_params Query parameters
88
- # @option opts [Object] :body HTTP body (JSON/XML)
89
- # @return [Typhoeus::Request] A Typhoeus Request
90
- def build_request(http_method, path, opts = {})
91
- url = build_request_url(path)
92
- http_method = http_method.to_sym.downcase
93
-
94
- header_params = @default_headers.merge(opts[:header_params] || {})
95
- query_params = opts[:query_params] || {}
96
- form_params = opts[:form_params] || {}
97
-
98
- req_opts = {
99
- :method => http_method,
100
- :headers => header_params,
101
- :params => query_params,
102
- :params_encoding => @config.params_encoding,
103
- :timeout => @config.timeout,
104
- :ssl_verifypeer => true,
105
- :ssl_verifyhost => 2,
106
- :verbose => @config.debugging
107
- }
108
-
109
- if [:post, :patch, :put, :delete].include?(http_method)
110
- req_body = build_request_body(header_params, form_params, opts[:body])
111
- req_opts.update :body => req_body
112
- if @config.debugging
113
- @config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
114
- end
115
- end
116
-
117
- request = Typhoeus::Request.new(url, req_opts)
118
- download_file(request) if opts[:return_type] == 'File'
119
- request
120
- end
121
-
122
- # Check if the given MIME is a JSON MIME.
123
- # JSON MIME examples:
124
- # application/json
125
- # application/json; charset=UTF8
126
- # APPLICATION/JSON
127
- # */*
128
- # @param [String] mime MIME
129
- # @return [Boolean] True if the MIME is application/json
130
- def json_mime?(mime)
131
- (mime == "*/*") || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
132
- end
133
-
134
- # Deserialize the response to the given return type.
135
- #
136
- # @param [Response] response HTTP response
137
- # @param [String] return_type some examples: "User", "Array[User]", "Hash[String,Integer]"
138
- def deserialize(response, return_type)
139
- body = response.body
140
-
141
- # handle file downloading - return the File instance processed in request callbacks
142
- # note that response body is empty when the file is written in chunks in request on_body callback
143
- return @tempfile if return_type == 'File'
144
-
145
- return nil if body.nil? || body.empty?
146
-
147
- # return response body directly for String return type
148
- return body if return_type == 'String'
149
-
150
- # ensuring a default content type
151
- content_type = response.headers['Content-Type'] || 'application/json'
152
-
153
- fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
154
-
155
- begin
156
- data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
157
- rescue JSON::ParserError => e
158
- if %w(String Date DateTime).include?(return_type)
159
- data = body
160
- else
161
- raise e
162
- end
163
- end
164
-
165
- convert_to_type data, return_type
166
- end
167
-
168
- # Convert data to the given return type.
169
- # @param [Object] data Data to be converted
170
- # @param [String] return_type Return type
171
- # @return [Mixed] Data in a particular type
172
- def convert_to_type(data, return_type)
173
- return nil if data.nil?
174
- case return_type
175
- when 'String'
176
- data.to_s
177
- when 'Integer'
178
- data.to_i
179
- when 'Float'
180
- data.to_f
181
- when 'BOOLEAN'
182
- data == true
183
- when 'DateTime'
184
- # parse date time (expecting ISO 8601 format)
185
- DateTime.parse data
186
- when 'Date'
187
- # parse date time (expecting ISO 8601 format)
188
- Date.parse data
189
- when 'Object'
190
- # generic object (usually a Hash), return directly
191
- data
192
- when /\AArray<(.+)>\z/
193
- # e.g. Array<Pet>
194
- sub_type = $1
195
- data.map {|item| convert_to_type(item, sub_type) }
196
- when /\AHash\<String, (.+)\>\z/
197
- # e.g. Hash<String, Integer>
198
- sub_type = $1
199
- {}.tap do |hash|
200
- data.each {|k, v| hash[k] = convert_to_type(v, sub_type) }
201
- end
202
- else
203
- # models, e.g. Pet
204
- Pdf4me.const_get(return_type).new.tap do |model|
205
- model.build_from_hash data
206
- end
207
- end
208
- end
209
-
210
- # Save response body into a file in (the defined) temporary folder, using the filename
211
- # from the "Content-Disposition" header if provided, otherwise a random filename.
212
- # The response body is written to the file in chunks in order to handle files which
213
- # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
214
- # process can use.
215
- #
216
- # @see Configuration#temp_folder_path
217
- def download_file(request)
218
- tempfile = nil
219
- encoding = nil
220
- request.on_headers do |response|
221
- content_disposition = response.headers['Content-Disposition']
222
- if content_disposition and content_disposition =~ /filename=/i
223
- filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
224
- prefix = sanitize_filename(filename)
225
- else
226
- prefix = 'download-'
227
- end
228
- prefix = prefix + '-' unless prefix.end_with?('-')
229
- encoding = response.body.encoding
230
- tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
231
- @tempfile = tempfile
232
- end
233
- request.on_body do |chunk|
234
- chunk.force_encoding(encoding)
235
- tempfile.write(chunk)
236
- end
237
- request.on_complete do |response|
238
- tempfile.close
239
- @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
240
- "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
241
- "will be deleted automatically with GC. It's also recommended to delete the temp file "\
242
- "explicitly with `tempfile.delete`"
243
- end
244
- end
245
-
246
- # Sanitize filename by removing path.
247
- # e.g. ../../sun.gif becomes sun.gif
248
- #
249
- # @param [String] filename the filename to be sanitized
250
- # @return [String] the sanitized filename
251
- def sanitize_filename(filename)
252
- filename.gsub(/.*[\/\\]/, '')
253
- end
254
-
255
- def build_request_url(path)
256
- # Add leading and trailing slashes to path
257
- path = "/#{path}".gsub(/\/+/, '/')
258
- URI.encode(@config.base_url + path)
259
- end
260
-
261
- # Builds the HTTP request body
262
- #
263
- # @param [Hash] header_params Header parameters
264
- # @param [Hash] form_params Query parameters
265
- # @param [Object] body HTTP body (JSON/XML)
266
- # @return [String] HTTP body data in the form of string
267
- def build_request_body(header_params, form_params, body)
268
- # http form
269
- if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
270
- header_params['Content-Type'] == 'multipart/form-data'
271
- data = {}
272
- form_params.each do |key, value|
273
- case value
274
- when ::File, ::Array, nil
275
- # let typhoeus handle File, Array and nil parameters
276
- data[key] = value
277
- else
278
- data[key] = value.to_s
279
- end
280
- end
281
- elsif body
282
- data = body.is_a?(String) ? body : body.to_json
283
- else
284
- data = nil
285
- end
286
- data
287
- end
288
-
289
- # Update hearder and query params based on authentication settings.
290
- #
291
- # @param [Hash] header_params Header parameters
292
- # @param [Hash] query_params Query parameters
293
- # @param [String] auth_names Authentication scheme name
294
- def update_params_for_auth!(header_params, query_params, auth_names)
295
- Array(auth_names).each do |auth_name|
296
- auth_setting = @config.auth_settings[auth_name]
297
- next unless auth_setting
298
- case auth_setting[:in]
299
- when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
300
- when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
301
- else fail ArgumentError, 'Authentication token must be in `query` of `header`'
302
- end
303
- end
304
- end
305
-
306
- # Sets user agent in HTTP header
307
- #
308
- # @param [String] user_agent User agent (e.g. swagger-codegen/ruby/1.0.0)
309
- def user_agent=(user_agent)
310
- @user_agent = user_agent
311
- @default_headers['User-Agent'] = @user_agent
312
- end
313
-
314
- # Return Accept header based on an array of accepts provided.
315
- # @param [Array] accepts array for Accept
316
- # @return [String] the Accept header (e.g. application/json)
317
- def select_header_accept(accepts)
318
- return nil if accepts.nil? || accepts.empty?
319
- # use JSON when present, otherwise use all of the provided
320
- json_accept = accepts.find { |s| json_mime?(s) }
321
- return json_accept || accepts.join(',')
322
- end
323
-
324
- # Return Content-Type header based on an array of content types provided.
325
- # @param [Array] content_types array for Content-Type
326
- # @return [String] the Content-Type header (e.g. application/json)
327
- def select_header_content_type(content_types)
328
- # use application/json by default
329
- return 'application/json' if content_types.nil? || content_types.empty?
330
- # use JSON when present, otherwise use the first one
331
- json_content_type = content_types.find { |s| json_mime?(s) }
332
- return json_content_type || content_types.first
333
- end
334
-
335
- # Convert object (array, hash, object, etc) to JSON string.
336
- # @param [Object] model object to be converted into JSON string
337
- # @return [String] JSON string representation of the object
338
- def object_to_http_body(model)
339
- return model if model.nil? || model.is_a?(String)
340
- local_body = nil
341
- if model.is_a?(Array)
342
- local_body = model.map{|m| object_to_hash(m) }
343
- else
344
- local_body = object_to_hash(model)
345
- end
346
- local_body.to_json
347
- end
348
-
349
- # Convert object(non-array) to hash.
350
- # @param [Object] obj object to be converted into JSON string
351
- # @return [String] JSON string representation of the object
352
- def object_to_hash(obj)
353
- if obj.respond_to?(:to_hash)
354
- obj.to_hash
355
- else
356
- obj
357
- end
358
- end
359
-
360
- # Build parameter value according to the given collection format.
361
- # @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
362
- def build_collection_param(param, collection_format)
363
- case collection_format
364
- when :csv
365
- param.join(',')
366
- when :ssv
367
- param.join(' ')
368
- when :tsv
369
- param.join("\t")
370
- when :pipes
371
- param.join('|')
372
- when :multi
373
- # return the array directly as typhoeus will handle it as expected
374
- param
375
- else
376
- fail "unknown collection format: #{collection_format.inspect}"
377
- end
378
- end
379
- end
380
- end