rs4 0.1.4 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rs4.rb +2 -0
- data/lib/rs4/configuration.rb +1 -0
- data/lib/rs4/document.rb +28 -25
- data/lib/rs4/request.rb +13 -1
- data/lib/rs4/reusable_template.rb +27 -38
- data/lib/rs4/version.rb +1 -1
- data/lib/test/mock_request.rb +114 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4064ed9919a67b9d7b02c1b00452f2ba0ff1323ba8953a4a9826cfd000714dcc
|
4
|
+
data.tar.gz: 6907a7d5bad42fac43c1d9b372936cfe44c6d1ec8f2257573d3ed159e04908ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43d0f4b4ee7df70868c5c413967eeeca8047cf992fbebcc8fd286ad2c93f0590dec64df01b561927f4a7e2d7a682ecf515659a89c42cd207ed3f40f3e1c03950
|
7
|
+
data.tar.gz: a195784b8fb5f06e368fc8f89339d6b89fc282e95deaee5a126f2e42bca5157661f9e80398a291a301979a3ace429da7ce19d17ccb2e18020518da12b81acb53
|
data/lib/rs4.rb
CHANGED
data/lib/rs4/configuration.rb
CHANGED
data/lib/rs4/document.rb
CHANGED
@@ -9,6 +9,7 @@ module RS4
|
|
9
9
|
EXECUTED_STATE = :executed
|
10
10
|
|
11
11
|
attr_accessor :id
|
12
|
+
attr_accessor :original_guid
|
12
13
|
attr_accessor :current_signer_id
|
13
14
|
attr_accessor :name
|
14
15
|
attr_accessor :filename
|
@@ -82,47 +83,49 @@ module RS4
|
|
82
83
|
end
|
83
84
|
|
84
85
|
class << self
|
86
|
+
def get_archive_document(document_guid)
|
87
|
+
return unless document_guid.present?
|
88
|
+
|
89
|
+
path = "archived_documents_by_original_guid/#{document_guid}"
|
90
|
+
|
91
|
+
response = RS4.configuration.request_handler.execute(path, :get)
|
92
|
+
|
93
|
+
unless response.class == RS4::RequestError || response.nil?
|
94
|
+
archived_document = response.dig(:archived_document)
|
95
|
+
|
96
|
+
Document.new(archived_document) if archived_document
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
85
100
|
def get_document(document_guid)
|
86
|
-
return unless document_guid
|
101
|
+
return unless document_guid.present?
|
87
102
|
|
88
103
|
path = "documents/#{document_guid}"
|
89
104
|
|
90
|
-
response =
|
105
|
+
response = RS4.configuration.request_handler.execute(path, :get)
|
91
106
|
|
92
|
-
|
93
|
-
raw_document = JSON.parse(response.body, symbolize_names: true)
|
107
|
+
unless response.class == RS4::RequestError || response.nil? # .class == Net::HTTPOK
|
108
|
+
raw_document = response.dig(:document) # JSON.parse(response.body, symbolize_names: true)
|
94
109
|
|
95
|
-
Document.new(raw_document[:document])
|
96
|
-
|
97
|
-
Rails.logger.error("Unable to get document #{document_guid}")
|
98
|
-
RS4Api::RequestError.new(
|
99
|
-
response.code,
|
100
|
-
response.class,
|
101
|
-
JSON.parse(response.read_body)
|
102
|
-
)
|
110
|
+
# Document.new(raw_document[:document])
|
111
|
+
Document.new(raw_document) if raw_document
|
103
112
|
end
|
104
113
|
end
|
105
114
|
|
106
115
|
def get_documents
|
107
116
|
path = 'documents'
|
108
|
-
response =
|
117
|
+
response = RS4.configuration.request_handler.execute(path, :get)
|
109
118
|
|
110
|
-
|
119
|
+
unless response.class == RS4::RequestError || response.nil?
|
111
120
|
documents = []
|
112
121
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
documents << Document.new(raw_document[:document])
|
122
|
+
response.dig(:documents).each do |document_hash|
|
123
|
+
# document_hash = raw_document.pluck(:document)
|
124
|
+
documents << Document.new(document_hash)
|
117
125
|
end
|
118
|
-
else
|
119
|
-
Rails.logger.error('Unable to get documents')
|
120
|
-
RS4Api::RequestError.new(
|
121
|
-
response.code,
|
122
|
-
response.class,
|
123
|
-
JSON.parse(response.read_body)
|
124
|
-
)
|
125
126
|
end
|
127
|
+
|
128
|
+
documents
|
126
129
|
end
|
127
130
|
end
|
128
131
|
end
|
data/lib/rs4/request.rb
CHANGED
@@ -30,7 +30,19 @@ module RS4
|
|
30
30
|
# https://stackoverflow.com/questions/5370697/what-s-the-best-way-to-handle-exceptions-from-nethttp#answer-11802674
|
31
31
|
begin
|
32
32
|
retries ||= 0
|
33
|
-
http.request(request)
|
33
|
+
response = http.request(request)
|
34
|
+
|
35
|
+
result = if response.class == Net::HTTPOK
|
36
|
+
JSON.parse(response.body, symbolize_names: true)
|
37
|
+
else
|
38
|
+
RS4::RequestError.new(
|
39
|
+
response.code,
|
40
|
+
response.class,
|
41
|
+
JSON.parse(response.read_body)
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
result
|
34
46
|
rescue StandardError => e
|
35
47
|
Rails.logger.error(e)
|
36
48
|
retry if (retries += 1) < MAX_RETRIES
|
@@ -42,62 +42,51 @@ module RS4
|
|
42
42
|
@page_image_urls = options[:page_image_urls]
|
43
43
|
end
|
44
44
|
|
45
|
-
|
46
|
-
|
45
|
+
class << self
|
46
|
+
def get_reusable_template(template_guid)
|
47
|
+
return unless template_guid
|
47
48
|
|
48
|
-
|
49
|
+
path = "reusable_templates/#{template_guid}"
|
49
50
|
|
50
|
-
|
51
|
+
response = RS4.configuration.request_handler.execute(path, :get)
|
51
52
|
|
52
|
-
|
53
|
-
|
53
|
+
unless response.class == RS4::RequestError || response.nil?
|
54
|
+
# parsed_response = JSON.parse(response.read_body, symbolize_names: true)
|
54
55
|
|
55
|
-
|
56
|
+
template_hash = response.dig(:reusable_template)
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
RS4Api::RequestError.new(
|
60
|
-
response.code,
|
61
|
-
response.class,
|
62
|
-
JSON.parse(response.read_body)
|
63
|
-
)
|
58
|
+
RS4::ReusableTemplate.new(template_hash)
|
59
|
+
end
|
64
60
|
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def get_reusable_templates(options = {})
|
68
|
-
base_path = 'reusable_templates'
|
69
61
|
|
70
|
-
|
62
|
+
def get_reusable_templates(options = {})
|
63
|
+
base_path = 'reusable_templates'
|
71
64
|
|
72
|
-
|
65
|
+
query = CGI.unescape(options.to_query)
|
73
66
|
|
74
|
-
|
75
|
-
end
|
67
|
+
path = query.empty? ? base_path : "#{base_path}?#{query}"
|
76
68
|
|
77
|
-
|
78
|
-
|
69
|
+
RS4.configuration.request_handler.execute(path, :get)
|
70
|
+
end
|
79
71
|
|
80
|
-
|
72
|
+
def send_document(template_guid, options = {})
|
73
|
+
path = "reusable_templates/#{template_guid}/send_document"
|
81
74
|
|
82
|
-
|
75
|
+
body = options
|
83
76
|
|
84
|
-
|
77
|
+
body[:in_person] = true
|
85
78
|
|
86
|
-
|
79
|
+
response = RS4.configuration.request_handler.execute(path, :post, body)
|
87
80
|
|
88
|
-
|
89
|
-
parsed_response = JSON.parse(response.read_body, symbolize_names: true)
|
81
|
+
Rails.logger.info("RS4::ReusableTemplate::send_document:: #{response.inspect}")
|
90
82
|
|
91
|
-
|
83
|
+
unless response.class == RS4::RequestError || response.nil?
|
84
|
+
# parsed_response = JSON.parse(response.read_body, symbolize_names: true)
|
92
85
|
|
93
|
-
|
86
|
+
document_hash = response.dig(:document)
|
94
87
|
|
95
|
-
|
96
|
-
|
97
|
-
response.code,
|
98
|
-
response.class,
|
99
|
-
JSON.parse(response.read_body)
|
100
|
-
)
|
88
|
+
return RS4::Document.new(document_hash)
|
89
|
+
end
|
101
90
|
end
|
102
91
|
end
|
103
92
|
end
|
data/lib/rs4/version.rb
CHANGED
@@ -0,0 +1,114 @@
|
|
1
|
+
module RS4
|
2
|
+
class MockRequest
|
3
|
+
class << self
|
4
|
+
def execute(path, method = :get, _body = {})
|
5
|
+
mockument = {
|
6
|
+
id: SecureRandom.uuid,
|
7
|
+
current_signer_id: 0,
|
8
|
+
name: 'noname',
|
9
|
+
filename: 'noname.pdf',
|
10
|
+
executed_at: Date.today,
|
11
|
+
expired_at: Date.today + 1.day,
|
12
|
+
sent_at: Date.today,
|
13
|
+
state: 'draft',
|
14
|
+
thumbnail_url: 'google.com',
|
15
|
+
sender: 'sender',
|
16
|
+
recipients: [
|
17
|
+
{
|
18
|
+
role_name: 'Investor',
|
19
|
+
sign_url: 'www.google.com'
|
20
|
+
}
|
21
|
+
],
|
22
|
+
audits: nil,
|
23
|
+
page_image_urls: 'google.com',
|
24
|
+
signed_pdf_url: 'google.com/pdf.pdf',
|
25
|
+
tags: nil,
|
26
|
+
merge_field_values: nil,
|
27
|
+
embed_codes: nil,
|
28
|
+
in_person: true,
|
29
|
+
shared_with: nil,
|
30
|
+
identity_method: nil,
|
31
|
+
passcode_pin_enabled: false,
|
32
|
+
original_file_url: 'google.com'
|
33
|
+
}
|
34
|
+
|
35
|
+
if _body&.dig(:roles)&.any?
|
36
|
+
|
37
|
+
mockument[:recipients] = []
|
38
|
+
|
39
|
+
_body[:roles].each do |role|
|
40
|
+
mockument[:recipients] << {
|
41
|
+
role_name: role[:name],
|
42
|
+
sign_url: 'www.google.com'
|
43
|
+
}
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
mockplate = {
|
48
|
+
id: SecureRandom.uuid,
|
49
|
+
name: 'template',
|
50
|
+
creator: 'creator',
|
51
|
+
expires_in: Date.today + 1.day,
|
52
|
+
signer_sequencing: false,
|
53
|
+
shared_with: nil,
|
54
|
+
distribution_method: nil,
|
55
|
+
identity_method: nil,
|
56
|
+
kba: nil,
|
57
|
+
passcode: nil,
|
58
|
+
filename: 'template.pdf',
|
59
|
+
tags: nil,
|
60
|
+
user_id: 1,
|
61
|
+
roles: [],
|
62
|
+
merge_field_components: [],
|
63
|
+
created_at: Date.today,
|
64
|
+
updated_at: Date.today,
|
65
|
+
thumbnail_url: 'google.com/pdf.pdf',
|
66
|
+
page_image_urls: 'google.com/image'
|
67
|
+
}
|
68
|
+
|
69
|
+
case path
|
70
|
+
when %r{reusable_templates/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/send_document}
|
71
|
+
return {
|
72
|
+
document: mockument
|
73
|
+
}
|
74
|
+
when %r{reusable_templates/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}}
|
75
|
+
return {
|
76
|
+
reusable_template: mockplate
|
77
|
+
}
|
78
|
+
when /reusable_templates/
|
79
|
+
results = {
|
80
|
+
reusable_templates: []
|
81
|
+
}
|
82
|
+
|
83
|
+
i = 0
|
84
|
+
while i < 3
|
85
|
+
mockplate[:id] = SecureRandom.uuid
|
86
|
+
results[:reusable_templates] << mockplate
|
87
|
+
i += 1
|
88
|
+
end
|
89
|
+
|
90
|
+
return results
|
91
|
+
when %r{documents/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}}
|
92
|
+
return {
|
93
|
+
document: mockument
|
94
|
+
}
|
95
|
+
|
96
|
+
when /documents/
|
97
|
+
Rails.logger.info("#{method} documents")
|
98
|
+
|
99
|
+
results = {
|
100
|
+
documents: []
|
101
|
+
}
|
102
|
+
i = 0
|
103
|
+
while i < 3
|
104
|
+
results[:documents] << mockument
|
105
|
+
i += 1
|
106
|
+
end
|
107
|
+
|
108
|
+
return results
|
109
|
+
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rs4
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- donny
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Provides ruby access to CRUD operations for RightSignature documents
|
14
14
|
and reusable templates
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- lib/rs4/request_error.rb
|
35
35
|
- lib/rs4/reusable_template.rb
|
36
36
|
- lib/rs4/version.rb
|
37
|
+
- lib/test/mock_request.rb
|
37
38
|
- license.txt
|
38
39
|
- rs4.gemspec
|
39
40
|
homepage: https://github.com/equitymultiple/rs4
|