groupdocs 1.5.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. data/CHANGELOG.md +6 -0
  2. data/examples/api-samples/README.md +1 -1
  3. data/examples/api-samples/public/css/style.css +2 -2
  4. data/examples/api-samples/public/docs/annotation-sample.html +57 -0
  5. data/examples/api-samples/public/docs/envelope-sample.html +32 -32
  6. data/examples/api-samples/public/docs/sample1.html +3 -3
  7. data/examples/api-samples/public/docs/sample10.html +25 -24
  8. data/examples/api-samples/public/docs/sample11.html +17 -17
  9. data/examples/api-samples/public/docs/sample12.html +4 -4
  10. data/examples/api-samples/public/docs/sample13.html +5 -5
  11. data/examples/api-samples/public/docs/sample14.html +5 -5
  12. data/examples/api-samples/public/docs/sample15.html +4 -4
  13. data/examples/api-samples/public/docs/sample16.html +3 -3
  14. data/examples/api-samples/public/docs/sample17.html +3 -3
  15. data/examples/api-samples/public/docs/sample18.html +129 -34
  16. data/examples/api-samples/public/docs/sample19.html +59 -0
  17. data/examples/api-samples/public/docs/sample2.html +5 -5
  18. data/examples/api-samples/public/docs/sample20.html +51 -0
  19. data/examples/api-samples/public/docs/sample21.html +66 -0
  20. data/examples/api-samples/public/docs/sample22.html +53 -0
  21. data/examples/api-samples/public/docs/sample3.html +4 -4
  22. data/examples/api-samples/public/docs/sample4.html +27 -16
  23. data/examples/api-samples/public/docs/sample5.html +29 -22
  24. data/examples/api-samples/public/docs/sample6.html +6 -6
  25. data/examples/api-samples/public/docs/sample7.html +8 -8
  26. data/examples/api-samples/public/docs/sample8.html +31 -23
  27. data/examples/api-samples/public/docs/sample9.html +26 -8
  28. data/examples/api-samples/public/templates/merge_feid_doc.docx +0 -0
  29. data/examples/api-samples/samples/annotation-sample.rb +22 -16
  30. data/examples/api-samples/samples/envelope-sample.rb +26 -25
  31. data/examples/api-samples/samples/sample1.rb +2 -2
  32. data/examples/api-samples/samples/sample10.rb +21 -20
  33. data/examples/api-samples/samples/sample11.rb +18 -18
  34. data/examples/api-samples/samples/sample12.rb +3 -3
  35. data/examples/api-samples/samples/sample13.rb +4 -4
  36. data/examples/api-samples/samples/sample14.rb +4 -4
  37. data/examples/api-samples/samples/sample15.rb +3 -3
  38. data/examples/api-samples/samples/sample16.rb +2 -2
  39. data/examples/api-samples/samples/sample17.rb +2 -2
  40. data/examples/api-samples/samples/sample18.rb +90 -106
  41. data/examples/api-samples/samples/sample19.rb +5 -5
  42. data/examples/api-samples/samples/sample2.rb +4 -4
  43. data/examples/api-samples/samples/sample20.rb +4 -4
  44. data/examples/api-samples/samples/sample21.rb +4 -4
  45. data/examples/api-samples/samples/sample22.rb +2 -2
  46. data/examples/api-samples/samples/sample23.rb +0 -0
  47. data/examples/api-samples/samples/sample24.rb +0 -0
  48. data/examples/api-samples/samples/sample25.rb +96 -0
  49. data/examples/api-samples/samples/sample3.rb +3 -3
  50. data/examples/api-samples/samples/sample4.rb +23 -12
  51. data/examples/api-samples/samples/sample5.rb +23 -16
  52. data/examples/api-samples/samples/sample6.rb +8 -8
  53. data/examples/api-samples/samples/sample7.rb +7 -7
  54. data/examples/api-samples/samples/sample8.rb +29 -21
  55. data/examples/api-samples/samples/sample9.rb +23 -5
  56. data/examples/api-samples/views/_others_samples.haml +57 -0
  57. data/examples/api-samples/views/annotation_sample.haml +30 -30
  58. data/examples/api-samples/views/envelope_sample.haml +31 -31
  59. data/examples/api-samples/views/index.haml +33 -25
  60. data/examples/api-samples/views/sample1.haml +22 -69
  61. data/examples/api-samples/views/sample10.haml +57 -73
  62. data/examples/api-samples/views/sample11.haml +31 -79
  63. data/examples/api-samples/views/sample12.haml +18 -66
  64. data/examples/api-samples/views/sample13.haml +21 -70
  65. data/examples/api-samples/views/sample14.haml +18 -67
  66. data/examples/api-samples/views/sample15.haml +15 -63
  67. data/examples/api-samples/views/sample16.haml +13 -61
  68. data/examples/api-samples/views/sample17.haml +19 -67
  69. data/examples/api-samples/views/sample18.haml +74 -159
  70. data/examples/api-samples/views/sample19.haml +25 -74
  71. data/examples/api-samples/views/sample2.haml +19 -66
  72. data/examples/api-samples/views/sample20.haml +19 -68
  73. data/examples/api-samples/views/sample21.haml +28 -76
  74. data/examples/api-samples/views/sample22.haml +29 -77
  75. data/examples/api-samples/views/sample23.haml +0 -0
  76. data/examples/api-samples/views/sample24.haml +0 -0
  77. data/examples/api-samples/views/sample25.haml +91 -0
  78. data/examples/api-samples/views/sample3.haml +20 -68
  79. data/examples/api-samples/views/sample4.haml +53 -68
  80. data/examples/api-samples/views/sample5.haml +54 -70
  81. data/examples/api-samples/views/sample6.haml +21 -69
  82. data/examples/api-samples/views/sample7.haml +19 -66
  83. data/examples/api-samples/views/sample8.haml +60 -75
  84. data/examples/api-samples/views/sample9.haml +54 -70
  85. data/examples/api-samples/web.rb +20 -0
  86. data/lib/groupdocs/api/request.rb +4 -2
  87. data/lib/groupdocs/version.rb +1 -1
  88. data/spec/groupdocs/api/request_spec.rb +10 -2
  89. metadata +18 -5
  90. data/examples/api-samples/app.rb +0 -15
@@ -12,18 +12,18 @@ post '/sample14' do
12
12
 
13
13
  begin
14
14
  # check required variables
15
- raise "Please enter all required parameters" if settings.client_id.empty? or settings.private_key.empty? or settings.folder.empty?
15
+ raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty? or settings.folder.empty?
16
16
 
17
17
  # make a request to API using client_id and private_key
18
- files_list = GroupDocs::Storage::Folder.list!(settings.folder, {}, { :client_id => settings.client_id, :private_key => settings.private_key})
18
+ files_list = GroupDocs::Storage::Folder.list!(settings.folder, {}, {:client_id => settings.client_id, :private_key => settings.private_key})
19
19
 
20
20
  # get list of shares for a folder
21
- shares = files_list.first.sharers!({:client_id => settings.client_id, :private_key => settings.private_key})
21
+ shares = files_list.first.sharers!({:client_id => settings.client_id, :private_key => settings.private_key})
22
22
 
23
23
  rescue Exception => e
24
24
  err = e.message
25
25
  end
26
26
 
27
27
  # set variables for template
28
- haml :sample14, :locals => { :userId => settings.client_id, :privateKey => settings.private_key, :folder => settings.folder, :shares => shares, :err => err }
28
+ haml :sample14, :locals => {:userId => settings.client_id, :privateKey => settings.private_key, :folder => settings.folder, :shares => shares, :err => err}
29
29
  end
@@ -11,10 +11,10 @@ post '/sample15' do
11
11
 
12
12
  begin
13
13
  # check required variables
14
- raise "Please enter all required parameters" if settings.client_id.empty? or settings.private_key.empty?
14
+ raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty?
15
15
 
16
16
  # check the number of document's views. Make a request to API using client_id and private_key
17
- views = GroupDocs::Document.views!({}, { :client_id => settings.client_id, :private_key => settings.private_key})
17
+ views = GroupDocs::Document.views!({}, {:client_id => settings.client_id, :private_key => settings.private_key})
18
18
  total = views.count()
19
19
 
20
20
  rescue Exception => e
@@ -22,5 +22,5 @@ post '/sample15' do
22
22
  end
23
23
 
24
24
  # set variables for template
25
- haml :sample15, :locals => { :userId => settings.client_id, :privateKey => settings.private_key, :total => total, :err => err }
25
+ haml :sample15, :locals => {:userId => settings.client_id, :privateKey => settings.private_key, :total => total, :err => err}
26
26
  end
@@ -10,7 +10,7 @@ post '/sample16' do
10
10
 
11
11
  begin
12
12
  # check required variables
13
- raise "Please enter all required parameters" if settings.fileId.empty?
13
+ raise 'Please enter all required parameters' if settings.fileId.empty?
14
14
 
15
15
  # construct result iframe
16
16
  iframe = "<iframe src='https://apps.groupdocs.com/assembly2/questionnaire-assembly/#{settings.fileId}' frameborder='0' width='100%' height='600'></iframe>"
@@ -20,5 +20,5 @@ post '/sample16' do
20
20
  end
21
21
 
22
22
  # set variables for template
23
- haml :sample16, :locals => { :fileId => settings.fileId, :iframe => iframe, :err => err }
23
+ haml :sample16, :locals => {:fileId => settings.fileId, :iframe => iframe, :err => err}
24
24
  end
@@ -12,7 +12,7 @@ post '/sample17' do
12
12
 
13
13
  begin
14
14
  # check required variables
15
- raise "Please enter all required parameters" if settings.client_id.empty? or settings.private_key.empty? or settings.file.nil?
15
+ raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty? or settings.file.nil?
16
16
 
17
17
  # construct path
18
18
  filepath = "#{Dir.tmpdir}/#{params[:file][:filename]}"
@@ -32,5 +32,5 @@ post '/sample17' do
32
32
  end
33
33
 
34
34
  # set variables for template
35
- haml :sample17, :locals => { :userId => settings.client_id, :privateKey => settings.private_key, :iframe=>iframe, :massage => massage, :err => err }
35
+ haml :sample17, :locals => {:userId => settings.client_id, :privateKey => settings.private_key, :iframe => iframe, :massage => massage, :err => err}
36
36
  end
@@ -3,91 +3,42 @@ get '/sample18' do
3
3
  haml :sample18
4
4
  end
5
5
 
6
- post '/sample18/test_callback' do
7
- downloads_path = "#{File.dirname(__FILE__)}/../public/downloads"
8
- unless File.directory?(downloads_path)
9
- Dir::mkdir(downloads_path)
10
- else
11
- Dir.foreach(downloads_path) {|f| fn = File.join(downloads_path, f); File.delete(fn) if f != '.' && f != '..'}
12
- end
13
-
14
- SourceId = nil
15
- client_key = nil
16
- private_key = nil
17
-
18
- data = JSON.parse(request.body.read)
19
- data.each do |key, value|
20
- if key == 'SourceId'
21
- SourceId = value
22
- end
23
- end
24
-
25
- if File.exist?("#{File.dirname(__FILE__)}/../public/user_info.txt")
26
- contents = File.read("#{File.dirname(__FILE__)}/../public/user_info.txt")
27
- contents = contents.split(' ')
28
- client_key = contents.first
29
- private_key = contents.last
30
- end
31
-
32
- outFile = File.new("#{File.dirname(__FILE__)}/../public/downloads/signed", "w")
33
- outFile.write("private_key: #{private_key} \n")
34
- outFile.write("client_key: #{client_key} \n")
35
- outFile.write("SourceId: #{SourceId} \n")
36
- outFile.close
37
-
38
- job = GroupDocs::Job.new({:id=>SourceId})
39
- documents = job.documents!({:client_id => client_key, :private_key => private_key})
40
- tttt = documents[:inputs].first.file.download!(downloads_path, {:client_id => client_key, :private_key => private_key})
41
-
42
- outFile = File.new("#{File.dirname(__FILE__)}/../public/downloads/t", "w")
43
- outFile.write("documents: #{documents} \n")
44
- outFile.write("tttt: #{tttt} \n")
45
- outFile.close
46
- end
47
-
48
- # GET request to check if envelop was signed
49
- get '/sample18/test_check' do
50
- if File.exist?("#{File.dirname(__FILE__)}/../public/downloads/signed")
51
- File.readlines("#{File.dirname(__FILE__)}/../public/downloads/signed").each do |line|
52
- end
53
- else
54
- 'not yet'
55
- end
56
- end
57
-
58
- #
6
+ # POST request
59
7
  post '/sample18/convert_callback' do
8
+ # Set download path
60
9
  downloads_path = "#{File.dirname(__FILE__)}/../public/downloads"
61
- unless File.directory?(downloads_path)
62
- Dir::mkdir(downloads_path)
63
- else
64
- Dir.foreach(downloads_path) {|f| fn = File.join(downloads_path, f); File.delete(fn) if f != '.' && f != '..'}
65
- end
66
-
10
+
11
+ # Get callback request
67
12
  data = JSON.parse(request.body.read)
68
13
  begin
69
- raise "Empty params!" if data.empty?
70
- SourceId = nil
71
- client_key = nil
14
+ raise 'Empty params!' if data.empty?
15
+ source_id = nil
16
+ client_id = nil
72
17
  private_key = nil
73
18
 
74
-
19
+ # Get value of SourceId
75
20
  data.each do |key, value|
76
21
  if key == 'SourceId'
77
- SourceId = value
22
+ source_id = value
78
23
  end
79
24
  end
80
25
 
26
+ # Get private key and client_id from file user_info.txt
81
27
  if File.exist?("#{File.dirname(__FILE__)}/../public/user_info.txt")
82
28
  contents = File.read("#{File.dirname(__FILE__)}/../public/user_info.txt")
83
29
  contents = contents.split(' ')
84
- client_key = contents.first
30
+ client_id = contents.first
85
31
  private_key = contents.last
86
32
  end
87
33
 
88
- job = GroupDocs::Job.new({:id=>SourceId})
89
- documents = job.documents!({:client_id => client_key, :private_key => private_key})
90
- documents[:inputs].first.file.download!(downloads_path, {:client_id => client_key, :private_key => private_key})
34
+ # Create Job instance
35
+ job = GroupDocs::Job.new({:id => source_id})
36
+
37
+ # Get document by job id
38
+ documents = job.documents!({:client_id => client_id, :private_key => private_key})
39
+
40
+ # Download converted file
41
+ documents[:inputs].first.outputs.first.download!(downloads_path, {:client_id => client_id, :private_key => private_key})
91
42
 
92
43
  rescue Exception => e
93
44
  err = e.message
@@ -95,23 +46,27 @@ post '/sample18/convert_callback' do
95
46
  end
96
47
 
97
48
 
98
- #
49
+ # GET request
99
50
  get '/sample18/check' do
100
-
51
+
52
+ # Check is there download directory
101
53
  unless File.directory?("#{File.dirname(__FILE__)}/../public/downloads")
102
- return "Directory was not found."
54
+ return 'Directory was not found.'
103
55
  end
104
56
 
57
+ # Get file name from download directory
105
58
  name = nil
106
59
  Dir.entries("#{File.dirname(__FILE__)}/../public/downloads").each do |file|
107
60
  name = file if file != '.' && file != '..'
108
61
  end
109
62
 
110
- if name
111
- return name
112
- else
113
- return "File was not found."
114
- end
63
+ name
64
+ end
65
+
66
+ # GET request
67
+ get '/sample18/downloads/:filename' do |filename|
68
+ # Send file with header to download it
69
+ send_file "#{File.dirname(__FILE__)}/../public/downloads/#{filename}", :filename => filename, :type => 'Application/octet-stream'
115
70
  end
116
71
 
117
72
 
@@ -120,48 +75,77 @@ post '/sample18' do
120
75
  # set variables
121
76
  set :client_id, params[:client_id]
122
77
  set :private_key, params[:private_key]
78
+ set :source, params[:source]
123
79
  set :file_id, params[:fileId]
80
+ set :url, params[:url]
124
81
  set :convert_type, params[:convert_type]
125
82
  set :callback, params[:callback]
126
83
 
84
+ # Set download path
85
+ downloads_path = "#{File.dirname(__FILE__)}/../public/downloads"
86
+
87
+ # Remove all files from download directory or create folder if it not there
88
+ if File.directory?(downloads_path)
89
+ Dir.foreach(downloads_path) { |f| fn = File.join(downloads_path, f); File.delete(fn) if f != '.' && f != '..' }
90
+ else
91
+ Dir::mkdir(downloads_path)
92
+ end
93
+
127
94
  begin
128
95
  # check required variables
129
- raise "Please enter all required parameters" if settings.client_id.empty? or settings.private_key.empty? or settings.file_id.empty?
130
-
96
+ raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty?
97
+
98
+ # Write client and private key to the file for callback job
131
99
  if settings.callback[0]
132
- outFile = File.new("#{File.dirname(__FILE__)}/../public/user_info.txt", "w")
133
- outFile.write("#{settings.client_id} ")
134
- outFile.write("#{settings.private_key}")
135
- outFile.close
100
+ out_file = File.new("#{File.dirname(__FILE__)}/../public/user_info.txt", 'w')
101
+ # white space is required
102
+ out_file.write("#{settings.client_id} ")
103
+ out_file.write("#{settings.private_key}")
104
+ out_file.close
136
105
  end
137
106
 
138
- # make a request to API using client_id and private_key
139
- files_list = GroupDocs::Storage::Folder.list!('/', {}, { :client_id => settings.client_id, :private_key => settings.private_key})
140
107
  file = nil
141
108
 
142
- # get document by file ID
143
- files_list.each do |element|
144
- if element.respond_to?('guid') == true and element.guid == settings.file_id
145
- file = element
146
- end
109
+ # get document by file GUID
110
+ case settings.source
111
+ when 'guid'
112
+ # Create instance of File
113
+ file = GroupDocs::Storage::File.new({:guid => settings.file_id})
114
+ when 'local'
115
+ # construct path
116
+ file_path = "#{Dir.tmpdir}/#{params[:file][:filename]}"
117
+ # open file
118
+ File.open(file_path, 'wb') { |f| f.write(params[:file][:tempfile].read) }
119
+ # make a request to API using client_id and private_key
120
+ file = GroupDocs::Storage::File.upload!(file_path, {}, {:client_id => settings.client_id, :private_key => settings.private_key})
121
+ when 'url'
122
+ # Upload file from defined url
123
+ file = GroupDocs::Storage::File.upload_web!(settings.url, {:client_id => settings.client_id, :private_key => settings.private_key})
124
+ else
125
+ raise 'Wrong GUID source.'
147
126
  end
148
127
 
149
- message = "No file with such GUID"
150
- unless file.nil?
151
-
152
- document = file.to_document
153
- # convert file
154
- convert = document.convert!(settings.convert_type, {:callback=>settings.callback}, {:client_id => settings.client_id, :private_key => settings.private_key})
155
- sleep(10)
156
-
157
- original_document = convert.documents!({:client_id => settings.client_id, :private_key => settings.private_key})
158
- # TODO: add Exception if not enough time for convertation
159
- guid = original_document[:inputs].first.outputs.first.guid
160
-
161
- if guid
162
- iframe = "<iframe src='https://apps.groupdocs.com/document-viewer/embed/#{guid}' frameborder='0' width='100%' height='600'></iframe>"
163
- message = "<p>Converted file saved successfully."
164
- end
128
+ # Raise exception if something went wrong
129
+ raise 'No such file' unless file.is_a?(GroupDocs::Storage::File)
130
+
131
+ # Make document from file
132
+ document = file.to_document
133
+ # convert document
134
+ convert = document.convert!(settings.convert_type, {:callback => settings.callback}, {:client_id => settings.client_id, :private_key => settings.private_key})
135
+ # waite 10 seconds for while file converting
136
+ sleep(10)
137
+
138
+ # Get array of changes in document from job
139
+ original_document = convert.documents!({:client_id => settings.client_id, :private_key => settings.private_key})
140
+
141
+ # Get converted document GUID
142
+ guid = original_document[:inputs].first.outputs.first.guid
143
+
144
+ # Set iframe with document GUID or raise an error
145
+ if guid
146
+ iframe = "<iframe width='100%' height='600' frameborder='0' src='https://apps.groupdocs.com/document-viewer/embed/#{guid}'></iframe>"
147
+ else
148
+ raise 'File was not converted'
165
149
  end
166
150
 
167
151
  rescue Exception => e
@@ -169,5 +153,5 @@ post '/sample18' do
169
153
  end
170
154
 
171
155
  # set variables for template
172
- haml :sample18, :locals => { :userId => settings.client_id, :privateKey => settings.private_key, :fileId => settings.file_id, :message => message, :iframe => iframe, :err => err }
156
+ haml :sample18, :locals => {:userId => settings.client_id, :privateKey => settings.private_key, :callback => settings.callback, :fileId => file, :converted => guid, :iframe => iframe, :err => err}
173
157
  end
@@ -14,10 +14,10 @@ post '/sample19' do
14
14
 
15
15
  begin
16
16
  # check required variables
17
- raise "Please enter all required parameters" if settings.client_id.empty? or settings.private_key.empty? or settings.sourceFileId.empty? or settings.targetFileId.empty?
17
+ raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty? or settings.sourceFileId.empty? or settings.targetFileId.empty?
18
18
 
19
19
  # make a request to API using client_id and private_key
20
- files_list = GroupDocs::Storage::Folder.list!('/', {}, { :client_id => settings.client_id, :private_key => settings.private_key})
20
+ files_list = GroupDocs::Storage::Folder.list!('/', {}, {:client_id => settings.client_id, :private_key => settings.private_key})
21
21
 
22
22
  source_document = ''
23
23
  target_document = ''
@@ -34,7 +34,7 @@ post '/sample19' do
34
34
 
35
35
  unless source_document.instance_of? String and target_document.instance_of? String
36
36
 
37
- info = source_document.to_document.compare!(target_document.to_document, {:client_id => settings.client_id, :private_key => settings.private_key});
37
+ info = source_document.to_document.compare!(target_document.to_document, {:client_id => settings.client_id, :private_key => settings.private_key})
38
38
  sleep(5)
39
39
 
40
40
  # get job by ID
@@ -42,7 +42,7 @@ post '/sample19' do
42
42
  # get all job documents
43
43
  documents = job.documents!({:client_id => settings.client_id, :private_key => settings.private_key})
44
44
  # get compared file giud
45
- guid = documents[:outputs].first.file.guid
45
+ guid = documents[:outputs].first.file.guid
46
46
 
47
47
  # construct result iframe
48
48
  iframe = "<iframe src='https://apps.groupdocs.com/document-viewer/embed/#{guid}' frameborder='0' width='100%' height='600'></iframe>"
@@ -54,5 +54,5 @@ post '/sample19' do
54
54
  end
55
55
 
56
56
  # set variables for template
57
- haml :sample19, :locals => { :userId => settings.client_id, :privateKey => settings.private_key, :sourceFileId => settings.sourceFileId, :targetFileId => settings.targetFileId, :callbackUrl => settings.callbackUrl, :iframe => iframe, :err => err }
57
+ haml :sample19, :locals => {:userId => settings.client_id, :privateKey => settings.private_key, :sourceFileId => settings.sourceFileId, :targetFileId => settings.targetFileId, :callbackUrl => settings.callbackUrl, :iframe => iframe, :err => err}
58
58
  end
@@ -11,19 +11,19 @@ post '/sample2' do
11
11
 
12
12
  begin
13
13
  # check required variables
14
- raise "Please enter all required parameters" if settings.client_id.empty? or settings.private_key.empty?
14
+ raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty?
15
15
 
16
16
  # make a request to API using client_id and private_key
17
- files_list = GroupDocs::Storage::Folder.list!('/', {}, { :client_id => settings.client_id, :private_key => settings.private_key })
17
+ files_list = GroupDocs::Storage::Folder.list!('/', {}, {:client_id => settings.client_id, :private_key => settings.private_key})
18
18
 
19
19
  # construct list of files
20
20
  filelist = ''
21
- files_list.each {|element| filelist << "#{element.name}<br />"}
21
+ files_list.each { |element| filelist << "#{element.name}<br />" }
22
22
 
23
23
  rescue Exception => e
24
24
  err = e.message
25
25
  end
26
26
 
27
27
  # set variables for template
28
- haml :sample2, :locals => { :userId => settings.client_id, :privateKey => settings.private_key, :filelist => filelist, :err => err }
28
+ haml :sample2, :locals => {:userId => settings.client_id, :privateKey => settings.private_key, :filelist => filelist, :err => err}
29
29
  end
@@ -13,7 +13,7 @@ post '/sample20' do
13
13
  begin
14
14
 
15
15
  # check required variables
16
- raise "Please enter all required parameters" if settings.client_id.empty? or settings.private_key.empty? or settings.resultFileId.empty?
16
+ raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty? or settings.resultFileId.empty?
17
17
 
18
18
  # construct new storage file
19
19
  file = GroupDocs::Storage::File.new(guid: settings.resultFileId)
@@ -22,7 +22,7 @@ post '/sample20' do
22
22
  # get compare changes
23
23
  changes = document.changes!({:client_id => settings.client_id, :private_key => settings.private_key})
24
24
 
25
- result = ""
25
+ result = ''
26
26
  result += "<table class='border'>"
27
27
  result += "<tr><td><font color='green'>Change Name</font></td><td><font color='green'>Change</font></td></tr>"
28
28
  changes.each do |change|
@@ -39,12 +39,12 @@ post '/sample20' do
39
39
  result += "<tr bgcolor='#808080'><td></td><td></td></tr>"
40
40
  end
41
41
 
42
- result += "</table>"
42
+ result += '</table>'
43
43
 
44
44
  rescue Exception => e
45
45
  err = e.message
46
46
  end
47
47
 
48
48
  # set variables for template
49
- haml :sample20, :locals => { :userId => settings.client_id, :privateKey => settings.private_key, :resultFileId => settings.resultFileId, :result => result, :err => err }
49
+ haml :sample20, :locals => {:userId => settings.client_id, :privateKey => settings.private_key, :resultFileId => settings.resultFileId, :result => result, :err => err}
50
50
  end
@@ -16,7 +16,7 @@ post '/sample21' do
16
16
  begin
17
17
 
18
18
  # check required variables
19
- raise "Please enter all required parameters" if settings.client_id.empty? or settings.private_key.empty? or settings.email.empty? or settings.name.empty? or settings.lastName.empty? or settings.file.nil?
19
+ raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty? or settings.email.empty? or settings.name.empty? or settings.lastName.empty? or settings.file.nil?
20
20
 
21
21
  # construct path
22
22
  filepath = "#{Dir.tmpdir}/#{params[:file][:filename]}"
@@ -28,7 +28,7 @@ post '/sample21' do
28
28
  # create envelope using user id and entered by user name
29
29
  envelope = GroupDocs::Signature::Envelope.new
30
30
  envelope.name = params[:file][:filename]
31
- envelope.email_subject = "Sing this!"
31
+ envelope.email_subject = 'Sing this!'
32
32
  envelope.create!({}, client_id: settings.client_id, private_key: settings.private_key)
33
33
 
34
34
  # Add uploaded document to envelope
@@ -42,7 +42,7 @@ post '/sample21' do
42
42
  recipient.email = settings.email
43
43
  recipient.first_name = settings.name
44
44
  recipient.last_name = settings.lastName
45
- recipient.role_id = roles.detect { |role| role.name == "Signer" }.id
45
+ recipient.role_id = roles.detect { |role| role.name == 'Signer' }.id
46
46
 
47
47
  # Add recipient to envelope
48
48
  add = envelope.add_recipient!(recipient, {client_id: settings.client_id, private_key: settings.private_key})
@@ -61,5 +61,5 @@ post '/sample21' do
61
61
  end
62
62
 
63
63
  # set variables for template
64
- haml :sample21, :locals => { :userId => settings.client_id, :privateKey => settings.private_key, :email => settings.email, :name => settings.name, :lastName => settings.lastName, :iframe => iframe, :err => err }
64
+ haml :sample21, :locals => {:userId => settings.client_id, :privateKey => settings.private_key, :email => settings.email, :name => settings.name, :lastName => settings.lastName, :iframe => iframe, :err => err}
65
65
  end