class GroupDocs::Document::Annotation::Reply
Attributes
@attr [GroupDocs::Document::Annotation] annotation
@attr [String] annotationGuid
@attr [String] guid
@attr [Boolean] isAvatarExist
added in release 1.5.8 @attr [String] parentReplyGuid
@attr [Time] repliedOn
@attr [String] text
added in release 1.6.0 @attr [String] userEmail
@attr [String] userGuid
@attr [String] userName
Public Class Methods
Return an array of replies for given annotation.
@param [GroupDocs::Document::Annotation] annotation @param [Hash] options @option options [Time] :after @param [Hash] access Access credentials @option access [String] :client_id @option access [String] :private_key @return [Array<GroupDocs::Document::Annotation::Reply>]
@raise [ArgumentError] If annotation is not passed or is not an instance of GroupDocs::Document::Annotation
@raise [ArgumentError] If :after option is passed but it’s not an instance of Time
# File lib/groupdocs/document/annotation/reply.rb, line 18 def self.get!(annotation, options = {}, access = {}) annotation.is_a?(GroupDocs::Document::Annotation) or raise ArgumentError, "You have to pass GroupDocs::Document::Annotation object: #{annotation.inspect}." (options[:after] && !options[:after].is_a?(Time)) and raise ArgumentError, "Option :after should be an instance of Time, received: #{options[:after].inspect}" options[:after] = (options[:after].to_i * 1000) if options[:after] api = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/ant/{{client_id}}/annotations/#{annotation.guid}/replies" end api.add_params(options) json = api.execute! json[:replies].map do |reply| reply.merge!(:annotation => annotation) Document::Annotation::Reply.new(reply) end end
Creates new GroupDocs::Document::Annotation
.
@raise [ArgumentError] If annotation is not passed or is not an instance of GroupDocs::Document::Annotation
GroupDocs::Api::Entity::new
# File lib/groupdocs/document/annotation/reply.rb, line 82 def initialize(options = {}, &blk) super(options, &blk) annotation.is_a?(GroupDocs::Document::Annotation) or raise ArgumentError, "You have to pass GroupDocs::Document::Annotation object: #{annotation.inspect}." end
Public Instance Methods
Creates reply.
@example
document = GroupDocs::Storage::Folder.list!.first.to_document annotation = document.annotations!.first reply = GroupDocs::Document::Annotation::Reply.new(annotation: annotation) reply.text = "Reply text" reply.create!
@param [Hash] access Access credentials @option access [String] :client_id @option access [String] :private_key
# File lib/groupdocs/document/annotation/reply.rb, line 111 def create!(access = {}) json = Api::Request.new do |request| request[:access] = access request[:method] = :POST request[:path] = "/ant/{{client_id}}/annotations/#{get_annotation_guid}/replies" request[:request_body] = { :text => text } end.execute! self.guid = json[:replyGuid] self.annotation_guid = json[:annotationGuid] end
Edits reply.
@example
document = GroupDocs::Storage::Folder.list!.first.to_document annotation = document.annotations!.first reply = annotation.replies!.first reply.text = "New reply text" reply.edit!
@param [Hash] access Access credentials @option access [String] :client_id @option access [String] :private_key
# File lib/groupdocs/document/annotation/reply.rb, line 137 def edit!(access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/ant/{{client_id}}/replies/#{guid}" request[:request_body] = text end.execute! end
Removes reply.
@param [Hash] access Access credentials @option access [String] :client_id @option access [String] :private_key
# File lib/groupdocs/document/annotation/reply.rb, line 153 def remove!(access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :DELETE request[:path] = "/ant/{{client_id}}/replies/#{guid}" end.execute! end
Converts timestamp which is return by API server to Time object.
@return [Time]
# File lib/groupdocs/document/annotation/reply.rb, line 93 def replied_on Time.at(@repliedOn / 1000) end
Private Instance Methods
Returns annotation guid.
@return [String]
# File lib/groupdocs/document/annotation/reply.rb, line 168 def get_annotation_guid annotation_guid || annotation.guid end