clicksign_ruby 1.0
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 +4 -0
- data/.rspec +1 -0
- data/Gemfile +2 -0
- data/LICENSE +21 -0
- data/README.md +73 -0
- data/Rakefile +15 -0
- data/clicksign.gemspec +25 -0
- data/examples/simple_api.rb +29 -0
- data/lib/clicksign/base.rb +39 -0
- data/lib/clicksign/document.rb +20 -0
- data/lib/clicksign/envelope.rb +37 -0
- data/lib/clicksign/signer.rb +20 -0
- data/lib/clicksign/version.rb +3 -0
- data/lib/clicksign.rb +29 -0
- data/spec/clicksign_spec.rb +26 -0
- data/spec/spec_helper.rb +2 -0
- metadata +117 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 30813ecb47b7a24e1e4c1ababeee56fb2fcecb969f556671458e4a54e9e06724
|
4
|
+
data.tar.gz: 3ae5ce33b7069e04f12bf88cfcb7d0bbb840db23726102c86d33f6160551c88f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3ce8d9abd48c71f809d7681ff1c8fb8a5398e6f5cca3437aa70f8c78ea02731815daf0c001b3a0f6f826d7740c2a1a537ae4fa3e506aa4f9b7d4283913f2cb24
|
7
|
+
data.tar.gz: e7b3ce4ee3ecea33adcfe2bb687c2ded600769df4fc61068b7e6f994ab835cac9cb37081d5a22ebade042400190d140f8745def49542bcd80383e6a8bae42755
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Clicksign
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# Clicksign Ruby Client
|
2
|
+
|
3
|
+
Fork of deprecated clicksign gem in Ruby.
|
4
|
+
Works on documentation version 2.0: Envelope
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
With Bundler:
|
9
|
+
|
10
|
+
```
|
11
|
+
gem 'clicksign', github: 'davi-canuto/clicksign-ruby', branch: 'main'
|
12
|
+
```
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
### Setting up the client
|
17
|
+
|
18
|
+
You must provide a valid `token` in order to use the library.
|
19
|
+
|
20
|
+
The required `token` is provided by the Clicksign support team.
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
require 'clicksign'
|
24
|
+
|
25
|
+
Clicksign.configure do |config|
|
26
|
+
config.token = ENV['CLICKSIGN_TOKEN']
|
27
|
+
config.environment = 'production'
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
31
|
+
### Create a envelope
|
32
|
+
|
33
|
+
You'll be able to make requests to the Clicksign API right after the initial setup. The first step would be createa a envelope that will contain the rest of the documents, signers and e.t.c.
|
34
|
+
|
35
|
+
For knowledge the permit parameters, visit [here](https://developers.clicksign.com/docs/criar-envelope)
|
36
|
+
```ruby
|
37
|
+
envelope = Clicksign::Envelope.create({
|
38
|
+
name: ''
|
39
|
+
})
|
40
|
+
```
|
41
|
+
|
42
|
+
This request will return a id, save this key for later use
|
43
|
+
```ruby
|
44
|
+
@envelope_id = envelope["data"]["id"]
|
45
|
+
```
|
46
|
+
|
47
|
+
### Adding document
|
48
|
+
|
49
|
+
To upload a new document into Clicksign envelope you can use the following snippet:
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
document = Clicksign::Document.new(@envelope_id).add({
|
53
|
+
filename: '',
|
54
|
+
base64_content: "data:#{}\;base64,#{}"
|
55
|
+
})
|
56
|
+
```
|
57
|
+
|
58
|
+
### Adding signers
|
59
|
+
|
60
|
+
To add a new signer into Clicksign envelope you can use the following snippet:
|
61
|
+
|
62
|
+
For knowledge the permit parameters, visit [here](https://developers.clicksign.com/docs/adicionar-novo-signat%C3%A1rio-no-envelope)
|
63
|
+
```ruby
|
64
|
+
signer = Clicksign::Signer.new(@envelope_id).add({})
|
65
|
+
```
|
66
|
+
|
67
|
+
### Webhooks
|
68
|
+
|
69
|
+
To works with webhooks i'm also recomendely to use a [nexoos gem](https://github.com/NexoosBR/clicksign-webhooks)
|
70
|
+
Provided me with everything I needed.
|
71
|
+
|
72
|
+
This gem also created for a necessit implement integration with clicksign, and i`ve found the [deprecated documentation](https://github.com/clicksign/clicksign-ruby), forked it and works to my specifications.
|
73
|
+
## CONTRIBUTE
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new
|
5
|
+
|
6
|
+
task :console do
|
7
|
+
require 'irb'
|
8
|
+
require 'irb/completion'
|
9
|
+
require 'clicksign'
|
10
|
+
ARGV.clear
|
11
|
+
IRB.start
|
12
|
+
end
|
13
|
+
|
14
|
+
task :default => :spec
|
15
|
+
task :test => :spec
|
data/clicksign.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
$:.push File.expand_path('../lib', __FILE__)
|
2
|
+
require 'clicksign/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = 'clicksign_ruby'
|
6
|
+
spec.version = Clicksign::VERSION
|
7
|
+
spec.authors = ['davi-canuto']
|
8
|
+
spec.email = ['davicanutogregorio@gmail.com']
|
9
|
+
spec.description = %q{Ruby library to interact with Clicksign}
|
10
|
+
spec.summary = %q{Ruby library to interact with Clicksign}
|
11
|
+
spec.license = 'MIT'
|
12
|
+
|
13
|
+
spec.files = `git ls-files`.split($/)
|
14
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
15
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
16
|
+
spec.require_paths = ['lib']
|
17
|
+
|
18
|
+
spec.required_ruby_version = '>= 2.1.0'
|
19
|
+
|
20
|
+
spec.add_dependency 'rest-client', '>= 1.8'
|
21
|
+
|
22
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
24
|
+
spec.add_development_dependency 'rake'
|
25
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'clicksign'
|
2
|
+
|
3
|
+
Clicksign.configure do |config|
|
4
|
+
config.token = ENV['CLICKSIGN_TOKEN']
|
5
|
+
config.environment = :sandbox
|
6
|
+
end
|
7
|
+
|
8
|
+
# Create a envelope
|
9
|
+
envelope = Clicksign::Envelope.create({ name: 'test envelope' })
|
10
|
+
|
11
|
+
# Get Key identification
|
12
|
+
envelope_id = envelope['data']['id']
|
13
|
+
|
14
|
+
# Add a new document to signature
|
15
|
+
document = Clicksign::Document.new(envelope_id).create(
|
16
|
+
{
|
17
|
+
filename: 'samplename.jpg',
|
18
|
+
base64_content: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJwAAACACAYAAAD+rACtAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAFeSURBVHhe7dIxAQAgDMCwgX/NwIOGXslTA13n3DsQ2b+QMBwpw5EyHCnDkTIcKcORMhwpw5EyHCnDkTIcKcORMhwpw5EyHCnDkTIcKcORMhwpw5EyHCnDkTIcKcORMhwpw5EyHCnDkTIcKcORMhwpw5EyHCnDkTIcKcORMhwpw5EyHCnDkTIcKcORMhwpw5EyHCnDkTIcKcORMhwpw5EyHCnDkTIcKcORMhwpw5EyHCnDkTIcKcORMhwpw5EyHCnDkTIcKcORMhwpw5EyHCnDkTIcKcORMhwpw5EyHCnDkTIcKcORMhwpw5EyHCnDkTIcKcORMhwpw5EyHCnDkTIcKcORMhwpw5EyHCnDkTIcKcORMhwpw5EyHCnDkTIcKcORMhwpw5EyHCnDkTIcKcORMhwpw5EyHCnDkTIcKcORMhwpw5EyHCnDkTIcKcORMhwpw5EyHCnDkTIcKcMRmnltlQT6RDW/pgAAAABJRU5ErkJggg==",
|
19
|
+
}
|
20
|
+
)
|
21
|
+
|
22
|
+
# Add a new signer to signature
|
23
|
+
signer = Clicksign::Signer.new(envelope_id).create(
|
24
|
+
{
|
25
|
+
name: 'segundin',
|
26
|
+
email: 'mudin@mail.com',
|
27
|
+
birthdate: '1990-01-01'
|
28
|
+
}
|
29
|
+
)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Clicksign
|
2
|
+
class Base
|
3
|
+
def self.headers
|
4
|
+
{
|
5
|
+
accept: 'application/vnd.api+json',
|
6
|
+
content_type: 'application/vnd.api+json',
|
7
|
+
authorization: Clicksign.token
|
8
|
+
}
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.request(method, *params)
|
12
|
+
params.last.merge!(headers)
|
13
|
+
parse RestClient.public_send(method, *params)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.api_url(*path)
|
17
|
+
([Clicksign.endpoint] + path).join("/")
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.parse(response)
|
21
|
+
response = {} if response.empty?
|
22
|
+
JSON[response]
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.build_data(params, model_name, id='')
|
26
|
+
data = {
|
27
|
+
data: {
|
28
|
+
attributes: params,
|
29
|
+
type: model_name
|
30
|
+
}
|
31
|
+
}
|
32
|
+
unless id.empty?
|
33
|
+
data[:data][:id] = id
|
34
|
+
end
|
35
|
+
|
36
|
+
data.to_json
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Clicksign
|
2
|
+
class Document < Base
|
3
|
+
def self.model_name
|
4
|
+
'documents'
|
5
|
+
end
|
6
|
+
|
7
|
+
attr_accessor :envelope_key
|
8
|
+
|
9
|
+
def initialize(envelope_key)
|
10
|
+
@envelope_key = envelope_key
|
11
|
+
end
|
12
|
+
|
13
|
+
def add params={}
|
14
|
+
Base.request :post,
|
15
|
+
Base.api_url('envelopes', @envelope_key, Document.model_name),
|
16
|
+
Base.build_data(params, Document.model_name),
|
17
|
+
{}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Clicksign
|
2
|
+
class Envelope < Base
|
3
|
+
def self.model_name
|
4
|
+
'envelopes'
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.create params={}
|
8
|
+
request :post,
|
9
|
+
api_url(model_name),
|
10
|
+
build_data(params, model_name),
|
11
|
+
{}
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.find key
|
15
|
+
request :get,
|
16
|
+
api_url(model_name, key),
|
17
|
+
{}
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.update params={}, key
|
21
|
+
unless params[:data]&[:id]
|
22
|
+
raise 'must_send_envelope_id_inside_body'
|
23
|
+
end
|
24
|
+
|
25
|
+
request :patch,
|
26
|
+
api_url(model_name, key),
|
27
|
+
build_data(params, model_name, key ),
|
28
|
+
{}
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.remove key
|
32
|
+
request :delete,
|
33
|
+
api_url(model_name, key),
|
34
|
+
{}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Clicksign
|
2
|
+
class Signer < Base
|
3
|
+
def self.model_name
|
4
|
+
'signers'
|
5
|
+
end
|
6
|
+
|
7
|
+
attr_accessor :envelope_key
|
8
|
+
|
9
|
+
def initialize(envelope_key)
|
10
|
+
@envelope_key = envelope_key
|
11
|
+
end
|
12
|
+
|
13
|
+
def add params={}
|
14
|
+
Base.request :post,
|
15
|
+
Base.api_url('envelopes', @envelope_key, Signer.model_name),
|
16
|
+
Base.build_data(params, Signer.model_name),
|
17
|
+
{}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/clicksign.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'json/ext'
|
3
|
+
|
4
|
+
require 'clicksign/version'
|
5
|
+
require 'clicksign/base'
|
6
|
+
require 'clicksign/envelope'
|
7
|
+
require 'clicksign/document'
|
8
|
+
require 'clicksign/signer'
|
9
|
+
|
10
|
+
module Clicksign
|
11
|
+
class << self
|
12
|
+
attr_accessor :endpoint, :token, :api_version, :environment, :host
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.configure(&block)
|
16
|
+
self.api_version = 'v3'
|
17
|
+
self.environment = :sandbox
|
18
|
+
|
19
|
+
if self.environment.to_sym == :production
|
20
|
+
self.host = "https://app.clicksign.com"
|
21
|
+
else
|
22
|
+
self.host = "https://sandbox.clicksign.com"
|
23
|
+
end
|
24
|
+
|
25
|
+
self.endpoint = self.host + "/api/#{self.api_version}"
|
26
|
+
|
27
|
+
yield self
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Clicksign do
|
4
|
+
describe '.configure' do
|
5
|
+
before do
|
6
|
+
Clicksign.configure do |config|
|
7
|
+
config.token = 'my_token'
|
8
|
+
config.environment = :sandbox
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'set config values' do
|
13
|
+
expect(Clicksign.environment).to eq :sandbox
|
14
|
+
expect(Clicksign.endpoint).to eq "https://sandbox.clicksign.com/api/v3"
|
15
|
+
expect(Clicksign.token).to eq 'my_token'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe Clicksign::Envelope do
|
21
|
+
describe '.create' do
|
22
|
+
it 'create envelope with only required parameters' do
|
23
|
+
# was supposed to have tests xD
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: clicksign_ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '1.0'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- davi-canuto
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-06-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.8'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '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'
|
69
|
+
description: Ruby library to interact with Clicksign
|
70
|
+
email:
|
71
|
+
- davicanutogregorio@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- clicksign.gemspec
|
83
|
+
- examples/simple_api.rb
|
84
|
+
- lib/clicksign.rb
|
85
|
+
- lib/clicksign/base.rb
|
86
|
+
- lib/clicksign/document.rb
|
87
|
+
- lib/clicksign/envelope.rb
|
88
|
+
- lib/clicksign/signer.rb
|
89
|
+
- lib/clicksign/version.rb
|
90
|
+
- spec/clicksign_spec.rb
|
91
|
+
- spec/spec_helper.rb
|
92
|
+
homepage:
|
93
|
+
licenses:
|
94
|
+
- MIT
|
95
|
+
metadata: {}
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 2.1.0
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubygems_version: 3.4.10
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Ruby library to interact with Clicksign
|
115
|
+
test_files:
|
116
|
+
- spec/clicksign_spec.rb
|
117
|
+
- spec/spec_helper.rb
|