groupdocs 1.2.3 → 1.2.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -327,15 +327,20 @@ module GroupDocs
327
327
  #
328
328
  # Sends envelope.
329
329
  #
330
+ # @param [String] webhook URL to be hooked after envelope is completed
330
331
  # @param [Hash] access Access credentials
331
332
  # @option access [String] :client_id
332
333
  # @option access [String] :private_key
333
334
  #
334
- def send!(access = {})
335
+ def send!(webhook = nil, access = {})
335
336
  Api::Request.new do |request|
336
337
  request[:access] = access
337
338
  request[:method] = :PUT
338
339
  request[:path] = "/signature/{{client_id}}/envelopes/#{id}/send"
340
+ if webhook
341
+ request[:request_body] = webhook
342
+ request[:plain] = true
343
+ end
339
344
  end.execute!
340
345
  end
341
346
 
@@ -72,6 +72,8 @@ module GroupDocs
72
72
  # @param [GroupDocs::Signature::Field] field
73
73
  # @param [GroupDocs::Document] document
74
74
  # @param [GroupDocs::Signature::Recipient] recipient
75
+ # @param [Hash] options
76
+ # @option options [Boolean] :force_new_field Set to true to force new field create
75
77
  # @param [Hash] access Access credentials
76
78
  # @option access [String] :client_id
77
79
  # @option access [String] :private_key
@@ -80,7 +82,7 @@ module GroupDocs
80
82
  # @raise [ArgumentError] if recipient is not GroupDocs::Signature::Recipient
81
83
  # @raise [ArgumentError] if field does not specify location
82
84
  #
83
- def add_field!(field, document, recipient, access = {})
85
+ def add_field!(field, document, recipient, opts = {}, access = {})
84
86
  field.is_a?(GroupDocs::Signature::Field) or raise ArgumentError,
85
87
  "Field should be GroupDocs::Signature::Field object, received: #{field.inspect}"
86
88
  document.is_a?(GroupDocs::Document) or raise ArgumentError,
@@ -90,9 +92,10 @@ module GroupDocs
90
92
  field.location or raise ArgumentError,
91
93
  "You have to specify field location, received: #{field.location.inspect}"
92
94
 
95
+ opts[:force_new_field] = true if opts[:force_new_field].nil?
93
96
  payload = field.to_hash # field itself
94
97
  payload.merge!(field.location.to_hash) # location should added in plain view (i.e. not "location": {...})
95
- payload.merge!(forceNewField: true) # create new field flag
98
+ payload.merge!(forceNewField: opts[:force_new_field]) # create new field flag
96
99
 
97
100
  Api::Request.new do |request|
98
101
  request[:access] = access
@@ -1,3 +1,3 @@
1
1
  module GroupDocs
2
- VERSION = '1.2.3'
2
+ VERSION = '1.2.6'
3
3
  end # GroupDocs
@@ -257,9 +257,13 @@ describe GroupDocs::Signature::Envelope do
257
257
 
258
258
  it 'accepts access credentials hash' do
259
259
  lambda do
260
- subject.send!(client_id: 'client_id', private_key: 'private_key')
260
+ subject.send!(nil, client_id: 'client_id', private_key: 'private_key')
261
261
  end.should_not raise_error(ArgumentError)
262
262
  end
263
+
264
+ it 'accepts webhook callback URL and sends it as plain text' do
265
+ subject.send! 'http://mywebsite.com'
266
+ end
263
267
  end
264
268
 
265
269
  describe '#archive!' do
@@ -42,7 +42,7 @@ shared_examples_for GroupDocs::Signature::FieldMethods do
42
42
 
43
43
  it 'accepts access credentials hash' do
44
44
  lambda do
45
- subject.add_field!(field, document, recipient, client_id: 'client_id', private_key: 'private_key')
45
+ subject.add_field!(field, document, recipient, { force_new_field: false }, client_id: 'client_id', private_key: 'private_key')
46
46
  end.should_not raise_error(ArgumentError)
47
47
  end
48
48
 
@@ -63,7 +63,7 @@ shared_examples_for GroupDocs::Signature::FieldMethods do
63
63
  -> { subject.add_field!(field, document, recipient) }.should raise_error(ArgumentError)
64
64
  end
65
65
 
66
- it 'uses field, field location and forcedNewField flag as payload' do
66
+ it 'uses field and field locationas payload' do
67
67
  hash_one = {}
68
68
  payload = {}
69
69
  location = {}
@@ -73,6 +73,17 @@ shared_examples_for GroupDocs::Signature::FieldMethods do
73
73
  payload.should_receive(:merge!).with(forceNewField: true).and_return({})
74
74
  subject.add_field!(field, document, recipient)
75
75
  end
76
+
77
+ it 'allows overriding force new field flag' do
78
+ hash_one = {}
79
+ payload = {}
80
+ location = {}
81
+ field.should_receive(:to_hash).and_return(payload)
82
+ field.location.should_receive(:to_hash).and_return(location)
83
+ payload.should_receive(:merge!).with(location).and_return(payload)
84
+ payload.should_receive(:merge!).with(forceNewField: false).and_return({})
85
+ subject.add_field!(field, document, recipient, force_new_field: false)
86
+ end
76
87
  end
77
88
 
78
89
  describe '#modify_field!' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: groupdocs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.6
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: 2013-01-17 00:00:00.000000000 Z
12
+ date: 2013-02-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -422,7 +422,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
422
422
  version: '0'
423
423
  segments:
424
424
  - 0
425
- hash: 568401921435177902
425
+ hash: -3953683120914117386
426
426
  required_rubygems_version: !ruby/object:Gem::Requirement
427
427
  none: false
428
428
  requirements:
@@ -431,7 +431,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
431
431
  version: '0'
432
432
  segments:
433
433
  - 0
434
- hash: 568401921435177902
434
+ hash: -3953683120914117386
435
435
  requirements: []
436
436
  rubyforge_project:
437
437
  rubygems_version: 1.8.24