docuseal 0.1.1 → 1.0.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: 71374b71ef11af519bb47bc0c6f0c67635726528db6ce40bcc93527d579ed96a
4
- data.tar.gz: 9310cb9a409b912f8df388d4afae5a60376321d4859d4fb0dc0893b2fed2296d
3
+ metadata.gz: a42565a2583a622dcfef3e7d2c145b4ea79a5b57972791c00b3c8d80f03c2bf4
4
+ data.tar.gz: 10bdcee2c2f97e43b746773836ac548646156e3f2825bf4bc563533cf9430d61
5
5
  SHA512:
6
- metadata.gz: 1a8180b8f8a14b1db76ef934c91a33e528093881c59d147111ef3e49ae38a90ff3e653ec0cdd7a964fcb6b78dc0878c00e39608e40069579de900d5d39552389
7
- data.tar.gz: 37b7f9d321ddd45530bb41b13b1d96446da0af20f55fa3aa7a18210e10c2b0dde57c7498207525c80d790452d58def384c0569219ebcf93d195b212c8b9b7c99
6
+ metadata.gz: 4969ccfcdca73d84d274ff3d31c79ed5beab209179efbe9c8a561477366b4503082497af7cf74e523fce008adc7c88fe553947c042714fb303959ab2473c5ff6
7
+ data.tar.gz: a3ca3f193ed03196c1eef26dcd2cc768aa73cd5f2ead6294656928d4333f2dea06f7c9b92a549c928a6980cd122fba7e08064f785a6c751f15dd80cf13cb50f3
data/README.md CHANGED
@@ -1,255 +1,103 @@
1
- # Docuseal API Connector
1
+ # DocuSeal Ruby Library
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:
16
-
17
- $ bundle add docuseal
18
-
19
- If bundler is not being used to manage dependencies, install the gem by executing:
20
-
21
- $ gem install docuseal
22
-
23
- ## Usage
24
-
25
- ### Setup
11
+ To install the library, run:
26
12
 
27
- You'll need to set the Docuseal API key in the configuration.
28
-
29
- ```rb
30
- Docuseal.configure do |config|
31
- config.api_key = "{DOCUSEAL_API_KEY}"
32
- end
13
+ ```sh
14
+ gem install docuseal
33
15
  ```
34
16
 
35
- You can also set some other configurations like:
36
-
37
- ```rb
38
- Docuseal.configure do |config|
39
- config.api_key = "{DOCUSEAL_API_KEY}"
40
-
41
- # Set the docuseal API request timeout, the default is 120 seconds
42
- config.request_timeout = 20
43
-
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
- }
17
+ If you want to build the gem from source:
50
18
 
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
19
+ ```sh
20
+ gem build docuseal.gemspec
55
21
  ```
56
22
 
57
- ### Submissions
23
+ ### Requirements
58
24
 
59
- #### List
25
+ - Ruby 2.5+.
60
26
 
61
- Reference: https://www.docuseal.co/docs/api#list-all-submissions
27
+ ### Bundler
62
28
 
63
- ```rb
64
- submissions = Docuseal::Submission.list
65
- ```
66
-
67
- #### Find
29
+ Add the library to your Gemfile for projects using Bundler:
68
30
 
69
- Reference: https://www.docuseal.co/docs/api#get-a-submission
31
+ ```ruby
32
+ source 'https://rubygems.org'
70
33
 
71
- ```rb
72
- submission = Docuseal::Submission.find(1)
34
+ gem 'docuseal'
73
35
  ```
74
36
 
75
- #### Create
76
-
77
- Reference: https://www.docuseal.co/docs/api#create-a-submission
78
-
79
- ```rb
80
- submission = Docuseal::Submission.create(
81
- template_id: 1000001,
82
- send_email: true,
83
- submitters: [{role: 'First Party', email: 'john.doe@example.com'}]
84
- )
85
- ```
86
-
87
- #### Create From Email
88
-
89
- Reference: https://www.docuseal.co/docs/api#create-submissions-from-emails
90
-
91
- ```rb
92
- submission = Docuseal::Submission.create(
93
- from: :emails,
94
- template_id: 1000001,
95
- emails: 'hi@docuseal.co, example@docuseal.co'
96
- )
97
- ```
98
-
99
- #### Archive
100
-
101
- Reference: https://www.docuseal.co/docs/api#archive-a-submission
102
-
103
- ```rb
104
- submission = Docuseal::Submission.archive(1)
105
- ```
106
-
107
- ### Submitters
108
-
109
- #### List
110
-
111
- Reference: https://www.docuseal.co/docs/api#list-all-submitters
112
-
113
- ```rb
114
- submitters = Docuseal::Submitter.list
115
- ```
116
-
117
- #### Find
118
-
119
- Reference: https://www.docuseal.co/docs/api#get-a-submitter
120
-
121
- ```rb
122
- submitter = Docuseal::Submitter.find(1)
123
- ```
124
-
125
- #### Update
126
-
127
- Reference: https://www.docuseal.co/docs/api#update-a-submitter
128
-
129
- ```rb
130
- submitter = Docuseal::Submitter.update(1,
131
- email: 'john.doe@example.com',
132
- fields: [{name: 'First Name', default_value: 'Acme'}]
133
- )
134
- ```
135
-
136
- ### Templates
137
-
138
- #### List
139
-
140
- Reference: https://www.docuseal.co/docs/api#list-all-templates
141
-
142
- ```rb
143
- templates = Docuseal::Template.list
144
- ```
37
+ ## Usage
145
38
 
146
- #### Find
39
+ ### Configuration
147
40
 
148
- Reference: https://www.docuseal.co/docs/api#get-a-template
41
+ Set up the library with your DocuSeal API key based on your deployment. Retrieve your API key from the appropriate location:
149
42
 
150
- ```rb
151
- template = Docuseal::Template.find(1)
152
- ```
43
+ #### Global Cloud
153
44
 
154
- #### Create From DOCX
45
+ API keys for the global cloud can be obtained from your [Global DocuSeal Console](https://console.docuseal.com/api).
155
46
 
156
- Reference: https://www.docuseal.co/docs/api#create-a-template-from-word-docx
47
+ ```ruby
48
+ require 'docuseal'
157
49
 
158
- ```rb
159
- template = Docuseal::Template.create(
160
- from: :docx,
161
- name: 'Demo DOCX',
162
- documents: [{ name: 'Demo DOCX', file: 'base64' }]
163
- )
50
+ Docuseal.key = 'your_api_key_here'
164
51
  ```
165
52
 
166
- #### Create From HTML
53
+ #### EU Cloud
167
54
 
168
- Reference: https://www.docuseal.co/docs/api#create-a-template-from-html
55
+ API keys for the EU cloud can be obtained from your [EU DocuSeal Console](https://console.docuseal.eu/api).
169
56
 
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
- )
176
- ```
57
+ ```ruby
58
+ require 'docuseal'
177
59
 
178
- #### Create From PDF
179
-
180
- Reference: https://www.docuseal.co/docs/api#create-a-template-from-existing-pdf
181
-
182
- ```rb
183
- template = Docuseal::Template.create(
184
- from: :pdf,
185
- name: 'Test PDF',
186
- documents: [
187
- {
188
- name: 'string',
189
- file: 'base64',
190
- fields: [{name: 'string', areas: [{x: 0, y: 0, w: 0, h: 0, page: 0}]}]
191
- }
192
- ]
193
- )
60
+ Docuseal.key = 'your_api_key_here'
61
+ Docuseal.url = 'https://api.docuseal.eu'
194
62
  ```
195
63
 
196
- #### Clone
197
-
198
- Reference: https://www.docuseal.co/docs/api#clone-a-template
64
+ #### On-Premise
199
65
 
200
- ```rb
201
- template = Docuseal::Template.clone(1,
202
- name: 'Clone of Test',
203
- )
204
- ```
66
+ 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.
205
67
 
206
- #### Update
68
+ ```ruby
69
+ require 'docuseal'
207
70
 
208
- Reference: https://www.docuseal.co/docs/api#update-a-template
209
-
210
- ```rb
211
- template = Docuseal::Template.update(1,
212
- name: 'New Document Name',
213
- folder_name: 'New Folder'
214
- )
71
+ Docuseal.key = 'your_api_key_here'
72
+ Docuseal.url = 'https://yourdocusealapp.com/api'
215
73
  ```
216
74
 
217
- #### Update Documents
218
-
219
- Reference: https://www.docuseal.co/docs/api#update-template-documents
220
-
221
- ```rb
222
- template = Docuseal::Template.update_documents(1,
223
- documents: [{file: 'base64'}]
224
- )
225
- ```
75
+ ### Basic Examples
226
76
 
227
- #### Archive
77
+ #### List Templates
228
78
 
229
- Reference: https://www.docuseal.co/docs/api#archive-a-template
79
+ ```ruby
80
+ # list templates
81
+ Docuseal.list_templates
230
82
 
231
- ```rb
232
- template = Docuseal::Template.archive(1)
83
+ # retrieve single template
84
+ Docuseal.get_template(1)
233
85
  ```
234
86
 
235
- ## Development
87
+ ### Configuring Timeouts
236
88
 
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:
89
+ Set timeouts to avoid hanging requests:
238
90
 
239
- ```bash
240
- $ DOCUSEAL_API_KEY={YOUR API KEY} DOCUSEAL_BASE_URI={YOUR BASE URI} bin/console
91
+ ```ruby
92
+ Docuseal.open_timeout = 70
93
+ Docuseal.read_timeout = 90
241
94
  ```
242
95
 
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).
96
+ ## Support
244
97
 
245
- ## Contributing
98
+ For feature requests or bug reports, visit our [GitHub Issues page](https://github.com/docusealco/docuseal-ruby/issues).
246
99
 
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
100
 
249
101
  ## License
250
102
 
251
103
  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)
18
+ http.get("/templates/#{id}")
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)
62
+ http.get("/submissions/#{id}")
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)
86
+ http.get("/submitters/#{id}")
87
+ end
88
+
89
+ def update_submitter(id, data)
90
+ http.put("/submitters/#{id}", data)
91
+ end
92
+ end
93
+ end
data/lib/docuseal/http.rb CHANGED
@@ -1,62 +1,84 @@
1
- module Docuseal
2
- module HTTP
3
- def get(path, headers: {}, **query)
4
- full_uri = uri(path:, query:)
1
+ # frozen_string_literal: true
5
2
 
6
- conn.get(full_uri) do |req|
7
- req.headers = all_headers(headers)
8
- end
9
- end
3
+ require 'json'
4
+ require 'cgi'
5
+ require 'uri'
6
+ require 'net/http'
10
7
 
11
- def post(path, data: {}, headers: {}, **query)
12
- full_uri = uri(path:, query:)
8
+ module Docuseal
9
+ class Http
10
+ BODY_METHODS = %i[post put].freeze
13
11
 
14
- conn.post(full_uri) do |req|
15
- req.body = data.to_json if data.any?
16
- req.headers = all_headers(headers)
17
- end
12
+ attr_reader :config
13
+
14
+ def initialize(config)
15
+ @config = config
18
16
  end
19
17
 
20
- def put(path, data: {}, headers: {}, **query)
21
- full_uri = uri(path:, query:)
18
+ def get(path, params = {})
19
+ send_request(:get, path, params)
20
+ end
22
21
 
23
- conn.put(full_uri) do |req|
24
- req.body = data.to_json if data.any?
25
- req.headers = all_headers(headers)
26
- end
22
+ def post(path, body = {})
23
+ send_request(:post, path, {}, body)
27
24
  end
28
25
 
29
- def delete(path, headers: {}, **query)
30
- full_uri = uri(path:, query:)
26
+ def put(path, body = {})
27
+ send_request(:put, path, {}, body)
28
+ end
31
29
 
32
- conn.delete(full_uri) do |req|
33
- req.headers = all_headers(headers)
34
- end
30
+ def delete(path, params = {})
31
+ send_request(:delete, path, params)
35
32
  end
36
33
 
37
34
  private
38
35
 
39
- def conn
40
- connection = Faraday.new do |f|
41
- f.options[:timeout] = request_timeout
42
- f.request :json
43
- f.response :json
44
- f.response :raise_error
45
- end
36
+ def send_request(method, path, params = {}, body = {})
37
+ uri = URI.parse(config[:url] + path)
46
38
 
47
- @faraday_middleware&.call(connection)
39
+ path = uri.path + to_query(params)
48
40
 
49
- connection
50
- end
41
+ resp =
42
+ if BODY_METHODS.include?(method)
43
+ conn(uri).public_send(method, path, body.to_json, headers)
44
+ else
45
+ conn(uri).public_send(method, path, headers)
46
+ end
51
47
 
52
- def uri(path:, query: {})
53
- File.join(base_uri, path) + "?#{URI.encode_www_form(query)}"
48
+ handle_response(resp)
54
49
  end
55
50
 
56
- def all_headers(request_headers = {})
51
+ def headers
57
52
  {
58
- "X-Auth-Token" => api_key
59
- }.merge(global_headers).merge(request_headers)
53
+ 'X-Auth-Token' => config[:key],
54
+ 'Content-Type' => 'application/json'
55
+ }
56
+ end
57
+
58
+ def to_query(params)
59
+ return '' if params.empty?
60
+
61
+ "?#{params.map { |key, value| "#{CGI.escape(key.to_s)}=#{CGI.escape(value.to_s)}" }.join('&')}"
62
+ end
63
+
64
+ def conn(uri)
65
+ conn = Net::HTTP.new(uri.host, uri.port)
66
+
67
+ conn.read_timeout = config[:read_timeout]
68
+ conn.open_timeout = config[:open_timeout]
69
+
70
+ conn.use_ssl = uri.scheme == 'https'
71
+
72
+ conn
73
+ end
74
+
75
+ def handle_response(response)
76
+ case response.code.to_i
77
+ when 200..299
78
+ JSON.parse(response.body)
79
+ else
80
+ raise Api::Error, "API Error #{response.code}: #{response.body}"
81
+ end
60
82
  end
61
83
  end
62
84
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Docuseal
4
- VERSION = "0.1.1"
4
+ VERSION = '1.0.0'
5
5
  end
data/lib/docuseal.rb CHANGED
@@ -1,45 +1,68 @@
1
- require "faraday"
2
-
3
- require_relative "docuseal/http"
4
- require_relative "docuseal/client"
5
- require_relative "docuseal/model"
6
- require_relative "docuseal/submission"
7
- require_relative "docuseal/submitter"
8
- require_relative "docuseal/template"
1
+ # frozen_string_literal: true
9
2
 
10
3
  module Docuseal
11
- class Error < StandardError; end
4
+ autoload :VERSION, 'docuseal/version'
5
+ autoload :Api, 'docuseal/api'
6
+ autoload :Http, 'docuseal/http'
12
7
 
13
- class ConfigurationError < Error; end
8
+ DEFAULT_CONFIG = {
9
+ url: 'https://api.docuseal.com',
10
+ open_timeout: 60,
11
+ read_timeout: 60
12
+ }.freeze
14
13
 
15
- class Configuration
16
- attr_accessor :request_timeout, :base_uri, :global_headers
17
- attr_writer :api_key
14
+ Configuration = Struct.new(:key,
15
+ :url,
16
+ :read_timeout,
17
+ :open_timeout, keyword_init: true)
18
18
 
19
- DEFAULT_BASE_URI = "https://api.docuseal.co/".freeze
20
- DEFAULT_REQUEST_TIMEOUT = 120
19
+ class << self
20
+ require 'forwardable'
21
21
 
22
- def initialize
23
- @api_key = ENV["DOCUSEAL_API_KEY"]
24
- @request_timeout = DEFAULT_REQUEST_TIMEOUT
25
- @base_uri = ENV.fetch("DOCUSEAL_BASE_URI", DEFAULT_BASE_URI)
26
- @global_headers = {}
27
- end
22
+ extend Forwardable
28
23
 
29
- def api_key
30
- @api_key || (raise ConfigurationError, "Docuseal api_key missing!")
24
+ def_delegators :api,
25
+ :list_templates,
26
+ :get_template,
27
+ :create_template_from_docx,
28
+ :create_template_from_html,
29
+ :create_template_from_pdf,
30
+ :merge_templates,
31
+ :clone_template,
32
+ :update_template,
33
+ :update_template_documents,
34
+ :archive_template,
35
+ :permanently_delete_template,
36
+ :list_submissions,
37
+ :get_submission,
38
+ :create_submission,
39
+ :create_submission_from_emails,
40
+ :archive_submission,
41
+ :permanently_delete_submission,
42
+ :list_submitters,
43
+ :get_submitter,
44
+ :update_submitter
45
+
46
+ def_delegators :config,
47
+ :key, :key=,
48
+ :url, :url=,
49
+ :open_timeout, :open_timeout=,
50
+ :read_timeout, :read_timeout=
51
+
52
+ def config
53
+ @config ||= Configuration.new(DEFAULT_CONFIG)
31
54
  end
32
- end
33
55
 
34
- class << self
35
- attr_writer :configuration
36
- end
56
+ def setup
57
+ config.tap do |instance|
58
+ yield(instance) if block_given?
59
+ end
60
+ end
37
61
 
38
- def self.configuration
39
- @configuration ||= Docuseal::Configuration.new
40
- end
62
+ def api(config = nil)
63
+ config = config ? DEFAULT_CONFIG.merge(config) : Docuseal.config
41
64
 
42
- def self.configure
43
- yield(configuration)
65
+ Docuseal::Api.new(config)
66
+ end
44
67
  end
45
68
  end
metadata CHANGED
@@ -1,79 +1,38 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docuseal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - Martin Mochetti
8
- autorequire:
7
+ - DocuSeal
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-02 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: faraday
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '1'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '1'
27
- - !ruby/object:Gem::Dependency
28
- name: faraday_middleware
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '1'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '1'
41
- description: A lightway, simple and non-official docuseal API connector.
11
+ date: 2024-12-24 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: DocuSeal is a document signing platform. This gem provides a Ruby interface
14
+ to the DocuSeal API.
42
15
  email:
43
- - martin.mochetti@gmail.com
16
+ - support@docuseal.com
44
17
  executables: []
45
18
  extensions: []
46
19
  extra_rdoc_files: []
47
20
  files:
48
- - ".rspec"
49
- - ".ruby-version"
50
- - ".standard.yml"
51
- - ".vscode/settings.json"
52
- - CHANGELOG.md
53
- - CODE_OF_CONDUCT.md
54
- - CONTRIBUTING.md
55
- - Gemfile
56
- - Gemfile.lock
57
- - LICENSE.txt
58
21
  - README.md
59
- - Rakefile
60
22
  - lib/docuseal.rb
61
- - lib/docuseal/client.rb
23
+ - lib/docuseal/api.rb
62
24
  - lib/docuseal/http.rb
63
- - lib/docuseal/model.rb
64
- - lib/docuseal/submission.rb
65
- - lib/docuseal/submitter.rb
66
- - lib/docuseal/template.rb
67
25
  - lib/docuseal/version.rb
68
- - sig/docuseal.rbs
69
- homepage: https://github.com/moraki-finance/docuseal
26
+ homepage: https://www.docuseal.com
70
27
  licenses:
71
28
  - MIT
72
29
  metadata:
73
- homepage_uri: https://github.com/moraki-finance/docuseal
74
- source_code_uri: https://github.com/moraki-finance/docuseal
75
- changelog_uri: https://github.com/moraki-finance/docuseal/blob/main/CHANGELOG.md
76
- post_install_message:
30
+ bug_tracker_uri: https://github.com/docusealco/docuseal-ruby/issues
31
+ homepage_uri: https://www.docuseal.com
32
+ source_code_uri: https://github.com/docusealco/docuseal-ruby
33
+ documentation_uri: https://www.docuseal.com/docs/api
34
+ rubygems_mfa_required: 'true'
35
+ post_install_message:
77
36
  rdoc_options: []
78
37
  require_paths:
79
38
  - lib
@@ -81,15 +40,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
40
  requirements:
82
41
  - - ">="
83
42
  - !ruby/object:Gem::Version
84
- version: 3.0.0
43
+ version: 2.5.0
85
44
  required_rubygems_version: !ruby/object:Gem::Requirement
86
45
  requirements:
87
46
  - - ">="
88
47
  - !ruby/object:Gem::Version
89
48
  version: '0'
90
49
  requirements: []
91
- rubygems_version: 3.5.3
92
- signing_key:
50
+ rubygems_version: 3.2.33
51
+ signing_key:
93
52
  specification_version: 4
94
- summary: A lightweight docuseal API connector.
53
+ summary: Ruby bindings for DocuSeal API
95
54
  test_files: []
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 3.3.0
data/.standard.yml DELETED
@@ -1,3 +0,0 @@
1
- # For available configuration options, see:
2
- # https://github.com/testdouble/standard
3
- ruby_version: 3.3.0
@@ -1,11 +0,0 @@
1
- {
2
- "rubyLsp.formatter": "none", // Use standard rbfmt instead
3
- "editor.formatOnSave": true,
4
- "editor.codeActionsOnSave": {
5
- "source.organizeImports": "explicit"
6
- },
7
- "[ruby]": {
8
- "editor.defaultFormatter": "testdouble.vscode-standard-ruby"
9
- },
10
- "standardRuby.autofix": true
11
- }
data/CHANGELOG.md DELETED
@@ -1,5 +0,0 @@
1
- ## [Unreleased]
2
-
3
- ## [0.1.0] - 2024-02-22
4
-
5
- - Initial release
data/CODE_OF_CONDUCT.md DELETED
@@ -1,84 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
-
7
- We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
-
9
- ## Our Standards
10
-
11
- Examples of behavior that contributes to a positive environment for our community include:
12
-
13
- * Demonstrating empathy and kindness toward other people
14
- * Being respectful of differing opinions, viewpoints, and experiences
15
- * Giving and gracefully accepting constructive feedback
16
- * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
- * Focusing on what is best not just for us as individuals, but for the overall community
18
-
19
- Examples of unacceptable behavior include:
20
-
21
- * The use of sexualized language or imagery, and sexual attention or
22
- advances of any kind
23
- * Trolling, insulting or derogatory comments, and personal or political attacks
24
- * Public or private harassment
25
- * Publishing others' private information, such as a physical or email
26
- address, without their explicit permission
27
- * Other conduct which could reasonably be considered inappropriate in a
28
- professional setting
29
-
30
- ## Enforcement Responsibilities
31
-
32
- Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
-
34
- Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
-
36
- ## Scope
37
-
38
- This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
-
40
- ## Enforcement
41
-
42
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at martin.mochetti@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
-
44
- All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
-
46
- ## Enforcement Guidelines
47
-
48
- Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
-
50
- ### 1. Correction
51
-
52
- **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
-
54
- **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
-
56
- ### 2. Warning
57
-
58
- **Community Impact**: A violation through a single incident or series of actions.
59
-
60
- **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
-
62
- ### 3. Temporary Ban
63
-
64
- **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
-
66
- **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
-
68
- ### 4. Permanent Ban
69
-
70
- **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
-
72
- **Consequence**: A permanent ban from any sort of public interaction within the community.
73
-
74
- ## Attribution
75
-
76
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
- available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
-
79
- Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
-
81
- [homepage]: https://www.contributor-covenant.org
82
-
83
- For answers to common questions about this code of conduct, see the FAQ at
84
- https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/CONTRIBUTING.md DELETED
@@ -1,3 +0,0 @@
1
- ## Contributing
2
-
3
- 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).
data/Gemfile DELETED
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- # Specify your gem's dependencies in docuseal.gemspec
6
- gemspec
7
-
8
- gem "rake", "~> 13.0"
9
-
10
- gem "rspec", "~> 3.0"
11
-
12
- gem "standard", "~> 1.3"
13
-
14
- group :development, :test do
15
- gem "webmock", "~> 3.22.0"
16
- gem "byebug", "~> 11.1"
17
- gem "pry", "~> 0.14.2"
18
- gem "pry-byebug", "~> 3.10"
19
- gem "pry-rescue", "~> 1.5"
20
- gem "pry-stack_explorer", "~> 0.6.1"
21
- end
22
-
23
- group :test do
24
- gem "simplecov"
25
- gem "simplecov-cobertura"
26
- end
data/Gemfile.lock DELETED
@@ -1,156 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- docuseal (0.1.1)
5
- faraday (>= 1)
6
- faraday_middleware (>= 1)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- addressable (2.8.6)
12
- public_suffix (>= 2.0.2, < 6.0)
13
- ast (2.4.2)
14
- bigdecimal (3.1.6)
15
- binding_of_caller (1.0.0)
16
- debug_inspector (>= 0.0.1)
17
- byebug (11.1.3)
18
- coderay (1.1.3)
19
- crack (1.0.0)
20
- bigdecimal
21
- rexml
22
- debug_inspector (1.2.0)
23
- diff-lcs (1.5.1)
24
- docile (1.4.0)
25
- faraday (1.10.3)
26
- faraday-em_http (~> 1.0)
27
- faraday-em_synchrony (~> 1.0)
28
- faraday-excon (~> 1.1)
29
- faraday-httpclient (~> 1.0)
30
- faraday-multipart (~> 1.0)
31
- faraday-net_http (~> 1.0)
32
- faraday-net_http_persistent (~> 1.0)
33
- faraday-patron (~> 1.0)
34
- faraday-rack (~> 1.0)
35
- faraday-retry (~> 1.0)
36
- ruby2_keywords (>= 0.0.4)
37
- faraday-em_http (1.0.0)
38
- faraday-em_synchrony (1.0.0)
39
- faraday-excon (1.1.0)
40
- faraday-httpclient (1.0.1)
41
- faraday-multipart (1.0.4)
42
- multipart-post (~> 2)
43
- faraday-net_http (1.0.1)
44
- faraday-net_http_persistent (1.2.0)
45
- faraday-patron (1.0.0)
46
- faraday-rack (1.0.0)
47
- faraday-retry (1.0.3)
48
- faraday_middleware (1.2.0)
49
- faraday (~> 1.0)
50
- hashdiff (1.1.0)
51
- interception (0.5)
52
- json (2.7.1)
53
- language_server-protocol (3.17.0.3)
54
- lint_roller (1.1.0)
55
- method_source (1.0.0)
56
- multipart-post (2.4.0)
57
- parallel (1.24.0)
58
- parser (3.3.0.5)
59
- ast (~> 2.4.1)
60
- racc
61
- pry (0.14.2)
62
- coderay (~> 1.1)
63
- method_source (~> 1.0)
64
- pry-byebug (3.10.1)
65
- byebug (~> 11.0)
66
- pry (>= 0.13, < 0.15)
67
- pry-rescue (1.6.0)
68
- interception (>= 0.5)
69
- pry (>= 0.12.0)
70
- pry-stack_explorer (0.6.1)
71
- binding_of_caller (~> 1.0)
72
- pry (~> 0.13)
73
- public_suffix (5.0.4)
74
- racc (1.7.3)
75
- rainbow (3.1.1)
76
- rake (13.1.0)
77
- regexp_parser (2.9.0)
78
- rexml (3.2.6)
79
- rspec (3.13.0)
80
- rspec-core (~> 3.13.0)
81
- rspec-expectations (~> 3.13.0)
82
- rspec-mocks (~> 3.13.0)
83
- rspec-core (3.13.0)
84
- rspec-support (~> 3.13.0)
85
- rspec-expectations (3.13.0)
86
- diff-lcs (>= 1.2.0, < 2.0)
87
- rspec-support (~> 3.13.0)
88
- rspec-mocks (3.13.0)
89
- diff-lcs (>= 1.2.0, < 2.0)
90
- rspec-support (~> 3.13.0)
91
- rspec-support (3.13.0)
92
- rubocop (1.60.2)
93
- json (~> 2.3)
94
- language_server-protocol (>= 3.17.0)
95
- parallel (~> 1.10)
96
- parser (>= 3.3.0.2)
97
- rainbow (>= 2.2.2, < 4.0)
98
- regexp_parser (>= 1.8, < 3.0)
99
- rexml (>= 3.2.5, < 4.0)
100
- rubocop-ast (>= 1.30.0, < 2.0)
101
- ruby-progressbar (~> 1.7)
102
- unicode-display_width (>= 2.4.0, < 3.0)
103
- rubocop-ast (1.30.0)
104
- parser (>= 3.2.1.0)
105
- rubocop-performance (1.20.2)
106
- rubocop (>= 1.48.1, < 2.0)
107
- rubocop-ast (>= 1.30.0, < 2.0)
108
- ruby-progressbar (1.13.0)
109
- ruby2_keywords (0.0.5)
110
- simplecov (0.22.0)
111
- docile (~> 1.1)
112
- simplecov-html (~> 0.11)
113
- simplecov_json_formatter (~> 0.1)
114
- simplecov-cobertura (2.1.0)
115
- rexml
116
- simplecov (~> 0.19)
117
- simplecov-html (0.12.3)
118
- simplecov_json_formatter (0.1.4)
119
- standard (1.34.0)
120
- language_server-protocol (~> 3.17.0.2)
121
- lint_roller (~> 1.0)
122
- rubocop (~> 1.60)
123
- standard-custom (~> 1.0.0)
124
- standard-performance (~> 1.3)
125
- standard-custom (1.0.2)
126
- lint_roller (~> 1.0)
127
- rubocop (~> 1.50)
128
- standard-performance (1.3.1)
129
- lint_roller (~> 1.1)
130
- rubocop-performance (~> 1.20.2)
131
- unicode-display_width (2.5.0)
132
- webmock (3.22.0)
133
- addressable (>= 2.8.0)
134
- crack (>= 0.3.2)
135
- hashdiff (>= 0.4.0, < 2.0.0)
136
-
137
- PLATFORMS
138
- ruby
139
- x86_64-darwin-23
140
-
141
- DEPENDENCIES
142
- byebug (~> 11.1)
143
- docuseal!
144
- pry (~> 0.14.2)
145
- pry-byebug (~> 3.10)
146
- pry-rescue (~> 1.5)
147
- pry-stack_explorer (~> 0.6.1)
148
- rake (~> 13.0)
149
- rspec (~> 3.0)
150
- simplecov
151
- simplecov-cobertura
152
- standard (~> 1.3)
153
- webmock (~> 3.22.0)
154
-
155
- BUNDLED WITH
156
- 2.5.5
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2024 Martin Mochetti
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
13
- all 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
21
- THE SOFTWARE.
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- require "standard/rake"
9
-
10
- task default: %i[spec standard]
@@ -1,25 +0,0 @@
1
- module Docuseal
2
- class Client
3
- include Docuseal::HTTP
4
-
5
- CONFIG_KEYS = %i[
6
- api_key request_timeout base_uri global_headers
7
- ].freeze
8
-
9
- attr_reader(*CONFIG_KEYS)
10
-
11
- def self.instance
12
- @instance ||= new
13
- end
14
-
15
- private
16
-
17
- def initialize
18
- CONFIG_KEYS.each do |key|
19
- # Set instance variables like api_type & access_token. Fall back to global config
20
- # if not present.
21
- instance_variable_set(:"@#{key}", Docuseal.configuration.send(key))
22
- end
23
- end
24
- end
25
- end
@@ -1,87 +0,0 @@
1
- module Docuseal
2
- class Model
3
- class << self
4
- def create(path: self.path, **attrs)
5
- raise Docuseal::Error, "Method not allowed" if not_allowed_to.include?(:create)
6
-
7
- response = Docuseal::Client.instance.post(path, data: attrs)
8
- body = response.body
9
-
10
- return body.map(&self) if body.is_a?(Array)
11
-
12
- new(body)
13
- end
14
-
15
- def find(id)
16
- raise Docuseal::Error, "Method not allowed" if not_allowed_to.include?(:find)
17
-
18
- response = Docuseal::Client.instance.get("#{path}/#{id}")
19
- new(response.body)
20
- end
21
-
22
- def update(id, **attrs)
23
- raise Docuseal::Error, "Method not allowed" if not_allowed_to.include?(:update)
24
-
25
- response = Docuseal::Client.instance.put("#{path}/#{id}", data: attrs)
26
- new(response.body)
27
- end
28
-
29
- def list(**)
30
- raise Docuseal::Error, "Method not allowed" if not_allowed_to.include?(:list)
31
-
32
- response = Docuseal::Client.instance.get(path, **)
33
- response.body["data"].map(&self)
34
- end
35
-
36
- def archive(id)
37
- raise Docuseal::Error, "Method not allowed" if not_allowed_to.include?(:archive)
38
-
39
- response = Docuseal::Client.instance.delete("#{path}/#{id}")
40
- new(response.body)
41
- end
42
-
43
- # Auxiliary methods
44
-
45
- def to_proc
46
- ->(attrs) { new(attrs) }
47
- end
48
-
49
- def skip_coertion_for(attrs = [])
50
- @skip_coertion_for ||= attrs
51
- end
52
-
53
- def not_allowed_to(attrs = [])
54
- @not_allowed_to ||= attrs
55
- end
56
- end
57
-
58
- def to_json
59
- @_raw.to_json
60
- end
61
-
62
- protected
63
-
64
- def initialize(attrs = {})
65
- @_raw = attrs
66
-
67
- attrs.each do |key, value|
68
- if self.class.skip_coertion_for.include?(key.to_sym)
69
- instance_variable_set(:"@#{key}", value)
70
- else
71
- coerced_value = if value.is_a?(Hash)
72
- Docuseal::Model.new(value)
73
- elsif value.is_a?(Array)
74
- value.map do |v|
75
- v.is_a?(Hash) ? Docuseal::Model.new(v) : v
76
- end
77
- else
78
- value
79
- end
80
- instance_variable_set(:"@#{key}", coerced_value)
81
- end
82
- end
83
-
84
- instance_variables.each { |iv| self.class.send(:attr_reader, iv.to_s[1..].to_sym) }
85
- end
86
- end
87
- end
@@ -1,18 +0,0 @@
1
- module Docuseal
2
- class Submission < Model
3
- skip_coertion_for [:values]
4
- not_allowed_to [:update]
5
-
6
- def self.path
7
- "/submissions"
8
- end
9
-
10
- def self.create(from: nil, **attrs)
11
- if from
12
- super(path: "#{path}/#{from}", **attrs)
13
- else
14
- super(**attrs)
15
- end
16
- end
17
- end
18
- end
@@ -1,9 +0,0 @@
1
- module Docuseal
2
- class Submitter < Model
3
- not_allowed_to %i[create archive]
4
-
5
- def self.path
6
- "/submitters"
7
- end
8
- end
9
- end
@@ -1,29 +0,0 @@
1
- module Docuseal
2
- class Template < Model
3
- def self.path
4
- "/templates"
5
- end
6
-
7
- # from: :html, :docx or :pdf
8
- #
9
- # https://www.docuseal.co/docs/api#create-a-template-from-html
10
- # https://www.docuseal.co/docs/api#create-a-template-from-word-docx
11
- # https://www.docuseal.co/docs/api#create-a-template-from-existing-pdf
12
- def self.create(from:, **attrs)
13
- super(path: "#{path}/#{from}", **attrs)
14
- end
15
-
16
- # https://www.docuseal.co/docs/api#update-template-documents
17
- def self.update_documents(id, documents: [])
18
- return if documents.empty?
19
- response = Docuseal::Client.instance.put("#{path}/#{id}/documents", data: {documents:})
20
- new(response.body)
21
- end
22
-
23
- # https://www.docuseal.co/docs/api#clone-a-template
24
- def self.clone(id, **attrs)
25
- response = Docuseal::Client.instance.post("#{path}/#{id}/clone", data: attrs)
26
- new(response.body)
27
- end
28
- end
29
- end
data/sig/docuseal.rbs DELETED
@@ -1,4 +0,0 @@
1
- module Docuseal
2
- VERSION: String
3
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
- end