groupdocs 1.2.9 → 1.2.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -25,7 +25,7 @@ module GroupDocs
25
25
  # end
26
26
  #
27
27
  # @param [Hash] options
28
- # @option options [Symbol] :method HTTP method. One of :GET, :DOWNLOAD, :POST, :PUT or :DELETE.
28
+ # @option options [Symbol, String] :method HTTP method. One of :GET, :DOWNLOAD, :POST, :PUT or :DELETE.
29
29
  # @option options [String] :path Path to send request to
30
30
  # @option options [Hash] :headers Additional HTTP headers
31
31
  # @option options [Hash] :access Access credentials hash
@@ -814,7 +814,7 @@ module GroupDocs
814
814
  # @return [Array<Symbol>]
815
815
  #
816
816
  def set_shared_link_access_rights!(rights, access = {})
817
- json = Api::Request.new do |request|
817
+ Api::Request.new do |request|
818
818
  request[:access] = access
819
819
  request[:method] = :PUT
820
820
  request[:path] = "/ant/{{client_id}}/files/#{file.guid}/sharedLinkAccessRights"
@@ -822,6 +822,23 @@ module GroupDocs
822
822
  end.execute!
823
823
  end
824
824
 
825
+ #
826
+ # Sets session callback URL.
827
+ #
828
+ # @param [String] url Callback URL
829
+ # @param [Hash] access Access credentials
830
+ # @option access [String] :client_id
831
+ # @option access [String] :private_key
832
+ #
833
+ def set_session_callback!(url, access = {})
834
+ Api::Request.new do |request|
835
+ request[:access] = access
836
+ request[:method] = :PUT
837
+ request[:path] = "/ant/{{client_id}}/files/#{file.guid}/sessionCallbackUrl"
838
+ request[:request_body] = url
839
+ end.execute!
840
+ end
841
+
825
842
  #
826
843
  # Pass all unknown methods to file.
827
844
  #
@@ -156,12 +156,12 @@ module GroupDocs
156
156
  end
157
157
 
158
158
  #
159
- # Returns an array of documents associated to job.
159
+ # Returns an hash of input and output documents associated to job.
160
160
  #
161
161
  # @param [Hash] access Access credentials
162
162
  # @option access [String] :client_id
163
163
  # @option access [String] :private_key
164
- # @return [Array<GroupDocs::Document>]
164
+ # @return [Hash]
165
165
  #
166
166
  def documents!(access = {})
167
167
  json = Api::Request.new do |request|
@@ -171,14 +171,28 @@ module GroupDocs
171
171
  end.execute!
172
172
 
173
173
  self.status = json[:job_status]
174
+ documents = {
175
+ inputs: [],
176
+ outputs: [],
177
+ }
178
+
179
+ # add input documents
174
180
  if json[:inputs]
175
- json[:inputs].map do |document|
181
+ json[:inputs].each do |document|
176
182
  document.merge!(file: GroupDocs::Storage::File.new(document))
177
- Document.new(document)
183
+ documents[:inputs] << Document.new(document)
178
184
  end
179
- else
180
- []
181
185
  end
186
+
187
+ # add output documents
188
+ if json[:outputs]
189
+ json[:outputs].each do |document|
190
+ document.merge!(file: GroupDocs::Storage::File.new(document))
191
+ documents[:outputs] << Document.new(document)
192
+ end
193
+ end
194
+
195
+ documents
182
196
  end
183
197
 
184
198
  #
@@ -1,3 +1,3 @@
1
1
  module GroupDocs
2
- VERSION = '1.2.9'
2
+ VERSION = '1.2.10'
3
3
  end # GroupDocs
@@ -770,6 +770,18 @@ describe GroupDocs::Document do
770
770
  end
771
771
  end
772
772
 
773
+ describe '#set_session_callback!' do
774
+ before(:each) do
775
+ mock_api_server('{ "status": "Ok", "result": {}}')
776
+ end
777
+
778
+ it 'accepts access credentials hash' do
779
+ lambda do
780
+ subject.set_session_callback!('http://www.example.com', client_id: 'client_id', private_key: 'private_key')
781
+ end.should_not raise_error(ArgumentError)
782
+ end
783
+ end
784
+
773
785
  describe '#method_missing' do
774
786
  it 'passes unknown methods to file object' do
775
787
  -> { subject.name }.should_not raise_error(NoMethodError)
@@ -151,17 +151,29 @@ describe GroupDocs::Job do
151
151
  subject.status.should == :archived
152
152
  end
153
153
 
154
- it 'returns array of GroupDocs::Document objects' do
155
- documents = subject.documents!
154
+ it 'returns hash' do
155
+ subject.documents!.should be_a(Hash)
156
+ end
157
+
158
+ it 'returns array of input documents' do
159
+ documents = subject.documents![:inputs]
160
+ documents.should be_an(Array)
161
+ documents.each do |document|
162
+ document.should be_a(GroupDocs::Document)
163
+ end
164
+ end
165
+
166
+ it 'returns array of output documents' do
167
+ documents = subject.documents![:outputs]
156
168
  documents.should be_an(Array)
157
169
  documents.each do |document|
158
170
  document.should be_a(GroupDocs::Document)
159
171
  end
160
172
  end
161
173
 
162
- it 'returns empty array if null is returned instead of inputs array' do
174
+ it 'returns empty arrays if there are no documents' do
163
175
  mock_api_server('{ "status": "Ok", "result": {}}')
164
- subject.documents!.should be_empty
176
+ subject.documents!.should == { inputs: [], outputs: [] }
165
177
  end
166
178
  end
167
179
 
@@ -32,7 +32,8 @@
32
32
  ],
33
33
  "id": 345
34
34
  }
35
- ]
35
+ ],
36
+ "outputs": null
36
37
  },
37
38
  "status": "Ok",
38
39
  "error_message": null
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.9
4
+ version: 1.2.10
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-02-11 00:00:00.000000000 Z
12
+ date: 2013-02-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -462,7 +462,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
462
462
  version: '0'
463
463
  segments:
464
464
  - 0
465
- hash: -3701528332984987950
465
+ hash: -4205405145410109468
466
466
  required_rubygems_version: !ruby/object:Gem::Requirement
467
467
  none: false
468
468
  requirements:
@@ -471,7 +471,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
471
471
  version: '0'
472
472
  segments:
473
473
  - 0
474
- hash: -3701528332984987950
474
+ hash: -4205405145410109468
475
475
  requirements: []
476
476
  rubyforge_project:
477
477
  rubygems_version: 1.8.24