docusign_rest 0.0.9 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,18 +1,21 @@
1
1
  module DocusignRest
2
2
  module Configuration
3
3
  VALID_CONNECTION_KEYS = [:endpoint, :api_version, :user_agent, :method].freeze
4
- VALID_OPTIONS_KEYS = [:username, :password, :integrator_key, :account_id, :format].freeze
4
+ VALID_OPTIONS_KEYS = [:access_token, :username, :password, :integrator_key, :account_id, :format, :ca_file].freeze
5
5
  VALID_CONFIG_KEYS = VALID_CONNECTION_KEYS + VALID_OPTIONS_KEYS
6
6
 
7
7
  DEFAULT_ENDPOINT = 'https://demo.docusign.net/restapi'
8
- DEFAULT_API_VERSION = 'v1'
8
+ DEFAULT_API_VERSION = 'v2'
9
9
  DEFAULT_USER_AGENT = "DocusignRest API Ruby Gem #{DocusignRest::VERSION}".freeze
10
10
  DEFAULT_METHOD = :get
11
11
 
12
+ DEFAULT_ACCESS_TOKEN = nil
13
+
12
14
  DEFAULT_USERNAME = nil
13
15
  DEFAULT_PASSWORD = nil
14
16
  DEFAULT_INTEGRATOR_KEY = nil
15
17
  DEFAULT_ACCOUNT_ID = nil
18
+ DEFAULT_CA_FILE = nil # often found at: '/etc/ssl/certs/cert.pem'
16
19
  DEFAULT_FORMAT = :json
17
20
 
18
21
  # Build accessor methods for every config options so we can do this, for example:
@@ -29,12 +32,13 @@ module DocusignRest
29
32
  self.api_version = DEFAULT_API_VERSION
30
33
  self.user_agent = DEFAULT_USER_AGENT
31
34
  self.method = DEFAULT_METHOD
32
-
35
+ self.access_token = DEFAULT_ACCESS_TOKEN
33
36
  self.username = DEFAULT_USERNAME
34
37
  self.password = DEFAULT_PASSWORD
35
38
  self.integrator_key = DEFAULT_INTEGRATOR_KEY
36
39
  self.account_id = DEFAULT_ACCOUNT_ID
37
40
  self.format = DEFAULT_FORMAT
41
+ self.ca_file = DEFAULT_CA_FILE
38
42
  end
39
43
 
40
44
  # Allow configuration via a block
@@ -1,5 +1,4 @@
1
1
  module DocusignRest
2
-
3
2
  class Utility
4
3
  # Public takes a path to redirect to and breaks the redirect out of an iFrame
5
4
  #
@@ -35,10 +34,10 @@ module DocusignRest
35
34
  #
36
35
  # if params[:event] == "signing_complete"
37
36
  # flash[:notice] = "Thanks! Successfully signed"
38
- # render :text => utility.breakout_path(posts_path), content_type: :html
37
+ # render :text => utility.breakout_path(posts_path), content_type: 'text/html'
39
38
  # else
40
39
  # flash[:notice] = "You chose not to sign the document."
41
- # render :text => utility.breakout_path(logout_path), content_type: :html
40
+ # render :text => utility.breakout_path(logout_path), content_type: 'text/html'
42
41
  # end
43
42
  # end
44
43
  #
@@ -50,5 +49,4 @@ module DocusignRest
50
49
  "<html><body><script type='text/javascript' charset='utf-8'>parent.location.href = '#{path}';</script></body></html>"
51
50
  end
52
51
  end
53
-
54
52
  end
@@ -1,3 +1,3 @@
1
1
  module DocusignRest
2
- VERSION = "0.0.9"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -2,10 +2,17 @@ require 'multipart_post'
2
2
  require 'parts'
3
3
 
4
4
  Parts::ParamPart.class_eval do
5
- def build_part(boundary, name, value)
6
- part = "\r\n" #Add a leading carriage return line feed (not sure why DocuSign requires this)
5
+ def build_part(boundary, name, value, headers = {})
6
+ part = ""
7
7
  part << "--#{boundary}\r\n"
8
- part << "Content-Type: application/json\r\n" #Add the content type which isn't present in the multipart-post gem, but DocuSign requires
8
+
9
+ # TODO (2014-02-03) jonk => multipart-post seems to allow for adding
10
+ # a configurable header, hence the headers param in the method definition
11
+ # above. However, I can't seem to figure out how to acctually get it passed
12
+ # all the way through to line 42 of the Parts module in the parts.rb file.
13
+ # So for now, we still monkeypatch the content-type in directly.
14
+
15
+ part << "Content-Type: application/json\r\n"
9
16
  part << "Content-Disposition: form-data; name=\"#{name.to_s}\"\r\n"
10
17
  part << "\r\n"
11
18
  part << "#{value}\r\n"
@@ -0,0 +1,14 @@
1
+ # This file was generated by the docusign_rest:generate_config rake task.
2
+ # You can run 'ruby lib/tasks/docusign_task.rb' as many times as you need
3
+ # to replace the content of this file with a new config.
4
+
5
+ require_relative '../lib/docusign_rest'
6
+
7
+ DocusignRest.configure do |config|
8
+ config.username = 'jonkinney@gmail.com'
9
+ config.password = 'MnUWneAH3xqL2G'
10
+ config.integrator_key = 'NAXX-93c39e8c-36c4-4cb5-8099-c4fcedddd7ad'
11
+ config.account_id = '327367'
12
+ config.endpoint = 'https://demo.docusign.net/restapi'
13
+ config.api_version = 'v2'
14
+ end
@@ -38,6 +38,8 @@ describe DocusignRest::Client do
38
38
  :api_version => 'av',
39
39
  :user_agent => 'ua',
40
40
  :method => 'md',
41
+ :ca_file => 'ca',
42
+ :access_token => 'at'
41
43
  }
42
44
  end
43
45
 
@@ -81,7 +83,7 @@ describe DocusignRest::Client do
81
83
  end
82
84
 
83
85
  it "should allow creating an envelope from a document" do
84
- VCR.use_cassette("create_envelope/from_document", record: :all) do
86
+ VCR.use_cassette("create_envelope/from_document") do
85
87
  response = @client.create_envelope_from_document(
86
88
  email: {
87
89
  subject: "test email subject",
@@ -95,7 +97,7 @@ describe DocusignRest::Client do
95
97
  {
96
98
  embedded: true,
97
99
  name: 'Test Guy',
98
- email: 'testguy@gmail.com',
100
+ email: 'testguy@example.com',
99
101
  role_name: 'Issuer',
100
102
  sign_here_tabs: [
101
103
  {
@@ -103,12 +105,34 @@ describe DocusignRest::Client do
103
105
  anchor_x_offset: '125',
104
106
  anchor_y_offset: '-12'
105
107
  }
106
- ]
108
+ ],
109
+ list_tabs: [
110
+ {
111
+ anchor_string: 'another test',
112
+ width: '180',
113
+ height: '14',
114
+ anchor_x_offset: '10',
115
+ anchor_y_offset: '-5',
116
+ label: 'another test',
117
+ list_items: [
118
+ {
119
+ selected: false,
120
+ text: 'Option 1',
121
+ value: 'option_1'
122
+ },
123
+ {
124
+ selected: true,
125
+ text: 'Option 2',
126
+ value: 'option_2'
127
+ }
128
+ ]
129
+ }
130
+ ],
107
131
  },
108
132
  {
109
133
  embedded: true,
110
134
  name: 'Test Girl',
111
- email: 'testgirl@gmail.com',
135
+ email: 'testgirl@example.com',
112
136
  role_name: 'Attorney',
113
137
  sign_here_tabs: [
114
138
  {
@@ -125,6 +149,7 @@ describe DocusignRest::Client do
125
149
  ],
126
150
  status: 'sent'
127
151
  )
152
+
128
153
  response["status"].must_equal "sent"
129
154
  end
130
155
  end
@@ -132,7 +157,7 @@ describe DocusignRest::Client do
132
157
  describe "embedded signing" do
133
158
  before do
134
159
  # create the template dynamically
135
- VCR.use_cassette("create_template", record: :all) do
160
+ VCR.use_cassette("create_template") do
136
161
  @template_response = @client.create_template(
137
162
  description: 'Cool Description',
138
163
  name: "Cool Template Name",
@@ -140,14 +165,14 @@ describe DocusignRest::Client do
140
165
  {
141
166
  embedded: true,
142
167
  name: 'jon',
143
- email: 'someone@gmail.com',
168
+ email: 'someone@example.com',
144
169
  role_name: 'Issuer',
145
170
  sign_here_tabs: [
146
171
  {
147
172
  anchor_string: 'sign here',
148
173
  template_locked: true, #doesn't seem to do anything
149
174
  template_required: true, #doesn't seem to do anything
150
- email_notification: false #FIXME if signer is setup as 'embedded' initial email notifications don't go out, but even when I set up a signer as non-embedded this setting didn't seem to make the email notifications actually stop...
175
+ email_notification: {supportedLanguage: 'en'} #FIXME if signer is setup as 'embedded' initial email notifications don't go out, but even when I set up a signer as non-embedded this setting didn't seem to make the email notifications actually stop...
151
176
  }
152
177
  ]
153
178
  }
@@ -156,10 +181,14 @@ describe DocusignRest::Client do
156
181
  {path: 'test.pdf', name: 'test.pdf'}
157
182
  ]
158
183
  )
184
+ if ! @template_response["errorCode"].nil?
185
+ puts "[API ERROR] (create_template) errorCode: '#{@template_response["errorCode"]}', message: '#{@template_response["message"]}'"
186
+ end
159
187
  end
160
188
 
189
+
161
190
  # use the templateId to get the envelopeId
162
- VCR.use_cassette("create_envelope/from_template", record: :all) do
191
+ VCR.use_cassette("create_envelope/from_template") do
163
192
  @envelope_response = @client.create_envelope_from_template(
164
193
  status: 'sent',
165
194
  email: {
@@ -171,11 +200,21 @@ describe DocusignRest::Client do
171
200
  {
172
201
  embedded: true,
173
202
  name: 'jon',
174
- email: 'someone@gmail.com',
203
+ email: 'someone@example.com',
175
204
  role_name: 'Issuer'
176
205
  }
177
206
  ]
178
207
  )
208
+ if ! @envelope_response["errorCode"].nil?
209
+ puts "[API ERROR] (create_envelope/from_template) errorCode: '#{@envelope_response["errorCode"]}', message: '#{@envelope_response["message"]}'"
210
+ end
211
+ end
212
+ end
213
+
214
+ it "should get a template" do
215
+ VCR.use_cassette("get_template", record: :all) do
216
+ response = @client.get_template(@template_response["templateId"])
217
+ assert_equal @template_response["templateId"], response['envelopeTemplateDefinition']['templateId']
179
218
  end
180
219
  end
181
220
 
@@ -188,33 +227,32 @@ describe DocusignRest::Client do
188
227
  @envelope_response["errorCode"].must_be_nil
189
228
 
190
229
  #return the URL for embedded signing
191
- VCR.use_cassette("get_recipient_view", record: :all) do
230
+ VCR.use_cassette("get_recipient_view") do
192
231
  response = @client.get_recipient_view(
193
232
  envelope_id: @envelope_response["envelopeId"],
194
233
  name: 'jon',
195
- email: 'someone@gmail.com',
234
+ email: 'someone@example.com',
196
235
  return_url: 'http://google.com'
197
236
  )
198
- response.must_match(/http/)
237
+ response['url'].must_match(/http/)
199
238
  end
200
239
  end
201
240
 
202
241
  #status return values = "sent", "delivered", "completed"
203
242
  it "should retrieve the envelope recipients status" do
204
- VCR.use_cassette("get_envelope_recipients", record: :all) do
243
+ VCR.use_cassette("get_envelope_recipients") do
205
244
  response = @client.get_envelope_recipients(
206
245
  envelope_id: @envelope_response["envelopeId"],
207
246
  include_tabs: true,
208
247
  include_extended: true
209
248
  )
210
249
  response["signers"].wont_be_nil
211
- #puts response["signers"]
212
250
  end
213
251
  end
214
252
 
215
253
  #status return values = "sent", "delivered", "completed"
216
254
  it "should retrieve the byte stream of the envelope doc from DocuSign" do
217
- VCR.use_cassette("get_document_from_envelope", record: :all) do
255
+ VCR.use_cassette("get_document_from_envelope") do
218
256
  @client.get_document_from_envelope(
219
257
  envelope_id: @envelope_response["envelopeId"],
220
258
  document_id: 1,
@@ -223,9 +261,6 @@ describe DocusignRest::Client do
223
261
  # NOTE manually check that this file has the content you'd expect
224
262
  end
225
263
  end
226
-
227
264
  end
228
-
229
265
  end
230
-
231
266
  end
@@ -1,4 +1,4 @@
1
- require 'helper'
1
+ require_relative '../helper'
2
2
 
3
3
  describe 'configuration' do
4
4
  after do
data/test/helper.rb CHANGED
@@ -1,12 +1,14 @@
1
- require 'docusign_rest'
1
+ require_relative '../lib/docusign_rest'
2
2
  require 'minitest/spec'
3
3
  require 'minitest/autorun'
4
4
  require 'turn'
5
5
  require 'json'
6
6
  require 'vcr'
7
- require 'docusign_login_config'
7
+ require_relative 'docusign_login_config'
8
+ require 'pry'
8
9
 
9
10
  VCR.configure do |c|
10
11
  c.cassette_library_dir = "test/fixtures/vcr"
11
12
  c.hook_into :fakeweb
13
+ c.default_cassette_options = { record: :all }
12
14
  end
metadata CHANGED
@@ -1,142 +1,153 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docusign_rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
5
- prerelease:
4
+ version: 0.1.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jon Kinney
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-07-09 00:00:00.000000000 Z
11
+ date: 2014-02-03 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: multipart-post
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
- version: 1.1.5
19
+ version: '1.2'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
- version: 1.1.5
26
+ version: '1.2'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: json
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rake
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: minitest
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '4.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '4.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard-minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
68
74
  - !ruby/object:Gem::Version
69
75
  version: '0'
70
76
  type: :development
71
77
  prerelease: false
72
78
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
79
  requirements:
75
- - - ! '>='
80
+ - - '>='
76
81
  - !ruby/object:Gem::Version
77
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rb-fsevent
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '0.9'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '0.9'
78
97
  - !ruby/object:Gem::Dependency
79
98
  name: turn
80
99
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
100
  requirements:
83
- - - ! '>='
101
+ - - '>='
84
102
  - !ruby/object:Gem::Version
85
103
  version: '0'
86
104
  type: :development
87
105
  prerelease: false
88
106
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
107
  requirements:
91
- - - ! '>='
108
+ - - '>='
92
109
  - !ruby/object:Gem::Version
93
110
  version: '0'
94
111
  - !ruby/object:Gem::Dependency
95
112
  name: pry
96
113
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
114
  requirements:
99
- - - ! '>='
115
+ - - '>='
100
116
  - !ruby/object:Gem::Version
101
117
  version: '0'
102
118
  type: :development
103
119
  prerelease: false
104
120
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
121
  requirements:
107
- - - ! '>='
122
+ - - '>='
108
123
  - !ruby/object:Gem::Version
109
124
  version: '0'
110
125
  - !ruby/object:Gem::Dependency
111
126
  name: vcr
112
127
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
128
  requirements:
115
- - - ! '>='
129
+ - - '>='
116
130
  - !ruby/object:Gem::Version
117
131
  version: '0'
118
132
  type: :development
119
133
  prerelease: false
120
134
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
135
  requirements:
123
- - - ! '>='
136
+ - - '>='
124
137
  - !ruby/object:Gem::Version
125
138
  version: '0'
126
139
  - !ruby/object:Gem::Dependency
127
140
  name: fakeweb
128
141
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
142
  requirements:
131
- - - ! '>='
143
+ - - '>='
132
144
  - !ruby/object:Gem::Version
133
145
  version: '0'
134
146
  type: :development
135
147
  prerelease: false
136
148
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
149
  requirements:
139
- - - ! '>='
150
+ - - '>='
140
151
  - !ruby/object:Gem::Version
141
152
  version: '0'
142
153
  description: Hooks a Rails app up to the DocuSign service through the DocuSign REST
@@ -149,11 +160,14 @@ extra_rdoc_files: []
149
160
  files:
150
161
  - .gitignore
151
162
  - Gemfile
163
+ - Guardfile
152
164
  - LICENSE
153
165
  - README.md
154
166
  - Rakefile
167
+ - cacert.pem
155
168
  - docusign_rest.gemspec
156
- - example.rb
169
+ - examples/request_via_gem.rb
170
+ - examples/request_via_raw_net_http.rb
157
171
  - lib/docusign_rest.rb
158
172
  - lib/docusign_rest/client.rb
159
173
  - lib/docusign_rest/configuration.rb
@@ -164,37 +178,38 @@ files:
164
178
  - lib/tasks/docusign_task.rake
165
179
  - lib/tasks/docusign_task.rb
166
180
  - test.pdf
181
+ - test/docusign_login_config.rb
167
182
  - test/docusign_rest/client_test.rb
168
183
  - test/docusign_rest/configuration_test.rb
169
184
  - test/docusign_rest/docusign_rest_test.rb
170
185
  - test/helper.rb
171
186
  - test2.pdf
172
- homepage: https://github.com/j2fly/docusign_rest
187
+ homepage: https://github.com/jondkinney/docusign_rest
173
188
  licenses: []
189
+ metadata: {}
174
190
  post_install_message:
175
191
  rdoc_options: []
176
192
  require_paths:
177
193
  - lib
178
194
  required_ruby_version: !ruby/object:Gem::Requirement
179
- none: false
180
195
  requirements:
181
- - - ! '>='
196
+ - - '>='
182
197
  - !ruby/object:Gem::Version
183
- version: '0'
198
+ version: 1.9.2
184
199
  required_rubygems_version: !ruby/object:Gem::Requirement
185
- none: false
186
200
  requirements:
187
- - - ! '>='
201
+ - - '>='
188
202
  - !ruby/object:Gem::Version
189
203
  version: '0'
190
204
  requirements: []
191
205
  rubyforge_project:
192
- rubygems_version: 1.8.24
206
+ rubygems_version: 2.0.6
193
207
  signing_key:
194
- specification_version: 3
208
+ specification_version: 4
195
209
  summary: Use this gem to embed signing of documents in a Rails app through the DocuSign
196
210
  REST API
197
211
  test_files:
212
+ - test/docusign_login_config.rb
198
213
  - test/docusign_rest/client_test.rb
199
214
  - test/docusign_rest/configuration_test.rb
200
215
  - test/docusign_rest/docusign_rest_test.rb