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



68
69
70
71
72
# File 'lib/groupdocs/document/annotation/reply.rb', line 68

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

#repliedOnObject



55
56
57
# File 'lib/groupdocs/document/annotation/reply.rb', line 55

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)


97
98
99
100
101
102
103
104
105
106
107
# File 'lib/groupdocs/document/annotation/reply.rb', line 97

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)


123
124
125
126
127
128
129
130
# File 'lib/groupdocs/document/annotation/reply.rb', line 123

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)


139
140
141
142
143
144
145
# File 'lib/groupdocs/document/annotation/reply.rb', line 139

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)


79
80
81
# File 'lib/groupdocs/document/annotation/reply.rb', line 79

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