projectal.entities.webhook API documentation

# projectal.entities.webhook

View Source

    from projectal import api
    from projectal.entity import Entity

    class Webhook(Entity):
        """
        Implementation of the [Webhook](https://projectal.com/docs/latest/#tag/Webhook) API.
        """
        _path = 'webhook'
        _name = 'webhook'

        @classmethod
        def update(cls, entities):
            # The webhook API differs from the rest of the system. We need to send some
            # mandatory fields over even if they haven't changed. Do this by faking
            # the change history to always include the required fields.
            if isinstance(entities, dict):
                e_list = [entities]
            else:
                e_list = entities

            for e in e_list:
                if isinstance(e, Webhook):
                    e._Entity__old.pop('entity', None)
                    e._Entity__old.pop('action', None)
                    e._Entity__old.pop('url', None)
            return super(Webhook, cls).update(e_list)

        @classmethod
        def list(cls, start=0, limit=101, ksort='entity', order='asc'):
            """
            Get a list of registered webhooks.

            Optionally specify a range for pagination.
            """
            url = '/api/webhook/list?start={}&limit={}&ksort={}&order={}'.\
                      format(start, limit, ksort, order)
            return api.get(url)

class Webhook(projectal.entity.Entity):
View Source

    class Webhook(Entity):
        """
        Implementation of the [Webhook](https://projectal.com/docs/latest/#tag/Webhook) API.
        """
        _path = 'webhook'
        _name = 'webhook'

        @classmethod
        def update(cls, entities):
            # The webhook API differs from the rest of the system. We need to send some
            # mandatory fields over even if they haven't changed. Do this by faking
            # the change history to always include the required fields.
            if isinstance(entities, dict):
                e_list = [entities]
            else:
                e_list = entities

            for e in e_list:
                if isinstance(e, Webhook):
                    e._Entity__old.pop('entity', None)
                    e._Entity__old.pop('action', None)
                    e._Entity__old.pop('url', None)
            return super(Webhook, cls).update(e_list)

        @classmethod
        def list(cls, start=0, limit=101, ksort='entity', order='asc'):
            """
            Get a list of registered webhooks.

            Optionally specify a range for pagination.
            """
            url = '/api/webhook/list?start={}&limit={}&ksort={}&order={}'.\
                      format(start, limit, ksort, order)
            return api.get(url)

Implementation of the Webhook API.

@classmethod
def update(cls, entities):
View Source

        @classmethod
        def update(cls, entities):
            # The webhook API differs from the rest of the system. We need to send some
            # mandatory fields over even if they haven't changed. Do this by faking
            # the change history to always include the required fields.
            if isinstance(entities, dict):
                e_list = [entities]
            else:
                e_list = entities

            for e in e_list:
                if isinstance(e, Webhook):
                    e._Entity__old.pop('entity', None)
                    e._Entity__old.pop('action', None)
                    e._Entity__old.pop('url', None)
            return super(Webhook, cls).update(e_list)

Save one or more entities of the same type. The entity type is determined by the subclass calling this method. Only the fields that have been modifier will be sent to the server as part of the request.

`entities`: Can be a `dict` to update a single entity, or a list of `dict`s to update many entities in bulk.

Returns `True` if all entities update successfully.

    # Example usage:
    rebate = projectal.Rebate.create({'name': 'Rebate2022', 'rebate': 0.2})
    rebate['name'] = 'Rebate2024'
    projectal.Rebate.update(rebate)
    # Returns True. New rebate name has been saved.

@classmethod
def list(cls, start=0, limit=101, ksort='entity', order='asc'):
View Source

        @classmethod
        def list(cls, start=0, limit=101, ksort='entity', order='asc'):
            """
            Get a list of registered webhooks.

            Optionally specify a range for pagination.
            """
            url = '/api/webhook/list?start={}&limit={}&ksort={}&order={}'.\
                      format(start, limit, ksort, order)
            return api.get(url)

Get a list of registered webhooks.

Optionally specify a range for pagination.

##### Inherited Members

projectal.entity.Entity
  Entity
  get
  delete
  history
  create
  save
  clone
  match
  match_startswith
  match_endswith
  match_one
  match_startswith_one
  match_endswith_one
  search
  query
  profile_get
  profile_set
  changes
  set_readonly
  entity_name
builtins.dict
  setdefault
  pop
  popitem
  keys
  items
  values
  fromkeys
  clear
  copy