Comment

class moco_wrapper.models.Comment(moco)

Class for handling comments.

Comments can be created for a multitude of objects. So when creating comments one must specify which type of object they mean (see CommentTargetType)

Example Usage:

m = Moco()
project_id = 22
comment_create = m.Comment.create(
    project_id, #id of the thing we comment
    "PROJECT", #object type
    "example comment text"
)
create(commentable_id: int, commentable_type: moco_wrapper.models.comment.CommentTargetType, text: str)

create a comment

Parameters:
  • commentable_id – id of the object to create the comment of (i.e the project id of the project we want to comment on)
  • commentable_type – type of object to create the comment for. For allowed values see CommentTargetType.
  • text – comment text
Returns:

the created comment

create_bulk(commentable_ids: list, commentable_type: moco_wrapper.models.comment.CommentTargetType, text: str)

create a comment for multiple target objects

Parameters:
  • commentable_ids – ids of the objects we want to comment under ie. [123, 124, 125]
  • commentable_type – type of object to create the comment for. For allowed values see CommentTargetType.
  • text – comment text
Returns:

list of created comments

delete(id: int)

delete a comment

Parameters:id – id of the comment to delete
Returns:empty response on success
get(id: int)

retrieve a single comment

Parameters:id – id of the comment
Returns:a single comment
getlist(commentable_type: moco_wrapper.models.comment.CommentTargetType = None, commentable_id: int = None, user_id: int = None, manual: bool = None, sort_by: str = None, sort_order: str = 'asc', page: int = 1)

retrieve a list of comments

Parameters:
  • commentable_type – type of object the comment(s) belong to. For allowed values see CommentTargetType.
  • commentable_id – id of the object the comment belongs to
  • user_id – user id of the creator
  • manual – true/false user-created of generated
  • sort_by – field to sort the results by
  • sort_order – asc or desc
  • page – page number (default 1)
Returns:

list of comments

update(id: int, text: str)

update a comment

Parameters:
  • id – the id of the comment to update
  • text – comment text
Returns:

the created comment

class moco_wrapper.models.comment.CommentTargetType

Enumeration for allowed values used that can be supplied for the commentable_type argument in Comment.create(), Comment.create_bulk() and Comment.getlist()

from moco_wrapper import Moco
from moco_wrapper.models.comment import CommentTargetType

m = Moco()
comment_create = m.Comment.create(
    ..
    commentable_type = CommentTargetType.DEAL
)
CONTACT = 'Contact'
CUSTOMER = 'Customer'
DEAL = 'Deal'
INVOICE = 'Invoice'
OFFER = 'Offer'
OFFERCONFIRMATION = 'OfferConfirmation'
PROJECT = 'Project'
USER = 'User'