rs4 0.2.3 → 0.2.10
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 +1 -0
- data/lib/rs4/configuration.rb +15 -0
- data/lib/rs4/configuration_error.rb +15 -0
- data/lib/rs4/document.rb +33 -3
- data/lib/rs4/error.rb +12 -0
- data/lib/rs4/request.rb +5 -0
- data/lib/rs4/request_error.rb +5 -3
- data/lib/rs4/reusable_template.rb +38 -4
- data/lib/rs4/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67df5afff0e76629545e1cc0d5fd9721395812a6b5c72c7adb6d3f9bc03e149b
|
4
|
+
data.tar.gz: '08dcb4aa33cfc70fbdd359cbe1fcd42e16ba0adf78a944b2ce36d37eb476d839'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '062720059d3fcd5e026e0b4e130121eacec1de5b1fe07d3432218902bf4303cadf67ef4c2037cef6a3454c0ee60691dac129b7e6e9a48bb5a92595095c51d72e'
|
7
|
+
data.tar.gz: 13a9dbcf8616d98dc76af53048b71ae60b136976084a194d16b4fcd03f759705945d3c1cca2ae429fb0b1811a255b3775b6c6ec962f032179f698e2b158dde70
|
data/lib/rs4.rb
CHANGED
data/lib/rs4/configuration.rb
CHANGED
@@ -14,5 +14,20 @@ module RS4
|
|
14
14
|
attr_accessor :request_handler
|
15
15
|
attr_accessor :private_api_key
|
16
16
|
attr_accessor :api_host
|
17
|
+
attr_accessor :errors
|
18
|
+
|
19
|
+
def valid?
|
20
|
+
@errors = []
|
21
|
+
|
22
|
+
@errors << '`private_api_key` not set' unless private_api_key.present?
|
23
|
+
@errors << '`api_host` not set' unless api_host.present?
|
24
|
+
|
25
|
+
if @errors.any?
|
26
|
+
Rails.logger.error("RS4 Configuration Invalid: #{@errors.join(',')}")
|
27
|
+
return false
|
28
|
+
else
|
29
|
+
return true
|
30
|
+
end
|
31
|
+
end
|
17
32
|
end
|
18
33
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rs4/error.rb'
|
2
|
+
|
3
|
+
module RS4
|
4
|
+
# Error should be returned when the module has been
|
5
|
+
# improperly configured
|
6
|
+
class ConfigurationError < Error
|
7
|
+
attr_accessor :error_fields
|
8
|
+
|
9
|
+
def initialize(error_fields = [], message)
|
10
|
+
super(message)
|
11
|
+
|
12
|
+
@error_fields = error_fields
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/rs4/document.rb
CHANGED
@@ -90,7 +90,7 @@ module RS4
|
|
90
90
|
|
91
91
|
response = RS4.configuration.request_handler.execute(path, :get)
|
92
92
|
|
93
|
-
unless response.
|
93
|
+
unless response.is_a?(RS4::Error) || response.nil?
|
94
94
|
archived_document = response.dig(:archived_document)
|
95
95
|
|
96
96
|
Document.new(archived_document) if archived_document
|
@@ -104,7 +104,37 @@ module RS4
|
|
104
104
|
|
105
105
|
response = RS4.configuration.request_handler.execute(path, :get)
|
106
106
|
|
107
|
-
unless response.
|
107
|
+
unless response.is_a?(RS4::Error) || response.nil? # .class == Net::HTTPOK
|
108
|
+
raw_document = response.dig(:document) # JSON.parse(response.body, symbolize_names: true)
|
109
|
+
|
110
|
+
# Document.new(raw_document[:document])
|
111
|
+
Document.new(raw_document) if raw_document
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def get_force_complete(document_guid)
|
116
|
+
return unless document_guid.present?
|
117
|
+
|
118
|
+
path = "documents/#{document_guid}/force_complete"
|
119
|
+
|
120
|
+
response = RS4.configuration.request_handler.execute(path, :post)
|
121
|
+
|
122
|
+
unless response.is_a?(RS4::Error) || response.nil? # .class == Net::HTTPOK
|
123
|
+
raw_document = response.dig(:document) # JSON.parse(response.body, symbolize_names: true)
|
124
|
+
|
125
|
+
# Document.new(raw_document[:document])
|
126
|
+
Document.new(raw_document) if raw_document
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def get_force_complete(document_guid)
|
131
|
+
return unless document_guid.present?
|
132
|
+
|
133
|
+
path = "documents/#{document_guid}/force_complete"
|
134
|
+
|
135
|
+
response = RS4.configuration.request_handler.execute(path, :get)
|
136
|
+
|
137
|
+
unless response.is_a?(RS4::Error) || response.nil? # .class == Net::HTTPOK
|
108
138
|
raw_document = response.dig(:document) # JSON.parse(response.body, symbolize_names: true)
|
109
139
|
|
110
140
|
# Document.new(raw_document[:document])
|
@@ -116,7 +146,7 @@ module RS4
|
|
116
146
|
path = 'documents'
|
117
147
|
response = RS4.configuration.request_handler.execute(path, :get)
|
118
148
|
|
119
|
-
unless response.
|
149
|
+
unless response.is_a?(RS4::Error) || response.nil?
|
120
150
|
documents = []
|
121
151
|
|
122
152
|
response.dig(:documents).each do |document_hash|
|
data/lib/rs4/error.rb
ADDED
data/lib/rs4/request.rb
CHANGED
@@ -7,6 +7,11 @@ module RS4
|
|
7
7
|
|
8
8
|
class << self
|
9
9
|
def execute(path, method = :get, body = {})
|
10
|
+
# Check required keys exist before continuing
|
11
|
+
unless RS4.configuration.valid?
|
12
|
+
return RS4::ConfigurationError.new(RS4.configuration.errors, 'Invalid Configuration')
|
13
|
+
end
|
14
|
+
|
10
15
|
url = URI(RS4.configuration.api_host + '/public/v1/' + path)
|
11
16
|
|
12
17
|
http = Net::HTTP.new(url.host, url.port)
|
data/lib/rs4/request_error.rb
CHANGED
@@ -1,18 +1,20 @@
|
|
1
|
+
require 'rs4/error.rb'
|
2
|
+
|
1
3
|
module RS4
|
2
4
|
# The standard error returned when a request to the RS4
|
3
5
|
# API fails
|
4
6
|
# code - the NetHTTP response code as a number (eg - 200)
|
5
7
|
# error_class - which NetHTTP class was returned by the response
|
6
8
|
# message - the error message (if any) returned in the response
|
7
|
-
class RequestError
|
9
|
+
class RequestError < Error
|
8
10
|
attr_accessor :code
|
9
11
|
attr_accessor :error_class
|
10
|
-
attr_accessor :message
|
11
12
|
|
12
13
|
def initialize(code, error_class, message)
|
14
|
+
super(message)
|
15
|
+
|
13
16
|
@code = code
|
14
17
|
@error_class = error_class
|
15
|
-
@message = message
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
@@ -50,7 +50,7 @@ module RS4
|
|
50
50
|
|
51
51
|
response = RS4.configuration.request_handler.execute(path, :get)
|
52
52
|
|
53
|
-
unless response.
|
53
|
+
unless response.is_a?(RS4::Error) || response.nil?
|
54
54
|
# parsed_response = JSON.parse(response.read_body, symbolize_names: true)
|
55
55
|
|
56
56
|
template_hash = response.dig(:reusable_template)
|
@@ -69,18 +69,52 @@ module RS4
|
|
69
69
|
RS4.configuration.request_handler.execute(path, :get)
|
70
70
|
end
|
71
71
|
|
72
|
+
def prepare_document(template_guid, options = {})
|
73
|
+
path = "reusable_templates/#{template_guid}/prepare_document"
|
74
|
+
|
75
|
+
body = options
|
76
|
+
|
77
|
+
response = RS4.configuration.request_handler.execute(path, :post, body)
|
78
|
+
|
79
|
+
Rails.logger.info("RS4::ReusableTemplate::embed_document:: #{response.inspect}")
|
80
|
+
|
81
|
+
unless response.is_a?(RS4::Error) || response.nil?
|
82
|
+
# parsed_response = JSON.parse(response.read_body, symbolize_names: true)
|
83
|
+
|
84
|
+
document_hash = response.dig(:document)
|
85
|
+
|
86
|
+
return RS4::Document.new(document_hash)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def embed_document(template_guid, options = {})
|
91
|
+
path = "reusable_templates/#{template_guid}/embed_document"
|
92
|
+
|
93
|
+
body = options
|
94
|
+
|
95
|
+
response = RS4.configuration.request_handler.execute(path, :post, body)
|
96
|
+
|
97
|
+
Rails.logger.info("RS4::ReusableTemplate::embed_document:: #{response.inspect}")
|
98
|
+
|
99
|
+
unless response.is_a?(RS4::Error) || response.nil?
|
100
|
+
# parsed_response = JSON.parse(response.read_body, symbolize_names: true)
|
101
|
+
|
102
|
+
document_hash = response.dig(:document)
|
103
|
+
|
104
|
+
return RS4::Document.new(document_hash)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
72
108
|
def send_document(template_guid, options = {})
|
73
109
|
path = "reusable_templates/#{template_guid}/send_document"
|
74
110
|
|
75
111
|
body = options
|
76
112
|
|
77
|
-
body[:in_person] = true
|
78
|
-
|
79
113
|
response = RS4.configuration.request_handler.execute(path, :post, body)
|
80
114
|
|
81
115
|
Rails.logger.info("RS4::ReusableTemplate::send_document:: #{response.inspect}")
|
82
116
|
|
83
|
-
unless response.
|
117
|
+
unless response.is_a?(RS4::Error) || response.nil?
|
84
118
|
# parsed_response = JSON.parse(response.read_body, symbolize_names: true)
|
85
119
|
|
86
120
|
document_hash = response.dig(:document)
|
data/lib/rs4/version.rb
CHANGED
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.2.
|
4
|
+
version: 0.2.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- donny
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-10 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
|
@@ -29,7 +29,9 @@ files:
|
|
29
29
|
- bin/setup
|
30
30
|
- lib/rs4.rb
|
31
31
|
- lib/rs4/configuration.rb
|
32
|
+
- lib/rs4/configuration_error.rb
|
32
33
|
- lib/rs4/document.rb
|
34
|
+
- lib/rs4/error.rb
|
33
35
|
- lib/rs4/request.rb
|
34
36
|
- lib/rs4/request_error.rb
|
35
37
|
- lib/rs4/reusable_template.rb
|