groupdocs 1.5.7 → 1.5.8
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/CHANGELOG.md +51 -0
- data/examples/api-samples/Gemfile +1 -1
- data/examples/api-samples/Gemfile.lock +43 -0
- data/examples/api-samples/public/docs/{sample2.html → sample01.html} +39 -19
- data/examples/api-samples/public/docs/{sample3.html → sample02.html} +28 -22
- data/examples/api-samples/public/docs/sample03.html +285 -0
- data/examples/api-samples/public/docs/{sample4.html → sample04.html} +30 -36
- data/examples/api-samples/public/docs/{sample5.html → sample05.html} +68 -31
- data/examples/api-samples/public/docs/sample06.html +299 -0
- data/examples/api-samples/public/docs/{sample7.html → sample07.html} +53 -18
- data/examples/api-samples/public/docs/{sample8.html → sample08.html} +64 -41
- data/examples/api-samples/public/docs/sample09.html +260 -0
- data/examples/api-samples/public/docs/sample10.html +67 -28
- data/examples/api-samples/public/docs/sample11.html +171 -55
- data/examples/api-samples/public/docs/sample12.html +53 -17
- data/examples/api-samples/public/docs/sample13.html +52 -16
- data/examples/api-samples/public/docs/sample14.html +51 -8
- data/examples/api-samples/public/docs/sample15.html +46 -10
- data/examples/api-samples/public/docs/sample16.html +81 -7
- data/examples/api-samples/public/docs/sample17.html +103 -15
- data/examples/api-samples/public/docs/sample18.html +117 -41
- data/examples/api-samples/public/docs/sample19.html +410 -36
- data/examples/api-samples/public/docs/sample20.html +46 -10
- data/examples/api-samples/public/docs/sample21.html +504 -45
- data/examples/api-samples/public/docs/sample22.html +166 -28
- data/examples/api-samples/public/docs/sample23.html +61 -25
- data/examples/api-samples/public/docs/sample24.html +100 -12
- data/examples/api-samples/public/docs/sample25.html +123 -49
- data/examples/api-samples/public/docs/sample26.html +41 -8
- data/examples/api-samples/public/docs/sample27.html +125 -50
- data/examples/api-samples/public/docs/sample28.html +27 -9
- data/examples/api-samples/public/docs/sample29.html +10 -10
- data/examples/api-samples/public/docs/sample30.html +70 -14
- data/examples/api-samples/public/docs/sample31.html +108 -67
- data/examples/api-samples/public/docs/sample32.html +71 -99
- data/examples/api-samples/public/docs/sample33.html +107 -32
- data/examples/api-samples/public/docs/{sample1.html → sample34.html} +58 -18
- data/examples/api-samples/public/docs/sample35.html +666 -0
- data/examples/api-samples/public/docs/{sample6.html → sample36.html} +56 -37
- data/examples/api-samples/public/docs/sample37.html +815 -0
- data/examples/api-samples/public/docs/sample38.html +508 -0
- data/examples/api-samples/public/docs/sample39.html +921 -0
- data/examples/api-samples/public/docs/sample40.html +510 -0
- data/examples/api-samples/public/docs/sample41.html +452 -0
- data/examples/api-samples/public/docs/sample42.html +311 -0
- data/examples/api-samples/public/templates/test_all_fields2.pdf +0 -0
- data/examples/api-samples/samples/sample01.rb +37 -0
- data/examples/api-samples/samples/sample02.rb +41 -0
- data/examples/api-samples/samples/sample03.rb +73 -0
- data/examples/api-samples/samples/sample04.rb +47 -0
- data/examples/api-samples/samples/{sample5.rb → sample05.rb} +26 -14
- data/examples/api-samples/samples/sample06.rb +80 -0
- data/examples/api-samples/samples/sample07.rb +52 -0
- data/examples/api-samples/samples/sample08.rb +69 -0
- data/examples/api-samples/samples/sample09.rb +83 -0
- data/examples/api-samples/samples/sample10.rb +29 -15
- data/examples/api-samples/samples/sample11.rb +89 -37
- data/examples/api-samples/samples/sample12.rb +22 -11
- data/examples/api-samples/samples/sample13.rb +22 -10
- data/examples/api-samples/samples/sample14.rb +23 -5
- data/examples/api-samples/samples/sample15.rb +18 -7
- data/examples/api-samples/samples/sample16.rb +28 -4
- data/examples/api-samples/samples/sample17.rb +31 -5
- data/examples/api-samples/samples/sample18.rb +36 -8
- data/examples/api-samples/samples/sample19.rb +138 -18
- data/examples/api-samples/samples/sample20.rb +14 -3
- data/examples/api-samples/samples/sample21.rb +162 -23
- data/examples/api-samples/samples/sample22.rb +73 -22
- data/examples/api-samples/samples/sample23.rb +17 -6
- data/examples/api-samples/samples/sample24.rb +34 -7
- data/examples/api-samples/samples/sample25.rb +37 -12
- data/examples/api-samples/samples/sample26.rb +12 -5
- data/examples/api-samples/samples/sample27.rb +38 -12
- data/examples/api-samples/samples/sample28.rb +25 -6
- data/examples/api-samples/samples/sample29.rb +12 -12
- data/examples/api-samples/samples/sample30.rb +27 -15
- data/examples/api-samples/samples/sample31.rb +44 -33
- data/examples/api-samples/samples/sample32.rb +43 -41
- data/examples/api-samples/samples/sample33.rb +42 -14
- data/examples/api-samples/samples/sample34.rb +40 -0
- data/examples/api-samples/samples/sample35.rb +224 -0
- data/examples/api-samples/samples/sample36.rb +58 -0
- data/examples/api-samples/samples/sample37.rb +229 -0
- data/examples/api-samples/samples/sample38.rb +128 -0
- data/examples/api-samples/samples/sample39.rb +252 -0
- data/examples/api-samples/samples/sample40.rb +164 -0
- data/examples/api-samples/samples/sample41.rb +118 -0
- data/examples/api-samples/samples/sample42.rb +97 -0
- data/examples/api-samples/views/_others_samples.haml +25 -11
- data/examples/api-samples/views/index.haml +23 -11
- data/examples/api-samples/views/popup.haml +32 -0
- data/examples/api-samples/views/{sample1.haml → sample01.haml} +12 -7
- data/examples/api-samples/views/{sample2.haml → sample02.haml} +20 -15
- data/examples/api-samples/views/sample03.haml +83 -0
- data/examples/api-samples/views/sample04.haml +49 -0
- data/examples/api-samples/views/{sample5.haml → sample05.haml} +19 -14
- data/examples/api-samples/views/sample06.haml +53 -0
- data/examples/api-samples/views/sample07.haml +47 -0
- data/examples/api-samples/views/{sample8.haml → sample08.haml} +17 -12
- data/examples/api-samples/views/{sample9.haml → sample09.haml} +19 -4
- data/examples/api-samples/views/sample10.haml +18 -13
- data/examples/api-samples/views/sample11.haml +48 -19
- data/examples/api-samples/views/sample12.haml +26 -21
- data/examples/api-samples/views/sample13.haml +18 -12
- data/examples/api-samples/views/sample14.haml +21 -15
- data/examples/api-samples/views/sample15.haml +16 -9
- data/examples/api-samples/views/sample16.haml +18 -5
- data/examples/api-samples/views/sample17.haml +14 -9
- data/examples/api-samples/views/sample18.haml +13 -7
- data/examples/api-samples/views/sample19.haml +37 -8
- data/examples/api-samples/views/sample20.haml +13 -8
- data/examples/api-samples/views/sample21.haml +71 -13
- data/examples/api-samples/views/sample22.haml +53 -16
- data/examples/api-samples/views/sample23.haml +9 -4
- data/examples/api-samples/views/sample24.haml +9 -4
- data/examples/api-samples/views/sample25.haml +18 -13
- data/examples/api-samples/views/sample26.haml +8 -3
- data/examples/api-samples/views/sample27.haml +20 -14
- data/examples/api-samples/views/sample28.haml +16 -10
- data/examples/api-samples/views/sample29.haml +4 -4
- data/examples/api-samples/views/sample30.haml +16 -10
- data/examples/api-samples/views/sample31.haml +39 -32
- data/examples/api-samples/views/sample32.haml +25 -36
- data/examples/api-samples/views/sample33.haml +14 -17
- data/examples/api-samples/views/sample34.haml +48 -0
- data/examples/api-samples/views/sample35.haml +95 -0
- data/examples/api-samples/views/sample36.haml +64 -0
- data/examples/api-samples/views/sample37.haml +124 -0
- data/examples/api-samples/views/sample38.haml +115 -0
- data/examples/api-samples/views/sample39.haml +236 -0
- data/examples/api-samples/views/sample40.haml +95 -0
- data/examples/api-samples/views/{sample4.haml → sample41.haml} +90 -72
- data/examples/api-samples/views/sample42.haml +59 -0
- data/lib/groupdocs/api/helpers/rest_helper.rb +13 -1
- data/lib/groupdocs/datasource.rb +2 -1
- data/lib/groupdocs/document.rb +101 -13
- data/lib/groupdocs/document/annotation.rb +28 -13
- data/lib/groupdocs/document/annotation/marker.rb +18 -0
- data/lib/groupdocs/document/annotation/reply.rb +9 -2
- data/lib/groupdocs/document/field.rb +5 -1
- data/lib/groupdocs/job.rb +12 -2
- data/lib/groupdocs/questionnaire.rb +174 -4
- data/lib/groupdocs/questionnaire/collector.rb +21 -0
- data/lib/groupdocs/questionnaire/question.rb +19 -0
- data/lib/groupdocs/questionnaire/question/answer.rb +5 -0
- data/lib/groupdocs/questionnaire/question/conditions.rb +20 -0
- data/lib/groupdocs/signature.rb +36 -308
- data/lib/groupdocs/signature/envelope.rb +146 -4
- data/lib/groupdocs/signature/field.rb +20 -1
- data/lib/groupdocs/signature/field/location.rb +18 -7
- data/lib/groupdocs/signature/form.rb +199 -10
- data/lib/groupdocs/signature/shared/document_methods.rb +38 -0
- data/lib/groupdocs/signature/shared/entity_methods.rb +0 -1
- data/lib/groupdocs/signature/shared/field_methods.rb +13 -38
- data/lib/groupdocs/signature/shared/recipient_methods.rb +8 -0
- data/lib/groupdocs/signature/template.rb +3 -1
- data/lib/groupdocs/storage.rb +4 -1
- data/lib/groupdocs/storage/file.rb +18 -1
- data/lib/groupdocs/subscription.rb +8 -3
- data/lib/groupdocs/user.rb +8 -0
- data/lib/groupdocs/version.rb +1 -1
- data/spec/groupdocs/document/annotation_spec.rb +1 -14
- data/spec/groupdocs/subscription_spec.rb +2 -2
- metadata +86 -32
- checksums.yaml +0 -15
- data/examples/api-samples/public/docs/sample9.html +0 -200
- data/examples/api-samples/samples/sample1.rb +0 -25
- data/examples/api-samples/samples/sample2.rb +0 -29
- data/examples/api-samples/samples/sample3.rb +0 -33
- data/examples/api-samples/samples/sample4.rb +0 -51
- data/examples/api-samples/samples/sample6.rb +0 -49
- data/examples/api-samples/samples/sample7.rb +0 -42
- data/examples/api-samples/samples/sample8.rb +0 -61
- data/examples/api-samples/samples/sample9.rb +0 -48
- data/examples/api-samples/views/sample3.haml +0 -44
- data/examples/api-samples/views/sample6.haml +0 -49
- data/examples/api-samples/views/sample7.haml +0 -42
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# GET request
|
|
2
|
+
get '/sample09' do
|
|
3
|
+
haml :sample09
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
# POST request
|
|
7
|
+
post '/sample09' do
|
|
8
|
+
# Set variables
|
|
9
|
+
set :file_id, params[:fileId]
|
|
10
|
+
set :width, params[:width]
|
|
11
|
+
set :height, params[:height]
|
|
12
|
+
set :source, params[:source]
|
|
13
|
+
set :client_id, params[:clientId]
|
|
14
|
+
set :private_key, params[:privateKey]
|
|
15
|
+
set :check, params[:check]
|
|
16
|
+
set :url, params[:url]
|
|
17
|
+
set :base_path, params[:basePath]
|
|
18
|
+
|
|
19
|
+
begin
|
|
20
|
+
# Check required variables
|
|
21
|
+
raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty? or settings.width.empty? or settings.height.empty?
|
|
22
|
+
|
|
23
|
+
if settings.base_path.empty? then settings.base_path = 'https://api.groupdocs.com' end
|
|
24
|
+
|
|
25
|
+
# Configure your access to API server
|
|
26
|
+
GroupDocs.configure do |groupdocs|
|
|
27
|
+
groupdocs.client_id = settings.client_id
|
|
28
|
+
groupdocs.private_key = settings.private_key
|
|
29
|
+
# Optionally specify API server and version
|
|
30
|
+
groupdocs.api_server = settings.base_path # default is 'https://api.groupdocs.com'
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Get document by file GUID
|
|
34
|
+
file = nil
|
|
35
|
+
case settings.source
|
|
36
|
+
when 'guid'
|
|
37
|
+
file = GroupDocs::Storage::File.new({:guid => settings.file_id})
|
|
38
|
+
when 'local'
|
|
39
|
+
# Construct path
|
|
40
|
+
filepath = "#{Dir.tmpdir}/#{params[:file][:filename]}"
|
|
41
|
+
# Open file
|
|
42
|
+
File.open(filepath, 'wb') { |f| f.write(params[:file][:tempfile].read) }
|
|
43
|
+
# Make a request to API using client_id and private_key
|
|
44
|
+
file = GroupDocs::Storage::File.upload!(filepath, {})
|
|
45
|
+
when 'url'
|
|
46
|
+
file = GroupDocs::Storage::File.upload_web!(settings.url)
|
|
47
|
+
else
|
|
48
|
+
raise 'Wrong GUID source.'
|
|
49
|
+
end
|
|
50
|
+
url = nil
|
|
51
|
+
|
|
52
|
+
case settings.check
|
|
53
|
+
when 'viewer'
|
|
54
|
+
case settings.base_path
|
|
55
|
+
when 'https://stage-api-groupdocs.dynabic.com'
|
|
56
|
+
url = "http://stage-apps-groupdocs.dynabic.com/document-viewer/embed/#{file.guid}?frameborder='0' width='#{settings.width}' height='#{settings.height}'"
|
|
57
|
+
when 'https://dev-api-groupdocs.dynabic.com'
|
|
58
|
+
url = "http://dev-apps-groupdocs.dynabic.com/document-viewer/embed/#{file.guid}?frameborder='0' width='#{settings.width}' height='#{settings.height}'"
|
|
59
|
+
else
|
|
60
|
+
url = "https://apps.groupdocs.com/document-viewer/embed/#{file.guid}?frameborder='0' width='#{settings.width}' height='#{settings.height}'"
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
when 'annotation'
|
|
64
|
+
case settings.base_path
|
|
65
|
+
when 'https://stage-api-groupdocs.dynabic.com'
|
|
66
|
+
url = "http://stage-apps-groupdocs.dynabic.com/document-annotation2/embed/#{file.guid}?frameborder='0' width='#{settings.width}' height='#{settings.height}'"
|
|
67
|
+
when 'https://dev-api-groupdocs.dynabic.com'
|
|
68
|
+
url = "http://dev-apps-groupdocs.dynabic.com/document-annotation2/embed/#{file.guid}?frameborder='0' width='#{settings.width}' height='#{settings.height}'"
|
|
69
|
+
else
|
|
70
|
+
url = "https://apps.groupdocs.com/document-annotation2/embed/#{file.guid}?frameborder='0' width='#{settings.width}' height='#{settings.height}'"
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Construct result string
|
|
75
|
+
url = GroupDocs::Api::Request.new(:path => url).prepare_and_sign_url
|
|
76
|
+
|
|
77
|
+
rescue Exception => e
|
|
78
|
+
err = e.message
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Set variables for template
|
|
82
|
+
haml :sample09, :locals => {:guid => file.guid, :width => settings.width, :height => settings.height, :v_url => url, :err => err}
|
|
83
|
+
end
|
|
@@ -5,38 +5,52 @@ end
|
|
|
5
5
|
|
|
6
6
|
# POST request
|
|
7
7
|
post '/sample10' do
|
|
8
|
-
#
|
|
9
|
-
set :client_id, params[:
|
|
10
|
-
set :private_key, params[:
|
|
8
|
+
# Set variables
|
|
9
|
+
set :client_id, params[:clientId]
|
|
10
|
+
set :private_key, params[:privateKey]
|
|
11
11
|
set :guid, params[:fileId]
|
|
12
12
|
set :email, params[:email]
|
|
13
|
+
set :source, params[:source]
|
|
14
|
+
set :base_path, params[:basePath]
|
|
13
15
|
|
|
14
16
|
begin
|
|
15
|
-
#
|
|
17
|
+
# Check required variables
|
|
16
18
|
raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty? or settings.guid.empty? or settings.email.empty?
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
|
|
21
|
+
if settings.base_path.empty? then settings.base_path = 'https://api.groupdocs.com' end
|
|
22
|
+
|
|
23
|
+
# Configure your access to API server
|
|
24
|
+
GroupDocs.configure do |groupdocs|
|
|
25
|
+
groupdocs.client_id = settings.client_id
|
|
26
|
+
groupdocs.private_key = settings.private_key
|
|
27
|
+
# Optionally specify API server and version
|
|
28
|
+
groupdocs.api_server = settings.base_path # default is 'https://api.groupdocs.com'
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Get document by file GUID
|
|
19
32
|
file = nil
|
|
20
33
|
case settings.source
|
|
21
34
|
when 'guid'
|
|
22
|
-
file = GroupDocs::Storage::File.new({:guid => settings.guid})
|
|
35
|
+
file = GroupDocs::Storage::File.new({:guid => settings.guid}).to_document.metadata!()
|
|
36
|
+
file = file.last_view.document.file
|
|
23
37
|
when 'local'
|
|
24
|
-
#
|
|
38
|
+
# Construct path
|
|
25
39
|
filepath = "#{Dir.tmpdir}/#{params[:file][:filename]}"
|
|
26
|
-
#
|
|
40
|
+
# Open file
|
|
27
41
|
File.open(filepath, 'wb') { |f| f.write(params[:file][:tempfile].read) }
|
|
28
|
-
#
|
|
29
|
-
file = GroupDocs::Storage::File.upload!(filepath, {}
|
|
42
|
+
# Make a request to API using client_id and private_key
|
|
43
|
+
file = GroupDocs::Storage::File.upload!(filepath, {})
|
|
30
44
|
when 'url'
|
|
31
|
-
file = GroupDocs::Storage::File.upload_web!(settings.url
|
|
45
|
+
file = GroupDocs::Storage::File.upload_web!(settings.url)
|
|
32
46
|
else
|
|
33
47
|
raise 'Wrong GUID source.'
|
|
34
48
|
end
|
|
35
49
|
|
|
36
50
|
# Share document. Make a request to API using client_id and private_key
|
|
37
|
-
shared = file.to_document.sharers_set!(settings.email.split(' ')
|
|
51
|
+
shared = file.to_document.sharers_set!(settings.email.split(' '))
|
|
38
52
|
|
|
39
|
-
#
|
|
53
|
+
# Result
|
|
40
54
|
if shared
|
|
41
55
|
shared_emails = settings.email
|
|
42
56
|
end
|
|
@@ -44,6 +58,6 @@ post '/sample10' do
|
|
|
44
58
|
err = e.message
|
|
45
59
|
end
|
|
46
60
|
|
|
47
|
-
#
|
|
48
|
-
haml :sample10, :locals => {:
|
|
61
|
+
# Set variables for template
|
|
62
|
+
haml :sample10, :locals => {:clientId => settings.client_id, :privateKey => settings.private_key, :guid => settings.guid, :email => settings.email, :shared => shared_emails, :err => err}
|
|
49
63
|
end
|
|
@@ -5,39 +5,63 @@ end
|
|
|
5
5
|
|
|
6
6
|
# POST request
|
|
7
7
|
post '/sample11' do
|
|
8
|
-
#
|
|
9
|
-
set :client_id, params[:
|
|
10
|
-
set :private_key, params[:
|
|
8
|
+
# Set variables
|
|
9
|
+
set :client_id, params[:clientId]
|
|
10
|
+
set :private_key, params[:privateKey]
|
|
11
11
|
set :file_id, params[:fileId]
|
|
12
|
-
set :annotation_type, params[:
|
|
12
|
+
set :annotation_type, params[:annotationType]
|
|
13
|
+
set :annotation_id, params[:annotationId]
|
|
14
|
+
set :base_path, params[:basePath]
|
|
13
15
|
|
|
14
16
|
begin
|
|
15
|
-
|
|
17
|
+
|
|
18
|
+
# Check required variables
|
|
16
19
|
raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty? or settings.file_id.empty? or settings.annotation_type.empty?
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
if settings.base_path.empty? then settings.base_path = 'https://api.groupdocs.com' end
|
|
22
|
+
|
|
23
|
+
# Configure your access to API server
|
|
24
|
+
GroupDocs.configure do |groupdocs|
|
|
25
|
+
groupdocs.client_id = settings.client_id
|
|
26
|
+
groupdocs.private_key = settings.private_key
|
|
27
|
+
# Optionally specify API server and version
|
|
28
|
+
groupdocs.api_server = settings.base_path # default is 'https://api.groupdocs.com'
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
if settings.annotation_id != ''
|
|
32
|
+
|
|
33
|
+
file = GroupDocs::Storage::File.new({:guid => settings.file_id}).to_document
|
|
34
|
+
annotation = file.annotations!()
|
|
20
35
|
|
|
21
|
-
|
|
22
|
-
|
|
36
|
+
# Remove annotation from document
|
|
37
|
+
remove = annotation.last.remove!()
|
|
38
|
+
message = "You delete the annotation id = #{remove[:guid]} "
|
|
39
|
+
else
|
|
40
|
+
# Annotation types
|
|
41
|
+
types = {:text => "0", :area => "1", :point => "2"}
|
|
23
42
|
|
|
24
|
-
|
|
43
|
+
|
|
44
|
+
# Required parameters
|
|
45
|
+
all_params = all_params = ['annotationType', 'boxX', 'boxY', 'text']
|
|
46
|
+
|
|
47
|
+
# Added required parameters depends on annotation type ['text' or 'area']
|
|
25
48
|
if settings.annotation_type == 'text'
|
|
26
|
-
all_params = all_params | ['
|
|
49
|
+
all_params = all_params | ['boxWidth', 'boxHeight', 'annotationPositionX', 'annotationPositionY', 'rangePosition', 'rangeLength']
|
|
27
50
|
elsif settings.annotation_type == 'area'
|
|
28
|
-
all_params = all_params | ['
|
|
51
|
+
all_params = all_params | ['boxWidth', 'boxHeight']
|
|
29
52
|
end
|
|
30
53
|
|
|
31
|
-
#
|
|
54
|
+
# Checking required parameters
|
|
32
55
|
all_params.each do |param|
|
|
33
56
|
raise 'Please enter all required parameters' if params[param].empty?
|
|
34
57
|
end
|
|
35
58
|
|
|
36
|
-
#
|
|
37
|
-
files_list = GroupDocs::Storage::Folder.list!('/', {}
|
|
59
|
+
# Make a request to API using client_id and private_key
|
|
60
|
+
files_list = GroupDocs::Storage::Folder.list!('/', {})
|
|
61
|
+
|
|
38
62
|
document = ''
|
|
39
63
|
|
|
40
|
-
#
|
|
64
|
+
# Get document by file ID
|
|
41
65
|
files_list.each do |element|
|
|
42
66
|
if element.respond_to?('guid') == true and element.guid == settings.file_id
|
|
43
67
|
document = element
|
|
@@ -46,34 +70,54 @@ post '/sample11' do
|
|
|
46
70
|
|
|
47
71
|
unless document.instance_of? String
|
|
48
72
|
|
|
49
|
-
#
|
|
73
|
+
# Start create new annotation
|
|
50
74
|
annotation = GroupDocs::Document::Annotation.new(document: document.to_document)
|
|
51
|
-
annotation.type = types[settings.annotation_type]
|
|
52
75
|
|
|
53
|
-
# construct requestBody depends on annotation type
|
|
54
|
-
# text annotation
|
|
55
|
-
if settings.annotation_type == 'text'
|
|
56
|
-
annotation.box = {x: params['box_x'], y: params['box_y'], width: params['box_width'], height: params['box_height']}
|
|
57
|
-
annotation.annotationPosition = {x: params['annotationPosition_x'], y: params['annotationPosition_y']}
|
|
58
76
|
|
|
59
|
-
|
|
77
|
+
info = nil
|
|
78
|
+
# Construct requestBody depends on annotation type
|
|
79
|
+
# Text annotation
|
|
80
|
+
if settings.annotation_type == 'text'
|
|
81
|
+
annotation.box = GroupDocs::Document::Rectangle.new ({x: params['boxX'], y: params['boxY'], width: params['boxWidth'], height: params['boxHeight']})
|
|
82
|
+
annotation.annotationPosition = {x: params['annotationPositionX'], y: params['annotationPositionY']}
|
|
83
|
+
range = {position: params['rangePosition'], length: params['rangeLength']}
|
|
84
|
+
info = {:box => annotation_box, :annotationPosition => annotation_annotationPosition, :range => range, :type => types[settings.annotation_type.to_sym], :replies => [{:text => params['text']}]}
|
|
85
|
+
# Area annotation
|
|
60
86
|
elsif settings.annotation_type == 'area'
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
#
|
|
87
|
+
annotation_box = {x: params['boxX'], y: params['boxY'], width: params['boxWidth'], height: params['boxHeight']}
|
|
88
|
+
annotation_annotationPosition = {x: 0, y: 0}
|
|
89
|
+
info = {:box => annotation_box, :annotationPosition => annotation_annotationPosition, :type => types[settings.annotation_type.to_sym], :replies => [{:text => params['text']}]}
|
|
90
|
+
# Point annotation
|
|
65
91
|
elsif settings.annotation_type == 'point'
|
|
66
|
-
|
|
67
|
-
|
|
92
|
+
annotation_box = {x: params['boxX'], y: params['boxY'], width: 0, height: 0}
|
|
93
|
+
annotation_annotationPosition = {x: 0, y: 0}
|
|
94
|
+
|
|
95
|
+
info = {:box => annotation_box, :annotationPosition => annotation_annotationPosition, :type => types[settings.annotation_type.to_sym], :replies => [{:text => params['text']}] }
|
|
68
96
|
end
|
|
69
97
|
|
|
70
|
-
# call create method
|
|
71
|
-
annotation.create!({:client_id => settings.client_id, :private_key => settings.private_key})
|
|
72
98
|
|
|
73
|
-
#
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
99
|
+
# Call create method
|
|
100
|
+
annotation.create!(info)
|
|
101
|
+
id = annotation.document.file.id
|
|
102
|
+
# Get document guid
|
|
103
|
+
guid = annotation.document.file.guid
|
|
104
|
+
|
|
105
|
+
case settings.base_path
|
|
106
|
+
|
|
107
|
+
when 'https://stage-api-groupdocs.dynabic.com'
|
|
108
|
+
url = "http://stage-apps-groupdocs.dynabic.com/document-annotation2/embed/#{guid}"
|
|
109
|
+
when 'https://dev-api-groupdocs.dynabic.com'
|
|
110
|
+
url = "http://dev-apps-groupdocs.dynabic.com/document-annotation2/embed/#{guid}"
|
|
111
|
+
else
|
|
112
|
+
url = "http://apps.groupdocs.com/document-annotation2/embed/#{guid}"
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
#Add the signature in url
|
|
116
|
+
url = GroupDocs::Api::Request.new(:path => url).prepare_and_sign_url
|
|
117
|
+
# Set iframe with document GUID
|
|
118
|
+
iframe = "<iframe src='#{url}' frameborder='0' width='720' height='600'></iframe>"
|
|
119
|
+
|
|
120
|
+
end
|
|
77
121
|
|
|
78
122
|
end
|
|
79
123
|
|
|
@@ -82,5 +126,13 @@ post '/sample11' do
|
|
|
82
126
|
end
|
|
83
127
|
|
|
84
128
|
# set variables for template
|
|
85
|
-
haml :sample11, :locals => {:
|
|
129
|
+
haml :sample11, :locals => {:clientId => settings.client_id,
|
|
130
|
+
:privateKey => settings.private_key,
|
|
131
|
+
:fileId => settings.file_id,
|
|
132
|
+
:annotationType => settings.annotation_type,
|
|
133
|
+
:annotationId => id,
|
|
134
|
+
:annotationText => params['text'],
|
|
135
|
+
:err => err,
|
|
136
|
+
:iframe => iframe,
|
|
137
|
+
:message => message}
|
|
86
138
|
end
|
|
@@ -5,20 +5,31 @@ end
|
|
|
5
5
|
|
|
6
6
|
# POST request
|
|
7
7
|
post '/sample12' do
|
|
8
|
-
#
|
|
9
|
-
set :client_id, params[:
|
|
10
|
-
set :private_key, params[:
|
|
8
|
+
# Set variables
|
|
9
|
+
set :client_id, params[:clientId]
|
|
10
|
+
set :private_key, params[:privateKey]
|
|
11
11
|
set :file_id, params[:fileId]
|
|
12
|
+
set :base_path, params[:basePath]
|
|
12
13
|
|
|
13
14
|
begin
|
|
14
|
-
#
|
|
15
|
+
# Check required variables
|
|
15
16
|
raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty? or settings.file_id.empty?
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
if settings.base_path.empty? then settings.base_path = 'https://api.groupdocs.com' end
|
|
19
|
+
|
|
20
|
+
# Configure your access to API server
|
|
21
|
+
GroupDocs.configure do |groupdocs|
|
|
22
|
+
groupdocs.client_id = settings.client_id
|
|
23
|
+
groupdocs.private_key = settings.private_key
|
|
24
|
+
# Optionally specify API server and version
|
|
25
|
+
groupdocs.api_server = settings.base_path # default is 'https://api.groupdocs.com'
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Make a request to API using client_id and private_key
|
|
29
|
+
files_list = GroupDocs::Storage::Folder.list!('/', {})
|
|
19
30
|
document = ''
|
|
20
31
|
|
|
21
|
-
#
|
|
32
|
+
# Get document by file ID
|
|
22
33
|
files_list.each do |element|
|
|
23
34
|
if element.respond_to?('guid') == true and element.guid == settings.file_id
|
|
24
35
|
document = element
|
|
@@ -26,14 +37,14 @@ post '/sample12' do
|
|
|
26
37
|
end
|
|
27
38
|
|
|
28
39
|
unless document.instance_of? String
|
|
29
|
-
#
|
|
30
|
-
annotations = document.to_document.annotations!(
|
|
40
|
+
# Get list of annotations
|
|
41
|
+
annotations = document.to_document.annotations!()
|
|
31
42
|
end
|
|
32
43
|
|
|
33
44
|
rescue Exception => e
|
|
34
45
|
err = e.message
|
|
35
46
|
end
|
|
36
47
|
|
|
37
|
-
#
|
|
38
|
-
haml :sample12, :locals => {:
|
|
48
|
+
# Set variables for template
|
|
49
|
+
haml :sample12, :locals => {:clientId => settings.client_id, :privateKey => settings.private_key, :annotations => annotations, :fileId => settings.file_id, :err => err}
|
|
39
50
|
end
|
|
@@ -5,21 +5,32 @@ end
|
|
|
5
5
|
|
|
6
6
|
# POST request
|
|
7
7
|
post '/sample13' do
|
|
8
|
-
#
|
|
9
|
-
set :client_id, params[:
|
|
10
|
-
set :private_key, params[:
|
|
8
|
+
# Set variables
|
|
9
|
+
set :client_id, params[:clientId]
|
|
10
|
+
set :private_key, params[:privateKey]
|
|
11
11
|
set :file_id, params[:fileId]
|
|
12
12
|
set :email, params[:email]
|
|
13
|
+
set :base_path, params[:basePath]
|
|
13
14
|
|
|
14
15
|
begin
|
|
15
|
-
#
|
|
16
|
+
# Check required variables
|
|
16
17
|
raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty? or settings.file_id.empty? or settings.email.empty?
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
if settings.base_path.empty? then settings.base_path = 'https://api.groupdocs.com' end
|
|
20
|
+
|
|
21
|
+
# Configure your access to API server
|
|
22
|
+
GroupDocs.configure do |groupdocs|
|
|
23
|
+
groupdocs.client_id = settings.client_id
|
|
24
|
+
groupdocs.private_key = settings.private_key
|
|
25
|
+
# Optionally specify API server and version
|
|
26
|
+
groupdocs.api_server = settings.base_path # default is 'https://api.groupdocs.com'
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Make a request to API using client_id and private_key
|
|
30
|
+
files_list = GroupDocs::Storage::Folder.list!('/', {})
|
|
20
31
|
document = ''
|
|
21
32
|
|
|
22
|
-
#
|
|
33
|
+
# Get document by file ID
|
|
23
34
|
files_list.each do |element|
|
|
24
35
|
if element.respond_to?('guid') == true and element.guid == settings.file_id
|
|
25
36
|
document = element
|
|
@@ -27,14 +38,15 @@ post '/sample13' do
|
|
|
27
38
|
end
|
|
28
39
|
|
|
29
40
|
unless document.instance_of? String
|
|
30
|
-
#
|
|
31
|
-
result = document.to_document.set_collaborators!(settings.email.split(' '), 1
|
|
41
|
+
# Add collaborator to doc with annotations
|
|
42
|
+
result = document.to_document.set_collaborators!(settings.email.split(' '), 1)
|
|
32
43
|
end
|
|
33
44
|
|
|
45
|
+
|
|
34
46
|
rescue Exception => e
|
|
35
47
|
err = e.message
|
|
36
48
|
end
|
|
37
49
|
|
|
38
50
|
# set variables for template
|
|
39
|
-
haml :sample13, :locals => {:
|
|
51
|
+
haml :sample13, :locals => {:clientId => settings.client_id, :privateKey => settings.private_key, :fileId => settings.file_id, :email => settings.email, :result => result, :err => err}
|
|
40
52
|
end
|
|
@@ -6,19 +6,37 @@ end
|
|
|
6
6
|
# POST request
|
|
7
7
|
post '/sample14' do
|
|
8
8
|
# set variables
|
|
9
|
-
set :client_id, params[:
|
|
10
|
-
set :private_key, params[:
|
|
11
|
-
set :folder, params[:
|
|
9
|
+
set :client_id, params[:clientId]
|
|
10
|
+
set :private_key, params[:privateKey]
|
|
11
|
+
set :folder, params[:path]
|
|
12
|
+
set :base_path, params[:basePath]
|
|
12
13
|
|
|
13
14
|
begin
|
|
14
15
|
# check required variables
|
|
15
16
|
raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty? or settings.folder.empty?
|
|
16
17
|
|
|
18
|
+
if settings.base_path.empty? then settings.base_path = 'https://api.groupdocs.com' end
|
|
19
|
+
|
|
20
|
+
# Configure your access to API server
|
|
21
|
+
GroupDocs.configure do |groupdocs|
|
|
22
|
+
groupdocs.client_id = settings.client_id
|
|
23
|
+
groupdocs.private_key = settings.private_key
|
|
24
|
+
# Optionally specify API server and version
|
|
25
|
+
groupdocs.api_server = settings.base_path # default is 'https://api.groupdocs.com'
|
|
26
|
+
end
|
|
27
|
+
folder = nil
|
|
17
28
|
# make a request to API using client_id and private_key
|
|
18
|
-
files_list = GroupDocs::Storage::Folder.list!(
|
|
29
|
+
files_list = GroupDocs::Storage::Folder.list!()
|
|
30
|
+
|
|
31
|
+
files_list.map do |e|
|
|
32
|
+
if e.name == settings.folder
|
|
33
|
+
folder = e
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
19
37
|
|
|
20
38
|
# get list of shares for a folder
|
|
21
|
-
shares =
|
|
39
|
+
shares = folder.sharers!()
|
|
22
40
|
|
|
23
41
|
rescue Exception => e
|
|
24
42
|
err = e.message
|