universign 0.2.0 → 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/.rubocop.yml +4 -0
- data/Rakefile +12 -3
- data/lib/universign.rb +52 -48
- data/lib/universign/hash.rb +7 -0
- data/lib/universign/version.rb +1 -1
- data/universign.gemspec +1 -0
- metadata +18 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4a162d62ec1ebc95ac4c719c2bebe7b47f64f7df
|
|
4
|
+
data.tar.gz: bc40b9c1401827933fd9d4223f7d199447929cb1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 55c5e8b2e43b16ba960f67d7400b53791123da170f4a81a3611bfdc06557b8ec539a18108251faec05b3ae8a71314f7e5b0e60834a652384f04117e23a23071d
|
|
7
|
+
data.tar.gz: 4b215f199a03f964cfb78118cfc14032de3f723c91f376c83f742253deb41d4d02489c5cb5b4ae562b4c031df206297d949ff1e8382f9167efa6eb068066a50a
|
data/.rubocop.yml
ADDED
data/Rakefile
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
1
|
+
require 'bundler/gem_tasks'
|
|
2
|
+
require 'rspec/core/rake_task'
|
|
3
|
+
require 'rubocop/rake_task'
|
|
4
|
+
|
|
5
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
|
6
|
+
task.patterns = ['Rakefile', 'lib/**/*.rb']
|
|
7
|
+
# only show the files with failures
|
|
8
|
+
# task.formatters = ['files']
|
|
9
|
+
# don't abort rake on failure
|
|
10
|
+
task.fail_on_error = false
|
|
11
|
+
end
|
|
3
12
|
|
|
4
13
|
RSpec::Core::RakeTask.new(:spec)
|
|
5
14
|
|
|
6
|
-
task :
|
|
15
|
+
task default: [:rubocop, :spec]
|
data/lib/universign.rb
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
require 'universign/version'
|
|
3
|
+
require 'universign/hash'
|
|
3
4
|
require 'base64'
|
|
4
5
|
require 'xmlrpc/client'
|
|
5
6
|
|
|
6
7
|
module Universign
|
|
7
|
-
|
|
8
8
|
class << self
|
|
9
9
|
attr_accessor :configuration
|
|
10
10
|
end
|
|
@@ -14,6 +14,7 @@ module Universign
|
|
|
14
14
|
yield(configuration) if block_given?
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
+
# Configuration class
|
|
17
18
|
class Configuration
|
|
18
19
|
attr_accessor :language, :production, :user, :password, :debug,
|
|
19
20
|
:profile
|
|
@@ -27,79 +28,82 @@ module Universign
|
|
|
27
28
|
end
|
|
28
29
|
|
|
29
30
|
module Sign
|
|
30
|
-
|
|
31
31
|
class << self
|
|
32
|
+
SignerDefaultOptions = { firstname: nil,
|
|
33
|
+
lastname: nil,
|
|
34
|
+
organization: nil,
|
|
35
|
+
profile: 'default',
|
|
36
|
+
emailAddress: nil,
|
|
37
|
+
phoneNum: nil,
|
|
38
|
+
role: 'signer',
|
|
39
|
+
signatureField: nil,
|
|
40
|
+
successURL: nil,
|
|
41
|
+
cancelURL: nil,
|
|
42
|
+
failURL: nil,
|
|
43
|
+
certificateType: 'simple',
|
|
44
|
+
idDocuments: nil
|
|
45
|
+
}.freeze
|
|
46
|
+
SANDBOX_URL = 'sign.test.cryptolog.com'.freeze
|
|
47
|
+
PROD_URL = 'sign.cryptolog.com'.freeze
|
|
32
48
|
|
|
33
49
|
def client
|
|
34
|
-
|
|
35
|
-
host = Universign.configuration.production ?
|
|
50
|
+
fail 'You need to set config options' if Universign.configuration.nil?
|
|
51
|
+
host = Universign.configuration.production ? PROD_URL : SANDBOX_URL
|
|
36
52
|
path = '/sign/rpc'
|
|
37
53
|
client = Universign::Sign::Client.new(
|
|
38
|
-
host, path, nil, nil, nil,
|
|
54
|
+
host, path, nil, nil, nil,
|
|
55
|
+
Universign.configuration.user,
|
|
56
|
+
Universign.configuration.password, true
|
|
39
57
|
)
|
|
40
58
|
client.set_debug if Universign.configuration.debug
|
|
41
59
|
client
|
|
42
60
|
end
|
|
43
61
|
|
|
44
|
-
|
|
62
|
+
def transaction_signer(options = {})
|
|
63
|
+
options = options.reverse_merge(SignerDefaultOptions)
|
|
64
|
+
validate_transaction_signer_argument options
|
|
65
|
+
options.reject! { |_, v| v.nil? }
|
|
66
|
+
end
|
|
45
67
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
:emailAddress,
|
|
50
|
-
:firstname,
|
|
51
|
-
:lastname,
|
|
52
|
-
:successURL,
|
|
53
|
-
:failURL,
|
|
54
|
-
:cancelURL
|
|
55
|
-
)
|
|
68
|
+
def transaction_document(content, name)
|
|
69
|
+
{ content: XMLRPC::Base64.new(content), name: name }
|
|
70
|
+
end
|
|
56
71
|
|
|
57
|
-
|
|
58
|
-
Signer.new(phoneNum, emailAddress, firstname, lastname, successURL, failURL, cancelURL)
|
|
59
|
-
end
|
|
72
|
+
private
|
|
60
73
|
|
|
61
|
-
|
|
62
|
-
|
|
74
|
+
def validate_transaction_signer_argument(options)
|
|
75
|
+
fail(ArgumentError, 'You have to provide a firstname') if
|
|
76
|
+
options[:firstname].empty?
|
|
77
|
+
fail(ArgumentError, 'You have to provide a lastname') if
|
|
78
|
+
options[:lastname].empty?
|
|
79
|
+
fail(ArgumentError, 'You have to provide an email') if
|
|
80
|
+
options[:emailAddress].empty?
|
|
81
|
+
end
|
|
63
82
|
end
|
|
64
83
|
|
|
65
84
|
class Client < XMLRPC::Client
|
|
66
|
-
|
|
67
|
-
RequestTransaction = Struct.new(
|
|
68
|
-
:documents,
|
|
69
|
-
:signers,
|
|
70
|
-
:handwrittenSignatureMode,
|
|
71
|
-
:profile,
|
|
72
|
-
:certificateType,
|
|
73
|
-
:language
|
|
74
|
-
)
|
|
75
|
-
|
|
76
85
|
# Request signature (Client side)
|
|
77
|
-
def
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
request =
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
Universign.configuration.profile,
|
|
85
|
-
'simple',
|
|
86
|
-
Universign.configuration.language
|
|
87
|
-
)
|
|
86
|
+
def request_transaction(signers, docs)
|
|
87
|
+
signers = [signers] unless signers.is_a? Array
|
|
88
|
+
docs = [docs] unless docs.is_a? Array
|
|
89
|
+
request = { documents: docs, signers: signers,
|
|
90
|
+
handwrittenSignatureMode: 0,
|
|
91
|
+
profile: Universign.configuration.profile,
|
|
92
|
+
language: Universign.configuration.language }
|
|
88
93
|
call('requester.requestTransaction', request)
|
|
89
94
|
end
|
|
90
95
|
|
|
91
|
-
def
|
|
92
|
-
call('requester.getTransactionInfo',
|
|
96
|
+
def get_transaction_info(transaction_id)
|
|
97
|
+
call('requester.getTransactionInfo', transaction_id)
|
|
93
98
|
end
|
|
94
99
|
|
|
95
|
-
def
|
|
96
|
-
call('requester.getDocuments',
|
|
100
|
+
def get_documents(transaction_id)
|
|
101
|
+
call('requester.getDocuments', transaction_id)
|
|
97
102
|
end
|
|
98
103
|
|
|
99
104
|
def set_debug
|
|
100
|
-
@http.set_debug_output($stderr)
|
|
105
|
+
@http.set_debug_output($stderr)
|
|
101
106
|
end
|
|
102
|
-
|
|
103
107
|
end
|
|
104
108
|
end
|
|
105
109
|
end
|
data/lib/universign/version.rb
CHANGED
data/universign.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: universign
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matthieu Foillard
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
11
|
+
date: 2016-02-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -52,6 +52,20 @@ dependencies:
|
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '3.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rubocop
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: 0.36.0
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: 0.36.0
|
|
55
69
|
description: 'A ruby client for the Universign XML-RPC api. Note : VERY EXPERIMENTAL
|
|
56
70
|
AND INCOMPLETE'
|
|
57
71
|
email:
|
|
@@ -63,12 +77,14 @@ files:
|
|
|
63
77
|
- ".gitignore"
|
|
64
78
|
- ".rbenv-gemsets"
|
|
65
79
|
- ".rspec"
|
|
80
|
+
- ".rubocop.yml"
|
|
66
81
|
- ".travis.yml"
|
|
67
82
|
- Gemfile
|
|
68
83
|
- LICENSE.txt
|
|
69
84
|
- README.md
|
|
70
85
|
- Rakefile
|
|
71
86
|
- lib/universign.rb
|
|
87
|
+
- lib/universign/hash.rb
|
|
72
88
|
- lib/universign/version.rb
|
|
73
89
|
- universign.gemspec
|
|
74
90
|
homepage: https://www.github.com/mgtf/universign
|