Class: GroupDocs::Document::Annotation::Reply

Inherits:
Api::Entity
  • Object
show all
Defined in:
lib/groupdocs/document/annotation/reply.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Api::Entity

#inspect, #to_hash

Methods included from Api::Helpers::Accessor

#alias_accessor

Constructor Details

#initialize(options = {}, &blk) ⇒ Reply

Creates new GroupDocs::Document::Annotation.

Raises:

  • (ArgumentError)

    If annotation is not passed or is not an instance of GroupDocs::Document::Annotation



75
76
77
78
79
# File 'lib/groupdocs/document/annotation/reply.rb', line 75

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

Instance Attribute Details

#annotationObject



41
42
43
# File 'lib/groupdocs/document/annotation/reply.rb', line 41

def annotation
  @annotation
end

#annotationGuidObject



47
48
49
# File 'lib/groupdocs/document/annotation/reply.rb', line 47

def annotationGuid
  @annotationGuid
end

#guidObject



45
46
47
# File 'lib/groupdocs/document/annotation/reply.rb', line 45

def guid
  @guid
end

#isAvatarExistObject



59
60
61
# File 'lib/groupdocs/document/annotation/reply.rb', line 59

def isAvatarExist
  @isAvatarExist
end

#parentReplyGuidObject

added in release 1.5.8



57
58
59
# File 'lib/groupdocs/document/annotation/reply.rb', line 57

def parentReplyGuid
  @parentReplyGuid
end

#repliedOnObject



53
54
55
# File 'lib/groupdocs/document/annotation/reply.rb', line 53

def repliedOn
  @repliedOn
end

#textObject



43
44
45
# File 'lib/groupdocs/document/annotation/reply.rb', line 43

def text
  @text
end

#userGuidObject



49
50
51
# File 'lib/groupdocs/document/annotation/reply.rb', line 49

def userGuid
  @userGuid
end

#userNameObject



51
52
53
# File 'lib/groupdocs/document/annotation/reply.rb', line 51

def userName
  @userName
end

Class Method Details

.get!(annotation, options = {}, access = {}) ⇒ Array<GroupDocs::Document::Annotation::Reply>

Return an array of replies for given annotation.

Parameters:

Options Hash (options):

  • :after (Time)

Options Hash (access):

  • :client_id (String)
  • :private_key (String)

Returns:

Raises:

  • (ArgumentError)

    If annotation is not passed or is not an instance of GroupDocs::Document::Annotation

  • (ArgumentError)

    If :after option is passed but it’s not an instance of Time



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# 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

Instance Method Details

#create!(access = {}) ⇒ Object

Creates reply.

Examples:

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!

Parameters:

  • access (Hash) (defaults to: {})

    Access credentials

Options Hash (access):

  • :client_id (String)
  • :private_key (String)


104
105
106
107
108
109
110
111
112
113
114
# File 'lib/groupdocs/document/annotation/reply.rb', line 104

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 = {}) ⇒ Object

Edits reply.

Examples:

document = GroupDocs::Storage::Folder.list!.first.to_document
annotation = document.annotations!.first
reply = annotation.replies!.first
reply.text = "New reply text"
reply.edit!

Parameters:

  • access (Hash) (defaults to: {})

    Access credentials

Options Hash (access):

  • :client_id (String)
  • :private_key (String)


130
131
132
133
134
135
136
137
# File 'lib/groupdocs/document/annotation/reply.rb', line 130

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 = {}) ⇒ Object

Removes reply.

Parameters:

  • access (Hash) (defaults to: {})

    Access credentials

Options Hash (access):

  • :client_id (String)
  • :private_key (String)


146
147
148
149
150
151
152
# File 'lib/groupdocs/document/annotation/reply.rb', line 146

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_onTime

Converts timestamp which is return by API server to Time object.

Returns:

  • (Time)


86
87
88
# File 'lib/groupdocs/document/annotation/reply.rb', line 86

def replied_on
  Time.at(@repliedOn / 1000)
end