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.
Files changed (177) hide show
  1. data/CHANGELOG.md +51 -0
  2. data/examples/api-samples/Gemfile +1 -1
  3. data/examples/api-samples/Gemfile.lock +43 -0
  4. data/examples/api-samples/public/docs/{sample2.html → sample01.html} +39 -19
  5. data/examples/api-samples/public/docs/{sample3.html → sample02.html} +28 -22
  6. data/examples/api-samples/public/docs/sample03.html +285 -0
  7. data/examples/api-samples/public/docs/{sample4.html → sample04.html} +30 -36
  8. data/examples/api-samples/public/docs/{sample5.html → sample05.html} +68 -31
  9. data/examples/api-samples/public/docs/sample06.html +299 -0
  10. data/examples/api-samples/public/docs/{sample7.html → sample07.html} +53 -18
  11. data/examples/api-samples/public/docs/{sample8.html → sample08.html} +64 -41
  12. data/examples/api-samples/public/docs/sample09.html +260 -0
  13. data/examples/api-samples/public/docs/sample10.html +67 -28
  14. data/examples/api-samples/public/docs/sample11.html +171 -55
  15. data/examples/api-samples/public/docs/sample12.html +53 -17
  16. data/examples/api-samples/public/docs/sample13.html +52 -16
  17. data/examples/api-samples/public/docs/sample14.html +51 -8
  18. data/examples/api-samples/public/docs/sample15.html +46 -10
  19. data/examples/api-samples/public/docs/sample16.html +81 -7
  20. data/examples/api-samples/public/docs/sample17.html +103 -15
  21. data/examples/api-samples/public/docs/sample18.html +117 -41
  22. data/examples/api-samples/public/docs/sample19.html +410 -36
  23. data/examples/api-samples/public/docs/sample20.html +46 -10
  24. data/examples/api-samples/public/docs/sample21.html +504 -45
  25. data/examples/api-samples/public/docs/sample22.html +166 -28
  26. data/examples/api-samples/public/docs/sample23.html +61 -25
  27. data/examples/api-samples/public/docs/sample24.html +100 -12
  28. data/examples/api-samples/public/docs/sample25.html +123 -49
  29. data/examples/api-samples/public/docs/sample26.html +41 -8
  30. data/examples/api-samples/public/docs/sample27.html +125 -50
  31. data/examples/api-samples/public/docs/sample28.html +27 -9
  32. data/examples/api-samples/public/docs/sample29.html +10 -10
  33. data/examples/api-samples/public/docs/sample30.html +70 -14
  34. data/examples/api-samples/public/docs/sample31.html +108 -67
  35. data/examples/api-samples/public/docs/sample32.html +71 -99
  36. data/examples/api-samples/public/docs/sample33.html +107 -32
  37. data/examples/api-samples/public/docs/{sample1.html → sample34.html} +58 -18
  38. data/examples/api-samples/public/docs/sample35.html +666 -0
  39. data/examples/api-samples/public/docs/{sample6.html → sample36.html} +56 -37
  40. data/examples/api-samples/public/docs/sample37.html +815 -0
  41. data/examples/api-samples/public/docs/sample38.html +508 -0
  42. data/examples/api-samples/public/docs/sample39.html +921 -0
  43. data/examples/api-samples/public/docs/sample40.html +510 -0
  44. data/examples/api-samples/public/docs/sample41.html +452 -0
  45. data/examples/api-samples/public/docs/sample42.html +311 -0
  46. data/examples/api-samples/public/templates/test_all_fields2.pdf +0 -0
  47. data/examples/api-samples/samples/sample01.rb +37 -0
  48. data/examples/api-samples/samples/sample02.rb +41 -0
  49. data/examples/api-samples/samples/sample03.rb +73 -0
  50. data/examples/api-samples/samples/sample04.rb +47 -0
  51. data/examples/api-samples/samples/{sample5.rb → sample05.rb} +26 -14
  52. data/examples/api-samples/samples/sample06.rb +80 -0
  53. data/examples/api-samples/samples/sample07.rb +52 -0
  54. data/examples/api-samples/samples/sample08.rb +69 -0
  55. data/examples/api-samples/samples/sample09.rb +83 -0
  56. data/examples/api-samples/samples/sample10.rb +29 -15
  57. data/examples/api-samples/samples/sample11.rb +89 -37
  58. data/examples/api-samples/samples/sample12.rb +22 -11
  59. data/examples/api-samples/samples/sample13.rb +22 -10
  60. data/examples/api-samples/samples/sample14.rb +23 -5
  61. data/examples/api-samples/samples/sample15.rb +18 -7
  62. data/examples/api-samples/samples/sample16.rb +28 -4
  63. data/examples/api-samples/samples/sample17.rb +31 -5
  64. data/examples/api-samples/samples/sample18.rb +36 -8
  65. data/examples/api-samples/samples/sample19.rb +138 -18
  66. data/examples/api-samples/samples/sample20.rb +14 -3
  67. data/examples/api-samples/samples/sample21.rb +162 -23
  68. data/examples/api-samples/samples/sample22.rb +73 -22
  69. data/examples/api-samples/samples/sample23.rb +17 -6
  70. data/examples/api-samples/samples/sample24.rb +34 -7
  71. data/examples/api-samples/samples/sample25.rb +37 -12
  72. data/examples/api-samples/samples/sample26.rb +12 -5
  73. data/examples/api-samples/samples/sample27.rb +38 -12
  74. data/examples/api-samples/samples/sample28.rb +25 -6
  75. data/examples/api-samples/samples/sample29.rb +12 -12
  76. data/examples/api-samples/samples/sample30.rb +27 -15
  77. data/examples/api-samples/samples/sample31.rb +44 -33
  78. data/examples/api-samples/samples/sample32.rb +43 -41
  79. data/examples/api-samples/samples/sample33.rb +42 -14
  80. data/examples/api-samples/samples/sample34.rb +40 -0
  81. data/examples/api-samples/samples/sample35.rb +224 -0
  82. data/examples/api-samples/samples/sample36.rb +58 -0
  83. data/examples/api-samples/samples/sample37.rb +229 -0
  84. data/examples/api-samples/samples/sample38.rb +128 -0
  85. data/examples/api-samples/samples/sample39.rb +252 -0
  86. data/examples/api-samples/samples/sample40.rb +164 -0
  87. data/examples/api-samples/samples/sample41.rb +118 -0
  88. data/examples/api-samples/samples/sample42.rb +97 -0
  89. data/examples/api-samples/views/_others_samples.haml +25 -11
  90. data/examples/api-samples/views/index.haml +23 -11
  91. data/examples/api-samples/views/popup.haml +32 -0
  92. data/examples/api-samples/views/{sample1.haml → sample01.haml} +12 -7
  93. data/examples/api-samples/views/{sample2.haml → sample02.haml} +20 -15
  94. data/examples/api-samples/views/sample03.haml +83 -0
  95. data/examples/api-samples/views/sample04.haml +49 -0
  96. data/examples/api-samples/views/{sample5.haml → sample05.haml} +19 -14
  97. data/examples/api-samples/views/sample06.haml +53 -0
  98. data/examples/api-samples/views/sample07.haml +47 -0
  99. data/examples/api-samples/views/{sample8.haml → sample08.haml} +17 -12
  100. data/examples/api-samples/views/{sample9.haml → sample09.haml} +19 -4
  101. data/examples/api-samples/views/sample10.haml +18 -13
  102. data/examples/api-samples/views/sample11.haml +48 -19
  103. data/examples/api-samples/views/sample12.haml +26 -21
  104. data/examples/api-samples/views/sample13.haml +18 -12
  105. data/examples/api-samples/views/sample14.haml +21 -15
  106. data/examples/api-samples/views/sample15.haml +16 -9
  107. data/examples/api-samples/views/sample16.haml +18 -5
  108. data/examples/api-samples/views/sample17.haml +14 -9
  109. data/examples/api-samples/views/sample18.haml +13 -7
  110. data/examples/api-samples/views/sample19.haml +37 -8
  111. data/examples/api-samples/views/sample20.haml +13 -8
  112. data/examples/api-samples/views/sample21.haml +71 -13
  113. data/examples/api-samples/views/sample22.haml +53 -16
  114. data/examples/api-samples/views/sample23.haml +9 -4
  115. data/examples/api-samples/views/sample24.haml +9 -4
  116. data/examples/api-samples/views/sample25.haml +18 -13
  117. data/examples/api-samples/views/sample26.haml +8 -3
  118. data/examples/api-samples/views/sample27.haml +20 -14
  119. data/examples/api-samples/views/sample28.haml +16 -10
  120. data/examples/api-samples/views/sample29.haml +4 -4
  121. data/examples/api-samples/views/sample30.haml +16 -10
  122. data/examples/api-samples/views/sample31.haml +39 -32
  123. data/examples/api-samples/views/sample32.haml +25 -36
  124. data/examples/api-samples/views/sample33.haml +14 -17
  125. data/examples/api-samples/views/sample34.haml +48 -0
  126. data/examples/api-samples/views/sample35.haml +95 -0
  127. data/examples/api-samples/views/sample36.haml +64 -0
  128. data/examples/api-samples/views/sample37.haml +124 -0
  129. data/examples/api-samples/views/sample38.haml +115 -0
  130. data/examples/api-samples/views/sample39.haml +236 -0
  131. data/examples/api-samples/views/sample40.haml +95 -0
  132. data/examples/api-samples/views/{sample4.haml → sample41.haml} +90 -72
  133. data/examples/api-samples/views/sample42.haml +59 -0
  134. data/lib/groupdocs/api/helpers/rest_helper.rb +13 -1
  135. data/lib/groupdocs/datasource.rb +2 -1
  136. data/lib/groupdocs/document.rb +101 -13
  137. data/lib/groupdocs/document/annotation.rb +28 -13
  138. data/lib/groupdocs/document/annotation/marker.rb +18 -0
  139. data/lib/groupdocs/document/annotation/reply.rb +9 -2
  140. data/lib/groupdocs/document/field.rb +5 -1
  141. data/lib/groupdocs/job.rb +12 -2
  142. data/lib/groupdocs/questionnaire.rb +174 -4
  143. data/lib/groupdocs/questionnaire/collector.rb +21 -0
  144. data/lib/groupdocs/questionnaire/question.rb +19 -0
  145. data/lib/groupdocs/questionnaire/question/answer.rb +5 -0
  146. data/lib/groupdocs/questionnaire/question/conditions.rb +20 -0
  147. data/lib/groupdocs/signature.rb +36 -308
  148. data/lib/groupdocs/signature/envelope.rb +146 -4
  149. data/lib/groupdocs/signature/field.rb +20 -1
  150. data/lib/groupdocs/signature/field/location.rb +18 -7
  151. data/lib/groupdocs/signature/form.rb +199 -10
  152. data/lib/groupdocs/signature/shared/document_methods.rb +38 -0
  153. data/lib/groupdocs/signature/shared/entity_methods.rb +0 -1
  154. data/lib/groupdocs/signature/shared/field_methods.rb +13 -38
  155. data/lib/groupdocs/signature/shared/recipient_methods.rb +8 -0
  156. data/lib/groupdocs/signature/template.rb +3 -1
  157. data/lib/groupdocs/storage.rb +4 -1
  158. data/lib/groupdocs/storage/file.rb +18 -1
  159. data/lib/groupdocs/subscription.rb +8 -3
  160. data/lib/groupdocs/user.rb +8 -0
  161. data/lib/groupdocs/version.rb +1 -1
  162. data/spec/groupdocs/document/annotation_spec.rb +1 -14
  163. data/spec/groupdocs/subscription_spec.rb +2 -2
  164. metadata +86 -32
  165. checksums.yaml +0 -15
  166. data/examples/api-samples/public/docs/sample9.html +0 -200
  167. data/examples/api-samples/samples/sample1.rb +0 -25
  168. data/examples/api-samples/samples/sample2.rb +0 -29
  169. data/examples/api-samples/samples/sample3.rb +0 -33
  170. data/examples/api-samples/samples/sample4.rb +0 -51
  171. data/examples/api-samples/samples/sample6.rb +0 -49
  172. data/examples/api-samples/samples/sample7.rb +0 -42
  173. data/examples/api-samples/samples/sample8.rb +0 -61
  174. data/examples/api-samples/samples/sample9.rb +0 -48
  175. data/examples/api-samples/views/sample3.haml +0 -44
  176. data/examples/api-samples/views/sample6.haml +0 -49
  177. data/examples/api-samples/views/sample7.haml +0 -42
@@ -6,11 +6,12 @@ end
6
6
  # POST request
7
7
  post '/sample25' do
8
8
  # set variables
9
- set :client_id, params[:client_id]
10
- set :private_key, params[:private_key]
9
+ set :client_id, params[:clientId]
10
+ set :private_key, params[:privateKey]
11
11
  set :source, params[:source]
12
12
  set :file_id, params[:fileId]
13
13
  set :url, params[:url]
14
+ set :base_path, params[:basePath]
14
15
 
15
16
  # Set download path
16
17
  downloads_path = "#{File.dirname(__FILE__)}/../public/downloads"
@@ -26,8 +27,17 @@ post '/sample25' do
26
27
  # Check required variables
27
28
  raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty?
28
29
 
30
+ if settings.base_path.empty? then settings.base_path = 'https://api.groupdocs.com' end
29
31
 
30
- # get document by file GUID
32
+ # Configure your access to API server
33
+ GroupDocs.configure do |groupdocs|
34
+ groupdocs.client_id = settings.client_id
35
+ groupdocs.private_key = settings.private_key
36
+ # Optionally specify API server and version
37
+ groupdocs.api_server = settings.base_path # default is 'https://api.groupdocs.com'
38
+ end
39
+
40
+ # Get document by file GUID
31
41
  case settings.source
32
42
  when 'guid'
33
43
  # Create instance of File
@@ -38,10 +48,10 @@ post '/sample25' do
38
48
  # Open file
39
49
  File.open(file_path, 'wb') { |f| f.write(params[:file][:tempfile].read) }
40
50
  # Make a request to API using client_id and private_key
41
- file = GroupDocs::Storage::File.upload!(file_path, {}, {:client_id => settings.client_id, :private_key => settings.private_key})
51
+ file = GroupDocs::Storage::File.upload!(file_path, {})
42
52
  when 'url'
43
53
  # Upload file from defined url
44
- file = GroupDocs::Storage::File.upload_web!(settings.url, {:client_id => settings.client_id, :private_key => settings.private_key})
54
+ file = GroupDocs::Storage::File.upload_web!(settings.url)
45
55
  else
46
56
  raise 'Wrong GUID source.'
47
57
  end
@@ -56,33 +66,48 @@ post '/sample25' do
56
66
  datasource = GroupDocs::DataSource.new
57
67
 
58
68
  # Get arry of document's fields
59
- fields = document.fields!({:client_id => settings.client_id, :private_key => settings.private_key})
69
+ fields = document.fields!()
60
70
 
61
71
  # Create Field instance and fill the fields
62
72
  datasource.fields = fields.map { |field| GroupDocs::DataSource::Field.new(name: field.name, type: :text, values: %w(value1 value2)) }
63
73
 
64
74
  # Adds datasource.
65
- datasource.add!({:client_id => settings.client_id, :private_key => settings.private_key})
75
+ datasource.add!()
66
76
 
67
77
 
68
78
  # Creates new job to merge datasource into document.
69
- job = document.datasource!(datasource, {:new_type => 'pdf'}, {:client_id => settings.client_id, :private_key => settings.private_key})
79
+ job = document.datasource!(datasource, {:new_type => 'pdf'})
70
80
  sleep 10 # wait for merge and convert
71
81
 
72
82
  # Returns an hash of input and output documents associated to job.
73
- document = job.documents!({:client_id => settings.client_id, :private_key => settings.private_key})
83
+ document = job.documents!()
74
84
 
75
85
  # Download file
76
- document[:inputs][0].outputs[0].download!("#{File.dirname(__FILE__)}/../public/downloads", {:client_id => settings.client_id, :private_key => settings.private_key})
86
+ document[:inputs][0].outputs[0].download!("#{File.dirname(__FILE__)}/../public/downloads")
77
87
 
78
88
  # Set converted document GUID
79
89
  guid = document[:inputs][0].outputs[0].guid
80
90
  # Set converted document Name
81
91
  file_name = document[:inputs][0].outputs[0].name
82
92
 
93
+ #Get url from request
94
+ case settings.base_path
95
+
96
+ when 'https://stage-api-groupdocs.dynabic.com'
97
+ url = "http://stage-apps-groupdocs.dynabic.com/document-viewer/embed/#{guid}"
98
+ when 'https://dev-api-groupdocs.dynabic.com'
99
+ url = "http://dev-apps-groupdocs.dynabic.com/document-viewer/embed/#{guid}"
100
+ else
101
+ url = "https://apps.groupdocs.com/document-viewer/embed/#{guid}"
102
+ end
103
+
104
+ # Add the signature to url the request
105
+
106
+ iframe = GroupDocs::Api::Request.new(:path => url).prepare_and_sign_url
107
+
83
108
  # Set iframe with document GUID or raise an error
84
109
  if guid
85
- iframe = "<iframe width='100%' height='600' frameborder='0' src='https://apps.groupdocs.com/document-viewer/embed/#{guid}'></iframe>"
110
+ iframe = "<iframe width='100%' height='600' frameborder='0' src='#{iframe}'></iframe>"
86
111
  else
87
112
  raise 'File was not converted'
88
113
  end
@@ -92,5 +117,5 @@ post '/sample25' do
92
117
  end
93
118
 
94
119
  # set variables for template
95
- haml :sample25, :locals => {:userId => settings.client_id, :privateKey => settings.private_key, :iframe => iframe, :file_name => file_name, :err => err}
120
+ haml :sample25, :locals => {:userId => settings.client_id, :privateKey => settings.private_key, :iframe => iframe, :fileName => file_name, :err => err}
96
121
  end
@@ -5,21 +5,28 @@ end
5
5
 
6
6
  # POST request
7
7
  post '/sample26' do
8
- set :email, params[:email]
8
+ set :email, params[:login]
9
9
  set :password, params[:password]
10
-
10
+ set :base_path, params[:basePath]
11
11
 
12
12
  begin
13
- # check required variables
13
+ # Check required variables
14
14
  raise 'Please enter all required parameters' if settings.email.empty? or settings.password.empty?
15
15
 
16
- # make a request to API using email and password
16
+ if settings.base_path.empty? then settings.base_path = 'https://api.groupdocs.com' end
17
+
18
+ # Configure your access to API server
19
+ GroupDocs.configure do |groupdocs|
20
+ # Optionally specify API server and version
21
+ groupdocs.api_server = settings.base_path # default is 'https://api.groupdocs.com'
22
+ end
23
+ # Make a request to API using email and password
17
24
  user = GroupDocs::User.login!(settings.email, settings.password)
18
25
 
19
26
  rescue Exception => e
20
27
  err = e.message
21
28
  end
22
29
 
23
- # set variables for template
30
+ # Set variables for template
24
31
  haml :sample26, :locals => {:user => user, :err => err}
25
32
  end
@@ -5,9 +5,9 @@ end
5
5
 
6
6
  # POST request
7
7
  post '/sample27' do
8
- # set variables
9
- set :client_id, params[:client_id]
10
- set :private_key, params[:private_key]
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 :source, params[:source]
13
13
  set :sex, params[:sex]
@@ -15,6 +15,7 @@ post '/sample27' do
15
15
  set :sunrise, params[:sunrise]
16
16
  set :name, params[:name]
17
17
  set :type, params[:type]
18
+ set :base_path, params[:basePath]
18
19
 
19
20
  # Set download path
20
21
  downloads_path = "#{File.dirname(__FILE__)}/../public/downloads"
@@ -30,7 +31,17 @@ post '/sample27' do
30
31
  # Check required variables
31
32
  raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty?
32
33
 
33
- # get document by file GUID
34
+ if settings.base_path.empty? then settings.base_path = 'https://api.groupdocs.com' end
35
+
36
+ # Configure your access to API server
37
+ GroupDocs.configure do |groupdocs|
38
+ groupdocs.client_id = settings.client_id
39
+ groupdocs.private_key = settings.private_key
40
+ # Optionally specify API server and version
41
+ groupdocs.api_server = settings.base_path # default is 'https://api.groupdocs.com'
42
+ end
43
+
44
+ # Get document by file GUID
34
45
  case settings.source
35
46
  when 'guid'
36
47
  # Create instance of File
@@ -41,10 +52,10 @@ post '/sample27' do
41
52
  # Open file
42
53
  File.open(file_path, 'wb') { |f| f.write(params[:file][:tempfile].read) }
43
54
  # Make a request to API using client_id and private_key
44
- file = GroupDocs::Storage::File.upload!(file_path, {}, {:client_id => settings.client_id, :private_key => settings.private_key})
55
+ file = GroupDocs::Storage::File.upload!(file_path, {})
45
56
  when 'url'
46
57
  # Upload file from defined url
47
- file = GroupDocs::Storage::File.upload_web!(settings.url, {:client_id => settings.client_id, :private_key => settings.private_key})
58
+ file = GroupDocs::Storage::File.upload_web!(settings.url)
48
59
  else
49
60
  raise 'Wrong GUID source.'
50
61
  end
@@ -66,17 +77,17 @@ post '/sample27' do
66
77
 
67
78
 
68
79
  # Adds datasource.
69
- datasource.add!({:client_id => settings.client_id, :private_key => settings.private_key})
80
+ datasource.add!()
70
81
 
71
82
  # Creates new job to merge datasource into document.
72
- job = document.datasource!(datasource, {:new_type => settings.type}, {:client_id => settings.client_id, :private_key => settings.private_key})
83
+ job = document.datasource!(datasource, {:new_type => settings.type})
73
84
  sleep 10 # wait for merge and convert
74
85
 
75
86
  # Returns an hash of input and output documents associated to job.
76
- document = job.documents!({:client_id => settings.client_id, :private_key => settings.private_key})
87
+ document = job.documents!()
77
88
 
78
89
  # Download file
79
- document[:inputs][0].outputs[0].download!(downloads_path, {:client_id => settings.client_id, :private_key => settings.private_key})
90
+ document[:inputs][0].outputs[0].download!(downloads_path)
80
91
 
81
92
  # Set converted document GUID
82
93
  guid = document[:inputs][0].outputs[0].guid
@@ -84,9 +95,24 @@ post '/sample27' do
84
95
  # Set converted document Name
85
96
  file_name = document[:inputs][0].outputs[0].name
86
97
 
98
+ #Get url from request
99
+ case settings.base_path
100
+
101
+ when 'https://stage-api-groupdocs.dynabic.com'
102
+ url = "http://stage-apps-groupdocs.dynabic.com/document-viewer/embed/#{guid}"
103
+ when 'https://dev-api-groupdocs.dynabic.com'
104
+ url = "http://dev-apps-groupdocs.dynabic.com/document-viewer/embed/#{guid}"
105
+ else
106
+ url = "https://apps.groupdocs.com/document-viewer/embed/#{guid}"
107
+ end
108
+
109
+ # Add the signature to url the request
110
+
111
+ iframe = GroupDocs::Api::Request.new(:path => url).prepare_and_sign_url
112
+
87
113
  # Set iframe with document GUID or raise an error
88
114
  if guid
89
- iframe = "<iframe width='100%' height='600' frameborder='0' src='https://apps.groupdocs.com/document-viewer/embed/#{guid}'></iframe>"
115
+ iframe = "<iframe width='100%' height='600' frameborder='0' src='#{iframe}'></iframe>"
90
116
  else
91
117
  raise 'File was not converted'
92
118
  end
@@ -95,6 +121,6 @@ post '/sample27' do
95
121
  err = e.message
96
122
  end
97
123
 
98
- # set variables for template
124
+ # Set variables for template
99
125
  haml :sample27, :locals => {:userId => settings.client_id, :privateKey => settings.private_key, :sex => settings.sex, :age => settings.age, :sunrise => settings.sunrise, :name => settings.name, :type => settings.type, :iframe => iframe, :file_name => file_name, :err => err}
100
126
  end
@@ -6,16 +6,27 @@ end
6
6
  # POST request
7
7
  post '/sample28' do
8
8
  # set variables
9
- set :client_id, params[:client_id]
10
- set :private_key, params[:private_key]
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
 
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
+
17
28
  # make a request to API using client_id and private_key
18
- files_list = GroupDocs::Storage::Folder.list!('/', {}, {:client_id => settings.client_id, :private_key => settings.private_key})
29
+ files_list = GroupDocs::Storage::Folder.list!('/', {})
19
30
  document = ''
20
31
 
21
32
  # get document by file ID
@@ -28,13 +39,21 @@ post '/sample28' do
28
39
 
29
40
  unless document.instance_of? String
30
41
  # get list of annotations
31
- annotations = document.to_document.annotations!(:client_id => settings.client_id, :private_key => settings.private_key)
42
+ annotations = document.to_document.annotations!()
32
43
 
33
44
  # delete all annotations from document
34
45
  annotations.each do |annotation|
35
- annotation.remove!(:client_id => settings.client_id, :private_key => settings.private_key)
46
+ annotation.remove!()
36
47
  end
48
+ case settings.base_path
37
49
 
50
+ when 'https://stage-api-groupdocs.dynabic.com'
51
+ iframe = "<iframe width='100%' height='600' frameborder='0' src='http://stage-apps-groupdocs.dynabic.com/document-viewer/embed/#{settings.file_id}'></iframe>"
52
+ when 'https://dev-api-groupdocs.dynabic.com'
53
+ iframe = "<iframe width='100%' height='600' frameborder='0' src='http://dev-apps-groupdocs.dynabic.com/document-viewer/embed/#{settings.file_id}'></iframe>"
54
+ else
55
+ iframe = "<iframe width='100%' height='600' frameborder='0' src='https://apps.groupdocs.com/document-viewer/embed/#{settings.file_id}'></iframe>"
56
+ end
38
57
  message = 'Annotations was deleted from document'
39
58
  end
40
59
 
@@ -43,5 +62,5 @@ post '/sample28' do
43
62
  end
44
63
 
45
64
  # set variables for template
46
- haml :sample28, :locals => {:userId => settings.client_id, :privateKey => settings.private_key, :messages => message, :fileId => settings.file_id, :err => err}
65
+ haml :sample28, :locals => {:userId => settings.client_id, :privateKey => settings.private_key, :messages => message, :iframe => iframe, :fileId => settings.file_id, :err => err}
47
66
  end
@@ -7,7 +7,7 @@ post '/sample29' do
7
7
 
8
8
  # set variables
9
9
  set :client_id, params[:clientId]
10
- set :base_path, params[:basePath]
10
+ set :base_path, params[:serverType]
11
11
  set :url, params[:url]
12
12
 
13
13
  url = settings.url
@@ -22,19 +22,19 @@ post '/sample29' do
22
22
  #Generate iframe url for chosen server
23
23
  if (!url.empty?)
24
24
 
25
- if (base_path == "https://api.groupdocs.com/v2.0")
26
- iframe = "https://apps.groupdocs.com/document-viewer/embed?url=#{url} + '&user_id=#{client_id}"
27
- elsif (base_path == "https://dev-api.groupdocs.com/v2.0")
25
+ if (base_path == "https://api.groupdocs.com/v2.0")
26
+ iframe = "https://apps.groupdocs.com/document-viewer/embed?url=#{url} &user_id=#{client_id}"
27
+ elsif (base_path == "https://dev-api.groupdocs.com/v2.0")
28
28
 
29
29
  #iframe to dev server
30
- iframe = "https://dev-apps.groupdocs.com/document-viewer/embed?url=#{url} + '&user_id=#{client_id}"
31
- elsif (base_path == "https://stage-api.groupdocs.com/v2.0")
32
-
33
- #iframe to test server
34
- iframe = "https://stage-apps.groupdocs.com/document-viewer/embed?url=#{url} + '&user_id=#{client_id}"
35
- elsif (base_path == "http://realtime-api.groupdocs.com")
36
- iframe = "http://realtime-apps.groupdocs.com/document-viewer/embed?url=#{url} + '&user_id=#{client_id}"
37
- end
30
+ iframe = "https://dev-apps.groupdocs.com/document-viewer/embed?url=#{url} &user_id=#{client_id}"
31
+ elsif (base_path == "https://stage-api.groupdocs.com/v2.0")
32
+
33
+ #iframe to test server
34
+ iframe = "https://stage-apps.groupdocs.com/document-viewer/embed?url=#{url} &user_id=#{client_id}"
35
+ elsif (base_path == "http://realtime-api.groupdocs.com")
36
+ iframe = "http://realtime-apps.groupdocs.com/document-viewer/embed?url=#{url} &user_id=#{client_id}"
37
+ end
38
38
 
39
39
 
40
40
  end
@@ -5,35 +5,47 @@ end
5
5
 
6
6
  # POST request
7
7
  post '/sample30' do
8
- # set variables
9
- set :client_id, params[:client_id]
10
- set :private_key, params[:private_key]
11
- set :name, params[:name]
8
+ # Set variables
9
+ set :client_id, params[:clientId]
10
+ set :private_key, params[:privateKey]
11
+ set :name, params[:fileName]
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.name.empty?
16
17
 
17
- # get List files from GroupDocs Storage
18
- file = GroupDocs::Storage::Folder.list!("", {}, {:client_id => settings.client_id, :private_key => settings.private_key})
19
- file_name = ''
18
+ if settings.base_path.empty? then settings.base_path = 'https://api.groupdocs.com' end
20
19
 
21
- # choose the desired file
22
- file.map do |element|
23
- if element.name == settings.name
24
- file_name = element
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!('/', {})
30
+ document = ''
31
+
32
+ # Get document by file ID
33
+ files_list.each do |element|
34
+ if element.respond_to?('name') == true and element.name == settings.name
35
+ document = element
25
36
  end
26
37
  end
27
38
 
28
- # delete file from GroupDocs Storage
29
- file_name.delete!({:client_id => settings.client_id, :private_key => settings.private_key})
30
39
 
31
- message = 'File was deleted from GroupDocs Storage'
40
+ # Delete file from GroupDocs Storage
41
+ document.delete!()
42
+
43
+ message = 'Done, file deleted from your GroupDocs Storage'
32
44
 
33
45
  rescue Exception => e
34
46
  err = e.message
35
47
  end
36
48
 
37
- # set variables for template
49
+ # Set variables for template
38
50
  haml :sample30, :locals => {:userId => settings.client_id, :privateKey => settings.private_key, :message => message, :name => settings.name, :err => err}
39
51
  end
@@ -73,16 +73,17 @@ end
73
73
  # POST request
74
74
  post '/sample31' do
75
75
  # set variables
76
- set :client_id, params[:client_id]
77
- set :private_key, params[:private_key]
78
- set :template_guid, params[:template_guid]
76
+ set :client_id, params[:clientId]
77
+ set :private_key, params[:privateKey]
78
+ set :template_guid, params[:templateGuid]
79
79
  set :name, params[:name]
80
80
  set :country, params[:country]
81
81
  set :city, params[:city]
82
82
  set :street, params[:street]
83
83
  set :email, params[:email]
84
84
  set :callback, params[:callback]
85
- set :last_name, params[:last_name]
85
+ set :last_name, params[:lastName]
86
+ set :base_path, params[:basePath]
86
87
 
87
88
  # Set download path
88
89
  downloads_path = "#{File.dirname(__FILE__)}/../public/downloads"
@@ -98,6 +99,16 @@ post '/sample31' do
98
99
  # check required variables
99
100
  raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty?
100
101
 
102
+ if settings.base_path.empty? then settings.base_path = 'https://api.groupdocs.com' end
103
+
104
+ # Configure your access to API server
105
+ GroupDocs.configure do |groupdocs|
106
+ groupdocs.client_id = settings.client_id
107
+ groupdocs.private_key = settings.private_key
108
+ # Optionally specify API server and version
109
+ groupdocs.api_server = settings.base_path # default is 'https://api.groupdocs.com'
110
+ end
111
+
101
112
  # Write client and private key to the file for callback job
102
113
  if settings.callback[0]
103
114
  out_file = File.new("#{File.dirname(__FILE__)}/../public/user_info.txt", 'w')
@@ -106,7 +117,9 @@ post '/sample31' do
106
117
  out_file.write("#{settings.private_key}")
107
118
  out_file.close
108
119
  end
109
-
120
+ if settings.last_name.empty?
121
+ settings.last_name = 'test'
122
+ end
110
123
  file = nil
111
124
  # Create instance of File
112
125
  file = GroupDocs::Storage::File.new({:guid => settings.template_guid})
@@ -127,15 +140,15 @@ post '/sample31' do
127
140
  datasource.fields = enteredData.map { |key, value| GroupDocs::DataSource::Field.new(name: key, type: :text, values: Array.new() << value) }
128
141
 
129
142
  # Adds datasource.
130
- datasource.add!({:client_id => settings.client_id, :private_key => settings.private_key})
143
+ datasource.add!()
131
144
 
132
145
 
133
146
  # Creates new job to merge datasource into document.
134
- job = document.datasource!(datasource, {:new_type => "pdf"}, {:client_id => settings.client_id, :private_key => settings.private_key})
147
+ job = document.datasource!(datasource, {:new_type => "pdf"})
135
148
  sleep 10 # wait for merge and convert
136
149
 
137
150
  # Returns an hash of input and output documents associated to job.
138
- jobInfo = job.documents!({:client_id => settings.client_id, :private_key => settings.private_key})
151
+ jobInfo = job.documents!()
139
152
 
140
153
  # Creates new document to envelope
141
154
  document = jobInfo[:inputs][0].outputs[0].to_document
@@ -143,47 +156,45 @@ post '/sample31' do
143
156
  # Creates envelope using user id and entered by user name
144
157
  envelope = GroupDocs::Signature::Envelope.new
145
158
  envelope.name = jobInfo[:inputs][0].outputs[0].name
146
- envelope.create!({}, {:client_id => settings.client_id, :private_key => settings.private_key})
159
+ envelope.create!({})
147
160
 
148
161
  # Adds uploaded document to envelope
149
- envelope.add_document!(document, {}, {:client_id => settings.client_id, :private_key => settings.private_key})
162
+ envelope.add_document!(document, {})
150
163
 
151
164
  # Get role list for current user
152
- roles = GroupDocs::Signature::Role.get!({}, {client_id: settings.client_id, private_key: settings.private_key})
165
+ roles = GroupDocs::Signature::Role.get!({})
153
166
 
154
167
  # Creates new recipient
155
168
  recipient = GroupDocs::Signature::Recipient.new
156
- recipient.email = 'test@test.com'
157
- recipient.first_name = 'test'
158
- recipient.last_name = 'test'
169
+ recipient.email = settings.email
170
+ recipient.first_name = settings.name
171
+ recipient.last_name = settings.last_name
159
172
  recipient.role_id = roles.detect { |role| role.name == 'Signer' }.id
160
173
 
161
174
  # Adds recipient to envelope
162
- envelope.add_recipient!(recipient, {client_id: settings.client_id, private_key: settings.private_key})
163
-
164
- #Get field
165
- fieldGet = GroupDocs::Signature::Field.get!({},{client_id: settings.client_id, private_key: settings.private_key}).detect { |f| f.type == :signature }
166
- fieldGet.location = { location_x: 0.15,
167
- location_y: 0.73,
168
- location_width: 150,
169
- location_height: 50,
170
- page: 1 }
171
-
172
- #Get document
173
- documentGet = envelope.documents!({}, {client_id: settings.client_id, private_key: settings.private_key}).first
174
-
175
+ envelope.add_recipient!(recipient)
175
176
  #Get recipients
176
- recipientGet = envelope.recipients!({},{client_id: settings.client_id, private_key: settings.private_key}).first
177
+ recipientGet = envelope.recipients!({}).first
178
+
179
+ # Send envelope
180
+ envelope.send!({:callbackUrl => settings.callback})
177
181
 
178
- # Add field to envelope
179
- addField = envelope.add_field!(fieldGet, documentGet, recipientGet, {}, {client_id: settings.client_id, private_key: settings.private_key})
182
+ #Get url from request
183
+ case settings.base_path
180
184
 
185
+ when 'https://stage-api-groupdocs.dynabic.com'
186
+ url = "http://stage-apps-groupdocs.dynabic.com/signature2/signembed/#{envelope.id}/#{recipientGet.id}"
187
+ when 'https://dev-api-groupdocs.dynabic.com'
188
+ url = "http://dev-apps-groupdocs.dynabic.com/signature2/signembed/#{envelope.id}/#{recipientGet.id}"
189
+ else
190
+ url = "https://apps.groupdocs.com/signature2/signembed/#{envelope.id}/#{recipientGet.id}"
191
+ end
181
192
 
182
- # Send envelope
183
- envelope.send!(settings.callback, {client_id: settings.client_id, private_key: settings.private_key})
193
+ # Add the signature in url
194
+ iframe = GroupDocs::Api::Request.new(:path => url).prepare_and_sign_url
184
195
 
185
196
  # Make iframe
186
- iframe = "<iframe src='https://apps.groupdocs.com/signature/signembed/#{envelope.id}/#{recipientGet.id}' frameborder='0' width='720' height='600'></iframe>"
197
+ iframe = "<iframe src='#{iframe}' frameborder='0' width='720' height='600'></iframe>"
187
198
 
188
199
 
189
200
  rescue Exception => e