Deal

class moco_wrapper.models.Deal(moco)

Class for handling deals/leads.

create(name: str, currency: str, money: float, reminder_date: datetime.date, user_id: int, deal_category_id: int, company_id: int = None, info: str = None, status: moco_wrapper.models.deal.DealStatus = <DealStatus.PENDING: 'pending'>, closed_on: datetime.date = None, tags: list = None, custom_properties: dict = None)

Create a new deal.

Parameters:
  • name (str) – Name of the deal
  • currency (str) – Currency used (e.g. EUR, CHF)
  • money (float) – How much money can be generated from this deal (e.g. 205.0)
  • reminder_date (datetime.date, str) – Reminder date
  • user_id (int) – Id of the user the is responsible for this lead
  • deal_category_id (int) – Deal category id
  • company_id (int) – Company id (default None)
  • info (str) – Additional information (default None)
  • status (DealStatus, str) – Current state of the deal (default DealStatus.PENDING)
  • closed_on (datetime.date, str) – Date the deal was closed on (default None)
  • tags (list) – List of tags (default None)
  • custom_properties (dict) – Dict of custom properties (default None)
Returns:

The created deal object

Return type:

moco_wrapper.util.response.ObjectResponse

Note

The closed_on field can only be set if the deal is in the state WON, LOST or DROPPED. Otherwise it will be ignored.

static endpoints() → List[moco_wrapper.util.endpoint.endpoint.Endpoint]

Returns all endpoints associated with the model

Returns:List of Endpoint objects
Return type:moco_wrapper.util.endpoint.Endpoint
get(deal_id: int)

Retrieve a single deal.

Parameters:deal_id (int) – Id of the deal
Returns:Single deal object
Return type:moco_wrapper.util.response.ObjectResponse
getlist(status: str = None, tags: list = None, sort_by: str = None, sort_order: str = 'asc', page: int = 1)

Retrieve a list of deal objects.

Parameters:
  • status (DealStatus, str) – State of deal (default None)
  • tags (list) – Array of tags (default None)
  • sort_by (str) – Field to order results by (default None)
  • sort_order (str) – asc or desc (default "asc")
  • page (int) – Page number (default 1)
Returns:

List of deal objects

Return type:

moco_wrapper.util.response.PagedListResponse

update(deal_id: int, name: str = None, currency: str = None, money: float = None, reminder_date: datetime.date = None, user_id: int = None, deal_category_id: int = None, company_id: int = None, info: str = None, status: moco_wrapper.models.deal.DealStatus = None, closed_on: datetime.date = None, tags: list = None, custom_properties: dict = None)

Update an existing deal.

Parameters:
  • deal_id (int) – Id of the deal
  • name (str) – Name of the deal (default None)
  • currency (str) – Currency used (e.g. EUR, CHF) (default None)
  • money (float) – How much money can be generated from this deal (e.g. 205.0) (default None)
  • reminder_date (datetime.date, str) – Reminder date (default None)
  • user_id (int) – Id of the user that is responsible for this deal (default None)
  • deal_category_id (int) – Deal category id (default None)
  • company_id (int) – Company id (default None)
  • info (str) – Additional information (default None)
  • status (DealStatus, str) – Current state of the deal (default None)
  • closed_on (datetime.date, str) – Date the deal was closed on (default None)
  • tags (list) – List of tags (default None)
  • custom_properties (dict) – Dict of custom properties (default None)
Returns:

The updated deal object

Return type:

moco_wrapper.util.response.ObjectResponse

Note

The closed_on field can only be set if the deal is in the state WON, LOST or DROPPED. Otherwise it will be ignored.

class moco_wrapper.models.deal.DealStatus

Enumeration for the allowed values that can be supplied for the status argument of Deal.create(), Deal.update() and Deal.getlist().

from moco_wrapper.models.deal import DealStatus
from moco_wrapper import Moco

m = Moco()

deal_create = m.Deal.create(
    ..
    status = DealStatus.WON
)
DROPPED = 'dropped'
LOST = 'lost'
PENDING = 'pending'
POTENTIAL = 'potential'
WON = 'won'