groupdocs 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. data/.travis.yml +5 -0
  2. data/Gemfile +3 -0
  3. data/README.md +141 -0
  4. data/Rakefile +9 -0
  5. data/groupdocs.gemspec +28 -0
  6. data/lib/groupdocs.rb +53 -0
  7. data/lib/groupdocs/api.rb +3 -0
  8. data/lib/groupdocs/api/entity.rb +113 -0
  9. data/lib/groupdocs/api/helpers.rb +5 -0
  10. data/lib/groupdocs/api/helpers/access_helper.rb +56 -0
  11. data/lib/groupdocs/api/helpers/actions_helper.rb +48 -0
  12. data/lib/groupdocs/api/helpers/rest_helper.rb +89 -0
  13. data/lib/groupdocs/api/helpers/status_helper.rb +48 -0
  14. data/lib/groupdocs/api/helpers/url_helper.rb +89 -0
  15. data/lib/groupdocs/api/request.rb +73 -0
  16. data/lib/groupdocs/api/sugar/lookup.rb +48 -0
  17. data/lib/groupdocs/datasource.rb +162 -0
  18. data/lib/groupdocs/datasource/field.rb +44 -0
  19. data/lib/groupdocs/document.rb +513 -0
  20. data/lib/groupdocs/document/annotation.rb +215 -0
  21. data/lib/groupdocs/document/annotation/reply.rb +167 -0
  22. data/lib/groupdocs/document/change.rb +35 -0
  23. data/lib/groupdocs/document/field.rb +27 -0
  24. data/lib/groupdocs/document/metadata.rb +26 -0
  25. data/lib/groupdocs/document/rectangle.rb +24 -0
  26. data/lib/groupdocs/document/view.rb +36 -0
  27. data/lib/groupdocs/errors.rb +10 -0
  28. data/lib/groupdocs/job.rb +201 -0
  29. data/lib/groupdocs/questionnaire.rb +221 -0
  30. data/lib/groupdocs/questionnaire/execution.rb +120 -0
  31. data/lib/groupdocs/questionnaire/page.rb +43 -0
  32. data/lib/groupdocs/questionnaire/question.rb +75 -0
  33. data/lib/groupdocs/questionnaire/question/answer.rb +10 -0
  34. data/lib/groupdocs/storage.rb +37 -0
  35. data/lib/groupdocs/storage/file.rb +248 -0
  36. data/lib/groupdocs/storage/folder.rb +314 -0
  37. data/lib/groupdocs/storage/package.rb +42 -0
  38. data/lib/groupdocs/user.rb +50 -0
  39. data/lib/groupdocs/version.rb +3 -0
  40. data/spec/groupdocs/api/entity_spec.rb +54 -0
  41. data/spec/groupdocs/api/helpers/access_helper_spec.rb +89 -0
  42. data/spec/groupdocs/api/helpers/actions_helper_spec.rb +51 -0
  43. data/spec/groupdocs/api/helpers/rest_helper_spec.rb +187 -0
  44. data/spec/groupdocs/api/helpers/status_helper_spec.rb +85 -0
  45. data/spec/groupdocs/api/helpers/url_helper_spec.rb +93 -0
  46. data/spec/groupdocs/api/request_spec.rb +85 -0
  47. data/spec/groupdocs/datasource/field_spec.rb +50 -0
  48. data/spec/groupdocs/datasource_spec.rb +156 -0
  49. data/spec/groupdocs/document/annotation/reply_spec.rb +179 -0
  50. data/spec/groupdocs/document/annotation_spec.rb +226 -0
  51. data/spec/groupdocs/document/change_spec.rb +35 -0
  52. data/spec/groupdocs/document/field_spec.rb +31 -0
  53. data/spec/groupdocs/document/metadata_spec.rb +26 -0
  54. data/spec/groupdocs/document/rectangle_spec.rb +34 -0
  55. data/spec/groupdocs/document/view_spec.rb +36 -0
  56. data/spec/groupdocs/document_spec.rb +509 -0
  57. data/spec/groupdocs/errors_spec.rb +7 -0
  58. data/spec/groupdocs/job_spec.rb +196 -0
  59. data/spec/groupdocs/questionnaire/execution_spec.rb +136 -0
  60. data/spec/groupdocs/questionnaire/page_spec.rb +50 -0
  61. data/spec/groupdocs/questionnaire/question/answer_spec.rb +11 -0
  62. data/spec/groupdocs/questionnaire/question_spec.rb +84 -0
  63. data/spec/groupdocs/questionnaire_spec.rb +217 -0
  64. data/spec/groupdocs/storage/file_spec.rb +242 -0
  65. data/spec/groupdocs/storage/folder_spec.rb +310 -0
  66. data/spec/groupdocs/storage/package_spec.rb +41 -0
  67. data/spec/groupdocs/storage_spec.rb +27 -0
  68. data/spec/groupdocs/user_spec.rb +53 -0
  69. data/spec/groupdocs_spec.rb +56 -0
  70. data/spec/spec_helper.rb +46 -0
  71. data/spec/support/files/resume.pdf +0 -0
  72. data/spec/support/json/annotation_collaborators_set.json +16 -0
  73. data/spec/support/json/annotation_create.json +12 -0
  74. data/spec/support/json/annotation_list.json +32 -0
  75. data/spec/support/json/annotation_remove.json +9 -0
  76. data/spec/support/json/annotation_replies_create.json +9 -0
  77. data/spec/support/json/annotation_replies_get.json +25 -0
  78. data/spec/support/json/comparison_changes.json +46 -0
  79. data/spec/support/json/comparison_compare.json +8 -0
  80. data/spec/support/json/comparison_document.json +10 -0
  81. data/spec/support/json/datasource_add.json +8 -0
  82. data/spec/support/json/datasource_get.json +22 -0
  83. data/spec/support/json/datasource_remove.json +8 -0
  84. data/spec/support/json/datasource_update.json +8 -0
  85. data/spec/support/json/document_access_info_get.json +14 -0
  86. data/spec/support/json/document_convert.json +8 -0
  87. data/spec/support/json/document_datasource.json +10 -0
  88. data/spec/support/json/document_fields.json +34 -0
  89. data/spec/support/json/document_formats.json +8 -0
  90. data/spec/support/json/document_metadata.json +15 -0
  91. data/spec/support/json/document_questionnaire_create.json +9 -0
  92. data/spec/support/json/document_questionnaires.json +23 -0
  93. data/spec/support/json/document_sharers_remove.json +8 -0
  94. data/spec/support/json/document_sharers_set.json +16 -0
  95. data/spec/support/json/document_views.json +32 -0
  96. data/spec/support/json/file_compress.json +8 -0
  97. data/spec/support/json/file_copy.json +14 -0
  98. data/spec/support/json/file_delete.json +5 -0
  99. data/spec/support/json/file_move.json +14 -0
  100. data/spec/support/json/file_upload.json +8 -0
  101. data/spec/support/json/folder_create.json +8 -0
  102. data/spec/support/json/folder_delete.json +5 -0
  103. data/spec/support/json/folder_list.json +21 -0
  104. data/spec/support/json/folder_move.json +8 -0
  105. data/spec/support/json/folder_sharers_get.json +16 -0
  106. data/spec/support/json/folder_sharers_remove.json +8 -0
  107. data/spec/support/json/folder_sharers_set.json +16 -0
  108. data/spec/support/json/job_add_url.json +8 -0
  109. data/spec/support/json/job_create.json +8 -0
  110. data/spec/support/json/job_documents.json +39 -0
  111. data/spec/support/json/job_file_add.json +8 -0
  112. data/spec/support/json/job_update.json +7 -0
  113. data/spec/support/json/jobs_get.json +52 -0
  114. data/spec/support/json/package_create.json +7 -0
  115. data/spec/support/json/questionnaire_create.json +8 -0
  116. data/spec/support/json/questionnaire_datasources.json +26 -0
  117. data/spec/support/json/questionnaire_execution_create.json +9 -0
  118. data/spec/support/json/questionnaire_execution_status_set.json +8 -0
  119. data/spec/support/json/questionnaire_execution_update.json +8 -0
  120. data/spec/support/json/questionnaire_executions.json +24 -0
  121. data/spec/support/json/questionnaire_get.json +14 -0
  122. data/spec/support/json/questionnaire_remove.json +8 -0
  123. data/spec/support/json/questionnaire_update.json +8 -0
  124. data/spec/support/json/questionnaires_get.json +22 -0
  125. data/spec/support/json/storage_info.json +10 -0
  126. data/spec/support/shared_examples/api/entity.rb +37 -0
  127. data/spec/support/shared_examples/api/helpers/status_helper.rb +12 -0
  128. data/spec/support/shared_examples/api/sugar/lookup.rb +57 -0
  129. metadata +356 -0
@@ -0,0 +1,24 @@
1
+ module GroupDocs
2
+ class Document::Rectangle < GroupDocs::Api::Entity
3
+
4
+ # @attr [Float] X
5
+ attr_accessor :X
6
+ # @attr [Float] Y
7
+ attr_accessor :Y
8
+ # @attr [Float] Width
9
+ attr_accessor :Width
10
+ # @attr [Float] Height
11
+ attr_accessor :Height
12
+
13
+ # Human-readable accessors
14
+ alias_method :x, :X
15
+ alias_method :x=, :X=
16
+ alias_method :y, :Y
17
+ alias_method :y=, :Y=
18
+ alias_method :w, :Width
19
+ alias_method :w=, :Width=
20
+ alias_method :h, :Height
21
+ alias_method :h=, :Height=
22
+
23
+ end # Document::Rectangle
24
+ end # GroupDocs
@@ -0,0 +1,36 @@
1
+ module GroupDocs
2
+ class Document::View < GroupDocs::Api::Entity
3
+
4
+ # @attr [GroupDocs::Document] document
5
+ attr_accessor :document
6
+ # @attr [String] short_url
7
+ attr_accessor :short_url
8
+ # @attr [Time] viewed_on
9
+ attr_accessor :viewed_on
10
+
11
+ #
12
+ # Converts timestamp which is return by API server to Time object.
13
+ #
14
+ # @return [Time]
15
+ #
16
+ def viewed_on
17
+ Time.at(@viewed_on)
18
+ end
19
+
20
+ #
21
+ # Converts passed hash to GroupDocs::Document object.
22
+ #
23
+ # @param [GroupDocs::Document, Hash] object
24
+ # @return [GroupDocs::Document]
25
+ #
26
+ def document=(object)
27
+ if object.is_a?(GroupDocs::Document)
28
+ @document = object
29
+ else
30
+ object.merge!(file: GroupDocs::Storage::File.new(object))
31
+ @document = GroupDocs::Document.new(object)
32
+ end
33
+ end
34
+
35
+ end # Document::View
36
+ end # GroupDocs
@@ -0,0 +1,10 @@
1
+ module GroupDocs
2
+ module Errors
3
+
4
+ class NoClientIdError < StandardError ; end
5
+ class NoPrivateKeyError < StandardError ; end
6
+ class UnsupportedMethodError < StandardError ; end
7
+ class BadResponseError < StandardError ; end
8
+
9
+ end # Errors
10
+ end # GroupDocs
@@ -0,0 +1,201 @@
1
+ module GroupDocs
2
+ class Job < GroupDocs::Api::Entity
3
+
4
+ extend GroupDocs::Api::Helpers::Actions
5
+ include GroupDocs::Api::Helpers::Status
6
+
7
+ #
8
+ # Returns array of recent jobs.
9
+ #
10
+ # @param [Hash] options Hash of options
11
+ # @option options [Integer] :page Page to start with
12
+ # @option options [Integer] :count How many items to list
13
+ # @param [Hash] access Access credentials
14
+ # @option access [String] :client_id
15
+ # @option access [String] :private_key
16
+ # @return [Array<GroupDocs::Job>]
17
+ #
18
+ def self.all!(options = {}, access = {})
19
+ api = GroupDocs::Api::Request.new do |request|
20
+ request[:access] = access
21
+ request[:method] = :GET
22
+ request[:path] = '/async/{{client_id}}/jobs'
23
+ end
24
+ api.add_params(options)
25
+ json = api.execute!
26
+
27
+ json[:jobs].map do |job|
28
+ GroupDocs::Job.new(job)
29
+ end
30
+ end
31
+
32
+ #
33
+ # Creates new draft job.
34
+ #
35
+ # @param [Hash] options
36
+ # @option options [Integer] :actions Array of actions to be performed. Required
37
+ # @option options [Boolean] :emails_results
38
+ # @option options [Array] :out_formats
39
+ # @option options [Boolean] :url_only
40
+ # @param [Hash] access Access credentials
41
+ # @option access [String] :client_id
42
+ # @option access [String] :private_key
43
+ # @return [GroupDocs::Job]
44
+ #
45
+ def self.create!(options, access = {})
46
+ options[:actions] or raise ArgumentError, 'options[:actions] is required.'
47
+ options[:actions] = convert_actions(options[:actions])
48
+ options[:out_formats] = options[:out_formats].join(?;) if options[:out_formats]
49
+
50
+ api = GroupDocs::Api::Request.new do |request|
51
+ request[:access] = access
52
+ request[:method] = :POST
53
+ request[:path] = '/async/{{client_id}}/jobs'
54
+ request[:request_body] = options
55
+ end
56
+ json = api.execute!
57
+
58
+ GroupDocs::Job.new(id: json[:job_id])
59
+ end
60
+
61
+ # @attr [Integer] id
62
+ attr_accessor :id
63
+ # @attr [Array<GroupDocs::Document] documents
64
+ attr_accessor :documents
65
+
66
+ #
67
+ # Coverts passed array of attributes hash to array of GroupDocs::Document.
68
+ #
69
+ # @param [Array<Hash>] documents Array of document attributes hashes
70
+ #
71
+ def documents=(documents)
72
+ @documents = documents.map do |document|
73
+ document.merge!(file: GroupDocs::Storage::File.new(document))
74
+ GroupDocs::Document.new(document)
75
+ end
76
+ end
77
+
78
+ #
79
+ # Returns an array of documents associated to job.
80
+ #
81
+ # @param [Hash] access Access credentials
82
+ # @option access [String] :client_id
83
+ # @option access [String] :private_key
84
+ # @return [Array<GroupDocs::Document>]
85
+ #
86
+ def documents!(access = {})
87
+ json = GroupDocs::Api::Request.new do |request|
88
+ request[:access] = access
89
+ request[:method] = :GET
90
+ request[:path] = "/async/{{client_id}}/jobs/#{id}/documents"
91
+ end.execute!
92
+
93
+ json[:documents].map do |document|
94
+ document.merge!(file: GroupDocs::Storage::File.new(document))
95
+ GroupDocs::Document.new(document)
96
+ end
97
+ end
98
+
99
+ #
100
+ # Adds document to job.
101
+ #
102
+ # @param [GroupDocs::Document] document
103
+ # @param [Hash] options
104
+ # @option options [Array] :output_formats Array of output formats to override
105
+ # @param [Hash] access Access credentials
106
+ # @option access [String] :client_id
107
+ # @option access [String] :private_key
108
+ # @return [Integer] Document ID
109
+ #
110
+ # @raise [ArgumentError] If document is not a GroupDocs::Document object
111
+ #
112
+ def add_document!(document, options = {}, access = {})
113
+ document.is_a?(GroupDocs::Document) or raise ArgumentError,
114
+ "Document should be GroupDocs::Document object. Received: #{document.inspect}"
115
+
116
+ api = GroupDocs::Api::Request.new do |request|
117
+ request[:access] = access
118
+ request[:method] = :PUT
119
+ request[:path] = "/async/{{client_id}}/jobs/#{id}/files/#{document.file.guid}"
120
+ end
121
+ api.add_params(options)
122
+ json = api.execute!
123
+
124
+ json[:document_id]
125
+ end
126
+
127
+ #
128
+ # Adds datasource to job document.
129
+ #
130
+ # @param [GroupDocs::Document] document
131
+ # @param [GroupDocs::DataSource] datasource
132
+ # @param [Hash] access Access credentials
133
+ # @option access [String] :client_id
134
+ # @option access [String] :private_key
135
+ #
136
+ # @raise [ArgumentError] If document is not a GroupDocs::Document object
137
+ # @raise [ArgumentError] If datasource is not a GroupDocs::DataSource object
138
+ #
139
+ # @todo returns 404 (http://scotland.groupdocs.com/jira/browse/CORE-384)
140
+ #
141
+ def add_datasource!(document, datasource, access = {})
142
+ document.is_a?(GroupDocs::Document) or raise ArgumentError,
143
+ "Document should be GroupDocs::Document object. Received: #{document.inspect}"
144
+ datasource.is_a?(GroupDocs::DataSource) or raise ArgumentError,
145
+ "Datasource should be GroupDocs::DataSource object. Received: #{datasource.inspect}"
146
+
147
+ GroupDocs::Api::Request.new do |request|
148
+ request[:access] = access
149
+ request[:method] = :PUT
150
+ request[:path] = "/async/{{client_id}}/jobs/#{id}/files/#{document.file.guid}/datasources/#{datasource.id}"
151
+ end.execute!
152
+ end
153
+
154
+ #
155
+ # Adds URL of web page or document to be converted.
156
+ #
157
+ # @param [String] url Absolute URL
158
+ # @param [Hash] options
159
+ # @option options [Array] :output_formats Array of output formats to override
160
+ # @param [Hash] access Access credentials
161
+ # @option access [String] :client_id
162
+ # @option access [String] :private_key
163
+ # @return [Integer] Document ID
164
+ #
165
+ def add_url!(url, options = {}, access = {})
166
+ options.merge!(absolute_url: url)
167
+
168
+ api = GroupDocs::Api::Request.new do |request|
169
+ request[:access] = access
170
+ request[:method] = :PUT
171
+ request[:path] = "/async/{{client_id}}/jobs/#{id}/urls"
172
+ end
173
+ api.add_params(options)
174
+ json = api.execute!
175
+
176
+ json[:document_id]
177
+ end
178
+
179
+ #
180
+ # Updates job settings and/or status.
181
+ #
182
+ # @param [Hash] options
183
+ # @option options [Boolean] :email_results
184
+ # @option options [Symbol] :status
185
+ # @param [Hash] access Access credentials
186
+ # @option access [String] :client_id
187
+ # @option access [String] :private_key
188
+ #
189
+ def update!(options, access = {})
190
+ options[:status] = parse_status(options[:status]) if options[:status]
191
+
192
+ GroupDocs::Api::Request.new do |request|
193
+ request[:access] = access
194
+ request[:method] = :PUT
195
+ request[:path] = "/async/{{client_id}}/jobs/#{id}"
196
+ request[:request_body] = options
197
+ end.execute!
198
+ end
199
+
200
+ end # Job
201
+ end # GroupDocs
@@ -0,0 +1,221 @@
1
+ module GroupDocs
2
+ class Questionnaire < GroupDocs::Api::Entity
3
+
4
+ require 'groupdocs/questionnaire/execution'
5
+ require 'groupdocs/questionnaire/page'
6
+ require 'groupdocs/questionnaire/question'
7
+
8
+ include GroupDocs::Api::Helpers::Access
9
+
10
+ #
11
+ # Returns an array of all questionnaires.
12
+ #
13
+ # @param [Hash] access Access credentials
14
+ # @option access [String] :client_id
15
+ # @option access [String] :private_key
16
+ # @return [Array<GroupDocs::Questionnaire>]
17
+ #
18
+ def self.all!(access = {})
19
+ json = GroupDocs::Api::Request.new do |request|
20
+ request[:access] = access
21
+ request[:method] = :GET
22
+ request[:path] = '/merge/{{client_id}}/questionnaires'
23
+ end.execute!
24
+
25
+ json[:questionnaires].map do |questionnaire|
26
+ GroupDocs::Questionnaire.new(questionnaire)
27
+ end
28
+ end
29
+
30
+ #
31
+ # Returns questionnaire by identifier.
32
+ #
33
+ # @param [Integer] id
34
+ # @param [Hash] access Access credentials
35
+ # @option access [String] :client_id
36
+ # @option access [String] :private_key
37
+ # @return [GroupDocs::Questionnaire, nil]
38
+ #
39
+ def self.get!(id, access = {})
40
+ json = GroupDocs::Api::Request.new do |request|
41
+ request[:access] = access
42
+ request[:method] = :GET
43
+ request[:path] = "/merge/{{client_id}}/questionnaires/#{id}"
44
+ end.execute!
45
+
46
+ GroupDocs::Questionnaire.new(json[:questionnaire])
47
+ rescue RestClient::BadRequest
48
+ nil
49
+ end
50
+
51
+ #
52
+ # Returns an array of all executions.
53
+ #
54
+ # @param [Hash] access Access credentials
55
+ # @option access [String] :client_id
56
+ # @option access [String] :private_key
57
+ # @return [Array<GroupDocs::Questionnaire::Execution>]
58
+ #
59
+ def self.executions!(access = {})
60
+ json = GroupDocs::Api::Request.new do |request|
61
+ request[:access] = access
62
+ request[:method] = :GET
63
+ request[:path] = '/merge/{{client_id}}/questionnaires/executions'
64
+ end.execute!
65
+
66
+ json[:executions].map do |execution|
67
+ GroupDocs::Questionnaire::Execution.new(execution)
68
+ end
69
+ end
70
+
71
+ # @attr [Integer] id
72
+ attr_accessor :id
73
+ # @attr [String] name
74
+ attr_accessor :name
75
+ # @attr [String] descr
76
+ attr_accessor :descr
77
+ # @attr [Array<GroupDocs::Questionnaire::Page>] pages
78
+ attr_accessor :pages
79
+
80
+ # Human-readable accessors
81
+ alias_method :description, :descr
82
+ alias_method :description=, :descr=
83
+
84
+ #
85
+ # Converts each page to GroupDocs::Questionnaire::Page object.
86
+ #
87
+ # @param [Array<GroupDocs::Questionnaire::Page, Hash>] pages
88
+ #
89
+ def pages=(pages)
90
+ if pages
91
+ @pages = pages.map do |page|
92
+ if page.is_a?(GroupDocs::Questionnaire::Page)
93
+ page
94
+ else
95
+ GroupDocs::Questionnaire::Page.new(page)
96
+ end
97
+ end
98
+ end
99
+ end
100
+
101
+ #
102
+ # Adds page to questionnaire.
103
+ #
104
+ # @param [GroupDocs::Questionnaire::Page] page
105
+ # @raise [ArgumentError] if page is not GroupDocs::Questionnaire::Page object
106
+ #
107
+ def add_page(page)
108
+ page.is_a?(GroupDocs::Questionnaire::Page) or raise ArgumentError,
109
+ "Page should be GroupDocs::Questionnaire::Page object, received: #{page.inspect}"
110
+
111
+ @pages ||= Array.new
112
+ @pages << page
113
+ end
114
+
115
+ #
116
+ # Creates questionnaire.
117
+ #
118
+ # @param [Hash] access Access credentials
119
+ # @option access [String] :client_id
120
+ # @option access [String] :private_key
121
+ #
122
+ def create!(access = {})
123
+ json = GroupDocs::Api::Request.new do |request|
124
+ request[:access] = access
125
+ request[:method] = :POST
126
+ request[:path] = '/merge/{{client_id}}/questionnaires'
127
+ request[:request_body] = to_hash
128
+ end.execute!
129
+
130
+ self.id = json[:questionnaire_id]
131
+ end
132
+
133
+ #
134
+ # Updates questionnaire.
135
+ #
136
+ # @param [Hash] access Access credentials
137
+ # @option access [String] :client_id
138
+ # @option access [String] :private_key
139
+ #
140
+ def update!(access = {})
141
+ GroupDocs::Api::Request.new do |request|
142
+ request[:access] = access
143
+ request[:method] = :PUT
144
+ request[:path] = "/merge/{{client_id}}/questionnaires/#{id}"
145
+ request[:request_body] = to_hash
146
+ end.execute!
147
+ end
148
+
149
+ #
150
+ # Removes questionnaire.
151
+ #
152
+ # @param [Hash] access Access credentials
153
+ # @option access [String] :client_id
154
+ # @option access [String] :private_key
155
+ #
156
+ def remove!(access = {})
157
+ GroupDocs::Api::Request.new do |request|
158
+ request[:access] = access
159
+ request[:method] = :DELETE
160
+ request[:path] = "/merge/{{client_id}}/questionnaires/#{id}"
161
+ end.execute!
162
+ # TODO: fix this in API
163
+ rescue RestClient::BadRequest
164
+ nil
165
+ end
166
+
167
+ #
168
+ # Returns array of datasources for questionnaire.
169
+ #
170
+ # @param [Hash] access Access credentials
171
+ # @option access [String] :client_id
172
+ # @option access [String] :private_key
173
+ # @return [Array<GroupDocs::DataSource>]
174
+ #
175
+ def datasources!(access = {})
176
+ json = GroupDocs::Api::Request.new do |request|
177
+ request[:access] = access
178
+ request[:method] = :GET
179
+ request[:path] = "/merge/{{client_id}}/questionnaires/#{id}/datasources"
180
+ end.execute!
181
+
182
+ json[:datasources].map do |datasource|
183
+ GroupDocs::DataSource.new(datasource)
184
+ end
185
+ end
186
+
187
+ #
188
+ # Creates new questionnaire execution.
189
+ #
190
+ # @example
191
+ # execution = GroupDocs::Questionnaire::Execution.new
192
+ # questionnaire = GroupDocs::Questionnaire.get!(1)
193
+ # execution = questionnaire.create_execution!(execution, 'user@email.com')
194
+ # #=> #<GroupDocs::Questionnaire::Execution @id=1, @questionnaire_id=1>
195
+ #
196
+ # @param [GroupDocs::Questionnaire::Execution] execution
197
+ # @param [String] email
198
+ # @param [Hash] access Access credentials
199
+ # @option access [String] :client_id
200
+ # @option access [String] :private_key
201
+ # @return [GroupDocs::Questionnaire::Execution] updated execution
202
+ #
203
+ def create_execution!(execution, email, access = {})
204
+ execution.is_a?(GroupDocs::Questionnaire::Execution) or raise ArgumentError,
205
+ "Execution should be GroupDocs::Questionnaire::Execution object, received: #{execution.inspect}"
206
+
207
+ json = GroupDocs::Api::Request.new do |request|
208
+ request[:access] = access
209
+ request[:method] = :POST
210
+ request[:path] = "/merge/{{client_id}}/questionnaires/#{id}/executions"
211
+ request[:request_body] = execution.to_hash.merge(executive: { primary_email: email })
212
+ end.execute!
213
+
214
+ execution.id = json[:execution_id]
215
+ execution.questionnaire_id = json[:questionnaire_id]
216
+
217
+ execution
218
+ end
219
+
220
+ end # Questionnaire
221
+ end # GroupDocs