clicksign 0.0.2 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2e5a45ed31afb3385da42cb5e4cc1bcc08306489
4
- data.tar.gz: 3622beb4ba84350a62e562b843bb5142ca9b3d87
3
+ metadata.gz: 92022f1569b2ad33a843cd4a225ca978e9bef14e
4
+ data.tar.gz: 2267d095b9e83ad083d58cbdf2681bff1a220fd5
5
5
  SHA512:
6
- metadata.gz: 2f94fd93549e112231817013942737c5e7afde123178d7ac2b82609c5f9d7665dee2939a39d3b3644930939c1fb53e23c5c921fb280ff25e4f1e57eb77f62a0c
7
- data.tar.gz: d70377367e9be154ed99da4f02db9011f96ad31e9cfbe964e2066d8e555073c675390f109cc125616a82ed6d6a80b8f0aaa6d0d177fc162b4e7f0f79f466d35b
6
+ metadata.gz: c2e0a45714e53c245cadcd9fbe4f29820ce309202db50760a8e34e5fdcc2834430036f4c26a43d42a8774ee72416fd8429ce39b5e8f5ff21d10e7d9ac08f704b
7
+ data.tar.gz: 1a38c26a2e400a8809a595623cf8f7d197a0be5dd270e9f0b7dfa07946caa1898aa00ef5e54fb5ce36f74c607a2a086c10edaf8a6bba419471f99a7fb31b1e80
data/README.md CHANGED
@@ -1,4 +1,131 @@
1
- clicksign-ruby
2
- ==============
1
+ # Clicksign Ruby Client
3
2
 
4
- Clicksign Ruby client
3
+ Official gem to comunicate with the **[Clicksign REST API](http://clicksign.github.io/rest-api/)**.
4
+
5
+ ## Installation
6
+
7
+ With Bundler:
8
+
9
+ ```
10
+ gem 'clicksign'
11
+ ```
12
+
13
+ Manual installation via RubyGems:
14
+
15
+ ```shell
16
+ gem install clicksign
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ### Setting up the client
22
+
23
+ You must provide a valid `token` in order to use the library. As an option, you can also set a different `endpoint`.
24
+
25
+ The required `token` is provided by the Clicksign support team.
26
+
27
+ ```ruby
28
+ require 'clicksign'
29
+
30
+ Clicksign.configure do |config|
31
+ config.token = ENV['CLICKSIGN_TOKEN']
32
+ config.endpoint = 'https://api.clicksign-demo.com' # Default: 'api.clicksign.com'
33
+ end
34
+ ```
35
+
36
+ ### Retrieving a list of documents
37
+
38
+ You'll be able to make requests to the Clicksign API right after the initial setup. The first step would be to retrieve a list of documents that you've previously uploaded to your account.
39
+
40
+ ```ruby
41
+ documents = Clicksign::Document.all
42
+ ```
43
+
44
+ ### Uploading a document
45
+
46
+ To upload a new document to Clicksign you can use the following snippet:
47
+
48
+ ```ruby
49
+ document = Clicksign::Document.create(File.new('example.pdf'))
50
+ ```
51
+
52
+ You can also upload a new document and at the same time set up a signature list
53
+ as follow:
54
+
55
+ ```ruby
56
+ document = Clicksign::Document.create(File.new('example.pdf'), signers: [{ act: 'sign', email: 'john.doe@example.com' }], message: 'Please sign it', skip_email: true)
57
+ ```
58
+
59
+ It is important to notice that the additional parameters to `create` method is
60
+ the same as the ones in the section [Creating a signature list](#user-content-creating-a-signature-list)
61
+
62
+
63
+ ### Retrieving a document
64
+
65
+ ```ruby
66
+ found = Clicksign::Document.find(document_key)
67
+ ```
68
+
69
+ ### Creating a signature list
70
+
71
+ The method `Clicksign::Document.create_list` accepts **3 arguments**, the latter being optional.
72
+
73
+ The first argument is `document_key`, which represents the document's unique identification.
74
+
75
+ The second argument is `signers`, an array of hashes with the e-mails of the signers and their actions (`act`). The available options for `act` are described in our [documentation](http://clicksign.github.io/rest-api/#criacao-de-lista-de-assinatura).
76
+
77
+ The third and optional parameter is `skip_email`, a boolean that says whether the API should send e-mails to the signers or not.
78
+
79
+ Example:
80
+
81
+ ```ruby
82
+ document_key = KEY
83
+ signers = [{ email: 'john.doe@example.com', act: 'sign' }]
84
+ result = Clicksign::Document.create_list(document, signers, true)
85
+ ```
86
+
87
+ ### Hooks
88
+
89
+ You can perform three different actions with hooks: **retrieve** all, **create** a new one or **delete** an existing hook.
90
+
91
+ Listing all hooks that belong to a document:
92
+
93
+ ```ruby
94
+ Clicksign::Hook.all(document_key)
95
+ ```
96
+
97
+ Creating a new hook for a specific document:
98
+
99
+ ```ruby
100
+ Clicksign::Hook.create(document_key, 'http://example.com')
101
+ ```
102
+
103
+ Destroying an existing hook:
104
+
105
+ ```ruby
106
+ Clicksign::Hook.delete(document_key, hook_id)
107
+ ```
108
+
109
+ ### Batches
110
+
111
+ Batches are you used to group documents in a package and perform batch signatures via the [Clicksign Widget](https://github.com/clicksign/widget).
112
+
113
+ You can perform three different actions with batches: **retrieve** all, **create** a new one or **delete** an existing batch.
114
+
115
+ Listing all batches:
116
+
117
+ ```ruby
118
+ Clicksign::Batch.all
119
+ ```
120
+
121
+ Creating a new batch for a group of documents:
122
+
123
+ ```ruby
124
+ Clicksign::Batch.create([key1, key2, key3])
125
+ ```
126
+
127
+ Destroying an existing batch:
128
+
129
+ ```ruby
130
+ Clicksign::Batch.delete(batch_key)
131
+ ```
@@ -12,10 +12,13 @@ module Clicksign
12
12
  {}
13
13
  end
14
14
 
15
- def self.create(file)
15
+ def self.create(file, params = {})
16
+ signers = params.delete(:signers)
17
+ params['signers[]'] = [signers].flatten(1) if signers
18
+
16
19
  request :post,
17
20
  api_url('documents'),
18
- { "document[archive][original]" => file },
21
+ { "document[archive][original]" => file }.merge(params),
19
22
  {}
20
23
  end
21
24
 
@@ -1,3 +1,3 @@
1
1
  module Clicksign
2
- VERSION = '0.0.2'
2
+ VERSION = '0.1.2'
3
3
  end
@@ -28,4 +28,29 @@ describe Clicksign::Document do
28
28
  expect(record['document']['status']).to eq 'completed'
29
29
  end
30
30
  end
31
+
32
+ describe '.create' do
33
+ it 'sends document and list params' do
34
+ file = File.new('spec/fixtures/all_documents.json')
35
+ signers = { act: 'sign', email: 'john.doe@example.com' }
36
+ message = 'Sign it please.'
37
+ skip_email = false
38
+
39
+ expect(RestClient).to receive(:post)
40
+ .with(
41
+ "http://example.com/v1/documents?access_token=my_token",
42
+ {
43
+ 'document[archive][original]' => file,
44
+ message: message,
45
+ skip_email: skip_email,
46
+ 'signers[]' => [signers],
47
+ }, { accept: 'json' }).and_return({})
48
+
49
+ Clicksign::Document.create(file, {
50
+ signers: signers,
51
+ message: message,
52
+ skip_email: skip_email
53
+ })
54
+ end
55
+ end
31
56
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clicksign
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clicksign
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-28 00:00:00.000000000 Z
11
+ date: 2014-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -121,3 +121,4 @@ test_files:
121
121
  - spec/fixtures/all_documents.json
122
122
  - spec/fixtures/document.xml
123
123
  - spec/spec_helper.rb
124
+ has_rdoc: