signnow 0.0.3 → 0.0.5
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.
- data/lib/signnow.rb +107 -20
- metadata +17 -1
data/lib/signnow.rb
CHANGED
@@ -1,44 +1,131 @@
|
|
1
|
+
# This gem is not officially provided by SignNow.com. This gem was created by Mike Simmons.
|
2
|
+
# Official documentaion to the SignNow API is availalbe at
|
3
|
+
# https://signnow.atlassian.net/wiki/dashboard.action
|
4
|
+
# Ruby implemntation of the SignNow API
|
5
|
+
#
|
6
|
+
# [Important Notes:]
|
7
|
+
# Before you can use the SignNow API you have to recieve an API key (encoded_client_credentials) from SignNow.
|
8
|
+
#
|
9
|
+
# Get Your key at http://developers.signnow.com/
|
10
|
+
#
|
11
|
+
# [Example:]
|
12
|
+
# > require 'signnow'
|
13
|
+
#
|
14
|
+
# > r = \Signnow.create_user(YOUR_ENCODED_CLIENT_CREDENTIALS, 'first', 'last', 'a1@xyz.com', 'password')
|
15
|
+
#
|
16
|
+
# <HTTParty::Response:0x7fff240525c8 parsed_response={"expires_in"=>2592000, "token_type"=>"bearer", "access_token"=>"7e36842d6d3494877f6ff0fbbb131fcf04134c6cf0d9581b9bf13f6ac4f2a69a", "refresh_token"=>"92554b4fe792313bdf604f362ca4373d8d390b00acb6cbfb949bc4b619448654", "scope"=>"*", "id"=>"05a309627dd45114c9b874f2479b4335bb010835"}, @response=#<Net::HTTPOK 200 OK readbody=true>, @headers={"date"=>["Tue, 28 May 2013 02:10:12 GMT"], "server"=>["Apache/2.2.15 (CentOS)"], "x-powered-by"=>["PHP/5.3.3"], "access-control-allow-origin"=>["*"], "access-control-allow-headers"=>["Authorization"], "content-type"=>["application/json; charset=utf-8"], "set-cookie"=>["admin=lee56sfigb3cs0fk484sr3ci26; expires=Tue, 28-May-2013 03:10:12 GMT; path=/"], "connection"=>["close"], "transfer-encoding"=>["chunked"]}> </tt>
|
17
|
+
#
|
18
|
+
# > r.keys
|
19
|
+
# \=> ["expires_in", "token_type", "access_token", "refresh_token", "scope", "id"]
|
20
|
+
#
|
21
|
+
# > r.values
|
22
|
+
# \=> [2592000, "bearer", "1553698ece6e803886db1416bd043f9cd6ab79285620f3ed8f4ef1292c334745", "9bf640a692c4c1b6be34d9f28522344e8c902305e0e403ab65797d6f682f62a6", "*", "18fd5850a48b2433429c0dca832a7ed3faf604d0"]
|
23
|
+
#
|
24
|
+
# \>> \r["access_token"]
|
25
|
+
#
|
26
|
+
# \=> "7e36842d6d3494877f6ff0fbbb131fcf04134c6cf0d9581b9bf13f6ac4f2a69a"
|
27
|
+
|
28
|
+
|
1
29
|
class Signnow
|
2
|
-
|
30
|
+
|
31
|
+
require 'httmultiparty'
|
32
|
+
include HTTMultiParty
|
33
|
+
|
3
34
|
ssl_version :SSLv3
|
4
35
|
base_uri "https://capi-eval.signnow.com/api"
|
5
|
-
headers "Authorization" => "Basic MGZjY2RiYzczNTgxY2EwZjliZjhjMzc5ZTZhOTY4MTM6MzcxOWExMjRiY2ZjMDNjNTM0ZDRmNWMwNWI1YTE5NmI="
|
6
|
-
|
7
|
-
def initialize ()
|
8
|
-
end
|
9
36
|
|
10
|
-
|
11
|
-
|
37
|
+
# creates a new user by ENCODED_CLIENT_CREDENTIALS
|
38
|
+
# (encoded_client_credentials, first_name, last_name, email, password='basicpass')
|
39
|
+
# --- if no password is specified "basicpass" will be used
|
40
|
+
|
41
|
+
def self.create_user(encoded_client_credentials, first_name, last_name, email, password='basicpass')
|
42
|
+
self.headers "Authorization" => "Basic " + encoded_client_credentials
|
43
|
+
response = post("/user", :body => "{\"first_name\":\"#{first_name}\",\"last_name\":\"#{last_name}\",\"email\":\"#{email}\",\"password\":\"#{password}\"}")
|
12
44
|
return response
|
13
45
|
end
|
14
46
|
|
15
|
-
|
16
|
-
|
17
|
-
|
47
|
+
# creates a new user by an access_token
|
48
|
+
# (access_token, first_name, last_name, email, password='basicpass')
|
49
|
+
# --- if no password is specified "basicpass" will be used
|
50
|
+
|
51
|
+
def self.create_referenced_user (access_token, first_name, last_name, email, password='basicpass')
|
52
|
+
#creates a new user by an access_token
|
53
|
+
self.headers "Authorization" => "Bearer " + access_token
|
54
|
+
response = post("/user", :body => "{\"first_name\":\"#{first_name}\",\"last_name\":\"#{last_name}\",\"email\":\"#{email}\",\"password\":\"#{password}\"}")
|
18
55
|
return response
|
19
56
|
end
|
20
57
|
|
21
|
-
|
22
|
-
|
23
|
-
|
58
|
+
# Request an access token for a user
|
59
|
+
# (encoded_client_credentials, user_email, password)
|
60
|
+
def self.request_token (encoded_client_credentials, user_email, password)
|
61
|
+
self.headers "Authorization" => "Basic " + encoded_client_credentials
|
62
|
+
response = post("/oauth2/token", :body =>"username=#{user_email}&password=#{password}&grant_type=password")
|
63
|
+
return response
|
64
|
+
end
|
65
|
+
|
66
|
+
# Verify an access token for a user
|
67
|
+
# (access_token)
|
68
|
+
def self.verify_token(access_token)
|
69
|
+
self.headers "Authorization" => "Bearer " + access_token
|
70
|
+
response = get('/oauth2/token')
|
24
71
|
return response
|
25
72
|
end
|
26
73
|
|
27
|
-
|
28
|
-
|
74
|
+
# Retrieve a user resource
|
75
|
+
# (access_token)
|
76
|
+
def self.retrieve_user(access_token)
|
77
|
+
self.headers "Authorization" => "Bearer " + access_token
|
78
|
+
response = get('/user')
|
79
|
+
return response
|
80
|
+
end
|
81
|
+
|
82
|
+
# Uploads a file
|
83
|
+
# (access_token, file)
|
84
|
+
def self.create_document (access_token, file)
|
85
|
+
self.headers "Authorization" => "Bearer " + access_token
|
29
86
|
response = post("/document", :body => {:file => File.new(file)})
|
30
87
|
return response
|
31
88
|
end
|
32
89
|
|
33
|
-
|
34
|
-
|
35
|
-
|
90
|
+
|
91
|
+
# Retrieve a list of the user’s documents
|
92
|
+
# (access_token)
|
93
|
+
def self.get_file_list(access_token)
|
94
|
+
self.headers "Authorization" => "Bearer " + access_token
|
95
|
+
response = get("/user/documentsv2")
|
36
96
|
return response
|
37
97
|
end
|
38
|
-
|
39
|
-
|
98
|
+
|
99
|
+
# Retrieve a document resource
|
100
|
+
# (access_token, document_id)
|
101
|
+
def self.get_document(access_token, document_id)
|
102
|
+
self.headers "Authorization" => "Bearer " + access_token
|
103
|
+
response = get("/document/#{document_id}")
|
104
|
+
end
|
105
|
+
|
106
|
+
# Download a document
|
107
|
+
# (access_token, document_id)
|
108
|
+
def self.download_document(access_token, document_id)
|
109
|
+
self.headers "Authorization" => "Bearer " + access_token
|
110
|
+
response = get("/document/#{document_id}/download?type=collapsed")
|
111
|
+
return response
|
112
|
+
end
|
113
|
+
|
114
|
+
# Create an invite to sign a document
|
115
|
+
# (access_token, from_email, to_email, document_id)
|
116
|
+
def self.invite_signer(access_token, from_email, to_email, document_id)
|
117
|
+
self.headers "Authorization" => "Bearer " + access_token
|
40
118
|
response = post("/document/#{document_id}/invite", :body => "{\"from\":\"#{from_email}\",\"to\":\"#{to_email}\"}")
|
41
119
|
return response
|
42
120
|
end
|
43
121
|
|
122
|
+
# Create a notary invite to sign a document
|
123
|
+
# (access_token, from_email, to_email, document_id, originator_pay=true)
|
124
|
+
|
125
|
+
def self.invite_notary(access_token, from_email, to_email, document_id, originator_pay=true)
|
126
|
+
self.headers "Authorization" => "Bearer " + access_token
|
127
|
+
response = post("/notaryinvite", :body => "{\"from\":\"#{from_email}\",\"to\":\"#{to_email}\",\"document_id\":\"#{document_id}\",\"originator_pay\":#{originator_pay}}")
|
128
|
+
return response
|
129
|
+
end
|
130
|
+
|
44
131
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: signnow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 0.3.10
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: httmultiparty
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 0.3.10
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.3.10
|
30
46
|
description: A ruby implementation of the signnow API
|
31
47
|
email: nearmars@gmail.com
|
32
48
|
executables: []
|