boldsign 0.1.0 → 0.2.0

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: f0a4d128418d45a484979b044ce83a9e868ef1a142145962ec0580b0f34f4e20
4
- data.tar.gz: 4ee136cc02d3020b4beb1e70d614929de07f0f64e7965d8e0742a3e74cb0b893
3
+ metadata.gz: 32abdfa0ebbbb1803c298cc8055169d7330f7cc43a62b15838f9ae39594c146e
4
+ data.tar.gz: 4dd1f27abb3fb5209d5fe9a570db74336b6babc7300692f82cfa992544700263
5
5
  SHA512:
6
- metadata.gz: 486cb527ac17cef2ddcf9505a5a2bfe59b3736ee75d9e9b8778344c16a8b6c0e5795d17f5fa7d739fb87f6dc70e1e353fea13929e4303ab8abf1c08adf66e792
7
- data.tar.gz: 79edff344004bd59f868a44b6812c1c16bfa922823d0a16eaf28be54f970714b75c16d19be411e6ea175d37b4de8e7ab7bcc30b75da592ade64c49a7afbd9a12
6
+ metadata.gz: a92371ad102e288e429f7bcb3d2d535d64572dcf1208de7459bfe41dde8f3b52b72eb895af05fd0ee9dfe3dad9f38bae86bd3d678ebf03ac13c986df0b6312c0
7
+ data.tar.gz: 4fc0bf95e332d59d2a170225bf6d75173951d03594b2017fddc82d28cec38bccbe308bc826a5894fe5cb426b0880b5c2f1d962b195569852b68dacee90021816
data/CHANGELOG.md CHANGED
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.2.0] — 2026-05-22
11
+
12
+ ### Added
13
+ - `Boldsign::Resources::Document#send_document` now supports multipart file
14
+ uploads via a `files:` keyword. Pass an array of `{io:, filename:,
15
+ content_type:}` hashes (or `Faraday::Multipart::FilePart` instances) to
16
+ send PDFs (or other supported file types) for signature. When `files:` is
17
+ omitted the request is sent as JSON, preserving the prior behavior.
18
+
10
19
  ## [0.1.0] — 2026-05-22
11
20
 
12
21
  ### Added
@@ -4,11 +4,17 @@ module Boldsign
4
4
  # sending, listing, downloading, editing, reminding, authenticating, tagging,
5
5
  # and embedded signing flows.
6
6
  #
7
- # @example Send a document
7
+ # @example Send a document (JSON body)
8
+ # client.documents.send_document(
9
+ # title: "NDA",
10
+ # signers: [{ name: "Jane", emailAddress: "jane@example.com", signerOrder: 1 }]
11
+ # )
12
+ #
13
+ # @example Send a document with file uploads (multipart)
8
14
  # client.documents.send_document(
9
15
  # title: "NDA",
10
16
  # signers: [{ name: "Jane", emailAddress: "jane@example.com", signerOrder: 1 }],
11
- # files: [...]
17
+ # files: [{ io: StringIO.new(pdf_bytes), filename: "nda.pdf", content_type: "application/pdf" }]
12
18
  # )
13
19
  #
14
20
  # @see https://developers.boldsign.com/documents
@@ -18,7 +24,25 @@ module Boldsign
18
24
  def behalf_list(**params); @client.get("/v1/document/behalfList", params); end
19
25
  def properties(document_id); @client.get("/v1/document/properties", documentId: document_id); end
20
26
 
21
- def send_document(body); @client.post("/v1/document/send", body: body); end
27
+ # Send a document for signature.
28
+ #
29
+ # Pass `files:` to upload one or more PDFs (or other supported file types)
30
+ # via multipart/form-data. Without `files:`, the request is sent as JSON
31
+ # and BoldSign must already know the file content (e.g. via Base64 in the
32
+ # body or by referencing an existing template).
33
+ #
34
+ # @param files [Array<Hash>, nil] When present, each hash must include
35
+ # `:io` and `:filename` and may include `:content_type`. The request
36
+ # switches to multipart/form-data and remaining kwargs are serialized
37
+ # to multipart string parts (non-scalar values become JSON strings).
38
+ # @param body [Hash] Top-level BoldSign send-document fields
39
+ # (`title:`, `signers:`, `disableEmails:`, `metadata:`, etc.).
40
+ def send_document(files: nil, **body)
41
+ return @client.post("/v1/document/send", body: body) if files.nil?
42
+
43
+ @client.post("/v1/document/send", body: multipart_send_body(body, files), multipart: true)
44
+ end
45
+
22
46
  def draft_send(body); @client.post("/v1/document/draftSend", body: body); end
23
47
  def edit(document_id, body); @client.put("/v1/document/edit", body: body, params: { documentId: document_id }); end
24
48
  def cancel_editing(document_id); @client.post("/v1/document/cancelEditing", params: { documentId: document_id }); end
@@ -46,6 +70,35 @@ module Boldsign
46
70
  def add_authentication(document_id, body); @client.patch("/v1/document/addAuthentication", body: body, params: { documentId: document_id }); end
47
71
 
48
72
  def prefill_fields(document_id, body); @client.patch("/v1/document/prefillFields", body: body, params: { documentId: document_id }); end
73
+
74
+ private
75
+
76
+ def multipart_send_body(body, files)
77
+ parts = body.each_with_object({}) do |(key, value), acc|
78
+ next if value.nil?
79
+
80
+ acc[key.to_s] = scalar?(value) ? value.to_s : JSON.generate(value)
81
+ end
82
+ parts["Files"] = Array(files).map { |f| file_part(f) }
83
+ parts
84
+ end
85
+
86
+ def file_part(file)
87
+ return file if file.is_a?(Faraday::Multipart::FilePart)
88
+
89
+ unless file.is_a?(Hash)
90
+ raise ArgumentError, "files entries must be Hash with :io and :filename, or Faraday::Multipart::FilePart"
91
+ end
92
+
93
+ io = file[:io] || file["io"] or raise ArgumentError, "file part missing :io"
94
+ filename = file[:filename] || file["filename"] or raise ArgumentError, "file part missing :filename"
95
+ type = file[:content_type] || file["content_type"] || "application/octet-stream"
96
+ Faraday::Multipart::FilePart.new(io, type, filename)
97
+ end
98
+
99
+ def scalar?(value)
100
+ value.is_a?(String) || value.is_a?(Numeric) || value == true || value == false
101
+ end
49
102
  end
50
103
  end
51
104
  end
@@ -1,3 +1,3 @@
1
1
  module Boldsign
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boldsign
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Klein