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

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



72
73
74
75
76
# File 'lib/groupdocs/document/annotation/reply.rb', line 72

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 Also known as: annotation_guid



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 Also known as: replied_on



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 Also known as: user_guid



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

def userGuid
  @userGuid
end

#userNameObject Also known as: user_name



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::Document.find!(:name, 'CV.doc')
annotation = GroupDocs::Document::Annotation.new(document: document)
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)

Raises:

  • (NameError)

    if annotation or annotation_guid are not set



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

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
  end.execute!

  self.guid            = json[:replyGuid]
  self.annotation_guid = json[:annotationGuid]
end

#edit!(access = {}) ⇒ Object

Edits reply.

Examples:

document = GroupDocs::Document.find!(:name, 'CV.doc')
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)


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

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

TODO:

currently not implemented in API

Removes reply.

Parameters:

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

    Access credentials

Options Hash (access):

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


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

def remove!(access = {})
  Api::Request.new do |request|
    request[:access] = access
    request[:method] = :DELETE
    request[:path] = "/ant/{{client_id}}/replies/#{guid}"
  end.execute!
end