lib/groupdocs/questionnaire.rb in groupdocs-1.5.7 vs lib/groupdocs/questionnaire.rb in groupdocs-1.5.8

- old
+ new

@@ -85,10 +85,27 @@ # @attr [Integer] expires attr_accessor :expires # @attr [Array<String>] document_ids attr_accessor :document_ids + # added in release 1.5.8 + # + # @attr [Array<String>] formats + attr_accessor :formats + # @attr [String] folder + attr_accessor :folder + # @attr [String] emails + attr_accessor :emails + # @attr [String] output_format + attr_accessor :output_format + # @attr [Boolean] open_on_completion + attr_accessor :open_on_completion + # @atrr [Integer] allowed_operations + attr_accessor :allowed_operations + + + # Human-readable accessors alias_accessor :description, :descr # # Converts each page to GroupDocs::Questionnaire::Page object. @@ -132,10 +149,23 @@ # # Creates questionnaire. # + # @example + # + # questionnaire = GroupDocs::Questionnaire.new() + # pages = GroupDocs::Questionnaire::Page.new() + # questions = GroupDocs::Questionnaire::Question.new() + # answer = GroupDocs::Questionnaire::Question::Answer.new() + # questions.answers = [answer] + # conditions = GroupDocs::Questionnaire::Question::Conditions.new() + # questions.conditions = [conditions] + # pages.questions = [questions] + # questionnaire.pages = [pages] + # questionnaire.create! + # # @param [Hash] access Access credentials # @option access [String] :client_id # @option access [String] :private_key # def create!(access = {}) @@ -223,11 +253,14 @@ json[:executions].map do |execution| Execution.new(execution) end end - # + # + # Changed in release 1.5.8 + # + # # Returns an array of questionnaire collectors. # # # @param [Hash] options Options # @option options [String] :orderBy Order by column (required) @@ -241,11 +274,11 @@ api = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/merge/{{client_id}}/questionnaires/#{guid}/collectors" end - api = add_params(options) + api.add_params(options) json = api.execute! json[:collectors].map do |collector| collector.merge!(:questionnaire => self) Collector.new(collector) @@ -316,11 +349,13 @@ json[:fields].map do |field| Document::Field.new(field) end end - # + # + # Changed in release 1.5.8 + # # Copy file to given path. # # @param [String] path (required) # @param [String] mode Mode (optional) # @param [Hash] options @@ -338,13 +373,148 @@ request[:access] = access request[:method] = :PUT request[:headers] = { :'Groupdocs-Copy' => id } request[:path] = "/merge/{{client_id}}/files/#{path}" end - api = add_params(:mode => mode) + api.add_params(:mode => mode) json = api.execute! json[:templates] end + + + # + # Added in release 1.5.8 + # + # Get associated document by questionnaire + # + # @param [Hash] access Access credentials + # @option access [String] :client_id + # @option access [String] :private_key + # + def get_document!(access = {}) + Api::Request.new do |request| + request[:access] = access + request[:method] = :GET + request[:path] = "/merge/{{client_id}}/questionnaires/#{id}/document" + end.execute! + end + + # + # Added in release 1.5.8 + # + # Returns an array of questionnaires by name. + # + # @param [Hash] options Hash of options + # @option options [String] :name Questionnaire name + # @option options [Symbol] :status Filter questionnaires by status + # @option options [Integer] :page_number Page to start with + # @option options [Integer] :page_size How many items to list + # @option options [String] :orderBy Order by column (optional) + # @option options [Bool] :isAscending Order by ascending or descending (optional) + # @param [Hash] access Access credentials + # @option access [String] :client_id + # @option access [String] :private_key + # @return [Array<GroupDocs::Questionnaire>] + # + def self.get_by_name!(options = {}, access = {}) + if options[:status] + # TODO find better way to parse status + options[:status] = new.send(:parse_status, options[:status]) + end + + api = Api::Request.new do |request| + request[:access] = access + request[:method] = :GET + request[:path] = '/merge/{{client_id}}/questionnaires/filter' + end + + api.add_params(options) + json = api.execute! + + json[:questionnaires].map do |questionnaire| + new(questionnaire) + end + end + + # + # Added in release 1.5.8 + # + # Delete list of questionnaires by GUIDs. + # + # @param [Hash] access Access credentials + # @option guids [Array<String>] List of Questionnaires Guid + # @option access [String] :client_id + # @option access [String] :private_key + # + def delete_list!(guids, access = {}) + api = Api::Request.new do |request| + request[:access] = access + request[:method] = :DELETE + request[:path] = "/merge/{{client_id}}/questionnaires/list" + request[:request_body] = guids + end + + api.execute! + end + + # + # Added in release 1.5.8 + # + # Removes questionnaire collector. + # + # @param [Hash] access Access credentials + # @option collectors [Array<String>] List of Collectors Guid + # @option access [String] :client_id + # @option access [String] :private_key + # + def delete_collectors_list!(collectors, access = {}) + Api::Request.new do |request| + request[:access] = access + request[:method] = :DELETE + request[:path] = "/merge/{{client_id}}/questionnaires/collectors/list" + request[:request_body] = collectors + end.execute! + end + + # + # Added in release 1.5.8 + # + # Removes questionnaire execution. + # + # @param [Hash] access Access credentials + # @option executions [Array<String>] List of Executions Guid + # @option access [String] :client_id + # @option access [String] :private_key + # + def delete_executions_list!(executions, access = {}) + Api::Request.new do |request| + request[:access] = access + request[:method] = :DELETE + request[:path] = "/merge/{{client_id}}/questionnaires/executions/list" + request[:request_body] = executions + end.execute! + end + + # + # Added in release 1.5.8 + # + # Delete list of datasource fields. + # + # @param [Hash] access Access credentials + # @option datasource [Array<String>] List of Datasources Guid + # @option access [String] :client_id + # @option access [String] :private_key + # + def delete_datasources_list!(datasources, access = {}) + Api::Request.new do |request| + request[:access] = access + request[:method] = :DELETE + request[:path] = "/merge/{{client_id}}datasources/list" + request[:request_body] = datasources + end.execute! + end + + end # Questionnaire end # GroupDocs