sign_host 0.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 +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +1 -0
- data/Rakefile +10 -0
- data/lib/sign_host/api_client.rb +68 -0
- data/lib/sign_host/checksum.rb +19 -0
- data/lib/sign_host/configuration.rb +18 -0
- data/lib/sign_host/payload_creator.rb +44 -0
- data/lib/sign_host/status.rb +42 -0
- data/lib/sign_host/version.rb +3 -0
- data/lib/sign_host.rb +22 -0
- data/sign_host.gemspec +29 -0
- data/spec/fixtures/contract_test.pdf +0 -0
- data/spec/fixtures/postback_transaction.json +1 -0
- data/spec/fixtures/successful_new_transaction.json +1 -0
- data/spec/fixtures/transaction_with_two_signers.json +1 -0
- data/spec/lib/sign_host/api_client_spec.rb +25 -0
- data/spec/lib/sign_host/checksum_spec.rb +9 -0
- data/spec/lib/sign_host/payload_creator_spec.rb +65 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/support/signhost_helper.rb +6 -0
- metadata +202 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cd6f5b8d33fd45b4e1496f11bffbc09fb586f809
|
4
|
+
data.tar.gz: 27f686e28e13ca3e46a2e0df97de4ba413a0fc80
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0b55342a9664daeab7bda1d12f548ae1c05bdf672a4bfd7ff5e781362cb154a1788c4a051ec60d36625b4314ca54c54788225f0f26ec99e54b1385290d8586f3
|
7
|
+
data.tar.gz: 7e7ba6e8c8a519430f50f4e95286617f65f4681057c9b5c32981e9836dcbed0fdf3ae173c196681a5f0e16f861f664fbc40bffc18d59216e8ea31a5b8f3f375f
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Stephan Kaag
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# SignHost
|
data/Rakefile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'rspec/core/rake_task'
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
|
4
|
+
# Default directory to look in is `/specs`
|
5
|
+
# Run with `rake spec`
|
6
|
+
RSpec::Core::RakeTask.new(:spec) do |task|
|
7
|
+
task.rspec_opts = ['--color', '--format', 'progress']
|
8
|
+
end
|
9
|
+
|
10
|
+
task :default => :spec
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module SignHost
|
2
|
+
class ApiClient
|
3
|
+
attr_reader :configuration
|
4
|
+
|
5
|
+
def initialize(configuration)
|
6
|
+
@configuration = configuration
|
7
|
+
end
|
8
|
+
|
9
|
+
def post_transaction(payload)
|
10
|
+
RestClient.post(new_transaction_url, payload.to_json, auth_headers.merge(content_type: 'application/json', accept: 'application/json')){ |response, request, result, &block|
|
11
|
+
case response.code
|
12
|
+
when 200
|
13
|
+
JSON.parse(response.body)
|
14
|
+
else
|
15
|
+
response.return!(request, result, &block)
|
16
|
+
end
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def put_file(file_id, file)
|
21
|
+
RestClient.put(upload_file_url(file_id), file, auth_headers.merge(multipart: true, content_type: 'application/pdf')) { |response, request, result, &block |
|
22
|
+
case response.code
|
23
|
+
when 200
|
24
|
+
true
|
25
|
+
else
|
26
|
+
response.return!(request, result, &block)
|
27
|
+
end
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_transaction(transaction_id)
|
32
|
+
RestClient.get(transaction_url(transaction_id), auth_headers.merge(content_type: 'application/json', accept: 'application/json')){ |response, request, result, &block |
|
33
|
+
case response.code
|
34
|
+
when 200
|
35
|
+
JSON.parse(response.body)
|
36
|
+
else
|
37
|
+
response.return!(request, result, &block)
|
38
|
+
end
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def new_transaction_url
|
45
|
+
api_url + "transaction"
|
46
|
+
end
|
47
|
+
|
48
|
+
def upload_file_url(file_id)
|
49
|
+
api_url + "file/" + file_id
|
50
|
+
end
|
51
|
+
|
52
|
+
def transaction_url(transaction_id)
|
53
|
+
api_url + "transaction/" + transaction_id
|
54
|
+
end
|
55
|
+
|
56
|
+
def api_url
|
57
|
+
"https://api.signhost.com/api/"
|
58
|
+
end
|
59
|
+
|
60
|
+
def auth_headers
|
61
|
+
{
|
62
|
+
authorization: "APIKey #{configuration.api_key}",
|
63
|
+
application: "APPKey #{configuration.application_key}"
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module SignHost
|
2
|
+
class Checksum
|
3
|
+
attr_reader :configuration
|
4
|
+
|
5
|
+
def initialize(configuration)
|
6
|
+
@configuration = configuration
|
7
|
+
end
|
8
|
+
|
9
|
+
def create(transaction_id, file_id, status)
|
10
|
+
create_checksum(transaction_id, file_id, status)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def create_checksum(transaction_id, file_id, status)
|
16
|
+
Digest::SHA1.hexdigest("#{transaction_id}|#{file_id}|#{status}|#{configuration.shared_secret}")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module SignHost
|
2
|
+
class Configuration
|
3
|
+
ATTRIBUTES = %i(app_name api_key app_key shared_secret)
|
4
|
+
attr_reader *ATTRIBUTES
|
5
|
+
|
6
|
+
def initialize(arguments)
|
7
|
+
arguments.assert_valid_keys(ATTRIBUTES)
|
8
|
+
arguments.each do |key, value|
|
9
|
+
instance_variable_set("@#{key}", value)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def application_key
|
14
|
+
"#{app_name} #{app_key}"
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module SignHost::PayloadCreator
|
2
|
+
|
3
|
+
def self.create(hash)
|
4
|
+
build_hash(hash)
|
5
|
+
end
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def self.build_hash(hash)
|
10
|
+
hash.assert_valid_keys(:file, :seal, :signers, :reference, :postback_url, :send_email_notifications)
|
11
|
+
hash.require_keys(:file, :signers)
|
12
|
+
hash[:file].assert_valid_keys(:name)
|
13
|
+
hash[:file].require_keys(:name)
|
14
|
+
|
15
|
+
{
|
16
|
+
File: {Name: hash[:file][:name]},
|
17
|
+
Seal: hash[:seal],
|
18
|
+
Signers: inject_signers(hash[:signers]),
|
19
|
+
Reference: hash[:reference],
|
20
|
+
PostbackUrl: hash[:postback_url],
|
21
|
+
SendEmailNotifications: hash[:send_email_notifications]
|
22
|
+
}.reject{|k,v| v.nil?}
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.inject_signers(signers)
|
26
|
+
signers.collect do |hash|
|
27
|
+
hash.assert_valid_keys(:email, :mobile, :require_sms_verification, :send_sign_request, :sign_request_message, :language, :reference, :return_url)
|
28
|
+
hash.require_keys(:email)
|
29
|
+
hash.require_keys(:sign_request_message) if hash[:send_sign_request]
|
30
|
+
|
31
|
+
{
|
32
|
+
Email: hash[:email],
|
33
|
+
Mobile: hash[:mobile],
|
34
|
+
RequireSmsVerification: hash[:require_sms_verification],
|
35
|
+
SendSignRequest: hash[:send_sign_request],
|
36
|
+
SignRequestMessage: hash[:sign_request_message],
|
37
|
+
Language: hash[:language],
|
38
|
+
Reference: hash[:reference],
|
39
|
+
ReturnUrl: hash[:return_url]
|
40
|
+
}.reject{|k,v| v.nil?}
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module SignHost::Status
|
2
|
+
CONTRACT_STATUSES = {
|
3
|
+
"5" => "Waiting for document",
|
4
|
+
"10" => "Waiting for signer",
|
5
|
+
"20" => "In progress",
|
6
|
+
"30" => "Signed",
|
7
|
+
"40" => "Rejected",
|
8
|
+
"50" => "Expired",
|
9
|
+
"60" => "Cancelled",
|
10
|
+
"70" => "Failed"
|
11
|
+
}
|
12
|
+
|
13
|
+
SIGNER_STATUSES = {
|
14
|
+
"101" => "Initation sent",
|
15
|
+
"102" => "Received",
|
16
|
+
"103" => "Opened",
|
17
|
+
"104" => "Reminder sent",
|
18
|
+
"201" => "Cancelled",
|
19
|
+
"202" => "Rejected",
|
20
|
+
"203" => "Signed",
|
21
|
+
"301" => "Signed document sent",
|
22
|
+
"302" => "Signed document opened",
|
23
|
+
"303" => "Signed document downloaded",
|
24
|
+
"401" => "Receipt sent",
|
25
|
+
"402" => "Receipt opened",
|
26
|
+
"403" => "Receipt downloaded",
|
27
|
+
"500" => "Finished",
|
28
|
+
"600" => "Deleted",
|
29
|
+
"700" => "Expired",
|
30
|
+
"999" => "Failed"
|
31
|
+
}
|
32
|
+
|
33
|
+
def self.lookup_contract_status(status)
|
34
|
+
return "" unless status
|
35
|
+
CONTRACT_STATUSES.fetch(status.to_s)
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.lookup_signer_status(status)
|
39
|
+
return "" unless status
|
40
|
+
SIGNER_STATUSES.fetch(status.to_s)
|
41
|
+
end
|
42
|
+
end
|
data/lib/sign_host.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'json'
|
4
|
+
require 'rest-client'
|
5
|
+
require 'pry'
|
6
|
+
require 'active_support/core_ext/hash/keys'
|
7
|
+
|
8
|
+
class Hash
|
9
|
+
def require_keys(*keys)
|
10
|
+
raise ArgumentError, "#{keys.reject{|k| key?(k)}.inspect} are missing" unless keys.all?{|k| key?(k)}
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module SignHost
|
15
|
+
end
|
16
|
+
|
17
|
+
require 'sign_host/api_client'
|
18
|
+
require 'sign_host/checksum'
|
19
|
+
require 'sign_host/configuration'
|
20
|
+
require 'sign_host/payload_creator'
|
21
|
+
require 'sign_host/status'
|
22
|
+
require 'sign_host/version'
|
data/sign_host.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sign_host/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "sign_host"
|
8
|
+
spec.version = SignHost::VERSION
|
9
|
+
spec.authors = ["Stephan Kaag", "Sander Kuijper"]
|
10
|
+
spec.email = ["stephan.kaag@bettyblocks.com"]
|
11
|
+
spec.summary = %q{signhost.com}
|
12
|
+
spec.license = "MIT"
|
13
|
+
|
14
|
+
spec.files = `git ls-files -z`.split("\x0")
|
15
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_dependency "rest-client"
|
20
|
+
spec.add_dependency "activesupport"
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
spec.add_development_dependency "rspec-nc"
|
26
|
+
spec.add_development_dependency "guard"
|
27
|
+
spec.add_development_dependency "guard-rspec"
|
28
|
+
spec.add_development_dependency "webmock"
|
29
|
+
end
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
{"Id":"a8056bf4-0c2a-47df-baa4-cd4363c182fd","Status":30,"File":{"Id":"32226fbe-3d00-414a-8901-1872110545b4","Name":"golang.pdf"},"Seal":false,"Signers":[{"Id":"ce3f4965-f61f-4efa-a0aa-29cf7d5409d2","Email":"sander.kuijper+test15@holder.nl","Mobile":"+31642715674","RequireScribble":true,"RequireEmailVerification":true,"RequireSmsVerification":false,"SendSignRequest":false,"ReturnUrl":null,"SignRequestMessage":null,"Reference":"Signer #x","Activities":[{"Id":"1ec33513-8104-4f27-8dcc-babe8d8bc15c","Activity":"Opened","CreatedDateTime":"2014-09-10T15:32:00.477"},{"Id":"40406c27-4b23-4bdd-8c33-f11e5507231d","Activity":"Signed","CreatedDateTime":"2014-09-10T15:32:41.068645+02:00"}],"RejectReason":null,"SignUrl":"https://woeler.signhost.com/sign/ce3f4965-f61f-4efa-a0aa-29cf7d5409d2","SignedDateTime":"2014-09-10T15:32:35.7022356+02:00","RejectDateTime":null,"CreatedDateTime":"2014-09-10T15:28:41.17","ModifiedDateTime":"2014-09-10T15:32:41.068645+02:00"}],"Reference":"Sander #15","PostbackUrl":"http://requestb.in/qs3youqs","CreatedDateTime":"2014-09-10T15:28:41.157","ModifiedDateTime":"2014-09-10T15:32:40.9750449+02:00","CanceledDateTime":null,"Checksum":"7c7ba137504abb2145bf112e03455f1bb52536f6"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"Id":"eb619c10-0504-44aa-b7b8-8637fe670884","Status":5,"File":{"Id":"29915fd4-0d1f-4bce-90ab-20f68ccf978e","Name":"file.pdf"},"Seal":false,"Signers":[{"Id":"aa3b5e2c-3985-4190-9a5f-837cc4794e9d","Email":"user@example.com","Mobile":null,"RequireScribble":false,"RequireEmailVerification":true,"RequireSmsVerification":false,"SendSignRequest":false,"ReturnUrl":null,"SignRequestMessage":null,"Reference":null,"Activities":[],"RejectReason":null,"SignUrl":"https://woeler.signhost.com/sign/aa3b5e2c-3985-4190-9a5f-837cc4794e9d","SignedDateTime":"2014-09-05T10:44:44.8678126+02:00","RejectDateTime":"2014-09-05T10:44:44.8678126+02:00","CreatedDateTime":"2014-09-05T10:44:44.8678126+02:00","ModifiedDateTime":"2014-09-05T10:44:44.8678126+02:00"}],"Reference":null,"PostbackUrl":null,"CreatedDateTime":"2014-09-05T10:44:44.6650123+02:00","ModifiedDateTime":"2014-09-05T10:55:44.6650123+02:00","CanceledDateTime":"2014-09-05T10:55:44.6650123+02:00"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"Id":"be11b68a-6df2-4cde-9b6a-fef824b7fab7","Status":5,"File":{"Id":"df1e4dfa-7bd8-48ad-946a-4fa7ee224f00","Name":"contract_number_one.pdf"},"Seal":false,"Signers":[{"Id":"536ea844-849a-4594-91b7-9ed8a30d9465","Email":"user@example.com","Mobile":"+31642715674","RequireScribble":true,"RequireEmailVerification":true,"RequireSmsVerification":true,"SendSignRequest":false,"ReturnUrl":null,"SignRequestMessage":null,"Reference":"Signer #1","Activities":[],"RejectReason":null,"SignUrl":"https://woeler.signhost.com/sign/536ea844-849a-4594-91b7-9ed8a30d9465","SignedDateTime":null,"RejectDateTime":null,"CreatedDateTime":"2014-09-08T13:37:06.7257583+02:00","ModifiedDateTime":"2014-09-08T13:37:06.7257583+02:00"},{"Id":"5f34de48-6613-4c25-acf0-55781a4703f6","Email":"user@exampletwo.com","Mobile":"+31642715675","RequireScribble":true,"RequireEmailVerification":true,"RequireSmsVerification":true,"SendSignRequest":false,"ReturnUrl":null,"SignRequestMessage":null,"Reference":"Signer #2","Activities":[],"RejectReason":null,"SignUrl":"https://woeler.signhost.com/sign/5f34de48-6613-4c25-acf0-55781a4703f6","SignedDateTime":null,"RejectDateTime":null,"CreatedDateTime":"2014-09-08T13:37:06.7257583+02:00","ModifiedDateTime":"2014-09-08T13:37:06.7257583+02:00"}],"Reference":"John and Jane Doe","PostbackUrl":null,"CreatedDateTime":"2014-09-08T13:37:06.7257583+02:00","ModifiedDateTime":"2014-09-08T13:37:06.7257583+02:00","CanceledDateTime":null}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SignHost::ApiClient do
|
4
|
+
it 'parses the response' do
|
5
|
+
stub_transaction_request_with_status(200)
|
6
|
+
parsed_response = SignHost::ApiClient.new($configuration).post_transaction({})
|
7
|
+
expect(parsed_response.class).to eq(Hash)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'raises an error when something went wrong' do
|
11
|
+
stub_transaction_request_with_status(401)
|
12
|
+
expect{SignHost::ApiClient.post_transaction({})}.to raise_error
|
13
|
+
end
|
14
|
+
|
15
|
+
def stub_transaction_request_with_status(status)
|
16
|
+
stub_request(:post, "https://api.signhost.com/api/transaction").
|
17
|
+
with(:body => "{}",
|
18
|
+
:headers => {'Accept'=>'application/json',
|
19
|
+
'Accept-Encoding'=>'gzip, deflate',
|
20
|
+
'Application'=>"APPKey Bettyblocks ziGoai8ldHamn6tSQFo7GlH5ORHiDd3P",
|
21
|
+
'Authorization'=>"APIKey 78lB6t3E8wv4n0mRXFU4iMNPF6mWg2yz",
|
22
|
+
}).
|
23
|
+
to_return(:status => status, :body => load_signhost_fixture("successful_new_transaction"), :headers => {})
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SignHost::Checksum do
|
4
|
+
it 'validates the checksum from the given params' do
|
5
|
+
postback_json = JSON.parse(load_signhost_fixture("postback_transaction"))
|
6
|
+
expect(SignHost::Checksum.new($configuration).create(postback_json['Id'], postback_json['File']['Id'], postback_json['Status'])).to eq(postback_json["Checksum"])
|
7
|
+
end
|
8
|
+
|
9
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SignHost::PayloadCreator do
|
4
|
+
it 'creates a json representation from a contract' do
|
5
|
+
contract = build_contract
|
6
|
+
json_contract = SignHost::PayloadCreator.create(contract)
|
7
|
+
expect(json_contract).to eq(expected_payload_with_signers(0))
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'creates a json representation with one signer' do
|
11
|
+
contract = build_contract
|
12
|
+
contract[:signers] << signer_hash
|
13
|
+
|
14
|
+
json_contract = SignHost::PayloadCreator.create(contract)
|
15
|
+
expect(json_contract).to eq(expected_payload_with_signers(1))
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'creates a json representation with two signers' do
|
19
|
+
contract = build_contract
|
20
|
+
contract[:signers] << signer_hash
|
21
|
+
contract[:signers] << signer_hash
|
22
|
+
|
23
|
+
json_contract = SignHost::PayloadCreator.create(contract)
|
24
|
+
expect(json_contract).to eq(expected_payload_with_signers(2))
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'creates a json representation with a partial contract' do
|
28
|
+
contract = {reference: 'Contract #1', file: {name: 'some_contract.pdf'}, :signers => []}
|
29
|
+
json_contract = SignHost::PayloadCreator.create(contract)
|
30
|
+
expect(json_contract).to eq({:File => {:Name=>"some_contract.pdf"}, :Reference => "Contract #1", :Signers => []})
|
31
|
+
end
|
32
|
+
|
33
|
+
def expected_payload_with_signers(times)
|
34
|
+
signers_payload = []
|
35
|
+
times.to_i.times do
|
36
|
+
signers_payload << signer_payload
|
37
|
+
end
|
38
|
+
{ File: {Name: "some_contract.pdf"},
|
39
|
+
Seal: true,
|
40
|
+
Reference: "Contract #1",
|
41
|
+
PostbackUrl: "localhost:3000/contracts/update",
|
42
|
+
Signers: signers_payload
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
def signer_payload
|
47
|
+
{
|
48
|
+
Email: 'user@email.com',
|
49
|
+
Mobile: '06555',
|
50
|
+
RequireSmsVerification: true,
|
51
|
+
SendSignRequest: true,
|
52
|
+
Reference: true,
|
53
|
+
ReturnUrl: true,
|
54
|
+
SignRequestMessage: "please sign"
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
def build_contract
|
59
|
+
{reference: 'Contract #1', file: {name: 'some_contract.pdf'}, seal: true, postback_url: "localhost:3000/contracts/update", :signers => []}
|
60
|
+
end
|
61
|
+
|
62
|
+
def signer_hash
|
63
|
+
{ email: "user@email.com", mobile: '06555', require_sms_verification: true, send_sign_request: true, :sign_request_message => "please sign", reference: true, return_url: true }
|
64
|
+
end
|
65
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require "sign_host"
|
2
|
+
require "webmock/rspec"
|
3
|
+
|
4
|
+
require_relative "support/signhost_helper"
|
5
|
+
|
6
|
+
$configuration = SignHost::Configuration.new({
|
7
|
+
api_key: "78lB6t3E8wv4n0mRXFU4iMNPF6mWg2yz",
|
8
|
+
app_name: "Bettyblocks",
|
9
|
+
app_key: "ziGoai8ldHamn6tSQFo7GlH5ORHiDd3P",
|
10
|
+
shared_secret: "xeIfAhOpONoKGJfsYDuRN24L4wUMhyUp"
|
11
|
+
})
|
12
|
+
|
13
|
+
RSpec.configure do |config|
|
14
|
+
config.include SignhostHelper
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sign_host
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stephan Kaag
|
8
|
+
- Sander Kuijper
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-10-22 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rest-client
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: activesupport
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: bundler
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '1.7'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '1.7'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rake
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '10.0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '10.0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rspec
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: rspec-nc
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: guard
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: guard-rspec
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: webmock
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
description:
|
141
|
+
email:
|
142
|
+
- stephan.kaag@bettyblocks.com
|
143
|
+
executables: []
|
144
|
+
extensions: []
|
145
|
+
extra_rdoc_files: []
|
146
|
+
files:
|
147
|
+
- ".gitignore"
|
148
|
+
- Gemfile
|
149
|
+
- LICENSE.txt
|
150
|
+
- README.md
|
151
|
+
- Rakefile
|
152
|
+
- lib/sign_host.rb
|
153
|
+
- lib/sign_host/api_client.rb
|
154
|
+
- lib/sign_host/checksum.rb
|
155
|
+
- lib/sign_host/configuration.rb
|
156
|
+
- lib/sign_host/payload_creator.rb
|
157
|
+
- lib/sign_host/status.rb
|
158
|
+
- lib/sign_host/version.rb
|
159
|
+
- sign_host.gemspec
|
160
|
+
- spec/fixtures/contract_test.pdf
|
161
|
+
- spec/fixtures/postback_transaction.json
|
162
|
+
- spec/fixtures/successful_new_transaction.json
|
163
|
+
- spec/fixtures/transaction_with_two_signers.json
|
164
|
+
- spec/lib/sign_host/api_client_spec.rb
|
165
|
+
- spec/lib/sign_host/checksum_spec.rb
|
166
|
+
- spec/lib/sign_host/payload_creator_spec.rb
|
167
|
+
- spec/spec_helper.rb
|
168
|
+
- spec/support/signhost_helper.rb
|
169
|
+
homepage:
|
170
|
+
licenses:
|
171
|
+
- MIT
|
172
|
+
metadata: {}
|
173
|
+
post_install_message:
|
174
|
+
rdoc_options: []
|
175
|
+
require_paths:
|
176
|
+
- lib
|
177
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - ">="
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
182
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - ">="
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '0'
|
187
|
+
requirements: []
|
188
|
+
rubyforge_project:
|
189
|
+
rubygems_version: 2.2.2
|
190
|
+
signing_key:
|
191
|
+
specification_version: 4
|
192
|
+
summary: signhost.com
|
193
|
+
test_files:
|
194
|
+
- spec/fixtures/contract_test.pdf
|
195
|
+
- spec/fixtures/postback_transaction.json
|
196
|
+
- spec/fixtures/successful_new_transaction.json
|
197
|
+
- spec/fixtures/transaction_with_two_signers.json
|
198
|
+
- spec/lib/sign_host/api_client_spec.rb
|
199
|
+
- spec/lib/sign_host/checksum_spec.rb
|
200
|
+
- spec/lib/sign_host/payload_creator_spec.rb
|
201
|
+
- spec/spec_helper.rb
|
202
|
+
- spec/support/signhost_helper.rb
|