groupdocs 1.1.0 → 1.2.0

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.
Files changed (130) hide show
  1. data/CHANGELOG.md +41 -0
  2. data/examples/README.md +2 -3
  3. data/examples/api-samples/Gemfile +5 -0
  4. data/examples/api-samples/Gemfile.lock +27 -0
  5. data/examples/api-samples/README.md +12 -0
  6. data/examples/api-samples/app.rb +17 -0
  7. data/examples/api-samples/public/css/style.css +166 -0
  8. data/examples/api-samples/samples/sample1.rb +17 -0
  9. data/examples/api-samples/samples/sample10.rb +36 -0
  10. data/examples/api-samples/samples/sample2.rb +19 -0
  11. data/examples/api-samples/samples/sample3.rb +23 -0
  12. data/examples/api-samples/samples/sample4.rb +31 -0
  13. data/examples/api-samples/samples/sample5.rb +44 -0
  14. data/examples/api-samples/samples/sample6.rb +3 -0
  15. data/examples/api-samples/samples/sample7.rb +33 -0
  16. data/examples/api-samples/samples/sample8.rb +40 -0
  17. data/examples/api-samples/samples/sample9.rb +22 -0
  18. data/examples/api-samples/views/index.haml +23 -0
  19. data/examples/api-samples/views/layout.haml +7 -0
  20. data/examples/api-samples/views/sample1.haml +71 -0
  21. data/examples/api-samples/views/sample10.haml +69 -0
  22. data/examples/api-samples/views/sample2.haml +59 -0
  23. data/examples/api-samples/views/sample3.haml +62 -0
  24. data/examples/api-samples/views/sample4.haml +58 -0
  25. data/examples/api-samples/views/sample5.haml +62 -0
  26. data/examples/api-samples/views/sample6.haml +145 -0
  27. data/examples/api-samples/views/sample7.haml +59 -0
  28. data/examples/api-samples/views/sample8.haml +75 -0
  29. data/examples/api-samples/views/sample9.haml +61 -0
  30. data/examples/{annotations → viewer}/Gemfile +0 -0
  31. data/examples/viewer/app.rb +52 -0
  32. data/groupdocs.gemspec +5 -4
  33. data/lib/groupdocs/api.rb +1 -0
  34. data/lib/groupdocs/api/entity.rb +2 -0
  35. data/lib/groupdocs/api/helpers.rb +2 -0
  36. data/lib/groupdocs/api/helpers/accessor_helper.rb +30 -0
  37. data/lib/groupdocs/api/helpers/mime_helper.rb +21 -0
  38. data/lib/groupdocs/api/helpers/rest_helper.rb +3 -2
  39. data/lib/groupdocs/api/request.rb +1 -3
  40. data/lib/groupdocs/datasource.rb +1 -2
  41. data/lib/groupdocs/document.rb +133 -3
  42. data/lib/groupdocs/document/annotation.rb +14 -13
  43. data/lib/groupdocs/document/annotation/reply.rb +4 -8
  44. data/lib/groupdocs/document/annotation/reviewer.rb +2 -4
  45. data/lib/groupdocs/document/field.rb +10 -8
  46. data/lib/groupdocs/document/rectangle.rb +10 -18
  47. data/lib/groupdocs/job.rb +1 -1
  48. data/lib/groupdocs/questionnaire.rb +138 -44
  49. data/lib/groupdocs/questionnaire/collector.rb +262 -0
  50. data/lib/groupdocs/questionnaire/execution.rb +93 -10
  51. data/lib/groupdocs/questionnaire/question.rb +1 -2
  52. data/lib/groupdocs/signature.rb +16 -24
  53. data/lib/groupdocs/signature/contact.rb +2 -4
  54. data/lib/groupdocs/signature/envelope.rb +3 -6
  55. data/lib/groupdocs/signature/envelope/log.rb +2 -4
  56. data/lib/groupdocs/signature/field.rb +21 -42
  57. data/lib/groupdocs/signature/field/location.rb +18 -36
  58. data/lib/groupdocs/signature/form.rb +9 -18
  59. data/lib/groupdocs/signature/list.rb +1 -2
  60. data/lib/groupdocs/signature/recipient.rb +3 -6
  61. data/lib/groupdocs/signature/role.rb +4 -8
  62. data/lib/groupdocs/signature/shared/entity_fields.rb +12 -20
  63. data/lib/groupdocs/signature/template.rb +1 -2
  64. data/lib/groupdocs/storage/file.rb +3 -1
  65. data/lib/groupdocs/storage/folder.rb +7 -1
  66. data/lib/groupdocs/subscription.rb +6 -12
  67. data/lib/groupdocs/subscription/limit.rb +4 -8
  68. data/lib/groupdocs/user.rb +3 -6
  69. data/lib/groupdocs/version.rb +1 -1
  70. data/spec/groupdocs/api/helpers/accessor_helper_spec.rb +16 -0
  71. data/spec/groupdocs/api/helpers/mime_helper_spec.rb +16 -0
  72. data/spec/groupdocs/api/helpers/rest_helper_spec.rb +4 -0
  73. data/spec/groupdocs/api/request_spec.rb +3 -5
  74. data/spec/groupdocs/datasource/field_spec.rb +3 -6
  75. data/spec/groupdocs/datasource_spec.rb +8 -15
  76. data/spec/groupdocs/document/annotation/reply_spec.rb +13 -24
  77. data/spec/groupdocs/document/annotation/reviewer_spec.rb +5 -9
  78. data/spec/groupdocs/document/annotation_spec.rb +35 -40
  79. data/spec/groupdocs/document/change_spec.rb +6 -11
  80. data/spec/groupdocs/document/field_spec.rb +13 -13
  81. data/spec/groupdocs/document/metadata_spec.rb +5 -10
  82. data/spec/groupdocs/document/rectangle_spec.rb +6 -18
  83. data/spec/groupdocs/document/view_spec.rb +3 -6
  84. data/spec/groupdocs/document_spec.rb +123 -10
  85. data/spec/groupdocs/job_spec.rb +9 -18
  86. data/spec/groupdocs/questionnaire/collector_spec.rb +201 -0
  87. data/spec/groupdocs/questionnaire/execution_spec.rb +91 -23
  88. data/spec/groupdocs/questionnaire/page_spec.rb +3 -6
  89. data/spec/groupdocs/questionnaire/question/answer_spec.rb +2 -4
  90. data/spec/groupdocs/questionnaire/question_spec.rb +7 -14
  91. data/spec/groupdocs/questionnaire_spec.rb +117 -41
  92. data/spec/groupdocs/signature/contact_spec.rb +9 -17
  93. data/spec/groupdocs/signature/envelope/log_spec.rb +8 -16
  94. data/spec/groupdocs/signature/envelope_spec.rb +9 -17
  95. data/spec/groupdocs/signature/field/location_spec.rb +32 -65
  96. data/spec/groupdocs/signature/field_spec.rb +48 -95
  97. data/spec/groupdocs/signature/form_spec.rb +22 -43
  98. data/spec/groupdocs/signature/list_spec.rb +6 -11
  99. data/spec/groupdocs/signature/recipient_spec.rb +11 -22
  100. data/spec/groupdocs/signature/role_spec.rb +11 -21
  101. data/spec/groupdocs/signature/template_spec.rb +2 -4
  102. data/spec/groupdocs/signature_spec.rb +28 -54
  103. data/spec/groupdocs/storage/file_spec.rb +14 -26
  104. data/spec/groupdocs/storage/folder_spec.rb +16 -22
  105. data/spec/groupdocs/storage/package_spec.rb +2 -4
  106. data/spec/groupdocs/subscription/limit_spec.rb +8 -16
  107. data/spec/groupdocs/subscription_spec.rb +11 -22
  108. data/spec/groupdocs/user_spec.rb +21 -41
  109. data/spec/groupdocs_spec.rb +4 -8
  110. data/spec/spec_helper.rb +12 -0
  111. data/spec/support/files/signature.png +0 -0
  112. data/spec/support/json/annotation_list.json +6 -6
  113. data/spec/support/json/comparison_changes.json +8 -8
  114. data/spec/support/json/document_fields.json +8 -8
  115. data/spec/support/json/document_page_images_get.json +20 -0
  116. data/spec/support/json/questionnaire_collector.json +17 -0
  117. data/spec/support/json/questionnaire_collectors.json +38 -0
  118. data/spec/support/json/questionnaire_collectors_add.json +10 -0
  119. data/spec/support/json/questionnaire_create.json +3 -1
  120. data/spec/support/json/{questionnaire_execution_create.json → questionnaire_execution_add.json} +1 -1
  121. data/spec/support/json/questionnaire_get.json +3 -0
  122. data/spec/support/json/questionnaires_get.json +36 -18
  123. data/spec/support/json/sign_documents.json +16 -0
  124. data/spec/support/json/templates_get.json +21 -0
  125. data/spec/support/shared_examples/api/entity.rb +2 -0
  126. data/spec/support/shared_examples/api/helpers/access_mode_helper.rb +1 -2
  127. data/spec/support/shared_examples/api/helpers/status_helper.rb +1 -2
  128. data/spec/support/shared_examples/signature/shared/entity_fields.rb +22 -43
  129. metadata +82 -16
  130. data/examples/annotations/app.rb +0 -67
data/CHANGELOG.md CHANGED
@@ -1,3 +1,44 @@
1
+ ## v1.2
2
+
3
+ **New**
4
+
5
+ * Added `Annotation::Collector` class
6
+ * Added `Collector.get!`
7
+ * Added `Collector#add!`
8
+ * Added `Collector#update!`
9
+ * Added `Collector#remove!`
10
+ * Added `Collector#executions!`
11
+ * Added `Collector#add_execution!`
12
+ * Added `Collector#fill!`
13
+ * Added `Document.templates!`
14
+ * Added `Questionnaire#executions!`
15
+ * Added `Questionnaire#collectors!`
16
+ * Added `Questionnaire#metadata!`
17
+ * Added `Questionnaire#update_metadata!`
18
+ * Added `Questionnaire#fields!`
19
+ * Added `Execution.get!`
20
+ * Added `Execution#delete!`
21
+ * Added `Execution#fill!`
22
+ * Added `Document.sign_documents!`
23
+ * Added `Document#page_images!`
24
+ * Added MIME helper
25
+
26
+ **Changes**
27
+
28
+ * Fixed `Questionnaire#create!`
29
+ * Fixed `Field#rectangle=`
30
+ * Fixed `File#download!`
31
+ * Fixed `Folder#list!` params handling (see issue #30)
32
+ * Fixed coordinates-related responses (they now have downcased fields)
33
+ * Fixed `Job#add_datasource!`
34
+ * `Questionnaire.all!` now accepts optional paging and status filter params
35
+ * New attributes for a lot of entities
36
+
37
+ **Removed**
38
+
39
+ * Removed `Questionnaire#create_execution!`
40
+
41
+
1
42
  ## v1.1
2
43
 
3
44
  **New**
data/examples/README.md CHANGED
@@ -1,12 +1,11 @@
1
1
  ## Examples
2
2
 
3
- ### Annotations
4
-
3
+ ### Viewer
5
4
  Grab the copy of examples
6
5
 
7
6
  gem install bundler # unless it's already installed
8
7
  git clone git@github.com:groupdocs/groupdocs-ruby.git
9
- cd groupdocs-ruby/examples/annotations
8
+ cd groupdocs-ruby/examples/viewer
10
9
  bundle install --path vendor/bundle
11
10
  bundle exec ruby app.rb
12
11
 
@@ -0,0 +1,5 @@
1
+ source :rubygems
2
+
3
+ gem 'sinatra'
4
+ gem 'groupdocs', :git => 'git://github.com/p0deje/groupdocs-ruby.git'
5
+ gem 'haml'
@@ -0,0 +1,27 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ groupdocs (1.1.0)
5
+ json (~> 1.7)
6
+ rest-client (~> 1.6)
7
+ haml (3.1.7)
8
+ json (1.7.5)
9
+ mime-types (1.19)
10
+ rack (1.4.1)
11
+ rack-protection (1.2.0)
12
+ rack
13
+ rest-client (1.6.7)
14
+ mime-types (>= 1.16)
15
+ sinatra (1.3.3)
16
+ rack (~> 1.3, >= 1.3.6)
17
+ rack-protection (~> 1.2)
18
+ tilt (~> 1.3, >= 1.3.3)
19
+ tilt (1.3.3)
20
+
21
+ PLATFORMS
22
+ ruby
23
+
24
+ DEPENDENCIES
25
+ groupdocs
26
+ haml
27
+ sinatra
@@ -0,0 +1,12 @@
1
+ ## Examples
2
+
3
+ ### Viewer
4
+ Grab the copy of examples
5
+
6
+ gem install bundler # unless it's already installed
7
+ git clone git@github.com:groupdocs/groupdocs-ruby.git
8
+ cd groupdocs-ruby/examples/viewer
9
+ bundle install --path vendor/bundle
10
+ bundle exec ruby app.rb
11
+
12
+ Now open `http://localhost:4567` and try it!
@@ -0,0 +1,17 @@
1
+ require 'sinatra'
2
+ require 'groupdocs'
3
+ require 'haml'
4
+ require 'pp'
5
+
6
+ GroupDocs.api_version = '2.0'
7
+
8
+ get '/' do
9
+ haml :index
10
+ end
11
+
12
+ get '/style.css' do
13
+ sass :style
14
+ end
15
+
16
+ Dir["samples/*.rb"].each {|file| require_relative file }
17
+
@@ -0,0 +1,166 @@
1
+ html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,
2
+ p,blockquote,pre,a,abbr,acronym,address,big,code,em,img,
3
+ small,strong,sub,sup,tt,b,u,i,center,
4
+ ol,ul,li,table,caption,tbody,tfoot,thead,tr,th,td {
5
+ margin:0;
6
+ padding:0;
7
+ border:0;
8
+ font-size:100%;
9
+ font:inherit;
10
+ vertical-align:baseline;
11
+ }
12
+ body { line-height:1; }
13
+ ol,ul { list-style:none; }
14
+ blockquote,q { quotes:none; }
15
+ blockquote:before,
16
+ blockquote:after,
17
+ q:before,q:after {
18
+ content:'';
19
+ content:none;
20
+ }
21
+ table {
22
+ border-collapse:collapse;
23
+ border-spacing:0;
24
+ }
25
+ @font-face {
26
+ font-family:qlassik;
27
+ src:url("../fonts/qlassik.eot");
28
+ }
29
+ @font-face {
30
+ font-family:qlassik;
31
+ src:url("../fonts/qlassik.otf") format("opentype");
32
+ }
33
+ @font-face {
34
+ font-family:monaco;
35
+ src:url("../fonts/monaco.eot");
36
+ }
37
+ @font-face {
38
+ font-family:monaco;
39
+ src:url("../fonts/monaco.ttf");
40
+ }
41
+ html {
42
+ font-family:verdana,helvetica,geneva,sans-serif;
43
+ font-size:15px;
44
+ background:#000;
45
+ overflow-y:scroll;
46
+ }
47
+ body {
48
+ background:#fff;
49
+ margin:20px auto;
50
+ width:980px;
51
+ border-radius:15px;
52
+ -moz-border-radius:15px;
53
+ -webkit-border-radius:15px;
54
+ }
55
+ h1,h2,h3,h4,h5 {
56
+ font-family:qlassik;
57
+ text-shadow:0 2px 5px #999;
58
+ clear:both;
59
+ }
60
+ h1 { font-size:64px; }
61
+ h2 { font-size:40px; }
62
+ h3 { font-size:36px; }
63
+ h4 { font-size:28px; }
64
+ h5 { font-size:21px; }
65
+ blockquote {
66
+ padding:10px;
67
+ border:1px solid #666;
68
+ margin:0 auto 15px auto;
69
+ width:610px;
70
+ border-radius:10px;
71
+ -moz-border-radius:10px;
72
+ -webkit-border-radius:10px;
73
+ }
74
+ blockquote:first-child {
75
+ margin-top:15px;
76
+ }
77
+ p,ul,ol {
78
+ line-height:18px;
79
+ margin-bottom:15px;
80
+ }
81
+ p:last-child { margin-bottom:0; }
82
+ ul,ol { margin:0 45px 15px 45px; }
83
+ li { list-style-type:disc; }
84
+ pre,code,tt {
85
+ font-family:monaco;
86
+ font-size:13px;
87
+ line-height:16px;
88
+ }
89
+ pre {
90
+ background:#ccc;
91
+ padding:15px;
92
+ margin-bottom:15px;
93
+ }
94
+ pre:last-child { margin-bottom:0; }
95
+ code,tt {
96
+ background:#ccc;
97
+ padding:2px 5px;
98
+ }
99
+ small { font-size:0.6em; }
100
+ a { text-decoration:none; }
101
+ a:link,a:visited { color:#069; }
102
+ a:hover { color:#09c; }
103
+ table {
104
+ margin-bottom:15px;
105
+ width:100%;
106
+ }
107
+ th,td {
108
+ font-size:15px;
109
+ line-height:15px;
110
+ padding:5px 15px 5px 5px;
111
+ vertical-align:top;
112
+ }
113
+ th {
114
+ font-size:11px;
115
+ font-variant:small-caps;
116
+ text-align:left;
117
+ vertical-align:top;
118
+ }
119
+ td:last-child {
120
+ padding-right:3px;
121
+ }
122
+ tr.odd { background:#ccc; }
123
+ div.header,div.content,div.footer { padding:30px; }
124
+ div.content h3,div.content h4 { margin-bottom:15px; }
125
+ div.content table {
126
+ border:1px solid #666;
127
+ margin:0 auto 15px auto;
128
+ width:640px;
129
+ }
130
+ div.content tr { border:1px solid #666; }
131
+ div.content th {
132
+ font-family:qlassik;
133
+ font-size:18px;
134
+ text-transform:uppercase;
135
+ color:#fff;
136
+ background:#666;
137
+ }
138
+ div.content th,div.content td { padding:8px; }
139
+ div.content td.pass { background:#cfc; }
140
+ div.content td.fail { background:#fcc; }
141
+ div.header {
142
+ background:#999;
143
+ border-radius:15px 15px 0 0;
144
+ -moz-border-radius:15px 15px 0 0;
145
+ -webkit-border-radius:15px 15px 0 0;
146
+ }
147
+ div.header h4 {
148
+ font-family:qlassik;
149
+ text-align:center;
150
+ color:#333;
151
+ }
152
+ div.header h1 {
153
+ color:#fff;
154
+ font-size:72px;
155
+ text-align:center;
156
+ text-shadow:0 2px 5px #000;
157
+ }
158
+ div.footer {
159
+ background:#333;
160
+ }
161
+ div.footer h5 {
162
+ color:#666;
163
+ text-align:center;
164
+ text-shadow:0 2px 5px #000;
165
+ margin:0;
166
+ }
@@ -0,0 +1,17 @@
1
+ get '/sample1' do
2
+
3
+ haml :sample1
4
+ end
5
+
6
+ post '/sample1' do
7
+ set :client_id, params[:client_id]
8
+ set :private_key, params[:private_key]
9
+ begin
10
+ raise "Please enter all required parameters" if settings.client_id.empty? or settings.private_key.empty?
11
+ user = GroupDocs::User.get!({:client_id => settings.client_id, :private_key => settings.private_key})
12
+ rescue Exception => e
13
+ err = e.message
14
+ end
15
+
16
+ haml :sample1, :locals => { :userId => settings.client_id, :privateKey => settings.private_key, :user => user, :err => err }
17
+ end
@@ -0,0 +1,36 @@
1
+ get '/sample10' do
2
+ haml :sample10
3
+ end
4
+
5
+ post '/sample10' do
6
+ set :client_id, params[:client_id]
7
+ set :private_key, params[:private_key]
8
+ set :guid, params[:guid]
9
+ set :email, params[:email]
10
+ begin
11
+ raise "Please enter all required parameters" if settings.client_id.empty? or settings.private_key.empty? or settings.guid.empty? or settings.email.empty?
12
+
13
+ files_list = GroupDocs::Storage::Folder.list!('/', {}, { :client_id => settings.client_id, :private_key => settings.private_key})
14
+ name = nil
15
+ doc = nil
16
+ files_list.each do |element|
17
+ if element.class.name.split('::').last == 'Folder'
18
+ next
19
+ end
20
+
21
+ if element.guid == settings.guid
22
+ name = element.name
23
+ doc = element
24
+ end
25
+ end
26
+
27
+ shared = doc.to_document.sharers_set!(settings.email.split(" "), { :client_id => settings.client_id, :private_key => settings.private_key});
28
+ if shared
29
+ shared_emails = settings.email
30
+ end
31
+ rescue Exception => e
32
+ err = e.message
33
+ end
34
+
35
+ haml :sample10, :locals => { :client_id => settings.client_id, :private_key => settings.private_key, :guid => settings.guid, :email=>settings.email, :shared => shared_emails, :err => err }
36
+ end
@@ -0,0 +1,19 @@
1
+ get '/sample2' do
2
+ haml :sample2
3
+ end
4
+
5
+ post '/sample2' do
6
+ set :client_id, params[:client_id]
7
+ set :private_key, params[:private_key]
8
+
9
+ begin
10
+ raise "Please enter all required parameters" if settings.client_id.empty? or settings.private_key.empty?
11
+ files_list = GroupDocs::Storage::Folder.list!('/', {}, { :client_id => settings.client_id, :private_key => settings.private_key})
12
+ filelist = ''
13
+ files_list.each {|element| filelist += element.name + '<br />'}
14
+ rescue Exception => e
15
+ err = e.message
16
+ end
17
+
18
+ haml :sample2, :locals => { :userId => settings.client_id, :privateKey => settings.private_key, :filelist => filelist, :err => err }
19
+ end
@@ -0,0 +1,23 @@
1
+ get '/sample3' do
2
+
3
+ haml :sample3
4
+ end
5
+
6
+ post '/sample3' do
7
+ set :client_id, params[:client_id]
8
+ set :private_key, params[:private_key]
9
+ begin
10
+ raise "Please enter all required parameters" if settings.client_id.empty? or settings.private_key.empty?
11
+
12
+ filepath = "#{Dir.tmpdir}/#{params[:file][:filename]}"
13
+ File.open(filepath, 'wb') { |f| f.write(params[:file][:tempfile].read) }
14
+ file = GroupDocs::Storage::File.upload!(filepath, {}, client_id: settings.client_id, private_key: settings.private_key)
15
+ massage = "<p>File was uploaded to GroupDocs. Here you can see your <strong>#{params[:file][:filename]}</strong> file in the GroupDocs Embedded Viewer.</p>"
16
+ iframe = "<iframe src='https://apps.groupdocs.com/document-viewer/Embed/#{file.guid}' frameborder='0' width='720' height='600'></iframe>"
17
+
18
+ rescue Exception => e
19
+ err = e.message
20
+ end
21
+
22
+ haml :sample3, :locals => { :userId => settings.client_id, :privateKey => settings.private_key, :iframe=>iframe, :massage => massage, :err => err }
23
+ end
@@ -0,0 +1,31 @@
1
+ get '/sample4' do
2
+ haml :sample4
3
+ end
4
+
5
+ post '/sample4' do
6
+ set :client_id, params[:client_id]
7
+ set :private_key, params[:private_key]
8
+ set :file_id, params[:file_id]
9
+ begin
10
+ raise "Please enter all required parameters" if settings.client_id.empty? or settings.private_key.empty? or settings.file_id.empty?
11
+
12
+ files_list = GroupDocs::Storage::Folder.list!('/', {}, { :client_id => settings.client_id, :private_key => settings.private_key})
13
+ dowload_file = ''
14
+
15
+ files_list.each do |element|
16
+ if element.id == Integer(settings.file_id)
17
+ dowload_file = element
18
+ end
19
+ end
20
+
21
+ dowloaded_file = dowload_file.download!(File.dirname(__FILE__), { :client_id => settings.client_id, :private_key => settings.private_key})
22
+ unless dowloaded_file.empty?
23
+ massage = "<font color='green'>File was downloaded to the <font color='blue'>#{dowloaded_file}</font> folder</font> <br />"
24
+ end
25
+
26
+ rescue Exception => e
27
+ err = e.message
28
+ end
29
+
30
+ haml :sample4, :locals => { :userId => settings.client_id, :privateKey => settings.private_key, :file_id => settings.file_id, :massage => massage, :err => err }
31
+ end
@@ -0,0 +1,44 @@
1
+ get '/sample5' do
2
+ haml :sample5
3
+ end
4
+
5
+ post '/sample5' do
6
+ set :client_id, params[:client_id]
7
+ set :private_key, params[:private_key]
8
+ set :file_id, params[:file_id]
9
+ set :copy, params[:copy]
10
+ set :move, params[:move]
11
+ set :dest_path, params[:dest_path]
12
+
13
+ begin
14
+ raise "Please enter all required parameters" if settings.client_id.empty? or settings.private_key.empty? or settings.file_id.empty?
15
+
16
+ files_list = GroupDocs::Storage::Folder.list!('/', {}, { :client_id => settings.client_id, :private_key => settings.private_key})
17
+ manipulate_file = nil
18
+ files_list.each do |element|
19
+ if element.id == Integer(settings.file_id)
20
+ manipulate_file = element
21
+ end
22
+ end
23
+ raise "No file with such FileID" if manipulate_file.nil?
24
+
25
+ unless settings.copy.nil?
26
+ file = manipulate_file.copy!(settings.dest_path, {}, { :client_id => settings.client_id, :private_key => settings.private_key})
27
+ button = settings.copy
28
+ end
29
+
30
+ unless settings.move.nil?
31
+ file = manipulate_file.move!(settings.dest_path, {}, { :client_id => settings.client_id, :private_key => settings.private_key})
32
+ button = settings.move
33
+ end
34
+
35
+ if file
36
+ massage = "File was #{button}'ed to the #{settings.dest_path} folder"
37
+ end
38
+
39
+ rescue Exception => e
40
+ err = e.message
41
+ end
42
+
43
+ haml :sample5, :locals => { :userId => settings.client_id, :privateKey => settings.private_key, :file_id => settings.file_id, :dest_path => settings.dest_path, :massage => massage, :err => err }
44
+ end