docusign_rest 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -54,7 +54,7 @@ outputs:
54
54
  config.password = 'p@ssw0rd1'
55
55
  config.integrator_key = 'KEYS-19ddd1cc-cb56-4ca6-87ec-38db47d14b32'
56
56
  config.account_id = '123456'
57
- #config.endpoint = 'https://docusign.net'
57
+ #config.endpoint = 'https://www.docusign.net/restapi'
58
58
  #config.api_version = 'v1'
59
59
  end
60
60
 
@@ -64,7 +64,7 @@ outputs:
64
64
  There are several other configuration options available but the two most likely to be needed are:
65
65
 
66
66
  ```ruby
67
- config.endpoint = 'https://docusign.net'
67
+ config.endpoint = 'https://docusign.net/restapi'
68
68
  config.api_version = 'v1'
69
69
  ```
70
70
 
@@ -83,7 +83,11 @@ module DocusignRest
83
83
  def initialize_net_http_ssl(uri)
84
84
  http = Net::HTTP.new(uri.host, uri.port)
85
85
  http.use_ssl = true
86
+
87
+ # Explicitly verifies that the certificate matches the domain. Requires
88
+ # that we use www when calling the production DocuSign API
86
89
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER
90
+
87
91
  http
88
92
  end
89
93
 
@@ -136,36 +140,13 @@ module DocusignRest
136
140
  @acct_id
137
141
  end
138
142
 
143
+
139
144
  def check_embedded_signer(embedded, email)
140
145
  if embedded && embedded == true
141
146
  "\"clientUserId\" : \"#{email}\","
142
147
  end
143
148
  end
144
149
 
145
- # Internal: takes in an array of hashes of signers and calculates the
146
- # recipientId then concatenates all the hashes with commas
147
- #
148
- # embedded - Tells DocuSign if this is an embedded signer which determines
149
- # weather or not to deliver emails. Also lets us authenticate
150
- # them when they go to do embedded signing. Behind the scenes
151
- # this is setting the clientUserId value to the signer's email.
152
- # name - The name of the signer
153
- # email - The email of the signer
154
- #
155
- # Returns a hash of users that need to sign the document
156
- def get_signers(signers)
157
- doc_signers = []
158
- signers.each_with_index do |signer, index|
159
- doc_signers << "{
160
- #{check_embedded_signer(signer[:embedded], signer[:email])}
161
- \"name\" : \"#{signer[:name]}\",
162
- \"email\" : \"#{signer[:email]}\",
163
- \"recipientId\" : \"#{index+1}\"
164
- }"
165
- end
166
- doc_signers.join(",")
167
- end
168
-
169
150
 
170
151
  # Internal: takes in an array of hashes of signers and concatenates all the
171
152
  # hashes with commas
@@ -199,6 +180,10 @@ module DocusignRest
199
180
  # currently dynamic but that's easy to change/add which I (and I'm
200
181
  # sure others) will be doing in the future.
201
182
  #
183
+ # template - Includes other optional fields only used when
184
+ # being called from a template
185
+ # email - The signer's email
186
+ # name - The signer's name
202
187
  # embedded - Tells DocuSign if this is an embedded signer which
203
188
  # determines weather or not to deliver emails. Also
204
189
  # lets us authenticate them when they go to do
@@ -208,8 +193,6 @@ module DocusignRest
208
193
  # role_name - The signer's role, like 'Attorney' or 'Client', etc.
209
194
  # template_locked - Doesn't seem to work/do anything
210
195
  # template_required - Doesn't seem to work/do anything
211
- # email - The signer's email
212
- # name - The signer's name
213
196
  # anchor_string - The string of text to anchor the 'sign here' tab to
214
197
  # document_id - If the doc you want signed isn't the first doc in
215
198
  # the files options hash
@@ -222,31 +205,42 @@ module DocusignRest
222
205
  # currently work.
223
206
  # sign_here_tab_text - Instead of 'sign here'. Note: doesn't work
224
207
  # tab_label - TODO: figure out what this is
225
- def get_template_signers(signers)
208
+ def get_signers(signers, options={})
226
209
  doc_signers = []
227
210
  signers.each_with_index do |signer, index|
228
- doc_signers << "{
211
+ # Build up a string with concatenation so that we can append the full
212
+ # string to the doc_signers array as the last step in this block
213
+ doc_signer = ""
214
+ doc_signer << "{
215
+ \"email\":\"#{signer[:email]}\",
216
+ \"name\":\"#{signer[:name]}\",
229
217
  \"accessCode\":\"\",
230
218
  \"addAccessCodeToEmail\":false,
231
219
  #{check_embedded_signer(signer[:embedded], signer[:email])}
232
220
  \"customFields\":null,
233
221
  \"emailNotification\":#{signer[:email_notification] || 'null'},
234
- \"idCheckConfigurationName\":null,
235
- \"idCheckInformationInput\":null,
222
+ \"iDCheckConfigurationName\":null,
223
+ \"iDCheckInformationInput\":null,
236
224
  \"inheritEmailNotificationConfiguration\":false,
237
225
  \"note\":\"\",
238
226
  \"phoneAuthentication\":null,
239
- \"recipientAttachments\":null,
227
+ \"recipientAttachment\":null,
240
228
  \"recipientId\":\"#{index+1}\",
241
229
  \"requireIdLookup\":false,
242
230
  \"roleName\":\"#{signer[:role_name]}\",
243
231
  \"routingOrder\":#{index+1},
244
232
  \"socialAuthentications\":null,
245
- \"templateAccessCodeRequired\":false,
246
- \"templateLocked\":#{signer[:template_locked] || true},
247
- \"templateRequired\":#{signer[:template_required] || true},
248
- \"email\":\"#{signer[:email]}\",
249
- \"name\":\"#{signer[:name]}\",
233
+ "
234
+
235
+ if options[:template] == true
236
+ doc_signer << "
237
+ \"templateAccessCodeRequired\":false,
238
+ \"templateLocked\":#{signer[:template_locked] || true},
239
+ \"templateRequired\":#{signer[:template_required] || true},
240
+ "
241
+ end
242
+
243
+ doc_signer << "
250
244
  \"autoNavigation\":false,
251
245
  \"defaultRecipient\":false,
252
246
  \"signatureInfo\":null,
@@ -268,17 +262,23 @@ module DocusignRest
268
262
  \"signHereTabs\":[
269
263
  {
270
264
  \"anchorString\":\"#{signer[:anchor_string]}\",
271
- \"anchorXOffset\": \"#{signer[:anchor_x_offset] || 0}\",
272
- \"anchorYOffset\": \"#{signer[:anchor_y_offset] || 0}\",
273
- \"anchorIgnoreIfNotPresent\": false,
265
+ \"anchorXOffset\": \"#{signer[:anchor_x_offset] || '0'}\",
266
+ \"anchorYOffset\": \"#{signer[:anchor_y_offset] || '0'}\",
267
+ \"anchorIgnoreIfNotPresent\": #{signer[:ignore_anchor_if_not_present] || false},
274
268
  \"anchorUnits\": \"pixels\",
275
269
  \"conditionalParentLabel\": null,
276
270
  \"conditionalParentValue\": null,
277
271
  \"documentId\":\"#{signer[:document_id] || '1'}\",
278
272
  \"pageNumber\":\"#{signer[:page_number] || '1'}\",
279
273
  \"recipientId\":\"#{index+1}\",
280
- \"templateLocked\":#{signer[:template_locked] || true},
281
- \"templateRequired\":#{signer[:template_required] || true},
274
+ "
275
+ if options[:template] == true
276
+ doc_signer << "
277
+ \"templateLocked\":#{signer[:template_locked] || true},
278
+ \"templateRequired\":#{signer[:template_required] || true},
279
+ "
280
+ end
281
+ doc_signer << "
282
282
  \"xPosition\":\"#{signer[:x_position] || '0'}\",
283
283
  \"yPosition\":\"#{signer[:y_position] || '0'}\",
284
284
  \"name\":\"#{signer[:sign_here_tab_text] || 'Sign Here'}\",
@@ -294,11 +294,12 @@ module DocusignRest
294
294
  \"zipTabs\":null
295
295
  }
296
296
  }"
297
+ # append the fully build string to the array
298
+ doc_signers << doc_signer
297
299
  end
298
300
  doc_signers.join(",")
299
301
  end
300
302
 
301
-
302
303
  # Internal: sets up the file ios array
303
304
  #
304
305
  # files - a hash of file params
@@ -481,7 +482,7 @@ module DocusignRest
481
482
  # seems to override this, not sure why it needs to be
482
483
  # configured here as well. I usually leave it blank.
483
484
  # signers - An array of hashes of signers. See the
484
- # get_template_signers method definition for options.
485
+ # get_signers method definition for options.
485
486
  # description - The template description
486
487
  # name - The template name
487
488
  # headers - Optional hash of headers to merge into the existing
@@ -500,7 +501,7 @@ module DocusignRest
500
501
  \"emailSubject\" : \"#{options[:email][:subject] if options[:email]}\",
501
502
  \"documents\" : [#{get_documents(ios)}],
502
503
  \"recipients\" : {
503
- \"signers\" : [#{get_template_signers(options[:signers])}]
504
+ \"signers\" : [#{get_signers(options[:signers], template: true)}]
504
505
  },
505
506
  \"envelopeTemplateDefinition\" : {
506
507
  \"description\" : \"#{options[:description]}\",
@@ -661,8 +662,8 @@ module DocusignRest
661
662
  response = http.request(request)
662
663
 
663
664
  split_path = options[:local_save_path].split('/')
664
- split_path.pop
665
- path = split_path.join("/")
665
+ split_path.pop #removes the document name and extension from the array
666
+ path = split_path.join("/") #rejoins the array to form path to the folder that will contain the file
666
667
 
667
668
  FileUtils.mkdir_p(path)
668
669
  File.open(options[:local_save_path], 'wb') do |output|
@@ -1,3 +1,3 @@
1
1
  module DocusignRest
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -46,7 +46,7 @@ DocusignRest.configure do |config|
46
46
  config.password = '#{password}'
47
47
  config.integrator_key = '#{integrator_key}'
48
48
  config.account_id = '#{acct_id}'
49
- #config.endpoint = 'https://docusign.net'
49
+ #config.endpoint = 'https://www.docusign.net/restapi'
50
50
  #config.api_version = 'v1'
51
51
  end\n\n}
52
52
 
@@ -95,12 +95,20 @@ describe DocusignRest::Client do
95
95
  {
96
96
  embedded: true,
97
97
  name: 'Test Guy',
98
- email: 'someone@gmail.com'
98
+ email: 'testguy@gmail.com',
99
+ role_name: 'Issuer',
100
+ anchor_string: 'sign here',
101
+ anchor_x_offset: '125',
102
+ anchor_y_offset: '-12'
99
103
  },
100
104
  {
101
- #embedded: true,
105
+ embedded: true,
102
106
  name: 'Test Girl',
103
- email: 'someone+else@gmail.com'
107
+ email: 'testgirl@gmail.com',
108
+ role_name: 'Attorney',
109
+ anchor_string: 'sign here',
110
+ anchor_x_offset: '140',
111
+ anchor_y_offset: '-12'
104
112
  }
105
113
  ],
106
114
  files: [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docusign_rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-28 00:00:00.000000000 Z
12
+ date: 2012-07-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multipart-post