clicksign 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7d4b389f3944bfe890206fb86408085f30d74d19
4
+ data.tar.gz: 2734e686519f5264fc46da61a5c975628ae73ddc
5
+ SHA512:
6
+ metadata.gz: 13e62ccded57a9c168b2f615eb58db11f82f1dc4e6c1b6cb0aa68eb5318962567abd424b2134bcfc706c84c139a3fc3d1ae67493d786fdf9a62ecdffa378b78d
7
+ data.tar.gz: a25670e4dfad04176f528112d1f83188ef4c4c4aa1c13cfa41609cfd76a82f1a684aaf609b0385c06d37c648080303e0c2d8c2edb33b6e569733e47072eb7c46
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ *.gem
2
+ tmp/
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,37 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ clicksign (0.0.1)
5
+ rest-client
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.2.5)
11
+ mime-types (2.4.1)
12
+ netrc (0.7.7)
13
+ rake (10.3.2)
14
+ rest-client (1.7.2)
15
+ mime-types (>= 1.16, < 3.0)
16
+ netrc (~> 0.7)
17
+ rspec (3.0.0)
18
+ rspec-core (~> 3.0.0)
19
+ rspec-expectations (~> 3.0.0)
20
+ rspec-mocks (~> 3.0.0)
21
+ rspec-core (3.0.0)
22
+ rspec-support (~> 3.0.0)
23
+ rspec-expectations (3.0.0)
24
+ diff-lcs (>= 1.2.0, < 2.0)
25
+ rspec-support (~> 3.0.0)
26
+ rspec-mocks (3.0.1)
27
+ rspec-support (~> 3.0.0)
28
+ rspec-support (3.0.0)
29
+
30
+ PLATFORMS
31
+ ruby
32
+
33
+ DEPENDENCIES
34
+ bundler (~> 1.6)
35
+ clicksign!
36
+ rake
37
+ rspec (~> 3.0)
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,4 @@
1
+ clicksign-ruby
2
+ ==============
3
+
4
+ Clicksign Ruby client
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"
6
+ spec.version = Clicksign::VERSION
7
+ spec.authors = ["Clicksign"]
8
+ spec.email = ["suporte@clicksign.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 = '>= 1.9.3'
19
+
20
+ spec.add_dependency "rest-client"
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,17 @@
1
+ require 'clicksign'
2
+
3
+ Clicksign.configure do |config|
4
+ config.token = ENV['CLICKSIGN_TOKEN']
5
+ end
6
+
7
+ # Create a document
8
+ doc = Clicksign::Document.create(File.new('/deal.pdf'))
9
+
10
+ # Get Key identification
11
+ doc_key = doc['document']['key']
12
+
13
+ # Create a new signature list
14
+ result = Clicksign::Document.create_list(doc_key, { email: 'john.doe@example.com', act: 'sign' })
15
+
16
+ # Print document details with signatures and list
17
+ puts result
data/lib/clicksign.rb ADDED
@@ -0,0 +1,21 @@
1
+ require 'rest_client'
2
+ require 'json/ext'
3
+
4
+ require 'clicksign/version'
5
+ require 'clicksign/base'
6
+ require 'clicksign/document'
7
+ require 'clicksign/batch'
8
+ require 'clicksign/hook'
9
+
10
+ module Clicksign
11
+ class << self
12
+ attr_accessor :endpoint, :token, :api_version
13
+ end
14
+
15
+ def self.configure(&block)
16
+ self.endpoint = 'https://api.clicksign.com'
17
+ self.api_version = 'v1'
18
+
19
+ yield self
20
+ end
21
+ end
@@ -0,0 +1,22 @@
1
+ module Clicksign
2
+ class Base
3
+ def self.accept_header
4
+ { accept: 'json' }
5
+ end
6
+
7
+ def self.request(method, *params)
8
+ params.last.merge! accept_header
9
+ parse RestClient.public_send(method, *params)
10
+ end
11
+
12
+ def self.api_url(*path)
13
+ ([Clicksign.endpoint, Clicksign.api_version] + path).join("/") +
14
+ "?access_token=#{Clicksign.token}"
15
+ end
16
+
17
+ def self.parse(response)
18
+ response = {} if response.empty?
19
+ JSON[response]
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,24 @@
1
+ module Clicksign
2
+ class Batch < Base
3
+ def self.all
4
+ request :get,
5
+ api_url('batches'),
6
+ {}
7
+ end
8
+
9
+ def self.create(keys)
10
+ raise ArgumentError, "keys need to be an array" unless keys.is_a? Array
11
+
12
+ request :post,
13
+ api_url('batches'),
14
+ { keys: keys },
15
+ {}
16
+ end
17
+
18
+ def self.delete(id)
19
+ request :delete,
20
+ api_url('batches', id),
21
+ {}
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,29 @@
1
+ module Clicksign
2
+ class Document < Base
3
+ def self.all
4
+ request :get,
5
+ api_url('documents'),
6
+ {}
7
+ end
8
+
9
+ def self.find(key)
10
+ request :get,
11
+ api_url('documents', key),
12
+ {}
13
+ end
14
+
15
+ def self.create(file)
16
+ request :post,
17
+ api_url('documents'),
18
+ { "document[archive][original]" => file },
19
+ {}
20
+ end
21
+
22
+ def self.create_list(key, signers, skip_email = true)
23
+ request :post,
24
+ api_url('documents', key, 'list'),
25
+ { signers: Array.wrap(signers), skip_email: skip_email }.to_json,
26
+ content_type: "json"
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,22 @@
1
+ module Clicksign
2
+ class Hook < Base
3
+ def self.all(key)
4
+ request :get,
5
+ api_url('documents', key, 'hooks'),
6
+ {}
7
+ end
8
+
9
+ def self.create(key, url)
10
+ request :post,
11
+ api_url('documents', key, 'hooks'),
12
+ { url: url }.to_json,
13
+ { content_type: "json" }
14
+ end
15
+
16
+ def self.delete(key, id)
17
+ request :delete,
18
+ api_url('documents', key, 'hooks', id),
19
+ {}
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ module Clicksign
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe Clicksign do
4
+ describe '.configure' do
5
+ before do
6
+ Clicksign.configure do |config|
7
+ config.endpoint = 'http://example.com'
8
+ config.token = 'my_token'
9
+ end
10
+ end
11
+
12
+ it 'set config values' do
13
+ expect(Clicksign.endpoint).to eq "http://example.com"
14
+ expect(Clicksign.token).to eq 'my_token'
15
+ end
16
+ end
17
+ end
18
+
19
+ describe Clicksign::Document do
20
+ describe '.all' do
21
+ it 'returns a hash with documents' do
22
+ expect(RestClient).to receive(:get)
23
+ .with("http://example.com/v1/documents?access_token=my_token", {accept: 'json'})
24
+ .and_return(File.read('spec/fixtures/all_documents.json'))
25
+
26
+ records = Clicksign::Document.all
27
+ record = records.first
28
+ expect(record['document']['status']).to eq 'completed'
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,67 @@
1
+ [
2
+ {
3
+ "document": {
4
+ "key": "1123-4567-89ab-cdef",
5
+ "original_name": "document-2.pdf",
6
+ "status": "completed",
7
+ "archive_id": 2,
8
+ "created_at": "2014-06-18T09:55:16.873-03:00",
9
+ "updated_at": "2014-06-18T10:02:03.056-03:00",
10
+ "user_key":"A0BF-848B-0A42-916C",
11
+ "list": {
12
+ "locked":null,
13
+ "started_at":null,
14
+ "created_at":"2014-06-18T09:57:14.434-03:00",
15
+ "updated_at":"2014-06-18T09:57:14.434-03:00",
16
+ "user_key":"A0BF-848B-0A42-916C",
17
+ "signatures": []
18
+ }
19
+ }
20
+ },
21
+ {
22
+ "document": {
23
+ "key": "0123-4567-89ab-cdef",
24
+ "original_name": "document-1.pdf",
25
+ "status": "completed",
26
+ "archive_id": 1,
27
+ "created_at": "2014-06-18T09:55:16.873-03:00",
28
+ "updated_at": "2014-06-18T10:02:03.056-03:00",
29
+ "user_key":"A0BF-848B-0A42-916C",
30
+ "list": {
31
+ "locked":null,
32
+ "started_at":"2014-06-18T09:58:46.450-03:00",
33
+ "created_at":"2014-06-18T09:57:14.434-03:00",
34
+ "updated_at":"2014-06-18T09:58:46.452-03:00",
35
+ "user_key":"A0BF-848B-0A42-916C",
36
+ "signatures": [
37
+ {
38
+ "display_name":"John Doe",
39
+ "title":null,
40
+ "company_name":null,
41
+ "key":"A0BF-848B-0A42-916C",
42
+ "act":"receipt",
43
+ "decision":"agreed",
44
+ "address":"201.81.113.174",
45
+ "email":"john.doe@example.com",
46
+ "signed_at":"2014-06-18T09:59:58.713-03:00",
47
+ "created_at":"2014-06-18T09:57:24.191-03:00",
48
+ "updated_at":"2014-06-18T09:59:58.836-03:00"
49
+ },
50
+ {
51
+ "display_name":"Jane Doe",
52
+ "title":null,
53
+ "company_name":null,
54
+ "key":"A0BF-848B-0A42-916C",
55
+ "act":"intervening",
56
+ "decision":"agreed",
57
+ "address":"201.81.113.174",
58
+ "email":"jane.doe@example.com",
59
+ "signed_at":"2014-06-18T10:01:18.327-03:00",
60
+ "created_at":"2014-06-18T09:57:31.114-03:00",
61
+ "updated_at":"2014-06-18T10:01:18.389-03:00"
62
+ }
63
+ ]
64
+ }
65
+ }
66
+ }
67
+ ]
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <document>
3
+ <key>B3E5-C645-3259-EDEC</key>
4
+ <original_name>document.pdf</original_name>
5
+ <status>editing</status>
6
+ <created_at>2014-10-07 15:38:43 -0300</created_at>
7
+ <updated_at>2014-10-07 15:38:43 -0300</updated_at>
8
+ <user_key>4139-026A-D7FF-5466</user_key>
9
+ <list>
10
+ <started_at/>
11
+ <created_at>2014-10-07 15:38:43 -0300</created_at>
12
+ <updated_at>2014-10-07 15:38:43 -0300</updated_at>
13
+ </list>
14
+ </document>
@@ -0,0 +1,2 @@
1
+ $:.push File.expand_path("../../lib", __FILE__)
2
+ require 'clicksign'
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: clicksign
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Clicksign
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-27 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: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
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
+ - suporte@clicksign.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - Gemfile
79
+ - Gemfile.lock
80
+ - LICENSE
81
+ - README.md
82
+ - Rakefile
83
+ - clicksign.gemspec
84
+ - examples/simple_api.rb
85
+ - lib/clicksign.rb
86
+ - lib/clicksign/base.rb
87
+ - lib/clicksign/batch.rb
88
+ - lib/clicksign/document.rb
89
+ - lib/clicksign/hook.rb
90
+ - lib/clicksign/version.rb
91
+ - spec/clicksign_spec.rb
92
+ - spec/fixtures/all_documents.json
93
+ - spec/fixtures/document.xml
94
+ - spec/spec_helper.rb
95
+ homepage:
96
+ licenses:
97
+ - MIT
98
+ metadata: {}
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: 1.9.3
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubyforge_project:
115
+ rubygems_version: 2.2.2
116
+ signing_key:
117
+ specification_version: 4
118
+ summary: Ruby library to interact with Clicksign
119
+ test_files:
120
+ - spec/clicksign_spec.rb
121
+ - spec/fixtures/all_documents.json
122
+ - spec/fixtures/document.xml
123
+ - spec/spec_helper.rb