class GroupDocs::Document::Annotation::Reply

Attributes

annotation[RW]

@attr [GroupDocs::Document::Annotation] annotation

annotationGuid[RW]

@attr [String] annotationGuid

guid[RW]

@attr [String] guid

isAvatarExist[RW]

@attr [Boolean] isAvatarExist

parentReplyGuid[RW]

added in release 1.5.8 @attr [String] parentReplyGuid

repliedOn[RW]

@attr [Time] repliedOn

text[RW]

@attr [String] text

userEmail[RW]

added in release 1.6.0 @attr [String] userEmail

userGuid[RW]

@attr [String] userGuid

userName[RW]

@attr [String] userName

Public Class Methods

get!(annotation, options = {}, access = {}) click to toggle source

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
new(options = {}, &blk) click to toggle source

Creates new GroupDocs::Document::Annotation.

@raise [ArgumentError] If annotation is not passed or is not an instance of GroupDocs::Document::Annotation

Calls superclass method 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

create!(access = {}) click to toggle source

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
edit!(access = {}) click to toggle source

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
remove!(access = {}) click to toggle source

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
replied_on() click to toggle source

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

get_annotation_guid() click to toggle source

Returns annotation guid.

@return [String]

# File lib/groupdocs/document/annotation/reply.rb, line 168
def get_annotation_guid
  annotation_guid || annotation.guid
end