File Comments

A FileComment is a comment attached to a file by a user.

List File Comments by Path

SDK Method

\Files\Model\FileComment::listFor;

Return Object

FileComment[]

Authorization Requirement

Available to all authenticated keys or sessions.

Method Arguments

ArgumentDescription
path
string
Required
Path to operate on.

Additional Arguments

Example Request

try {
  $file_comments = \Files\Model\FileComment::listFor($path);
  foreach ($file_comments as $file_comment) {
    // Operate on $file_comment
  }
} catch (\Files\NotAuthenticated\InvalidUsernameOrPasswordException $e) {
  echo 'Authentication Error Occurred (' . get_class($e) . '): ', $e->getMessage(), "\n";
} catch (\Files\FilesException $e) {
  echo 'Unknown Error Occurred (' . get_class($e) . '): ', $e->getMessage(), "\n";
}

Create File Comment

SDK Method

\Files\Model\FileComment::create;

Return Object

FileComment

Authorization Requirement

Available to all authenticated keys or sessions.

Method Arguments

ArgumentDescription
body
string
Required
Comment body.
path
string
Required
File path.

Example Request

try {
  $file_comment = \Files\Model\FileComment::create([
    'body' => "What a great file!",
    'path' => "path"
  ]);
  // Operate on $file_comment
} catch (\Files\NotAuthenticated\InvalidUsernameOrPasswordException $e) {
  echo 'Authentication Error Occurred (' . get_class($e) . '): ', $e->getMessage(), "\n";
} catch (\Files\FilesException $e) {
  echo 'Unknown Error Occurred (' . get_class($e) . '): ', $e->getMessage(), "\n";
}

Update File Comment

SDK Method

$file_comment->update;

Return Object

FileComment

Authorization Requirement

Available to all authenticated keys or sessions.

Method Arguments

ArgumentDescription
body
string
Required
Comment body.

Example Request

try {
  $file_comment = \Files\Model\FileComment::list()[0];
  $file_comment->update([
    'body' => "What a great file!"
  ]);
} catch (\Files\NotAuthenticated\InvalidUsernameOrPasswordException $e) {
  echo 'Authentication Error Occurred (' . get_class($e) . '): ', $e->getMessage(), "\n";
} catch (\Files\FilesException $e) {
  echo 'Unknown Error Occurred (' . get_class($e) . '): ', $e->getMessage(), "\n";
}

Delete File Comment

SDK Method

$file_comment->delete;

Return Object

No return value.

Authorization Requirement

Available to all authenticated keys or sessions.

Example Request

try {
  $file_comment = \Files\Model\FileComment::list()[0];
  $file_comment->delete();
} catch (\Files\NotAuthenticated\InvalidUsernameOrPasswordException $e) {
  echo 'Authentication Error Occurred (' . get_class($e) . '): ', $e->getMessage(), "\n";
} catch (\Files\FilesException $e) {
  echo 'Unknown Error Occurred (' . get_class($e) . '): ', $e->getMessage(), "\n";
}

The FileComment Object

Some of the methods above return a FileComment object. The attributes of this object are listed below.

AttributeDescription
id
int64
File Comment ID
body
string
Comment body.
reactions
array(object)
Reactions to this comment.