rs4 0.1.6 → 0.2.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/lib/rs4.rb +2 -0
- data/lib/rs4/configuration.rb +1 -0
- data/lib/rs4/document.rb +12 -24
- data/lib/rs4/request.rb +13 -1
- data/lib/rs4/reusable_template.rb +9 -22
- data/lib/rs4/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e8e2fd74b61acb79edb0d4fbc64e49ef1c0fad6b8696d466b83a0cec8e6bab9
|
4
|
+
data.tar.gz: 2b611b82edec6aa6c897472a2163110cd8a1d01a8cb39cc85a47e1628de7d955
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0975d5000647806f81c71796563a0f13857093da7e4e18518c02bce918ce293e2247f50f08cc03a831bb0eca2dfaaf4f77b2784eafaf5032230f42773ebcf7b4'
|
7
|
+
data.tar.gz: 3bccea9722d64d825e1dc8aa5e542fc7bc6fd98b5ff521e3bd93661b8e2f56a2af8fbfd7ccaf9cf6b82252cde7dbbb868c0fe0af910e0c7214426e50e45bece7
|
data/lib/rs4.rb
CHANGED
data/lib/rs4/configuration.rb
CHANGED
data/lib/rs4/document.rb
CHANGED
@@ -87,42 +87,30 @@ module RS4
|
|
87
87
|
|
88
88
|
path = "documents/#{document_guid}"
|
89
89
|
|
90
|
-
response = RS4
|
90
|
+
response = RS4.configuration.request_handler.execute(path, :get)
|
91
91
|
|
92
|
-
|
93
|
-
raw_document = JSON.parse(response.body, symbolize_names: true)
|
92
|
+
unless response.class == RS4::RequestError || response.nil? # .class == Net::HTTPOK
|
93
|
+
raw_document = response.dig(:document) # JSON.parse(response.body, symbolize_names: true)
|
94
94
|
|
95
|
-
Document.new(raw_document[:document])
|
96
|
-
|
97
|
-
Rails.logger.error("Unable to get document #{document_guid}")
|
98
|
-
RS4::RequestError.new(
|
99
|
-
response.code,
|
100
|
-
response.class,
|
101
|
-
JSON.parse(response.read_body)
|
102
|
-
)
|
95
|
+
# Document.new(raw_document[:document])
|
96
|
+
Document.new(raw_document) if raw_document
|
103
97
|
end
|
104
98
|
end
|
105
99
|
|
106
100
|
def get_documents
|
107
101
|
path = 'documents'
|
108
|
-
response = RS4
|
102
|
+
response = RS4.configuration.request_handler.execute(path, :get)
|
109
103
|
|
110
|
-
|
104
|
+
unless response.class == RS4::RequestError || response.nil?
|
111
105
|
documents = []
|
112
106
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
documents << Document.new(raw_document[:document])
|
107
|
+
response.dig(:documents).each do |document_hash|
|
108
|
+
# document_hash = raw_document.pluck(:document)
|
109
|
+
documents << Document.new(document_hash)
|
117
110
|
end
|
118
|
-
else
|
119
|
-
Rails.logger.error('Unable to get documents')
|
120
|
-
RS4::RequestError.new(
|
121
|
-
response.code,
|
122
|
-
response.class,
|
123
|
-
JSON.parse(response.read_body)
|
124
|
-
)
|
125
111
|
end
|
112
|
+
|
113
|
+
documents
|
126
114
|
end
|
127
115
|
end
|
128
116
|
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
|
@@ -48,20 +48,14 @@ module RS4
|
|
48
48
|
|
49
49
|
path = "reusable_templates/#{template_guid}"
|
50
50
|
|
51
|
-
response = RS4
|
51
|
+
response = RS4.configuration.request_handler.execute(path, :get)
|
52
52
|
|
53
|
-
|
54
|
-
parsed_response = JSON.parse(response.read_body, symbolize_names: true)
|
53
|
+
unless response.class == RS4::RequestError || response.nil?
|
54
|
+
# parsed_response = JSON.parse(response.read_body, symbolize_names: true)
|
55
55
|
|
56
|
-
template_hash =
|
56
|
+
template_hash = response.dig(:reusable_template)
|
57
57
|
|
58
58
|
RS4::ReusableTemplate.new(template_hash)
|
59
|
-
else
|
60
|
-
RS4::RequestError.new(
|
61
|
-
response.code,
|
62
|
-
response.class,
|
63
|
-
JSON.parse(response.read_body)
|
64
|
-
)
|
65
59
|
end
|
66
60
|
end
|
67
61
|
|
@@ -72,7 +66,7 @@ module RS4
|
|
72
66
|
|
73
67
|
path = query.empty? ? base_path : "#{base_path}?#{query}"
|
74
68
|
|
75
|
-
RS4
|
69
|
+
RS4.configuration.request_handler.execute(path, :get)
|
76
70
|
end
|
77
71
|
|
78
72
|
def send_document(template_guid, options = {})
|
@@ -82,23 +76,16 @@ module RS4
|
|
82
76
|
|
83
77
|
body[:in_person] = true
|
84
78
|
|
85
|
-
response = RS4
|
79
|
+
response = RS4.configuration.request_handler.execute(path, :post, body)
|
86
80
|
|
87
81
|
Rails.logger.info("RS4::ReusableTemplate::send_document:: #{response.inspect}")
|
88
82
|
|
89
|
-
|
90
|
-
parsed_response = JSON.parse(response.read_body, symbolize_names: true)
|
83
|
+
unless response.class == RS4::RequestError || response.nil?
|
84
|
+
# parsed_response = JSON.parse(response.read_body, symbolize_names: true)
|
91
85
|
|
92
|
-
document_hash =
|
86
|
+
document_hash = response.dig(:document)
|
93
87
|
|
94
88
|
return RS4::Document.new(document_hash)
|
95
|
-
|
96
|
-
else
|
97
|
-
return RS4::RequestError.new(
|
98
|
-
response.code,
|
99
|
-
response.class,
|
100
|
-
JSON.parse(response.read_body)
|
101
|
-
)
|
102
89
|
end
|
103
90
|
end
|
104
91
|
end
|
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.1
|
4
|
+
version: 0.2.1
|
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-24 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
|