docraptor 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a3c994ce2ece25936f437a269f823e57a27f3f3c
4
- data.tar.gz: ef3483cd3a4c6edb339776e7ce3a7519624ca203
2
+ SHA256:
3
+ metadata.gz: 1d6b898db0c2631364545a4da3f3a87ef8a249e7e1db737091e42a8095dc2ba4
4
+ data.tar.gz: 38cc4dd86eb0ae69502ee42c6bdd8cfc1715f8b9b425aa15c4a8089a3edaa609
5
5
  SHA512:
6
- metadata.gz: 6803e9c81c3ba4075d314d0d5f7553c61de81281452a1cb42577da971de35debea9561d358de2657879665bc8a98b1efa82cd333df3b9e8c8742617c91d9e2c1
7
- data.tar.gz: a45210b3f371f1bc13a37fa25f08135647e73a69c39eb58ba90ff81b488612a61fe130b2a0261689c7b87d3b3f70f28b57e26de8196557f508106fc774d06513
6
+ metadata.gz: 648892ceb32bc298f8fe5689873212106f8059d47b009164d69ccec923a8437e2209e9f7a4d30de0bda430a1a5bb260ab34133797a3a8d796b3b515119120c58
7
+ data.tar.gz: 1479aabfe153182ef3e0afc66b9c7e5105a2c7873cbe3fe640c6078411895dc30bbb17d58568d22db55a3383f542c2feb9ad140c4ac054de9c58f89244adeb6f
data/.gitignore CHANGED
@@ -29,6 +29,7 @@ Gemfile.lock
29
29
  .ruby-version
30
30
  .ruby-gemset
31
31
  .rvmrc
32
+ .rubocop.yml
32
33
 
33
34
  ## Ignore dumb OSX files
34
35
  .DS_Store
@@ -38,4 +39,7 @@ Thumbs.db
38
39
  swagger-codegen
39
40
 
40
41
  ## Ignore dumb emacs files
41
- *~
42
+ *~
43
+
44
+ ## Ignore files that contain special keys
45
+ .docraptor_key
@@ -1 +1 @@
1
- 2.2.3
1
+ 2.4.14
@@ -1 +1 @@
1
- v2.2.3
1
+ v2.4.14
@@ -1,3 +1,7 @@
1
+ ### 1.4.0 [July 31, 2020]
2
+ * add support for hosted documents
3
+ * upgrade to latest swagger 2.4.14
4
+
1
5
  ### 1.3.0 [November 21, 2017]
2
6
  * Added support for `prince_options[pdf_title]` and `ignore_console_messages` options
3
7
 
data/Gemfile CHANGED
@@ -3,5 +3,5 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  group :development, :test do
6
- gem 'rake', '~> 12.0.0'
6
+ gem 'rake', '~> 12.3.3'
7
7
  end
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- #
2
+
3
3
  =begin
4
- #DocRaptor v1
4
+ #DocRaptor
5
5
 
6
6
  #A native client library for the DocRaptor HTML to PDF/XLS service.
7
7
 
8
- OpenAPI spec version: 1.3.0
8
+ OpenAPI spec version: 1.4.0
9
9
 
10
10
  Generated by: https://github.com/swagger-api/swagger-codegen.git
11
- Swagger Codegen version: 2.2.3
11
+ Swagger Codegen version: 2.4.14
12
12
 
13
13
  =end
14
14
 
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
24
24
  s.homepage = "https://github.com/docraptor/docraptor-ruby"
25
25
  s.summary = "A wrapper for the DocRaptor HTML to PDF/XLS service."
26
26
  s.description = "A native client library for the DocRaptor HTML to PDF/XLS service."
27
- s.license = "MIT"
27
+ s.license = 'MIT'
28
28
  s.required_ruby_version = ">= 1.9"
29
29
 
30
30
  s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
@@ -44,7 +44,7 @@ Gem::Specification.new do |s|
44
44
  # </added> : if the above lines are missing in the gemspec, then
45
45
  # the matcher for autotest is probably broken
46
46
 
47
- s.files = `git ls-files`.split("\n").uniq.sort.select{|f| !f.empty? }
47
+ s.files = `git ls-files`.split("\n").uniq.sort.select { |f| !f.empty? }
48
48
  s.test_files = `git ls-files spec test`.split("\n")
49
49
  s.executables = []
50
50
  s.require_paths = ["lib"]
@@ -1,8 +1,8 @@
1
1
  swagger: '2.0'
2
2
 
3
3
  info: # https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#info-object
4
- version: "1.3.0"
5
- title: DocRaptor v1
4
+ version: "1.4.0"
5
+ title: DocRaptor
6
6
  description: "A native client library for the DocRaptor HTML to PDF/XLS service."
7
7
  termsOfService: "https://docraptor.com/tos"
8
8
  license:
@@ -55,14 +55,79 @@ paths:
55
55
  description: Unprocessable Entity
56
56
  500:
57
57
  description: Server Error
58
+
59
+ /hosted_docs:
60
+ post:
61
+ operationId: createHostedDoc
62
+ tags: [Doc]
63
+ description: >
64
+ Creates a hosted document synchronously.
65
+ security:
66
+ - basicAuth: []
67
+ parameters:
68
+ - name: doc
69
+ in: body
70
+ description: The document to be created.
71
+ required: true
72
+ schema:
73
+ $ref: '#/definitions/Doc'
74
+ responses:
75
+ 200:
76
+ description: Successful response
77
+ schema:
78
+ $ref: '#/definitions/DocStatus'
79
+ 400:
80
+ description: Bad Request
81
+ 401:
82
+ description: Unauthorized
83
+ 403:
84
+ description: Forbidden
85
+ 422:
86
+ description: Unprocessable Entity
87
+ 500:
88
+ description: Server Error
89
+
58
90
  /async_docs:
59
91
  post:
60
92
  operationId: createAsyncDoc
61
93
  tags: [Doc]
62
94
  description: >
63
95
  Creates a document asynchronously.
64
- You must use a callback url or the the returned status id and the status api to find out when it completes.
65
- Then use the download api to get the document.
96
+ You must use a callback url or the returned status id and the status API to find out when it completes.
97
+ Then use the download API to get the document.
98
+ security:
99
+ - basicAuth: []
100
+ parameters:
101
+ - name: doc
102
+ in: body
103
+ description: The document to be created.
104
+ required: true
105
+ schema:
106
+ $ref: '#/definitions/Doc'
107
+ responses:
108
+ 200:
109
+ description: Successful response
110
+ schema:
111
+ $ref: '#/definitions/AsyncDoc'
112
+ 400:
113
+ description: Bad Request
114
+ 401:
115
+ description: Unauthorized
116
+ 403:
117
+ description: Forbidden
118
+ 422:
119
+ description: Unprocessable Entity
120
+ 500:
121
+ description: Server Error
122
+
123
+ /hosted_async_docs:
124
+ post:
125
+ operationId: createHostedAsyncDoc
126
+ tags: [Doc]
127
+ description: >
128
+ Creates a hosted document asynchronously.
129
+ You must use a callback url or the returned status id and the status API to find out when it completes.
130
+ Then use the download API to get the document.
66
131
  security:
67
132
  - basicAuth: []
68
133
  parameters:
@@ -101,13 +166,12 @@ paths:
101
166
  in: path
102
167
  description: The status_id returned when creating an asynchronous document.
103
168
  required: true
104
- schema:
105
- $ref: '#/definitions/AsyncDocStatus'
169
+ type: string
106
170
  responses:
107
171
  200:
108
172
  description: Successful response
109
173
  schema:
110
- $ref: '#/definitions/AsyncDocStatus'
174
+ $ref: '#/definitions/DocStatus'
111
175
  401:
112
176
  description: Unauthorized
113
177
  403:
@@ -120,14 +184,15 @@ paths:
120
184
  operationId: getAsyncDoc
121
185
  tags: [Doc]
122
186
  description: >
123
- Downloads a document.
187
+ Downloads a finished document.
124
188
  security:
125
189
  - basicAuth: []
126
190
  parameters:
127
191
  - name: id
128
192
  in: path
129
- description: The download_id returned from status request or a callback.
193
+ description: The download_id returned from an async status request or callback.
130
194
  required: true
195
+ type: string
131
196
  responses:
132
197
  200:
133
198
  description: Successful response
@@ -141,6 +206,30 @@ paths:
141
206
  500:
142
207
  description: Server Error
143
208
 
209
+ /expire/{id}:
210
+ patch:
211
+ operationId: expire
212
+ tags: [Doc]
213
+ description: >
214
+ Expires a previously created hosted doc.
215
+ security:
216
+ - basicAuth: []
217
+ parameters:
218
+ - name: id
219
+ in: path
220
+ description: The download_id returned from status request or hosted document response.
221
+ required: true
222
+ type: string
223
+ responses:
224
+ 200:
225
+ description: Successful response
226
+ 401:
227
+ description: Unauthorized
228
+ 403:
229
+ description: Forbidden
230
+ 500:
231
+ description: Server Error
232
+
144
233
  definitions:
145
234
  Doc:
146
235
  type: object
@@ -149,9 +238,6 @@ definitions:
149
238
  - document_type
150
239
  - document_content
151
240
  properties:
152
- pipeline:
153
- type: string
154
- description: Specify a specific verison of the DocRaptor Pipeline to use.
155
241
  name:
156
242
  type: string
157
243
  description: A name for identifying your document.
@@ -176,13 +262,15 @@ definitions:
176
262
  type: boolean
177
263
  description: Enable test mode for this document. Test documents are not charged for but include a watermark.
178
264
  default: true
265
+ pipeline:
266
+ type: string
267
+ description: Specify a specific verison of the DocRaptor Pipeline to use.
179
268
  strict:
180
269
  type: string
181
270
  description: Force strict HTML validation.
182
- default: none
183
271
  enum:
184
272
  - none
185
- - true
273
+ - html
186
274
  ignore_resource_errors:
187
275
  type: boolean
188
276
  description: Failed loading of images/javascripts/stylesheets/etc. will not cause the rendering to stop.
@@ -209,8 +297,14 @@ definitions:
209
297
  type: string
210
298
  description: >
211
299
  A URL that will receive a POST request after successfully completing an asynchronous document.
212
- The POST data will include download_url and download_id similar to status api responses.
300
+ The POST data will include download_url and download_id similar to status API responses.
213
301
  WARNING: this only works on asynchronous documents.
302
+ hosted_download_limit:
303
+ type: integer
304
+ description: The number of times a hosted document can be downloaded. If no limit is specified, the document will be available for an unlimited number of downloads.
305
+ hosted_expires_at:
306
+ type: string
307
+ description: The date and time at which a hosted document will be removed and no longer available. Must be a properly formatted ISO 8601 datetime, like 1981-01-23T08:02:30-05:00.
214
308
  prince_options:
215
309
  $ref: '#/definitions/PrinceOptions'
216
310
 
@@ -340,9 +434,9 @@ definitions:
340
434
  properties:
341
435
  status_id:
342
436
  type: string
343
- description: The identifier used to get the status of the document using the status api.
437
+ description: The identifier used to get the status of the document using the status API.
344
438
 
345
- AsyncDocStatus:
439
+ DocStatus:
346
440
  type: object
347
441
  properties:
348
442
  status:
@@ -353,7 +447,7 @@ definitions:
353
447
  description: The URL where the document can be retrieved. This URL may only be used a few times.
354
448
  download_id:
355
449
  type: string
356
- description: The identifier for downloading the document with the download api.
450
+ description: The identifier for downloading the document with the download API.
357
451
  message:
358
452
  type: string
359
453
  description: Additional information.
@@ -0,0 +1,75 @@
1
+ # As a paid add-on, DocRaptor can provide long-term, publicly-accessible hosting for your documents.
2
+ # This allows you to provide a URL to your end users, third party tools like Zapier and Salesforce,
3
+ # or anyone else. We'll host the document on your behalf at a completely unbranded URL for as long
4
+ # as you want, or within the limits you specify.
5
+ #
6
+ # This example demonstrates creating a PDF using common options that DocRaptor will host for you.
7
+ # By default, hosted documents do not have limits on downloads or hosting time, though you may
8
+ # pass additional parameters to the document generation call to set your own limits. Learn more
9
+ # about the specific options in the hosted API documentation.
10
+ # https://docraptor.com/documentation/api#api_hosted
11
+ #
12
+ # The document is created asynchronously, which means DocRaptor will allow it to generate for up to
13
+ # 10 minutes. This is useful when creating many documents in parallel, or very large documents with
14
+ # lots of assets.
15
+ #
16
+ # DocRaptor supports many options for output customization, the full list is
17
+ # https://docraptor.com/documentation/api#api_general
18
+ #
19
+ # You can run this example with: ruby hosted_async.rb
20
+
21
+ require "bundler/setup"
22
+ Bundler.require
23
+ require "open-uri"
24
+
25
+ DocRaptor.configure do |dr|
26
+ dr.username = "YOUR_API_KEY_HERE" # you will need a real api key to test hosted documents
27
+ # dr.debugging = true
28
+ end
29
+
30
+ $docraptor = DocRaptor::DocApi.new
31
+
32
+ begin
33
+
34
+ # https://docraptor.com/documentation/api#api_general
35
+ create_response = $docraptor.create_hosted_async_doc(
36
+ test: true, # test documents are free but watermarked
37
+ document_content: "<html><body>Hello World</body></html>", # supply content directly
38
+ # document_url: "http://docraptor.com/examples/invoice.html", # or use a url
39
+ name: "hosted-ruby-async.pdf", # helps you find a document later
40
+ document_type: "pdf", # pdf or xls or xlsx
41
+ # javascript: true, # enable JavaScript processing
42
+ # prince_options: {
43
+ # media: "screen", # use screen styles instead of print styles
44
+ # baseurl: "http://hello.com", # pretend URL when using document_content
45
+ # },
46
+ )
47
+
48
+ loop do
49
+ status_response = $docraptor.get_async_doc_status(create_response.status_id)
50
+ puts "doc status: #{status_response.status}"
51
+ case status_response.status
52
+ when "completed"
53
+ puts "The hosted PDF is now available for public download at #{status_response.download_url}"
54
+ File.open("/tmp/docraptor-ruby.pdf", "wb") do |file|
55
+ open(status_response.download_url) do |uri|
56
+ file.write(uri.read)
57
+ end
58
+ end
59
+ puts "Wrote PDF to /tmp/docraptor-ruby.pdf"
60
+ break
61
+ when "failed"
62
+ puts "FAILED"
63
+ puts status_response
64
+ break
65
+ else
66
+ sleep 1
67
+ end
68
+ end
69
+
70
+ rescue DocRaptor::ApiError => error
71
+ puts "#{error.class}: #{error.message}"
72
+ puts error.code # HTTP response code
73
+ puts error.response_body # HTTP response body
74
+ puts error.backtrace[0..3].join("\n")
75
+ end
@@ -0,0 +1,62 @@
1
+ # As a paid add-on, DocRaptor can provide long-term, publicly-accessible hosting for your documents.
2
+ # This allows you to provide a URL to your end users, third party tools like Zapier and Salesforce,
3
+ # or anyone else. We'll host the document on your behalf at a completely unbranded URL for as long
4
+ # as you want, or within the limits you specify.
5
+ #
6
+ # This example demonstrates creating a PDF that DocRaptor will host for you using common options.
7
+ # By default, hosted documents do not have limits on downloads or hosting time, though you may
8
+ # pass additional parameters to the document generation call to set your own limits. Learn more
9
+ # about the specific options in the hosted API documentation.
10
+ # https://docraptor.com/documentation/api#api_hosted
11
+ #
12
+ # It is created synchronously, which means DocRaptor will allow it to generate for up to 60 seconds.
13
+ # Since this document will be hosted by DocRaptor the response from this request will return a JSON
14
+ # formatted object containing public URL where the document can be downloaded from.
15
+ #
16
+ # DocRaptor supports many options for output customization, the full list is
17
+ # https://docraptor.com/documentation/api#api_general
18
+ #
19
+ # You can run this example with: ruby hosted_sync.rb
20
+
21
+ require "bundler/setup"
22
+ Bundler.require
23
+ require "open-uri"
24
+
25
+ DocRaptor.configure do |dr|
26
+ dr.username = "YOUR_API_KEY_HERE" # you will need a real api key to test hosted documents
27
+ # dr.debugging = true
28
+ end
29
+
30
+ $docraptor = DocRaptor::DocApi.new
31
+
32
+ begin
33
+
34
+ # https://docraptor.com/documentation/api#api_general
35
+ create_response = $docraptor.create_hosted_doc(
36
+ test: true, # test documents are free but watermarked
37
+ document_content: "<html><body>Hello World</body></html>", # supply content directly
38
+ # document_url: "http://docraptor.com/examples/invoice.html", # or use a url
39
+ name: "docraptor-ruby.pdf", # help you find a document later
40
+ document_type: "pdf", # pdf or xls or xlsx
41
+ # javascript: true, # enable JavaScript processing
42
+ # prince_options: {
43
+ # media: "screen", # use screen styles instead of print styles
44
+ # baseurl: "http://hello.com", # pretend URL when using document_content
45
+ # },
46
+ )
47
+ puts "The hosted PDF is now available for public download at #{create_response.download_url}"
48
+
49
+ File.open("/tmp/docraptor-ruby.pdf", "wb") do |file|
50
+ open(create_response.download_url) do |uri|
51
+ file.write(uri.read)
52
+ end
53
+ end
54
+
55
+ puts "Wrote PDF to /tmp/docraptor-ruby.pdf"
56
+
57
+ rescue DocRaptor::ApiError => error
58
+ puts "#{error.class}: #{error.message}"
59
+ puts error.code # HTTP response code
60
+ puts error.response_body # HTTP response body
61
+ puts error.backtrace[0..3].join("\n")
62
+ end