docuseal 0.1.2 → 1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9fd66438a5ff8a1c6e320d4481a8d93c2103ade62303b6a9c9e5e7648efcb59c
4
- data.tar.gz: 58ef168c6f51af33c7fee7c68caf5f443f20e7000a1d21718adda2585fe9733e
3
+ metadata.gz: df6cd59df11dcce0c5c2197072bbe147fd5547452f9cd8f4843adc70acfd3ab2
4
+ data.tar.gz: 23fe9247d7d9b90c170fdcdd6305cd66c990644674d22cf54cbf437c8444777d
5
5
  SHA512:
6
- metadata.gz: 4bf980bedcea969ecbfd7a9878867126e4023b801127c0fcc33e9c776d0e46777d2fbc97e78254a45d422d1fb8a03fc3cd69b95700581aec57687a446aa160ab
7
- data.tar.gz: 42638043365a9821f0bbdc8458b3691e7fde74ec7b406f9f946f87b7c5332b5c6d9ab0a4d6a27ae16ed4ad09c2b184517b0f83aee044dde9cedb79982b00f41f
6
+ metadata.gz: b3ac3d6203f31ec7c954aee6eef92d0d07bbf6c2c4b56dfee31cb93f365c4c17289484d2efd832868051b099eeae0124ca343057da2ba95fc226437a36eec290
7
+ data.tar.gz: d0444f297d866a07be0c104058eda775f05af1c0eb80159b8759390240c33efe1cf4b22d4b815b6f68d1f2dd478390b8512c68efc3a51e98fc025496901f671e
data/README.md CHANGED
@@ -1,255 +1,373 @@
1
- # Docuseal API Connector
1
+ # DocuSeal Ruby
2
2
 
3
- <a href="https://codecov.io/github/moraki-finance/docuseal" >
4
- <img src="https://codecov.io/github/moraki-finance/docuseal/graph/badge.svg?token=SKTT14JJGV"/>
5
- </a>
3
+ The DocuSeal Ruby library provides seamless integration with the DocuSeal API, allowing developers to interact with DocuSeal's electronic signature and document management features directly within Ruby applications. This library is designed to simplify API interactions and provide tools for efficient implementation.
6
4
 
7
- [![Tests](https://github.com/moraki-finance/docuseal/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/moraki-finance/docuseal/actions/workflows/main.yml)
5
+ ## Documentation
8
6
 
9
- A lightweight API connector for docuseal. Docuseal API docs: https://www.docuseal.co/docs/api
10
-
11
- :warning: The extracted API objects don't do input parameters validations. It's a simple faraday wrapper that allows you to send as many inputs as you want. The docuseal API might fail when passing a wrong set of parameters.
7
+ Detailed documentation is available at [DocuSeal API Docs](https://www.docuseal.com/docs/api).
12
8
 
13
9
  ## Installation
14
10
 
15
- Install the gem and add to the application's Gemfile by executing:
11
+ To install the library, run:
16
12
 
17
- $ bundle add docuseal
13
+ ```sh
14
+ gem install docuseal
15
+ ```
18
16
 
19
- If bundler is not being used to manage dependencies, install the gem by executing:
17
+ ### Bundler
20
18
 
21
- $ gem install docuseal
19
+ Add the library to your Gemfile for projects using Bundler:
20
+
21
+ ```ruby
22
+ gem 'docuseal'
23
+ ```
22
24
 
23
25
  ## Usage
24
26
 
25
- ### Setup
27
+ ### Configuration
28
+
29
+ Set up the library with your DocuSeal API key based on your deployment. Retrieve your API key from the appropriate location:
26
30
 
27
- You'll need to set the Docuseal API key in the configuration.
31
+ #### Global Cloud
28
32
 
29
- ```rb
30
- Docuseal.configure do |config|
31
- config.api_key = "{DOCUSEAL_API_KEY}"
32
- end
33
+ API keys for the global cloud can be obtained from your [Global DocuSeal Console](https://console.docuseal.com/api).
34
+
35
+ ```ruby
36
+ require 'docuseal'
37
+
38
+ Docuseal.key = 'your_api_key_here'
33
39
  ```
34
40
 
35
- You can also set some other configurations like:
41
+ #### EU Cloud
42
+
43
+ API keys for the EU cloud can be obtained from your [EU DocuSeal Console](https://console.docuseal.eu/api).
44
+
45
+ ```ruby
46
+ require 'docuseal'
36
47
 
37
- ```rb
38
- Docuseal.configure do |config|
39
- config.api_key = "{DOCUSEAL_API_KEY}"
48
+ Docuseal.key = 'your_api_key_here'
49
+ Docuseal.url = 'https://api.docuseal.eu'
50
+ ```
51
+
52
+ #### On-Premise
40
53
 
41
- # Set the docuseal API request timeout, the default is 120 seconds
42
- config.request_timeout = 20
54
+ For on-premise installations, API keys can be retrieved from the API settings page of your deployed application, e.g., https://yourdocusealapp.com/settings/api.
43
55
 
44
- # Set extra headers that will get attached to every docuseal api request.
45
- # Useful for observability tools like Helicone: https://www.helicone.ai/
46
- config.global_headers = {
47
- "Helicone-Auth": "Bearer HELICONE_API_KEY"
48
- "helicone-stream-force-format" => "true",
49
- }
56
+ ```ruby
57
+ require 'docuseal'
50
58
 
51
- # Set the base_uri to use the docuseal EU servers if you're account was registered there.
52
- # The default is https://api.docuseal.co/
53
- config.base_uri = "https://api.docuseal.eu/"
54
- end
59
+ Docuseal.key = 'your_api_key_here'
60
+ Docuseal.url = 'https://yourdocusealapp.com/api'
55
61
  ```
56
62
 
57
- ### Submissions
63
+ ## API Methods
64
+
65
+ ### list_submissions(params)
58
66
 
59
- #### List
67
+ [Documentation](https://www.docuseal.com/docs/api?lang=ruby#list-all-submissions)
60
68
 
61
- Reference: https://www.docuseal.co/docs/api#list-all-submissions
69
+ Provides the ability to retrieve a list of available submissions.
62
70
 
63
- ```rb
64
- submissions = Docuseal::Submission.list
71
+
72
+ ```ruby
73
+ Docuseal.list_submissions(limit: 10)
65
74
  ```
66
75
 
67
- #### Find
76
+ ### get_submission(id)
77
+
78
+ [Documentation](https://www.docuseal.com/docs/api?lang=ruby#get-a-submission)
68
79
 
69
- Reference: https://www.docuseal.co/docs/api#get-a-submission
80
+ Provides the functionality to retrieve information about a submission.
70
81
 
71
- ```rb
72
- submission = Docuseal::Submission.find(1)
82
+
83
+ ```ruby
84
+ Docuseal.get_submission(1001)
73
85
  ```
74
86
 
75
- #### Create
87
+ ### create_submission(data)
88
+
89
+ [Documentation](https://www.docuseal.com/docs/api?lang=ruby#create-a-submission)
90
+
91
+ This API endpoint allows you to create signature requests (submissions) for a document template and send them to the specified submitters (signers).
92
+
93
+ **Related Guides:**<br>
94
+ [Send documents for signature via API](https://www.docuseal.com/guides/send-documents-for-signature-via-api)
95
+ [Pre-fill PDF document form fields with API](https://www.docuseal.com/guides/pre-fill-pdf-document-form-fields-with-api)
76
96
 
77
- Reference: https://www.docuseal.co/docs/api#create-a-submission
78
97
 
79
- ```rb
80
- submission = Docuseal::Submission.create(
98
+ ```ruby
99
+ Docuseal.create_submission({
81
100
  template_id: 1000001,
82
101
  send_email: true,
83
- submitters: [{role: 'First Party', email: 'john.doe@example.com'}]
84
- )
102
+ submitters: [
103
+ {
104
+ role: "First Party",
105
+ email: "john.doe@example.com"
106
+ }
107
+ ]
108
+ })
85
109
  ```
86
110
 
87
- #### Create From Email
111
+ ### create_submission_from_emails(data)
112
+
113
+ [Documentation](https://www.docuseal.com/docs/api?lang=ruby#create-submissions-from-emails)
114
+
115
+ This API endpoint allows you to create submissions for a document template and send them to the specified email addresses. This is a simplified version of the POST /submissions API to be used with Zapier or other automation tools.
88
116
 
89
- Reference: https://www.docuseal.co/docs/api#create-submissions-from-emails
90
117
 
91
- ```rb
92
- submission = Docuseal::Submission.create(
93
- from: :emails,
118
+ ```ruby
119
+ Docuseal.create_submission_from_emails({
94
120
  template_id: 1000001,
95
- emails: 'hi@docuseal.co, example@docuseal.co'
96
- )
121
+ emails: "hi@docuseal.com, example@docuseal.com"
122
+ })
97
123
  ```
98
124
 
99
- #### Archive
125
+ ### archive_submission(id)
100
126
 
101
- Reference: https://www.docuseal.co/docs/api#archive-a-submission
127
+ [Documentation](https://www.docuseal.com/docs/api?lang=ruby#archive-a-submission)
102
128
 
103
- ```rb
104
- submission = Docuseal::Submission.archive(1)
129
+ Allows you to archive a submission.
130
+
131
+
132
+ ```ruby
133
+ Docuseal.archive_submission(1001)
105
134
  ```
106
135
 
107
- ### Submitters
136
+ ### list_submitters(params)
108
137
 
109
- #### List
138
+ [Documentation](https://www.docuseal.com/docs/api?lang=ruby#list-all-submitters)
110
139
 
111
- Reference: https://www.docuseal.co/docs/api#list-all-submitters
140
+ Provides the ability to retrieve a list of submitters.
112
141
 
113
- ```rb
114
- submitters = Docuseal::Submitter.list
142
+
143
+ ```ruby
144
+ Docuseal.list_submitters(limit: 10)
115
145
  ```
116
146
 
117
- #### Find
147
+ ### get_submitter(id)
148
+
149
+ [Documentation](https://www.docuseal.com/docs/api?lang=ruby#get-a-submitter)
150
+
151
+ Provides the functionality to retrieve information about a submitter.
152
+
153
+
154
+ ```ruby
155
+ Docuseal.get_submitter(500001)
156
+ ```
157
+
158
+ ### update_submitter(id, data)
159
+
160
+ [Documentation](https://www.docuseal.com/docs/api?lang=ruby#update-a-submitter)
161
+
162
+ Provides allows you to update submitter details, pre-fill or update field values and re-send emails.
163
+
164
+ **Related Guides:**<br>
165
+ [Automatically sign documents via API](https://www.docuseal.com/guides/pre-fill-pdf-document-form-fields-with-api#automatically_sign_documents_via_api)
118
166
 
119
- Reference: https://www.docuseal.co/docs/api#get-a-submitter
120
167
 
121
- ```rb
122
- submitter = Docuseal::Submitter.find(1)
168
+ ```ruby
169
+ Docuseal.update_submitter(500001, {
170
+ email: "john.doe@example.com",
171
+ fields: [
172
+ {
173
+ name: "First Name",
174
+ default_value: "Acme"
175
+ }
176
+ ]
177
+ })
123
178
  ```
124
179
 
125
- #### Update
180
+ ### list_templates(params)
181
+
182
+ [Documentation](https://www.docuseal.com/docs/api?lang=ruby#list-all-templates)
183
+
184
+ Provides the ability to retrieve a list of available document templates.
126
185
 
127
- Reference: https://www.docuseal.co/docs/api#update-a-submitter
128
186
 
129
- ```rb
130
- submitter = Docuseal::Submitter.update(1,
131
- email: 'john.doe@example.com',
132
- fields: [{name: 'First Name', default_value: 'Acme'}]
133
- )
187
+ ```ruby
188
+ Docuseal.list_templates(limit: 10)
134
189
  ```
135
190
 
136
- ### Templates
191
+ ### get_template(id)
137
192
 
138
- #### List
193
+ [Documentation](https://www.docuseal.com/docs/api?lang=ruby#get-a-template)
139
194
 
140
- Reference: https://www.docuseal.co/docs/api#list-all-templates
195
+ Provides the functionality to retrieve information about a document template.
141
196
 
142
- ```rb
143
- templates = Docuseal::Template.list
197
+
198
+ ```ruby
199
+ Docuseal.get_template(1000001)
144
200
  ```
145
201
 
146
- #### Find
202
+ ### create_template_from_docx(data)
203
+
204
+ [Documentation](https://www.docuseal.com/docs/api?lang=ruby#create-a-template-from-word-docx)
205
+
206
+ Provides the functionality to create a fillable document template for existing Microsoft Word document. Use `{{Field Name;role=Signer1;type=date}}` text tags to define fillable fields in the document. See [https://www.docuseal.com/examples/fieldtags.docx](https://www.docuseal.com/examples/fieldtags.docx) for more text tag formats. Or specify the exact pixel coordinates of the document fields using `fields` param.
207
+
208
+ **Related Guides:**<br>
209
+ [Use embedded text field tags to create a fillable form](https://www.docuseal.com/guides/use-embedded-text-field-tags-in-the-pdf-to-create-a-fillable-form)
147
210
 
148
- Reference: https://www.docuseal.co/docs/api#get-a-template
149
211
 
150
- ```rb
151
- template = Docuseal::Template.find(1)
212
+ ```ruby
213
+ Docuseal.create_template_from_docx({
214
+ name: "Test DOCX",
215
+ documents: [
216
+ {
217
+ name: "string",
218
+ file: "base64"
219
+ }
220
+ ]
221
+ })
152
222
  ```
153
223
 
154
- #### Create From DOCX
224
+ ### create_template_from_html(data)
225
+
226
+ [Documentation](https://www.docuseal.com/docs/api?lang=ruby#create-a-template-from-html)
155
227
 
156
- Reference: https://www.docuseal.co/docs/api#create-a-template-from-word-docx
228
+ Provides the functionality to seamlessly generate a PDF document template by utilizing the provided HTML content while incorporating pre-defined fields.
157
229
 
158
- ```rb
159
- template = Docuseal::Template.create(
160
- from: :docx,
161
- name: 'Demo DOCX',
162
- documents: [{ name: 'Demo DOCX', file: 'base64' }]
163
- )
230
+ **Related Guides:**<br>
231
+ [Create PDF document fillable form with HTML](https://www.docuseal.com/guides/create-pdf-document-fillable-form-with-html-api)
232
+
233
+
234
+ ```ruby
235
+ Docuseal.create_template_from_html({
236
+ html: "<p>Lorem Ipsum is simply dummy text of the
237
+ <text-field
238
+ name=\"Industry\"
239
+ role=\"First Party\"
240
+ required=\"false\"
241
+ style=\"width: 80px; height: 16px; display: inline-block; margin-bottom: -4px\">
242
+ </text-field>
243
+ and typesetting industry</p>
244
+ ",
245
+ name: "Test Template"
246
+ })
164
247
  ```
165
248
 
166
- #### Create From HTML
249
+ ### merge_templates(data)
250
+
251
+ [Documentation](https://www.docuseal.com/docs/api?lang=ruby#merge-templates)
252
+
253
+ Allows you to merge multiple templates with documents and fields into a new combined template.
167
254
 
168
- Reference: https://www.docuseal.co/docs/api#create-a-template-from-html
169
255
 
170
- ```rb
171
- template = Docuseal::Template.create(
172
- from: :html,
173
- html: '<p>Lorem Ipsum is simply dummy text of the\n<text-field\n name="Industry"\n role="First Party"\n required="false"\n style="width: 80px; height: 16px; display: inline-block; margin-bottom: -4px">\n</text-field>\nand typesetting industry</p>\n',
174
- name: 'Test Template'
175
- )
256
+ ```ruby
257
+ Docuseal.merge_templates({
258
+ template_ids: [
259
+ 321,
260
+ 432
261
+ ],
262
+ name: "Merged Template"
263
+ })
176
264
  ```
177
265
 
178
- #### Create From PDF
266
+ ### create_template_from_pdf(data)
179
267
 
180
- Reference: https://www.docuseal.co/docs/api#create-a-template-from-existing-pdf
268
+ [Documentation](https://www.docuseal.com/docs/api?lang=ruby#create-a-template-from-existing-pdf)
181
269
 
182
- ```rb
183
- template = Docuseal::Template.create(
184
- from: :pdf,
185
- name: 'Test PDF',
270
+ Provides the functionality to create a fillable document template for existing PDF file. Use `{{Field Name;role=Signer1;type=date}}` text tags to define fillable fields in the document. See [https://www.docuseal.com/examples/fieldtags.pdf](https://www.docuseal.com/examples/fieldtags.pdf) for more text tag formats. Or specify the exact pixel coordinates of the document fields using `fields` param.
271
+
272
+ **Related Guides:**<br>
273
+ [Use embedded text field tags to create a fillable form](https://www.docuseal.com/guides/use-embedded-text-field-tags-in-the-pdf-to-create-a-fillable-form)
274
+
275
+
276
+ ```ruby
277
+ Docuseal.create_template_from_pdf({
278
+ name: "Test PDF",
186
279
  documents: [
187
280
  {
188
- name: 'string',
189
- file: 'base64',
190
- fields: [{name: 'string', areas: [{x: 0, y: 0, w: 0, h: 0, page: 0}]}]
281
+ name: "string",
282
+ file: "base64",
283
+ fields: [
284
+ {
285
+ name: "string",
286
+ areas: [
287
+ {
288
+ x: 0,
289
+ y: 0,
290
+ w: 0,
291
+ h: 0,
292
+ page: 1
293
+ }
294
+ ]
295
+ }
296
+ ]
191
297
  }
192
298
  ]
193
- )
299
+ })
194
300
  ```
195
301
 
196
- #### Clone
302
+ ### clone_template(id, data)
303
+
304
+ [Documentation](https://www.docuseal.com/docs/api?lang=ruby#clone-a-template)
305
+
306
+ Allows you to clone existing template into a new template.
197
307
 
198
- Reference: https://www.docuseal.co/docs/api#clone-a-template
199
308
 
200
- ```rb
201
- template = Docuseal::Template.clone(1,
202
- name: 'Clone of Test',
203
- )
309
+ ```ruby
310
+ Docuseal.clone_template(1000001, {
311
+ name: "Cloned Template"
312
+ })
204
313
  ```
205
314
 
206
- #### Update
315
+ ### update_template(id, data)
207
316
 
208
- Reference: https://www.docuseal.co/docs/api#update-a-template
317
+ [Documentation](https://www.docuseal.com/docs/api?lang=ruby#update-a-template)
209
318
 
210
- ```rb
211
- template = Docuseal::Template.update(1,
212
- name: 'New Document Name',
213
- folder_name: 'New Folder'
214
- )
319
+ Provides the functionality to move a document template to a different folder and update the name of the template.
320
+
321
+
322
+ ```ruby
323
+ Docuseal.update_template(1000001, {
324
+ name: "New Document Name",
325
+ folder_name: "New Folder"
326
+ })
215
327
  ```
216
328
 
217
- #### Update Documents
329
+ ### update_template_documents(id, data)
330
+
331
+ [Documentation](https://www.docuseal.com/docs/api?lang=ruby#update-template-documents)
332
+
333
+ Allows you to add, remove or replace documents in the template with provided PDF/DOCX file or HTML content.
218
334
 
219
- Reference: https://www.docuseal.co/docs/api#update-template-documents
220
335
 
221
- ```rb
222
- template = Docuseal::Template.update_documents(1,
223
- documents: [{file: 'base64'}]
224
- )
336
+ ```ruby
337
+ Docuseal.update_template_documents(1000001, {
338
+ documents: [
339
+ {
340
+ file: "string"
341
+ }
342
+ ]
343
+ })
225
344
  ```
226
345
 
227
- #### Archive
346
+ ### archive_template(id)
228
347
 
229
- Reference: https://www.docuseal.co/docs/api#archive-a-template
348
+ [Documentation](https://www.docuseal.com/docs/api?lang=ruby#archive-a-template)
230
349
 
231
- ```rb
232
- template = Docuseal::Template.archive(1)
350
+ Allows you to archive a document template.
351
+
352
+
353
+ ```ruby
354
+ Docuseal.archive_template(1000001)
233
355
  ```
234
356
 
235
- ## Development
357
+ ### Configuring Timeouts
236
358
 
237
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment:
359
+ Set timeouts to avoid hanging requests:
238
360
 
239
- ```bash
240
- $ DOCUSEAL_API_KEY={YOUR API KEY} DOCUSEAL_BASE_URI={YOUR BASE URI} bin/console
361
+ ```ruby
362
+ Docuseal.open_timeout = 70
363
+ Docuseal.read_timeout = 90
241
364
  ```
242
365
 
243
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
366
+ ## Support
244
367
 
245
- ## Contributing
368
+ For feature requests or bug reports, visit our [GitHub Issues page](https://github.com/docusealco/docuseal-ruby/issues).
246
369
 
247
- Bug reports and pull requests are welcome on GitHub at https://github.com/moraki-finance/docuseal. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/moraki-finance/docuseal/blob/main/CODE_OF_CONDUCT.md).
248
370
 
249
371
  ## License
250
372
 
251
373
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
252
-
253
- ## Code of Conduct
254
-
255
- Everyone interacting in the Docuseal project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/docuseal/blob/main/CODE_OF_CONDUCT.md).
@@ -0,0 +1,93 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Docuseal
4
+ class Api
5
+ Error = Class.new(StandardError)
6
+
7
+ attr_reader :http
8
+
9
+ def initialize(config)
10
+ @http = Http.new(config)
11
+ end
12
+
13
+ def list_templates(params = {})
14
+ http.get('/templates', params)
15
+ end
16
+
17
+ def get_template(id, params = {})
18
+ http.get("/templates/#{id}", params)
19
+ end
20
+
21
+ def create_template_from_docx(data)
22
+ http.post('/templates/docx', data)
23
+ end
24
+
25
+ def create_template_from_html(data)
26
+ http.post('/templates/html', data)
27
+ end
28
+
29
+ def create_template_from_pdf(data)
30
+ http.post('/templates/pdf', data)
31
+ end
32
+
33
+ def merge_templates(data)
34
+ http.post('/templates/merge', data)
35
+ end
36
+
37
+ def clone_template(id, data)
38
+ http.post("/templates/#{id}/clone", data)
39
+ end
40
+
41
+ def update_template(id, data)
42
+ http.put("/templates/#{id}", data)
43
+ end
44
+
45
+ def update_template_documents(id, data)
46
+ http.put("/templates/#{id}/documents", data)
47
+ end
48
+
49
+ def archive_template(id)
50
+ http.delete("/templates/#{id}")
51
+ end
52
+
53
+ def permanently_delete_template(id)
54
+ http.delete("/templates/#{id}", { permanently: true })
55
+ end
56
+
57
+ def list_submissions(params = {})
58
+ http.get('/submissions', params)
59
+ end
60
+
61
+ def get_submission(id, params = {})
62
+ http.get("/submissions/#{id}", params)
63
+ end
64
+
65
+ def create_submission(data)
66
+ http.post('/submissions/init', data)
67
+ end
68
+
69
+ def create_submission_from_emails(data)
70
+ http.post('/submissions/emails', data)
71
+ end
72
+
73
+ def archive_submission(id)
74
+ http.delete("/submissions/#{id}")
75
+ end
76
+
77
+ def permanently_delete_submission(id)
78
+ http.delete("/submissions/#{id}", { permanently: true })
79
+ end
80
+
81
+ def list_submitters(params = {})
82
+ http.get('/submitters', params)
83
+ end
84
+
85
+ def get_submitter(id, params = {})
86
+ http.get("/submitters/#{id}", params)
87
+ end
88
+
89
+ def update_submitter(id, data)
90
+ http.put("/submitters/#{id}", data)
91
+ end
92
+ end
93
+ end