documenso_rails 1.0.0 → 1.1.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: db8c3390cae6ac493da6327ba0f962a86c85cdee4af5548b60e6d831c6f15d5e
4
- data.tar.gz: 594c617bdae545b684dca60af4c9228370785a3dce624d94cae02b8da4f4731b
3
+ metadata.gz: 4064073835ecf8db29f8c3c90bcb06adab7ce21102e06994eebef668da962b48
4
+ data.tar.gz: ba9483055da6c71239805134dca2907e29906ac88dc04e8bfe56c805da834a7a
5
5
  SHA512:
6
- metadata.gz: 9af2e33708145691bd69d3bb62a44ddea61405d9cf27f70da4f798cac30bcdb739302560275fc28375983117f3dafe1be87a37c56143c9177dc907ab60869ee1
7
- data.tar.gz: a10015369aa8d5e9cde12fdd0d2479d3087f33301f68931ec8cb79592ef93107af5260371de7b4db992be501e1ad798ba69c4547078092973f4635259894d2b8
6
+ metadata.gz: ec75729f3e32e140f2cae04ad6357fd01c3faff0becf8c102c8002378842a8fb45293a5d807524ac00b8bc72beaee27f53f3b499411bbea29c08bf1519715c01
7
+ data.tar.gz: '058a96150f674e054a7225ebab60410b9426334a11e972a1f9fa37aebdc64a6d5af285118a7e2e18e9c1f2854ee51883fca7d9cebfd4951060049727d82e8666'
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jeremy Weiland
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -23,6 +23,10 @@ A mountable Rails Engine and API v2 client for integrating Documenso (Cloud or s
23
23
  end
24
24
  ```
25
25
 
26
+ ## License
27
+
28
+ Released under the [MIT License](LICENSE.txt).
29
+
26
30
  ## Running Tests
27
31
 
28
32
  ```bash
@@ -18,9 +18,8 @@ module DocumensoRails
18
18
  redirect_url: redirect_url
19
19
  )
20
20
  envelope_id = envelope.fetch("id")
21
-
22
- distribute_envelope(envelope_id)
23
- envelope_id
21
+ distribute_result = distribute_envelope(envelope_id)
22
+ build_send_result(envelope_id, distribute_result)
24
23
  end
25
24
 
26
25
  def create_and_send_from_template(template_id:, signers:, prefill_fields: {}, title: nil, redirect_url: nil)
@@ -32,9 +31,8 @@ module DocumensoRails
32
31
  redirect_url: redirect_url
33
32
  )
34
33
  envelope_id = envelope.fetch("id")
35
-
36
- distribute_envelope(envelope_id)
37
- envelope_id
34
+ distribute_result = distribute_envelope(envelope_id)
35
+ build_send_result(envelope_id, distribute_result)
38
36
  end
39
37
 
40
38
  def create_envelope(file_io:, filename:, title:, signers:, fields:, redirect_url: nil)
@@ -115,7 +113,8 @@ module DocumensoRails
115
113
  request["Content-Type"] = "application/json"
116
114
  request.body = { envelopeId: envelope_id }.to_json
117
115
 
118
- execute(uri, request)
116
+ body = execute(uri, request).body
117
+ body.present? ? JSON.parse(body) : {}
119
118
  end
120
119
 
121
120
  def download_signed_pdf(envelope_id)
@@ -128,6 +127,19 @@ module DocumensoRails
128
127
 
129
128
  private
130
129
 
130
+ def build_send_result(envelope_id, distribute_payload)
131
+ raw_recipients = Array(distribute_payload["recipients"] || distribute_payload[:recipients])
132
+ recipients = raw_recipients.map do |recipient|
133
+ {
134
+ email: recipient["email"] || recipient[:email],
135
+ name: recipient["name"] || recipient[:name],
136
+ signing_url: recipient["signingUrl"] || recipient[:signingUrl] || recipient["signing_url"]
137
+ }
138
+ end
139
+
140
+ SendResult.new(envelope_id: envelope_id, recipients: recipients, raw: distribute_payload)
141
+ end
142
+
131
143
  def execute(uri, request)
132
144
  response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
133
145
  http.open_timeout = 10
@@ -19,11 +19,11 @@ module DocumensoRails
19
19
  unsigned_attachment = public_send(DocumensoRails.configuration.unsigned_attachment_name)
20
20
  raise Error, "No unsigned PDF attached to #{self.class.name}##{id}" unless unsigned_attachment.attached?
21
21
 
22
- envelope_id = nil
22
+ result = nil
23
23
  target_redirect = redirect_url || DocumensoRails.configuration.redirect_url
24
24
 
25
25
  unsigned_attachment.open do |tempfile|
26
- envelope_id = DocumensoRails.client.create_and_send(
26
+ result = DocumensoRails.client.create_and_send(
27
27
  file_io: tempfile,
28
28
  filename: "#{id}.pdf",
29
29
  title: try(:title) || "Document ##{id}",
@@ -33,19 +33,14 @@ module DocumensoRails
33
33
  )
34
34
  end
35
35
 
36
- update!(
37
- documenso_envelope_id: envelope_id,
38
- signature_status: "sent",
39
- signature_sent_at: Time.current
40
- )
41
-
42
- envelope_id
36
+ apply_send_result!(result)
37
+ result
43
38
  end
44
39
 
45
40
  def send_from_template!(template_id:, signers:, prefill_fields: {}, title: nil, redirect_url: nil)
46
41
  target_redirect = redirect_url || DocumensoRails.configuration.redirect_url
47
42
 
48
- envelope_id = DocumensoRails.client.create_and_send_from_template(
43
+ result = DocumensoRails.client.create_and_send_from_template(
49
44
  template_id: template_id,
50
45
  signers: signers,
51
46
  prefill_fields: prefill_fields,
@@ -53,13 +48,20 @@ module DocumensoRails
53
48
  redirect_url: target_redirect
54
49
  )
55
50
 
56
- update!(
57
- documenso_envelope_id: envelope_id,
51
+ apply_send_result!(result)
52
+ result
53
+ end
54
+
55
+ private
56
+
57
+ def apply_send_result!(result)
58
+ attrs = {
59
+ documenso_envelope_id: result.envelope_id,
58
60
  signature_status: "sent",
59
61
  signature_sent_at: Time.current
60
- )
61
-
62
- envelope_id
62
+ }
63
+ attrs[:signing_url] = result.signing_url if has_attribute?(:signing_url)
64
+ update!(attrs)
63
65
  end
64
66
  end
65
67
  end
@@ -0,0 +1,15 @@
1
+ module DocumensoRails
2
+ class SendResult
3
+ attr_reader :envelope_id, :recipients, :raw
4
+
5
+ def initialize(envelope_id:, recipients: [], raw: {})
6
+ @envelope_id = envelope_id
7
+ @recipients = recipients
8
+ @raw = raw
9
+ end
10
+
11
+ def signing_url
12
+ recipients.find { |r| r[:signing_url].present? }&.dig(:signing_url)
13
+ end
14
+ end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module DocumensoRails
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.1"
3
3
  end
@@ -1,5 +1,6 @@
1
1
  require "documenso_rails/version"
2
2
  require "documenso_rails/configuration"
3
+ require "documenso_rails/send_result"
3
4
  require "documenso_rails/client"
4
5
  require "documenso_rails/model"
5
6
  require "documenso_rails/engine"
@@ -1,6 +1,7 @@
1
1
  class AddDocumensoFieldsTo<%= table_name.camelize %> < ActiveRecord::Migration<%= migration_version %>
2
2
  def change
3
3
  add_column :<%= table_name %>, :documenso_envelope_id, :string
4
+ add_column :<%= table_name %>, :signing_url, :string
4
5
  add_column :<%= table_name %>, :signature_status, :string, default: "draft", null: false
5
6
  add_column :<%= table_name %>, :signature_sent_at, :datetime
6
7
  add_column :<%= table_name %>, :signature_completed_at, :datetime
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: documenso_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Weiland
@@ -69,6 +69,7 @@ executables: []
69
69
  extensions: []
70
70
  extra_rdoc_files: []
71
71
  files:
72
+ - LICENSE.txt
72
73
  - README.md
73
74
  - Rakefile
74
75
  - app/controllers/documenso_rails/webhooks_controller.rb
@@ -79,11 +80,13 @@ files:
79
80
  - lib/documenso_rails/configuration.rb
80
81
  - lib/documenso_rails/engine.rb
81
82
  - lib/documenso_rails/model.rb
83
+ - lib/documenso_rails/send_result.rb
82
84
  - lib/documenso_rails/version.rb
83
85
  - lib/generators/documenso_rails/install_generator.rb
84
86
  - lib/generators/documenso_rails/templates/initializer.rb.tt
85
87
  - lib/generators/documenso_rails/templates/migration.rb.tt
86
- licenses: []
88
+ licenses:
89
+ - MIT
87
90
  metadata: {}
88
91
  rdoc_options: []
89
92
  require_paths: