examples/api-samples/samples/sample11.rb in groupdocs-1.9.0 vs examples/api-samples/samples/sample11.rb in groupdocs-2.0.0

- old
+ new

@@ -45,21 +45,20 @@ message = "You delete the annotation id = #{remove[:guid]} " else #Annotation types types = {:text => "0", :area => "1", :point => "2"} - #Required parameters all_params = all_params = ['annotationType', 'boxX', 'boxY', 'text'] #Added required parameters depends on annotation type ['text' or 'area'] if settings.annotation_type == 'text' all_params = all_params | ['boxWidth', 'boxHeight', 'annotationPositionX', 'annotationPositionY', 'rangePosition', 'rangeLength'] elsif settings.annotation_type == 'area' all_params = all_params | ['boxWidth', 'boxHeight'] end - + #raise all_params.to_yaml #Checking required parameters all_params.each do |param| raise 'Please enter all required parameters' if params[param].empty? end @@ -73,14 +72,14 @@ info = nil #Construct requestBody depends on annotation type #Text annotation if settings.annotation_type == 'text' - annotation.box = GroupDocs::Document::Rectangle.new ({x: params['boxX'], y: params['boxY'], width: params['boxWidth'], height: params['boxHeight']}) - annotation.annotationPosition = {x: params['annotationPositionX'], y: params['annotationPositionY']} + annotation_box = {x: params['boxX'], y: params['boxY'], width: params['boxWidth'], height: params['boxHeight']} + annotation_position = {x: params['annotationPositionX'], y: params['annotationPositionY']} range = {position: params['rangePosition'], length: params['rangeLength']} - info = {:box => annotation_box, :annotationPosition => annotation_annotationPosition, :range => range, :type => types[settings.annotation_type.to_sym], :replies => [{:text => params['text']}]} + info = { :box => annotation_box, :annotationPosition => annotation_position, :range => range, :type => types[settings.annotation_type.to_sym], :replies => [{:text => params['text']}]} #Area annotation elsif settings.annotation_type == 'area' annotation_box = {x: params['boxX'], y: params['boxY'], width: params['boxWidth'], height: params['boxHeight']} annotation_annotationPosition = {x: 0, y: 0} info = {:box => annotation_box, :annotationPosition => annotation_annotationPosition, :type => types[settings.annotation_type.to_sym], :replies => [{:text => params['text']}]} @@ -89,10 +88,9 @@ annotation_box = {x: params['boxX'], y: params['boxY'], width: 0, height: 0} annotation_annotationPosition = {x: 0, y: 0} info = {:box => annotation_box, :annotationPosition => annotation_annotationPosition, :type => types[settings.annotation_type.to_sym], :replies => [{:text => params['text']}] } end - #Call create method annotation.create!(info) id = annotation.document.file.id #Get document guid guid = annotation.document.file.guid \ No newline at end of file