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 +4 -4
- data/README.md +263 -145
- data/lib/docuseal/api.rb +93 -0
- data/lib/docuseal/http.rb +63 -37
- data/lib/docuseal/version.rb +1 -1
- data/lib/docuseal.rb +55 -32
- metadata +17 -44
- data/.rspec +0 -3
- data/.ruby-version +0 -1
- data/.standard.yml +0 -3
- data/.vscode/settings.json +0 -11
- data/CHANGELOG.md +0 -5
- data/CODE_OF_CONDUCT.md +0 -84
- data/CONTRIBUTING.md +0 -3
- data/Gemfile +0 -26
- data/Gemfile.lock +0 -153
- data/LICENSE.txt +0 -21
- data/Rakefile +0 -10
- data/lib/docuseal/client.rb +0 -25
- data/lib/docuseal/model.rb +0 -87
- data/lib/docuseal/submission.rb +0 -18
- data/lib/docuseal/submitter.rb +0 -9
- data/lib/docuseal/template.rb +0 -29
- data/sig/docuseal.rbs +0 -4
data/lib/docuseal/client.rb
DELETED
|
@@ -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
|
data/lib/docuseal/model.rb
DELETED
|
@@ -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
|
data/lib/docuseal/submission.rb
DELETED
|
@@ -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
|
data/lib/docuseal/submitter.rb
DELETED
data/lib/docuseal/template.rb
DELETED
|
@@ -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